From 48f500e5a838ed7b45abe2d94a4c0c09c39edeba Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Wed, 3 Aug 2022 09:37:36 +0800 Subject: [PATCH 01/14] * Code for task #62951. --- config/zentaopms.php | 1 + module/doc/control.php | 39 +++++++++ module/doc/js/create.js | 64 ++++++++++++++ module/doc/js/createbasicinfo.js | 75 ++++++++++++++++ module/doc/lang/de.php | 1 + module/doc/lang/en.php | 1 + module/doc/lang/fr.php | 1 + module/doc/lang/zh-cn.php | 1 + module/doc/model.php | 11 +-- module/doc/view/create.html.php | 6 +- module/doc/view/createbasicinfo.html.php | 105 +++++++++++++++++++++++ module/doc/view/createtexttype.html.php | 1 + 12 files changed, 298 insertions(+), 8 deletions(-) create mode 100644 module/doc/js/createbasicinfo.js create mode 100644 module/doc/view/createbasicinfo.html.php diff --git a/config/zentaopms.php b/config/zentaopms.php index 646f396d0a..8678ad3569 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -222,6 +222,7 @@ $config->openMethods[] = 'kanban.deleteobjectcard'; $config->openMethods[] = 'admin.ignore'; $config->openMethods[] = 'personnel.unbindwhitelist'; $config->openMethods[] = 'tree.viewhistory'; +$config->openMethods[] = 'doc.createbasicinfo'; /* Define the tables. */ define('TABLE_COMPANY', '`' . $config->db->prefix . 'company`'); diff --git a/module/doc/control.php b/module/doc/control.php index 53307bc092..cce5b374d6 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -394,6 +394,45 @@ class doc extends control $this->display(); } + /** + * Create basic info for doc of text type. + * + * @param string $objectType + * @param int $objectID + * @param int|string $libID + * @param int $moduleID + * @param string $docType + * @access public + * @return void + */ + public function createBasicInfo($objectType, $objectID, $libID, $moduleID = 0, $docType = '') + { + /* Get libs and the default lib id. */ + $unclosed = strpos($this->config->doc->custom->showLibs, 'unclosed') !== false ? 'unclosedProject' : ''; + $libs = $this->doc->getLibs($objectType, $extra = "withObject,$unclosed", $libID, $objectID); + if(!$libID and !empty($libs)) $libID = key($libs); + + $lib = $this->doc->getLibByID($libID); + $type = isset($lib->type) ? $lib->type : 'product'; + $libName = isset($lib->name) ? $lib->name . $this->lang->colon : ''; + + $this->view->title = $libName . $this->lang->doc->create; + + $this->view->objectType = $objectType; + $this->view->objectID = zget($lib, $lib->type, 0); + $this->view->libID = $libID; + $this->view->lib = $lib; + $this->view->libs = $libs; + $this->view->libName = $this->dao->findByID($libID)->from(TABLE_DOCLIB)->fetch('name'); + $this->view->moduleOptionMenu = $this->tree->getOptionMenu($libID, 'doc', $startModuleID = 0); + $this->view->moduleID = $moduleID ? (int)$moduleID : (int)$this->cookie->lastDocModule; + $this->view->docType = $docType; + $this->view->groups = $this->loadModel('group')->getPairs(); + $this->view->users = $this->user->getPairs('nocode|noclosed|nodeleted'); + + $this->display(); + } + /** * Edit a doc. * diff --git a/module/doc/js/create.js b/module/doc/js/create.js index 8547c1beeb..f65160705c 100644 --- a/module/doc/js/create.js +++ b/module/doc/js/create.js @@ -61,6 +61,70 @@ $(function() }); if($(".createCustomLib").length == 1) $(".createCustomLib").click(); // Fix bug #15139. + + if(!fromGlobal) + { + var basicInfo = JSON.parse(sessionStorage.getItem('docBasicInfo')); + var docFiles = JSON.parse(sessionStorage.getItem('docFiles')); + var fileNames = []; + var mailto = []; + var groups = []; + var users = []; + var libID = 0; + var moduleID = 0; + var title = ''; + var keywords = ''; + var type = ''; + var acl = ''; + var contentType = ''; + + $.each(basicInfo, function(index, value) + { + switch(value.name) + { + case 'lib': + libID = value.value; + break; + case 'module': + moduleID = value.value; + break; + case 'title': + title = value.value; + break; + case 'keywords': + keywords = value.value; + break; + case 'type': + type = value.value; + break; + case 'acl': + acl = value.value; + break; + case 'contentType': + contentType = value.value; + break; + case 'labels[]': + fileNames.push(value.value); + break; + case 'mailto[]': + mailto.push(value.value); + break; + case 'groups[]': + groups.push(value.value); + break; + case 'users[]': + users.push(value.value); + break; + } + }) + + $('#modalBasicInfo #keywords').val(keywords); + $('#modalBasicInfo #mailto').data('zui.picker').setValue(mailto); + $('#modalBasicInfo input:radio[value='+ acl +']').attr('checked', 'checked'); + toggleAcl($('input[name="acl"]:checked').val(), 'doc'); + setTimeout(function(){$('#modalBasicInfo #groups').data('zui.picker').setValue(groups)}, 1000); + setTimeout(function(){$('#modalBasicInfo #users').data('zui.picker').setValue(users)}, 1000); + } }) function toggleEditor(type) diff --git a/module/doc/js/createbasicinfo.js b/module/doc/js/createbasicinfo.js new file mode 100644 index 0000000000..3b0ef56328 --- /dev/null +++ b/module/doc/js/createbasicinfo.js @@ -0,0 +1,75 @@ +$(function() +{ + toggleAcl($('input[name="acl"]:checked').val(), 'doc'); + + if($(".createCustomLib").length == 1) $(".createCustomLib").click(); // Fix bug #15139. + + $('#saveBtn').click(function() + { + var params = $('#dataform').serializeArray(); + + var files = []; + $("input[name^='file']").each(function() + { + files.push($(this).val()); + }); + + sessionStorage.setItem('docBasicInfo', JSON.stringify(params)); + sessionStorage.setItem('docFiles', JSON.stringify(files)); + + var libID = $('#lib').val(); + var moduleID = $('#module').val(); + var link = createLink('doc', 'create', 'objectType=' + objectType + '&objectID=' + objectID + '&libID=' + libID + '&moduleID=' + moduleID + '&docType=' + docType); + + parent.location.href = link; + }) +}) + +/** + * Load whitelist by libID. + * + * @param int $libID + * @access public + * @return void + */ +function loadWhitelist(libID) +{ + var groupLink = createLink('doc', 'ajaxGetWhitelist', 'libID=' + libID + '&acl=&control=group'); + var userLink = createLink('doc', 'ajaxGetWhitelist', 'libID=' + libID + '&acl=&control=user'); + $.post(groupLink, function(groups) + { + if(groups != 'private') + { + $('#groups').replaceWith(groups); + $('#groups').next('.picker').remove(); + $('#groups').picker(); + } + }); + + $.post(userLink, function(users) + { + if(users == 'private') + { + $('#aclopen').parent('.radio-inline').addClass('hidden'); + $('#aclcustom').parent('.radio-inline').addClass('hidden'); + $('#whiteListBox').addClass('hidden'); + $('#aclprivate').prop('checked', true); + } + else if(users == 'project') + { + $('#aclprivate').parent('.radio-inline').addClass('hidden'); + $('#aclcustom').parent('.radio-inline').addClass('hidden'); + $('#whiteListBox').addClass('hidden'); + $('#aclopen').prop('checked', true); + } + else + { + $('#aclopen').parent('.radio-inline').removeClass('hidden'); + $('#aclcustom').parent('.radio-inline').removeClass('hidden'); + + $('#users').replaceWith(users); + $('#users').next('.picker').remove(); + $('#users').picker(); + } + }); +} diff --git a/module/doc/lang/de.php b/module/doc/lang/de.php index d0cec076ed..1bda5ad37e 100644 --- a/module/doc/lang/de.php +++ b/module/doc/lang/de.php @@ -94,6 +94,7 @@ $lang->doc->main = 'Main Document Library'; $lang->doc->order = 'Order'; $lang->doc->doc = 'Document'; $lang->doc->updateOrder = 'Update Order'; +$lang->doc->nextStep = 'Next'; $lang->doc->moduleDoc = 'Nach Modulen'; $lang->doc->searchDoc = 'Suche'; diff --git a/module/doc/lang/en.php b/module/doc/lang/en.php index 89bbf20472..b719793600 100644 --- a/module/doc/lang/en.php +++ b/module/doc/lang/en.php @@ -94,6 +94,7 @@ $lang->doc->main = 'Main Document Library'; $lang->doc->order = 'Order'; $lang->doc->doc = 'Document'; $lang->doc->updateOrder = 'Update Order'; +$lang->doc->nextStep = 'Next'; $lang->doc->moduleDoc = 'By Module'; $lang->doc->searchDoc = 'Search'; diff --git a/module/doc/lang/fr.php b/module/doc/lang/fr.php index bddd310eb6..f544dd2113 100644 --- a/module/doc/lang/fr.php +++ b/module/doc/lang/fr.php @@ -94,6 +94,7 @@ $lang->doc->main = 'Main Document Library'; $lang->doc->order = 'Order'; $lang->doc->doc = 'Document'; $lang->doc->updateOrder = 'Update Order'; +$lang->doc->nextStep = 'Next'; $lang->doc->moduleDoc = 'Par Module'; $lang->doc->searchDoc = 'Rechercher'; diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index daf3821f7f..ca2ba27227 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -94,6 +94,7 @@ $lang->doc->main = '文档主库'; $lang->doc->order = '排序'; $lang->doc->doc = '文档'; $lang->doc->updateOrder = '更新排序'; +$lang->doc->nextStep = '下一步'; $lang->doc->moduleDoc = '按模块浏览'; $lang->doc->searchDoc = '搜索'; diff --git a/module/doc/model.php b/module/doc/model.php index 07fed51fb8..f63d788e49 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -2126,11 +2126,12 @@ class docModel extends model { foreach($this->lang->doc->typeList as $typeKey => $typeName) { - $class = (strpos($this->config->doc->officeTypes, $typeKey) !== false or strpos($this->config->doc->textTypes, $typeKey) !== false) ? 'iframe' : ''; - $icon = zget($this->config->doc->iconList, $typeKey); - $html .= "
  • "; - $html .= html::a(helper::createLink('doc', 'create', "objectType=$objectType&objectID=$objectID&libID=$libID&moduleID=0&type=$typeKey", '', $class ? true : false), " " . $typeName, '', "class='$class' data-app='{$this->app->tab}'"); - $html .= "
  • "; + $class = (strpos($this->config->doc->officeTypes, $typeKey) !== false or strpos($this->config->doc->textTypes, $typeKey) !== false) ? 'iframe' : ''; + $icon = zget($this->config->doc->iconList, $typeKey); + $method = strpos($this->config->doc->textTypes, $typeKey) !== false ? 'createBasicInfo' : 'create'; + $html .= "
  • "; + $html .= html::a(helper::createLink('doc', $method, "objectType=$objectType&objectID=$objectID&libID=$libID&moduleID=0&type=$typeKey", '', $class ? true : false), " " . $typeName, '', "class='$class' data-app='{$this->app->tab}'"); + $html .= "
  • "; if($typeKey == 'url') $html .= '
  • '; } } diff --git a/module/doc/view/create.html.php b/module/doc/view/create.html.php index 833b42349b..a8da1b73e2 100644 --- a/module/doc/view/create.html.php +++ b/module/doc/view/create.html.php @@ -10,7 +10,7 @@ * @link http://www.zentao.net */ ?> - +doc->textTypes, $docType) !== false):?> doc->officeTypes, $docType) !== false):?> @@ -72,8 +72,7 @@ $("a[href^='###']").click(function() doc->keywords;?> doc->keywordsTips}'");?> - config->doc->textTypes, $docType) !== false ? 'hidden' : '';?> - + doc->content;?>
    @@ -145,6 +144,7 @@ $("a[href^='###']").click(function() + doc->noticeAcl['doc']);?> diff --git a/module/doc/view/createbasicinfo.html.php b/module/doc/view/createbasicinfo.html.php new file mode 100644 index 0000000000..b732261772 --- /dev/null +++ b/module/doc/view/createbasicinfo.html.php @@ -0,0 +1,105 @@ + + * @package doc + * @version $Id: createbasicinfo.html.php 2022-08-02 13:49:25Z $ + * @link http://www.zentao.net + */ +?> + +doc->placeholder);?> + +
    +
    +
    +

    doc->create;?>

    +
    + + ' . $lang->doc->createLib, '', 'class="iframe hidden createCustomLib"');?> + +
    + + + + + + + + + + + + + + + + + + + + + doc->types as $typeKey => $typeName) $typeKeyList[$typeKey] = $typeKey; + ?> + + + + + + + + + + + + + + + + + + + + + + +
    doc->lib;?>
    doc->module;?> + +
    doc->title;?>
    doc->keywords;?>doc->keywordsTips}'");?>
    doc->files;?>fetch('file', 'buildform');?>
    doc->mailto;?> +
    + fetch('my', 'buildContactLists'); + ?> +
    +
    doclib->control;?> + acl == 'default' ? 'open' : $lib->acl;?> + type == 'project' and $acl == 'private') ? 'open' : $acl;?> + doc->aclList, $acl, "onchange='toggleAcl(this.value, \"doc\")'");?> + doc->noticeAcl['doc'][$acl];?> +
    + + doc->nextStep, "id='saveBtn'", "btn btn-wide btn-primary");?> +
    +
    +
    +
    + + + +doc->noticeAcl['doc']);?> + diff --git a/module/doc/view/createtexttype.html.php b/module/doc/view/createtexttype.html.php index 0f0c667773..ee6926a381 100644 --- a/module/doc/view/createtexttype.html.php +++ b/module/doc/view/createtexttype.html.php @@ -191,5 +191,6 @@ $(function() }) + doc->noticeAcl['doc']);?> From c5eb6c53d90ae5ea3560b0fe2d8d1a53ca042a09 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Wed, 3 Aug 2022 10:49:55 +0800 Subject: [PATCH 02/14] * Finish task #62962. --- module/doc/view/createtexttype.html.php | 1 - module/doc/view/edittexttype.html.php | 1 - 2 files changed, 2 deletions(-) diff --git a/module/doc/view/createtexttype.html.php b/module/doc/view/createtexttype.html.php index ee6926a381..23066ab618 100644 --- a/module/doc/view/createtexttype.html.php +++ b/module/doc/view/createtexttype.html.php @@ -55,7 +55,6 @@ #backBtn i {font-size: 20px;} .modal-title {font-size: 14px !important; font-weight: 700 !important;} -#modalBasicInfo .modal-dialog {width: 720px;} ' . $lang->doc->createLib, '', 'class="iframe hidden createCustomLib"');?> diff --git a/module/doc/view/edittexttype.html.php b/module/doc/view/edittexttype.html.php index ded396749b..d648f5a48a 100644 --- a/module/doc/view/edittexttype.html.php +++ b/module/doc/view/edittexttype.html.php @@ -58,7 +58,6 @@ #backBtn i {font-size: 20px;} .modal-title {font-size: 14px !important; font-weight: 700 !important;} -#modalBasicInfo .modal-dialog {width: 720px;} createLink('doc', 'objectlibs', "type=$type&objectID=$objectID&libID={$lib->id}&docID={$doc->id}");?>
    From 7ffe013d41605c03dbd2742c6d3723ab9f2ebbea Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Thu, 4 Aug 2022 10:24:26 +0800 Subject: [PATCH 03/14] * Change the upload file control to uploader. --- module/doc/control.php | 15 +----- module/doc/css/create.css | 1 + module/doc/css/createbasicinfo.css | 1 + module/doc/js/create.js | 25 ++++++---- module/doc/js/createbasicinfo.js | 9 ++-- module/doc/view/createbasicinfo.html.php | 26 +++++++++- module/doc/view/createtexttype.html.php | 61 ++++++++++++++++++++---- module/doc/view/edittexttype.html.php | 44 +++++++++++++---- module/doc/view/selectlibtype.html.php | 2 +- 9 files changed, 134 insertions(+), 50 deletions(-) create mode 100644 module/doc/css/createbasicinfo.css diff --git a/module/doc/control.php b/module/doc/control.php index cce5b374d6..4b6c2742e2 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -319,19 +319,8 @@ class doc extends control if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $docID)); $objectID = zget($lib, $lib->type, 0); $params = "type={$lib->type}&objectID=$objectID&libID={$lib->id}&docID=" . $docResult['id']; - $link = isonlybody() ? 'parent' : $this->createLink('doc', 'objectLibs', $params, 'html') . '#app=' . $this->app->tab; - $response = array('result' => 'success', 'message' => $this->lang->saveSuccess); - - if(isonlybody() and $docResult['docType'] == 'text') - { - $link = helper::createLink('doc', 'edit', "docID=$docID&comment=false&objectType=$objectType&objectID=$objectID&libID={$docResult['libID']}"); - - $response['callback'] = "redirect2Edit($docID, \"$objectType\", $objectID, {$docResult['libID']})"; - } - else - { - $response['locate'] = "$link"; - } + $link = isonlybody() ? 'parent' : $this->createLink('doc', 'objectLibs', $params) . '#app=' . $this->app->tab; + $response = array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $link); return $this->send($response); } diff --git a/module/doc/css/create.css b/module/doc/css/create.css index 2371fb6c58..e44778861c 100644 --- a/module/doc/css/create.css +++ b/module/doc/css/create.css @@ -1,2 +1,3 @@ #whiteListBox .input-group:last-child {margin-top: 10px;} .fullscreen-save, .markdown-fullscreen-save {position: fixed; top: 10px; right: 30px; z-index: 999999;} +#uploader {margin-bottom: 0 !important;} diff --git a/module/doc/css/createbasicinfo.css b/module/doc/css/createbasicinfo.css new file mode 100644 index 0000000000..95278f9d29 --- /dev/null +++ b/module/doc/css/createbasicinfo.css @@ -0,0 +1 @@ +#uploader {margin-bottom: 0 !important;} diff --git a/module/doc/js/create.js b/module/doc/js/create.js index f65160705c..73b1518580 100644 --- a/module/doc/js/create.js +++ b/module/doc/js/create.js @@ -64,12 +64,6 @@ $(function() if(!fromGlobal) { - var basicInfo = JSON.parse(sessionStorage.getItem('docBasicInfo')); - var docFiles = JSON.parse(sessionStorage.getItem('docFiles')); - var fileNames = []; - var mailto = []; - var groups = []; - var users = []; var libID = 0; var moduleID = 0; var title = ''; @@ -77,6 +71,13 @@ $(function() var type = ''; var acl = ''; var contentType = ''; + var fileNames = []; + var mailto = []; + var groups = []; + var users = []; + var basicInfo = JSON.parse(sessionStorage.getItem('docBasicInfo')); + var docFiles = JSON.parse(sessionStorage.getItem('docFiles')); + console.log(docFiles); $.each(basicInfo, function(index, value) { @@ -103,9 +104,6 @@ $(function() case 'contentType': contentType = value.value; break; - case 'labels[]': - fileNames.push(value.value); - break; case 'mailto[]': mailto.push(value.value); break; @@ -118,12 +116,21 @@ $(function() } }) + $('#title').val(title); $('#modalBasicInfo #keywords').val(keywords); $('#modalBasicInfo #mailto').data('zui.picker').setValue(mailto); $('#modalBasicInfo input:radio[value='+ acl +']').attr('checked', 'checked'); toggleAcl($('input[name="acl"]:checked').val(), 'doc'); setTimeout(function(){$('#modalBasicInfo #groups').data('zui.picker').setValue(groups)}, 1000); setTimeout(function(){$('#modalBasicInfo #users').data('zui.picker').setValue(users)}, 1000); + + $('#uploader').uploader({ + autoUpload: true, + deleteActionOnDone: function(file, doRemoveFile) { + doRemoveFile(); + }, + staticFiles: docFiles + }); } }) diff --git a/module/doc/js/createbasicinfo.js b/module/doc/js/createbasicinfo.js index 3b0ef56328..cbdd37130f 100644 --- a/module/doc/js/createbasicinfo.js +++ b/module/doc/js/createbasicinfo.js @@ -1,5 +1,7 @@ $(function() { + config.onlybody = 'no'; + toggleAcl($('input[name="acl"]:checked').val(), 'doc'); if($(".createCustomLib").length == 1) $(".createCustomLib").click(); // Fix bug #15139. @@ -7,12 +9,7 @@ $(function() $('#saveBtn').click(function() { var params = $('#dataform').serializeArray(); - - var files = []; - $("input[name^='file']").each(function() - { - files.push($(this).val()); - }); + var files = $('#uploader').data('zui.uploader').getFiles(); sessionStorage.setItem('docBasicInfo', JSON.stringify(params)); sessionStorage.setItem('docFiles', JSON.stringify(files)); diff --git a/module/doc/view/createbasicinfo.html.php b/module/doc/view/createbasicinfo.html.php index b732261772..81939b1945 100644 --- a/module/doc/view/createbasicinfo.html.php +++ b/module/doc/view/createbasicinfo.html.php @@ -11,6 +11,8 @@ */ ?> + + doc->placeholder);?>
    @@ -36,7 +38,7 @@ doc->title;?> - + doc->keywords;?> @@ -52,7 +54,19 @@ doc->files;?> - fetch('file', 'buildform');?> + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    + doc->mailto;?> @@ -102,4 +116,12 @@ doc->noticeAcl['doc']);?> + diff --git a/module/doc/view/createtexttype.html.php b/module/doc/view/createtexttype.html.php index 23066ab618..2c468ff7f7 100644 --- a/module/doc/view/createtexttype.html.php +++ b/module/doc/view/createtexttype.html.php @@ -13,6 +13,8 @@ + + doc->placeholder);?>