tabbar module
This commit is contained in:
parent
005bfe16c5
commit
a1317e4ec7
|
|
@ -310,6 +310,7 @@ export function makeActionManager(env, router = _router) {
|
||||||
* @returns {Controller|null}
|
* @returns {Controller|null}
|
||||||
*/
|
*/
|
||||||
function _getCurrentController() {
|
function _getCurrentController() {
|
||||||
|
debugger;
|
||||||
const stack = controllerStack;
|
const stack = controllerStack;
|
||||||
return stack.length ? stack[stack.length - 1] : null;
|
return stack.length ? stack[stack.length - 1] : null;
|
||||||
}
|
}
|
||||||
|
|
@ -440,6 +441,7 @@ export function makeActionManager(env, router = _router) {
|
||||||
* @returns {View | null}
|
* @returns {View | null}
|
||||||
*/
|
*/
|
||||||
function _getView(viewType) {
|
function _getView(viewType) {
|
||||||
|
debugger;
|
||||||
const currentController = controllerStack[controllerStack.length - 1];
|
const currentController = controllerStack[controllerStack.length - 1];
|
||||||
if (currentController.action.type !== 'ir.actions.act_window') {
|
if (currentController.action.type !== 'ir.actions.act_window') {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|
@ -837,6 +839,7 @@ export function makeActionManager(env, router = _router) {
|
||||||
*/
|
*/
|
||||||
async function _updateUI(controller, options = {}) {
|
async function _updateUI(controller, options = {}) {
|
||||||
let resolve;
|
let resolve;
|
||||||
|
debugger;
|
||||||
let reject;
|
let reject;
|
||||||
let dialogCloseResolve;
|
let dialogCloseResolve;
|
||||||
let removeDialogFn;
|
let removeDialogFn;
|
||||||
|
|
@ -1022,7 +1025,7 @@ export function makeActionManager(env, router = _router) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
debugger;
|
||||||
controllerStack = nextStack; // the controller is mounted, commit the new stack
|
controllerStack = nextStack; // the controller is mounted, commit the new stack
|
||||||
// todo del
|
// todo del
|
||||||
window.router = router
|
window.router = router
|
||||||
|
|
@ -1100,7 +1103,7 @@ export function makeActionManager(env, router = _router) {
|
||||||
};
|
};
|
||||||
return currentActionProm;
|
return currentActionProm;
|
||||||
}
|
}
|
||||||
|
debugger;
|
||||||
const currentController = _getCurrentController();
|
const currentController = _getCurrentController();
|
||||||
if (currentController && currentController.getLocalState) {
|
if (currentController && currentController.getLocalState) {
|
||||||
currentController.exportedState = currentController.getLocalState();
|
currentController.exportedState = currentController.getLocalState();
|
||||||
|
|
@ -1290,7 +1293,7 @@ export function makeActionManager(env, router = _router) {
|
||||||
options.newStack.splice(-1);
|
options.newStack.splice(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
debugger;
|
||||||
return _updateUI(controller, options);
|
return _updateUI(controller, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1338,6 +1341,7 @@ export function makeActionManager(env, router = _router) {
|
||||||
});
|
});
|
||||||
controller.displayName ||=
|
controller.displayName ||=
|
||||||
clientAction.displayName?.toString() || '';
|
clientAction.displayName?.toString() || '';
|
||||||
|
debugger;
|
||||||
return _updateUI(controller, options);
|
return _updateUI(controller, options);
|
||||||
} else {
|
} else {
|
||||||
const next = await clientAction(env, action);
|
const next = await clientAction(env, action);
|
||||||
|
|
@ -1367,7 +1371,7 @@ export function makeActionManager(env, router = _router) {
|
||||||
action,
|
action,
|
||||||
..._getActionInfo(action, props),
|
..._getActionInfo(action, props),
|
||||||
});
|
});
|
||||||
|
debugger;
|
||||||
return _updateUI(controller, options);
|
return _updateUI(controller, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1767,6 +1771,7 @@ export function makeActionManager(env, router = _router) {
|
||||||
);
|
);
|
||||||
index = index > -1 ? index : controllerStack.length;
|
index = index > -1 ? index : controllerStack.length;
|
||||||
}
|
}
|
||||||
|
debugger;
|
||||||
return _updateUI(newController, { index });
|
return _updateUI(newController, { index });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1821,6 +1826,7 @@ export function makeActionManager(env, router = _router) {
|
||||||
}
|
}
|
||||||
Object.assign(controller, _getViewInfo(view, action, views, props));
|
Object.assign(controller, _getViewInfo(view, action, views, props));
|
||||||
}
|
}
|
||||||
|
debugger;
|
||||||
return _updateUI(controller, { index });
|
return _updateUI(controller, { index });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1920,6 +1926,7 @@ export function makeActionManager(env, router = _router) {
|
||||||
return _preprocessAction(action, context);
|
return _preprocessAction(action, context);
|
||||||
},
|
},
|
||||||
get currentController() {
|
get currentController() {
|
||||||
|
debugger;
|
||||||
return _getCurrentController();
|
return _getCurrentController();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ patch(ActionContainer.prototype, {
|
||||||
super.setup();
|
super.setup();
|
||||||
this.action_infos = [];
|
this.action_infos = [];
|
||||||
this.controllerStacks = {};
|
this.controllerStacks = {};
|
||||||
// this.action_service = useService('action');
|
this.actionService = useService('action');
|
||||||
|
|
||||||
this.env.bus.addEventListener(
|
this.env.bus.addEventListener(
|
||||||
'ACTION_MANAGER:UPDATE',
|
'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) {
|
_on_close_action(action_info) {
|
||||||
this.action_infos = this.action_infos.filter((info) => {
|
this.action_infos = this.action_infos.filter((info) => {
|
||||||
|
|
@ -62,17 +38,103 @@ patch(ActionContainer.prototype, {
|
||||||
this.render();
|
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) {
|
_on_active_action(action_info) {
|
||||||
debugger
|
debugger;
|
||||||
this.action_infos.forEach((info) => {
|
this.action_infos.forEach((info) => {
|
||||||
info.active = info.key === action_info.key;
|
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();
|
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() {
|
_close_other_action() {
|
||||||
this.action_infos = this.action_infos.filter((info) => {
|
this.action_infos = this.action_infos.filter((info) => {
|
||||||
if (info.active == false) {
|
if (info.active == false) {
|
||||||
|
|
@ -84,7 +146,6 @@ patch(ActionContainer.prototype, {
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
_close_current_action() {
|
_close_current_action() {
|
||||||
debugger
|
|
||||||
this.action_infos = this.action_infos.filter((info) => {
|
this.action_infos = this.action_infos.filter((info) => {
|
||||||
if (info.active == true) {
|
if (info.active == true) {
|
||||||
delete this.controllerStacks[info.key];
|
delete this.controllerStacks[info.key];
|
||||||
|
|
@ -95,7 +156,6 @@ patch(ActionContainer.prototype, {
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
_on_close_all_action() {
|
_on_close_all_action() {
|
||||||
debugger
|
|
||||||
this.action_infos.forEach((info) => {
|
this.action_infos.forEach((info) => {
|
||||||
delete this.controllerStacks[info.key];
|
delete this.controllerStacks[info.key];
|
||||||
});
|
});
|
||||||
|
|
@ -108,11 +168,12 @@ ActionContainer.components = {
|
||||||
...ActionContainer.components,
|
...ActionContainer.components,
|
||||||
AklMultiTab,
|
AklMultiTab,
|
||||||
};
|
};
|
||||||
|
|
||||||
ActionContainer.template = xml`
|
ActionContainer.template = xml`
|
||||||
<t t-name="web.ActionContainer">
|
<t t-name="web.ActionContainer">
|
||||||
<t t-set="action_infos" t-value="action_infos" />
|
<t t-set="action_infos" t-value="action_infos" />
|
||||||
<div class="o_action_manager d-flex flex-colum">
|
<div class="o_action_manager d-flex flex-colum">
|
||||||
<AklMultiTab
|
<AklMultiTab
|
||||||
action_infos="action_infos"
|
action_infos="action_infos"
|
||||||
active_action="(action_info) => this._on_active_action(action_info)"
|
active_action="(action_info) => this._on_active_action(action_info)"
|
||||||
close_action="(action_info) => this._on_close_action(action_info)"
|
close_action="(action_info) => this._on_close_action(action_info)"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue