From 4c20a2428db153dfd0dd1c0d2d84c78f120e08b7 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 23 Mar 2023 14:51:00 +0800 Subject: [PATCH 1/3] * Modify module create. --- module/tree/model.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/module/tree/model.php b/module/tree/model.php index ec097f9200..6c57997f43 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -2349,12 +2349,10 @@ class treeModel extends model $module->order = $module->parent ? $parent->order : $data->order; $this->dao->insert(TABLE_MODULE)->data($module)->exec(); - $moduleID = $this->dao->lastInsertID(); - if($module->parent) - { - $modulePath = $parent->path . "$moduleID,"; - $this->dao->update(TABLE_MODULE)->set('path')->eq($modulePath)->where('id')->eq($moduleID)->limit(1)->exec(); - } + $moduleID = $this->dao->lastInsertID(); + $modulePath = "$moduleID,"; + if($module->parent) $modulePath = $parent->path . $modulePath; + $this->dao->update(TABLE_MODULE)->set('path')->eq($modulePath)->where('id')->eq($moduleID)->limit(1)->exec(); return $this->getByID($moduleID); } From 58423768fa752d42ca9f02934e8a665275412fe2 Mon Sep 17 00:00:00 2001 From: guofeilong Date: Thu, 23 Mar 2023 14:53:59 +0800 Subject: [PATCH 2/3] * Adjust code . --- module/doc/js/tablecontents.js | 63 ++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/module/doc/js/tablecontents.js b/module/doc/js/tablecontents.js index 45f3b0ff0f..61fb4dc136 100644 --- a/module/doc/js/tablecontents.js +++ b/module/doc/js/tablecontents.js @@ -150,6 +150,15 @@ $(function() return dropdown; }; + var moduleData = { + "name": "", + "createType": "", + "libID": '', + "parentID": '', + "objectID": '', + "moduleType": '', + "order": "" + }; $('#fileTree').on('click', '.icon-drop', function(e) { $('.dropdown-in-tree').css('display', 'none'); @@ -157,18 +166,31 @@ $(function() var dropDownID = isCatalogue ? 'dropDownCatalogue' : 'dropDownLibrary'; var libID = 0; var moduleID = 0; + var parentID = 0; var $module = $(this).closest('a'); var hasChildren = $module.data('has-children'); + var moduleType = ''; if($module.hasClass('lib')) { - libID = $module.data('id'); + libID = $module.data('id'); + moduleType = $module.data('type'); + parentID = libID; } else { - moduleID = $module.data('id'); - libID = $module.closest('.lib').data('id'); + moduleID = $module.data('id'); + libID = $module.closest('.lib').data('id'); + moduleType = $module.closest('.lib').data('type'); + parentID = $module.closest('ul').closest('.lib').data('id'); } - + moduleData = { + "createType": "", + "libID": libID, + "parentID": parentID, + "objectID": moduleID, + "moduleType": moduleType == 'lib' ? 'doc' : moduleType, + }; + console.log(moduleData); var option = { left : e.pageX, top : e.pageY, @@ -201,6 +223,8 @@ $(function() switch(item.method) { case 'addCataLib' : + moduleData.createType = 'child'; + moduleData.parentID = 0; var $input = ''; if(item.hasChildren) { @@ -223,32 +247,35 @@ $(function() } }).on('blur', '.file-tree input.input-tree', function() { - var value = $(this).val(); + var $this = $(this); + var value = $this.val(); if(!value) { - $(this).closest('[data-id=insert]').remove(); + $this.closest('[data-id=insert]').remove(); return; } - var moduleData = { - "name": "名称", - "parentID": "父ID", - "createType": "创建类型,child: 子目录, same: 同级", - "objectID": "当前点击对象ID", - "libID": "库ID", - "moduleType": "目录类型, doc|api", - "order": "排序信息" - }; + moduleData.name = value; $.post(createLink('tree', 'ajaxCreateModule'), moduleData, function(result) { + result = JSON.parse(result); if(result.result == 'fail') { - bootbox.alert(result.message); + bootbox.alert( + result.message[0], + function() + { + setTimeout(function() + { + $('.file-tree .input-tree').focus() + }, 10) + }); return false; } - var module = result.module; - $(this).replaceWith($('[data-id=aTreeModal]').html().replace(/%name%/g, module.name).replace(/%id%/g, module.id)); + var resultDom = $('[data-id=aTreeModal]').html().replace(/%name%/g, module.name).replace(/%id%/g, module.id) + $this.parent().append(resultDom); + $this.remove(); }); }); }); From 2448ba7908f3192837779d48adac74cb3f0a6d2c Mon Sep 17 00:00:00 2001 From: guofeilong Date: Thu, 23 Mar 2023 15:28:20 +0800 Subject: [PATCH 3/3] * Adjust code . --- module/doc/js/tablecontents.js | 10 ++++++++-- module/doc/view/tablecontents.html.php | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/module/doc/js/tablecontents.js b/module/doc/js/tablecontents.js index 61fb4dc136..310ebad8d8 100644 --- a/module/doc/js/tablecontents.js +++ b/module/doc/js/tablecontents.js @@ -220,12 +220,12 @@ $(function() } if(item.type !== 'add') return; var $item = $(this); + var $input = ''; switch(item.method) { case 'addCataLib' : moduleData.createType = 'child'; moduleData.parentID = 0; - var $input = ''; if(item.hasChildren) { var $rootDom = $('[data-id=' + item.libid + ']a').parent().find('ul'); @@ -240,7 +240,13 @@ $(function() $rootDom.prepend($input); $rootDom.find('input').focus(); break; - case 'addCata' : + case 'addCataBro' : + moduleData.createType = 'same'; + moduleData.parentID = 0; + $input += $('[data-id=liTreeModal]').html(); + var $rootDom = $('#fileTree [data-id=' + item.id + ']li').closest('ul'); + $rootDom.prepend($input); + $rootDom.find('input').focus(); break; case 'addCataChild' : break; diff --git a/module/doc/view/tablecontents.html.php b/module/doc/view/tablecontents.html.php index 3dffea9551..40931facca 100644 --- a/module/doc/view/tablecontents.html.php +++ b/module/doc/view/tablecontents.html.php @@ -116,8 +116,8 @@