N°3901 - Polishing: Menu

This commit is contained in:
acognet
2021-09-08 10:25:30 +02:00
parent d2b3de9734
commit 0193868581
3 changed files with 31 additions and 12 deletions

View File

@@ -197,7 +197,7 @@ $(function()
},
_onAddShortcutNode: function (oData) {
this._addShortcut(oData.parent_menu_node_id, oData.new_menu_node_html_rendering);
this._addShortcut(oData.parent_menu_node_id, oData.new_menu_node_html_rendering, oData.new_menu_name);
},
// Methods
@@ -374,13 +374,30 @@ $(function()
* @param sNewMenuNodeHtmlRendering {string} HTML rendering of the new menu node to add
* @return {boolean}
*/
_addShortcut: function (sParentMenuNodeId, sNewMenuNodeHtmlRendering) {
const oNewMenuNodeContainerElem = this.element.find(this.js_selectors.menu_node+'[data-menu-node-id="'+sParentMenuNodeId+'"] > ul');
_addShortcut: function (sParentMenuNodeId, sNewMenuNodeHtmlRendering, new_menu_name) {
const oNewMenuNodeContainerElem = this.element.find(this.js_selectors.menu_node+'[data-menu-node-id="'+sParentMenuNodeId+'"]');
if (oNewMenuNodeContainerElem.length === 0) {
return false;
}
oNewMenuNodeContainerElem.append(sNewMenuNodeHtmlRendering);
let oNewMenuNodeContainerElemUL = oNewMenuNodeContainerElem.find('ul');
if (oNewMenuNodeContainerElemUL.length === 0) {
oNewMenuNodeContainerElem.append('<ul>'+sNewMenuNodeHtmlRendering+'</ul>');
} else {
let children = oNewMenuNodeContainerElem.find('li');
let i = 0;
let bInsertToDo = true;
while (bInsertToDo) {
let currentChild = children.eq(i);
if (currentChild.find(".ibo-navigation-menu--menu-node-label").attr('title').toUpperCase() > new_menu_name.toUpperCase()) {
currentChild.before(sNewMenuNodeHtmlRendering);
bInsertToDo = false;
}
i++;
}
if (bInsertToDo) {
oNewMenuNodeContainerElemUL.append(sNewMenuNodeHtmlRendering);
}
}
return true;
}
});

View File

@@ -1223,7 +1223,8 @@ EOF
$oPage->add_script(<<<JS
$('body').trigger('add_shortcut_node.navigation_menu.itop', {
parent_menu_node_id: '{$sMenuGroupId}',
new_menu_node_html_rendering: `{$sHtml}`
new_menu_node_html_rendering: `{$sHtml}`,
new_menu_name: `{$aValues['name']}`
});
JS
);

View File

@@ -199,13 +199,14 @@ JS
$oBlock = new DisplayBlock($oShortcutsFilter, 'list', false);
$oShortcutsBlock->AddSubBlock($oBlock->GetDisplay($oP, $oShortcutsBlock->sIdShortcuts, [
'view_link' => false,
'menu' => false,
'toolkit_menu' => false,
'selection_mode' => true,
'selection_type' => 'multiple',
'table_id' => 'user_prefs_shortcuts',
'view_link' => false,
'menu' => false,
'toolkit_menu' => false,
'selection_mode' => true,
'selection_type' => 'multiple',
'table_id' => 'user_prefs_shortcuts',
'surround_with_panel' => false,
'id_for_select' => 'Shortcut/_key_',
]));
$oSet = new DBObjectSet($oShortcutsFilter);