tabbar module
This commit is contained in:
parent
69b7c01cb2
commit
eb5087fcef
|
|
@ -310,6 +310,7 @@ export function makeActionManager(env, router = _router) {
|
|||
* @returns {Controller|null}
|
||||
*/
|
||||
function _getCurrentController() {
|
||||
debugger;
|
||||
const stack = controllerStack;
|
||||
return stack.length ? stack[stack.length - 1] : null;
|
||||
}
|
||||
|
|
@ -440,6 +441,7 @@ export function makeActionManager(env, router = _router) {
|
|||
* @returns {View | null}
|
||||
*/
|
||||
function _getView(viewType) {
|
||||
debugger;
|
||||
const currentController = controllerStack[controllerStack.length - 1];
|
||||
if (currentController.action.type !== 'ir.actions.act_window') {
|
||||
throw new Error(
|
||||
|
|
@ -837,6 +839,7 @@ export function makeActionManager(env, router = _router) {
|
|||
*/
|
||||
async function _updateUI(controller, options = {}) {
|
||||
let resolve;
|
||||
debugger;
|
||||
let reject;
|
||||
let dialogCloseResolve;
|
||||
let removeDialogFn;
|
||||
|
|
@ -1022,7 +1025,7 @@ export function makeActionManager(env, router = _router) {
|
|||
);
|
||||
}
|
||||
};
|
||||
|
||||
debugger;
|
||||
controllerStack = nextStack; // the controller is mounted, commit the new stack
|
||||
// todo del
|
||||
window.router = router
|
||||
|
|
@ -1100,7 +1103,7 @@ export function makeActionManager(env, router = _router) {
|
|||
};
|
||||
return currentActionProm;
|
||||
}
|
||||
|
||||
debugger;
|
||||
const currentController = _getCurrentController();
|
||||
if (currentController && currentController.getLocalState) {
|
||||
currentController.exportedState = currentController.getLocalState();
|
||||
|
|
@ -1290,7 +1293,7 @@ export function makeActionManager(env, router = _router) {
|
|||
options.newStack.splice(-1);
|
||||
}
|
||||
}
|
||||
|
||||
debugger;
|
||||
return _updateUI(controller, options);
|
||||
}
|
||||
|
||||
|
|
@ -1338,6 +1341,7 @@ export function makeActionManager(env, router = _router) {
|
|||
});
|
||||
controller.displayName ||=
|
||||
clientAction.displayName?.toString() || '';
|
||||
debugger;
|
||||
return _updateUI(controller, options);
|
||||
} else {
|
||||
const next = await clientAction(env, action);
|
||||
|
|
@ -1367,7 +1371,7 @@ export function makeActionManager(env, router = _router) {
|
|||
action,
|
||||
..._getActionInfo(action, props),
|
||||
});
|
||||
|
||||
debugger;
|
||||
return _updateUI(controller, options);
|
||||
}
|
||||
|
||||
|
|
@ -1767,6 +1771,7 @@ export function makeActionManager(env, router = _router) {
|
|||
);
|
||||
index = index > -1 ? index : controllerStack.length;
|
||||
}
|
||||
debugger;
|
||||
return _updateUI(newController, { index });
|
||||
}
|
||||
|
||||
|
|
@ -1821,6 +1826,7 @@ export function makeActionManager(env, router = _router) {
|
|||
}
|
||||
Object.assign(controller, _getViewInfo(view, action, views, props));
|
||||
}
|
||||
debugger;
|
||||
return _updateUI(controller, { index });
|
||||
}
|
||||
|
||||
|
|
@ -1920,6 +1926,7 @@ export function makeActionManager(env, router = _router) {
|
|||
return _preprocessAction(action, context);
|
||||
},
|
||||
get currentController() {
|
||||
debugger;
|
||||
return _getCurrentController();
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ patch(ActionContainer.prototype, {
|
|||
super.setup();
|
||||
this.action_infos = [];
|
||||
this.controllerStacks = {};
|
||||
// this.action_service = useService('action');
|
||||
this.actionService = useService('action');
|
||||
|
||||
this.env.bus.addEventListener(
|
||||
'ACTION_MANAGER:UPDATE',
|
||||
|
|
@ -26,30 +26,6 @@ patch(ActionContainer.prototype, {
|
|||
}
|
||||
);
|
||||
},
|
||||
get_controllers(info) {
|
||||
const action_infos = [];
|
||||
const entries = Object.entries(info.controllerStacks);
|
||||
|
||||
entries.forEach(([key, stack]) => {
|
||||
const lastController = stack[stack.length - 1];
|
||||
|
||||
const action_info = {
|
||||
key: key,
|
||||
__info__: lastController,
|
||||
Component: lastController.__info__.Component,
|
||||
active: false,
|
||||
componentProps: lastController.__info__.componentProps || {},
|
||||
}
|
||||
|
||||
if (lastController.count == info.count) {
|
||||
action_info.active = true;
|
||||
}
|
||||
action_infos.push(action_info);
|
||||
})
|
||||
|
||||
|
||||
return action_infos;
|
||||
},
|
||||
|
||||
_on_close_action(action_info) {
|
||||
this.action_infos = this.action_infos.filter((info) => {
|
||||
|
|
@ -62,17 +38,103 @@ patch(ActionContainer.prototype, {
|
|||
this.render();
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
get_controllers(info) {
|
||||
const action_infos = [];
|
||||
const entries = Object.entries(info.controllerStacks);
|
||||
|
||||
entries.forEach(([key, stack]) => {
|
||||
const lastController = stack[stack.length - 1];
|
||||
|
||||
const action_info = {
|
||||
key: key,
|
||||
__info__: lastController,
|
||||
// Store the exact router state that was active for this tab
|
||||
routerState: lastController.state,
|
||||
Component: lastController.__info__.Component,
|
||||
active: false,
|
||||
componentProps: lastController.__info__.componentProps || {},
|
||||
}
|
||||
|
||||
if (lastController.count == info.count) {
|
||||
action_info.active = true;
|
||||
}
|
||||
action_infos.push(action_info);
|
||||
})
|
||||
|
||||
return action_infos;
|
||||
},
|
||||
|
||||
_on_active_action(action_info) {
|
||||
debugger
|
||||
debugger;
|
||||
this.action_infos.forEach((info) => {
|
||||
info.active = info.key === action_info.key;
|
||||
});
|
||||
const url = _router.stateToUrl(action_info.__info__.state)
|
||||
browser.history.pushState({}, "", url);
|
||||
|
||||
try {
|
||||
// Use the exact router state that was saved
|
||||
if (action_info.routerState) {
|
||||
_router.pushState(action_info.routerState, { replace: true });
|
||||
|
||||
// Force the action service to reload the state
|
||||
setTimeout(() => {
|
||||
this.actionService.loadState();
|
||||
}, 10);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error("Error switching controller stack:", e);
|
||||
}
|
||||
this.render();
|
||||
},
|
||||
// _on_active_action(action_info) {
|
||||
// debugger
|
||||
// this.action_infos.forEach((info) => {
|
||||
// info.active = info.key === action_info.key;
|
||||
// });
|
||||
//
|
||||
// // Get the action details from the action info
|
||||
// const action = action_info.__info__.jsId ?
|
||||
// { jsId: action_info.__info__.jsId } :
|
||||
// action_info.__info__.action;
|
||||
//
|
||||
// // Get the controller from the controller stack
|
||||
// const controllerStack = this.controllerStacks[action_info.key];
|
||||
// if (!controllerStack || controllerStack.length === 0) {
|
||||
// console.error("Cannot switch tabs: No controller found for tab", action_info);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// const controller = controllerStack[controllerStack.length - 1];
|
||||
//
|
||||
//
|
||||
// // Execute the action to switch context
|
||||
// this.actionService.loadAction(action_info.__info__.action.id).then(loadedAction => {
|
||||
// // Update the controller with the loaded action
|
||||
// controller.action = loadedAction;
|
||||
//
|
||||
// // Execute the action to switch context
|
||||
// this.actionService.doAction(loadedAction, {
|
||||
// clear_breadcrumbs: false,
|
||||
// pushState: false,
|
||||
// replaceState: true, // Replace the current state instead of pushing a new one
|
||||
// });
|
||||
//
|
||||
// try {
|
||||
// const url = _router.stateToUrl(action_info.__info__.state);
|
||||
// browser.history.pushState({}, "", url);
|
||||
// } catch (e) {
|
||||
// console.error("Error updating URL:", e);
|
||||
// }
|
||||
// this.render();
|
||||
// });
|
||||
// return;
|
||||
//
|
||||
// const url = _router.stateToUrl(action_info.__info__.state)
|
||||
// browser.history.pushState({}, "", url);
|
||||
// this.render();
|
||||
// },
|
||||
|
||||
_close_other_action() {
|
||||
this.action_infos = this.action_infos.filter((info) => {
|
||||
if (info.active == false) {
|
||||
|
|
@ -84,7 +146,6 @@ patch(ActionContainer.prototype, {
|
|||
this.render();
|
||||
},
|
||||
_close_current_action() {
|
||||
debugger
|
||||
this.action_infos = this.action_infos.filter((info) => {
|
||||
if (info.active == true) {
|
||||
delete this.controllerStacks[info.key];
|
||||
|
|
@ -95,7 +156,6 @@ patch(ActionContainer.prototype, {
|
|||
this.render();
|
||||
},
|
||||
_on_close_all_action() {
|
||||
debugger
|
||||
this.action_infos.forEach((info) => {
|
||||
delete this.controllerStacks[info.key];
|
||||
});
|
||||
|
|
@ -108,11 +168,12 @@ ActionContainer.components = {
|
|||
...ActionContainer.components,
|
||||
AklMultiTab,
|
||||
};
|
||||
|
||||
ActionContainer.template = xml`
|
||||
<t t-name="web.ActionContainer">
|
||||
<t t-set="action_infos" t-value="action_infos" />
|
||||
<div class="o_action_manager d-flex flex-colum">
|
||||
<AklMultiTab
|
||||
<AklMultiTab
|
||||
action_infos="action_infos"
|
||||
active_action="(action_info) => this._on_active_action(action_info)"
|
||||
close_action="(action_info) => this._on_close_action(action_info)"
|
||||
|
|
|
|||
Loading…
Reference in New Issue