From 14e43e71dc82aa8af2b6865eb4c93e3615e666bf Mon Sep 17 00:00:00 2001 From: wangyidong Date: Tue, 14 Nov 2023 17:32:26 +0800 Subject: [PATCH] * Adjust for create story in task kanban. --- lib/zin/wg/pastedialog/js/v1.js | 2 +- module/execution/js/taskkanban.ui.js | 4 ++-- module/story/js/common.ui.js | 15 ++++++++------- module/story/js/create.ui.js | 9 ++++++--- module/story/ui/create.html.php | 10 +++++----- module/story/zen.php | 3 ++- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/lib/zin/wg/pastedialog/js/v1.js b/lib/zin/wg/pastedialog/js/v1.js index 7d4256611d..0bfa1a4a2a 100644 --- a/lib/zin/wg/pastedialog/js/v1.js +++ b/lib/zin/wg/pastedialog/js/v1.js @@ -3,7 +3,7 @@ function importLines(target, field) const $modal = $(target).closest('.modal'); const $dialog = $modal.find('.modal-dialog'); const $lines = $modal.find('textarea'); - const $form = $modal.closest('.container').find('form.form-batch'); + const $form = $modal.closest('body').find('form.form-batch[data-zui-batchform]'); const modalID = $modal.attr('id'); $dialog.addClass('loading'); diff --git a/module/execution/js/taskkanban.ui.js b/module/execution/js/taskkanban.ui.js index e3fd46b65d..8087999cf6 100644 --- a/module/execution/js/taskkanban.ui.js +++ b/module/execution/js/taskkanban.ui.js @@ -137,14 +137,14 @@ window.buildColCardActions = function(col) let actions = []; if(col.type == 'backlog') { - if(priv.canCreateStory) actions.push({text: storyLang.create, url:$.createLink('story', 'create', 'productID=' + productID + '&branch=0&moduleID=0&storyID=0&objectID=' + executionID), 'data-toggle': 'modal'}); + if(priv.canCreateStory) actions.push({text: storyLang.create, url:$.createLink('story', 'create', 'productID=' + productID + '&branch=0&moduleID=0&storyID=0&objectID=' + executionID), 'data-toggle': 'modal', 'data-size': 'lg'}); if(priv.canBatchCreateStory) actions.push({text: executionLang.batchCreateStory, url: $.createLink('story', 'batchcreate', 'productID=' + productID + '&branch=0&moduleID=0&storyID=0&executionID=' + executionID), 'data-toggle': 'modal', 'data-size': 'lg'}); if(priv.canLinkStory) actions.push({text: executionLang.linkStory, url: $.createLink('execution', 'linkStory', 'executionID=' + executionID), 'data-toggle': 'modal', 'data-size': 'lg'}); if(priv.canLinkStoryByPlan) actions.push({text: executionLang.linkStoryByPlan, url: '#linkStoryByPlan', 'data-toggle': 'modal'}); } else if(col.type == 'unconfirmed') { - if(priv.canCreateBug) actions.push({text: bugLang.create, url: $.createLink('bug', 'create', 'productID=0&moduleID=0&extra=executionID=' + executionID), 'data-toggle': 'modal'}); + if(priv.canCreateBug) actions.push({text: bugLang.create, url: $.createLink('bug', 'create', 'productID=0&moduleID=0&extra=executionID=' + executionID), 'data-toggle': 'modal', 'data-size': 'lg'}); if(priv.canBatchCreateBug) { if(productNum > 1) actions.push({text: bugLang.batchCreate, url: '#batchCreateBug', 'data-toggle': 'modal', 'data-size': 'lg'}); diff --git a/module/story/js/common.ui.js b/module/story/js/common.ui.js index 0a78b1b86f..cdd64a4921 100644 --- a/module/story/js/common.ui.js +++ b/module/story/js/common.ui.js @@ -26,7 +26,7 @@ window.customSubmit = function(e) if($this.prop('tagName') != 'BUTTON') $this = $this.closest('button'); var storyStatus = 'active'; - if(!$dataform.hasClass('form-batch')) storyStatus = !$('#reviewer').zui('picker').$.value || $('#needNotReview').prop('checked') ? 'active' : 'reviewing'; + if(!$dataform.hasClass('form-batch')) storyStatus = !$('[name=reviewer]').val() || $('#needNotReview').prop('checked') ? 'active' : 'reviewing'; if($this.attr('id') == 'saveDraftButton') { storyStatus = 'draft'; @@ -38,6 +38,7 @@ window.customSubmit = function(e) $.ajaxSubmit( { + headers: $this.closest('.modal').length > 0 ? {'X-Zui-Modal': 'modal'} : {}, data: new FormData($dataform[0]), url: $dataform.attr('action'), onSuccess: function(result) {loadPage(result.load)}, @@ -111,10 +112,10 @@ window.toggleFeedback = function(obj) window.loadURS = function(allURS) { - var productID = $('#product').zui('picker').$.state.value; - var branchID = $('#branch').length == 0 ? 0 : $('#branch').zui('picker').$.state.value; - var moduleID = typeof(allURS) == 'undefined' ? $('#module').zui('picker').$.state.value : 0; - var requirementList = $('#URS').zui('picker').$.state.value; + var productID = $('[name=product]').val(); + var branchID = $('[name=branch]').length == 0 ? 0 : $('[name=#branch]').val(); + var moduleID = typeof(allURS) == 'undefined' ? $('[name=module]').val() : 0; + var requirementList = $('[name=URS]').val(); requirementList = requirementList ? encodeURIComponent(requirementList.join(',')) : ''; if(typeof(branchID) == 'undefined') branchID = 0; @@ -177,8 +178,8 @@ window.loadProductPlans = function(productID, branch) window.loadBranch = function() { - var branch = $('#branch').val(); - var productID = $('#product').val(); + var branch = $('[name=branch]').val(); + var productID = $('[name=product]').val(); if(typeof(branch) == 'undefined') branch = 0; loadProductModules(productID, branch); diff --git a/module/story/js/create.ui.js b/module/story/js/create.ui.js index 269de9e42d..7583447e10 100644 --- a/module/story/js/create.ui.js +++ b/module/story/js/create.ui.js @@ -5,7 +5,7 @@ window.toggleReviewer = function(obj) const $this = $(obj); const isChecked = $this.prop('checked'); - $reviewer = $('#reviewer').zui('picker'); + $reviewer = $('[name=reviewer]').zui('picker'); options = $reviewer.options; if(isChecked) { @@ -46,7 +46,10 @@ window.loadProduct = function(e) { const $this = $(e.target); const productID = $this.val(); - loadPage($.createLink('story', 'create', 'productID=' + productID + '&' + createParams)) + const $modal = $this.closest('.modal'); + const inModal = $modal.length > 0; + if(inModal) loadModal($.createLink('story', 'create', 'productID=' + productID + '&' + createParams), $modal.attr('id')); + if(!inModal) loadPage($.createLink('story', 'create', 'productID=' + productID + '&' + createParams)); }; window.loadBranchRelation = function(e) @@ -65,7 +68,7 @@ window.loadBranchRelation = function(e) window.addBranchesBox = function(e) { - const productID = $('#product').zui('picker').$.value; + const productID = $('[name=product]').val(); const $formRow = $(e.target).closest('.form-row'); const $branchPicker = $('.switchBranch #branchBox .picker-box').zui('picker'); const $modulePicker = $('.switchBranch #moduleIdBox .picker-box').zui('picker'); diff --git a/module/story/ui/create.html.php b/module/story/ui/create.html.php index 3109e23f61..b38ffa6e37 100644 --- a/module/story/ui/create.html.php +++ b/module/story/ui/create.html.php @@ -40,16 +40,16 @@ formPanel set::customFields(true), formRow ( - on::change('#product', 'loadProduct'), - on::change('#branch', 'loadBranch'), + on::change('[name=product]', 'loadProduct'), + on::change('[name=branch]', 'loadBranch'), formGroup ( set::label($lang->story->product), set::width('1/2'), inputGroup ( - picker(setID('product'), set::name('product'), set::value($fields['product']['default']), set::items($fields['product']['options'])), - isset($fields['branch']) && $type != 'story' ? picker(setID('branch'), set::name('branch'), set::items($fields['branch']['options']), set::value($fields['branch']['default'])) : null, + picker(set::name('product'), set::value($fields['product']['default']), set::items($fields['product']['options'])), + isset($fields['branch']) && $type != 'story' ? picker(set::name('branch'), set::items($fields['branch']['options']), set::value($fields['branch']['default'])) : null, ), set::required(true), ), @@ -167,7 +167,7 @@ formPanel span ( set::id('planIdBox'), - picker(setID('plan'), set::name('plan'), set::items($fields['plan']['options']), set::value($fields['plan']['default'])), + picker(set::name('plan'), set::items($fields['plan']['options']), set::value($fields['plan']['default'])), ), empty($fields['plan']['options']) ? btn(set::url($this->createLink('productplan', 'create', "productID=$productID&branch=$branch")), set('data-toggle', 'modal'), set::title($lang->productplan->create), icon('plus')) : null, empty($fields['plan']['options']) ? btn(setClass('refresh'), set::title($lang->refresh), set('onclick', "loadProductPlans($productID)"), icon('refresh')) : null, diff --git a/module/story/zen.php b/module/story/zen.php index 3b0bf9e1e1..537b044f5c 100644 --- a/module/story/zen.php +++ b/module/story/zen.php @@ -1072,9 +1072,10 @@ class storyZen extends story protected function getAssignMeBlockID(): int { if(!isonlybody()) return 0; - return (int)$this->dao->select('id')->from(TABLE_BLOCK)->where('block')->eq('assigntome') + return (int)$this->dao->select('id')->from(TABLE_BLOCK)->where('module')->eq('assigntome') ->andWhere('module')->eq('my') ->andWhere('account')->eq($this->app->user->account) + ->andWhere('vision')->eq($this->config->vision) ->orderBy('order_desc') ->limit(1) ->fetch('id');