+ Zin: Add module function.
This commit is contained in:
@@ -7,8 +7,10 @@
|
||||
#docDropmenu .is-leading {display: none;}
|
||||
#docDropmenu .primary {--tw-ring-color: var(--btn-border-color); background-color: var(--btn-bg); color: inherit; width: 100%;}
|
||||
|
||||
.module-menu .tree .tree-link {text-overflow: clip; overflow: hidden; flex: 1 1 auto;}
|
||||
.module-menu .tree .tree-actions {margin-left: 0;}
|
||||
.module-menu .tree .tree-item .tree-link {text-overflow: clip; overflow: hidden; flex: 1 10 auto;}
|
||||
.module-menu .tree .tree-item .tree-actions {margin-left: 0;}
|
||||
.module-menu .tree .tree-item .tree-actions .icon {display: none;}
|
||||
.module-menu .tree .tree-item .tree-item-content:hover .tree-actions .icon {display: block;}
|
||||
|
||||
.tree > .tree-item > .project-tree-title {font-size: 16px; margin-bottom: 0.5rem;}
|
||||
.tree > .tree-item > .project-tree-title .text {margin-left: 0.5rem;}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
window.saveModule = function()
|
||||
{
|
||||
const name = $(this).val();
|
||||
if(!name) return $(this).closest('.tree-item').remove();
|
||||
|
||||
const {id, type, lib, module} = $(this).data();
|
||||
const parentID = $(this).data('parent');
|
||||
|
||||
const $element = $(`div[data-id='${id}']`);
|
||||
$.ajaxSubmit({
|
||||
url: $.createLink('tree', 'ajaxCreateModule'),
|
||||
data: {
|
||||
name : name,
|
||||
libID : lib,
|
||||
parentID : parentID,
|
||||
objectID : id,
|
||||
moduleType : module,
|
||||
isUpdate : false,
|
||||
createType : type,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.addModule = function(id, addType)
|
||||
{
|
||||
const $element = $(`div[data-id='${id}']`);
|
||||
const {lib, type, module} = $element.data();
|
||||
|
||||
const parentID = ['docLib'].includes(type) ? '0' : $element.data('parent');
|
||||
const level = addType == 'same' ? $element.data('level') : $element.data('level') + 1;
|
||||
const style = `style="margin-left: calc(${level} * var(--tree-indent, 20px))"`;
|
||||
|
||||
let inputTpl = '<li class="tree-item">';
|
||||
inputTpl += `<div class="tree-item-content" ${style}>`;
|
||||
inputTpl += `<input id="moduleName" class="form-control"
|
||||
data-id="${id}" data-parent="${parentID}" data-type="${addType}" data-lib="${lib}" data-module="${module}"
|
||||
>`;
|
||||
inputTpl += '</div></li>';
|
||||
|
||||
if(addType == 'same')
|
||||
{
|
||||
$(`div[data-id='${id}']`).before(inputTpl);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$element.parent().hasClass('show')) $element.find('.tree-toggle-icon').trigger('click');
|
||||
|
||||
setTimeout(function()
|
||||
{
|
||||
$(`div[data-id='${id}']`).next('.tree').prepend(inputTpl);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
setTimeout(function()
|
||||
{
|
||||
$('#moduleName').trigger('focus');
|
||||
document.getElementById("moduleName").addEventListener('blur', saveModule);
|
||||
}, 1);
|
||||
}
|
||||
+28
-23
@@ -99,12 +99,17 @@ class docMenu extends wg
|
||||
$setting->parentID = $parentID;
|
||||
|
||||
$item = array(
|
||||
'key' => $setting->id,
|
||||
'text' => $setting->name,
|
||||
'icon' => $this->getIcon($setting),
|
||||
'url' => $this->buildLink($setting),
|
||||
'active' => zget($setting, 'active', $setting->id == $activeKey),
|
||||
'actions' => $this->getActions($setting)
|
||||
'key' => $setting->id,
|
||||
'text' => $setting->name,
|
||||
'icon' => $this->getIcon($setting),
|
||||
'url' => $this->buildLink($setting),
|
||||
'data-id' => $setting->id,
|
||||
'data-lib' => $setting->type == 'docLib' ? $setting->id : $setting->libID,
|
||||
'data-type' => $setting->type,
|
||||
'data-parent' => $setting->parentID,
|
||||
'data-module' => $this->currentModule,
|
||||
'active' => zget($setting, 'active', $setting->id == $activeKey),
|
||||
'actions' => $this->getActions($setting)
|
||||
);
|
||||
|
||||
$children = zget($setting, 'children', array());
|
||||
@@ -164,8 +169,8 @@ class docMenu extends wg
|
||||
$treeIcon = 'paper-clip';
|
||||
}
|
||||
$items[] = array(
|
||||
'text' => $treeTitle,
|
||||
'icon' => $treeIcon,
|
||||
'text' => $treeTitle,
|
||||
'icon' => $treeIcon,
|
||||
'class' => 'project-tree-title ' . ($index > 0 ? 'border-t mt-2 pt-2' : ''),
|
||||
);
|
||||
|
||||
@@ -206,19 +211,19 @@ class docMenu extends wg
|
||||
if(hasPriv($this->currentModule, 'addCatalog'))
|
||||
{
|
||||
$menus[] = array(
|
||||
'key' => 'adddirectory',
|
||||
'icon' => 'add-directory',
|
||||
'text' => $this->lang->doc->libDropdown['addModule'],
|
||||
'link' => '',
|
||||
'key' => 'adddirectory',
|
||||
'icon' => 'add-directory',
|
||||
'text' => $this->lang->doc->libDropdown['addModule'],
|
||||
'onClick' => jsRaw("() => addModule({$item->parentID}, 'child')")
|
||||
);
|
||||
}
|
||||
|
||||
if(hasPriv($this->currentModule, 'editCatalog'))
|
||||
{
|
||||
$menus[] = array(
|
||||
'key' => 'editlib',
|
||||
'icon' => 'edit',
|
||||
'text' => $this->lang->doc->libDropdown['editLib'],
|
||||
'key' => 'editlib',
|
||||
'icon' => 'edit',
|
||||
'text' => $this->lang->doc->libDropdown['editLib'],
|
||||
'data-toggle' => 'modal',
|
||||
'data-url' => createlink($this->currentModule, 'editlib', "libid={$item->parentID}"),
|
||||
);
|
||||
@@ -241,16 +246,16 @@ class docMenu extends wg
|
||||
if(hasPriv($this->currentModule, 'addCatalog'))
|
||||
{
|
||||
$menus[] = array(
|
||||
'key' => 'adddirectory',
|
||||
'icon' => 'add-directory',
|
||||
'text' => $this->lang->doc->libDropdown['addSameModule'],
|
||||
'link' => '',
|
||||
'key' => 'adddirectory',
|
||||
'icon' => 'add-directory',
|
||||
'text' => $this->lang->doc->libDropdown['addSameModule'],
|
||||
'onClick' => jsRaw("() => addModule({$item->id}, 'same')")
|
||||
);
|
||||
$menus[] = array(
|
||||
'key' => 'addsubdirectory',
|
||||
'icon' => 'add-directory',
|
||||
'text' => $this->lang->doc->libDropdown['addSubModule'],
|
||||
'link' => '',
|
||||
'key' => 'addsubdirectory',
|
||||
'icon' => 'add-directory',
|
||||
'text' => $this->lang->doc->libDropdown['addSubModule'],
|
||||
'onClick' => jsRaw("() => addModule({$item->id}, 'child')")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user