mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
N°3901 - Polishing: Menu
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user