| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- window.clickSubmit = function(e)
- {
- const status = $(e.submitter).data('status');
- if(status === undefined) return;
- const method = typeof(page) !== 'undefined' ? page : config.currentMethod;
- let storyStatus = status;
- if(status == 'active' && method != 'batchcreate')
- {
- storyStatus = !$('[name^=reviewer]').val() || $('#needNotReview').prop('checked') ? 'active' : 'reviewing';
- }
- if(status == 'draft' && (method == 'change' || (method == 'edit' && $('#status').val() == 'changing')))
- {
- storyStatus = 'changing';
- }
- $(e.submitter).closest('form').find('[name=status]').val(storyStatus);
- };
- window.unlinkTwins = function(e)
- {
- const $this = $(e.target).closest('li').find('.relievedTwins');
- const $ul = $this.closest('ul');
- const postData = new FormData();
- postData.append('twinID', $this.data('id'));
- zui.Modal.confirm({message: window.relievedTip || $ul.data('relievedTip'), icon:'icon-exclamation-sign', iconClass: 'warning-pale rounded-full icon-2x'}).then((res) =>
- {
- if(res)
- {
- $.post($.createLink('story', 'ajaxRelieveTwins'), postData, function()
- {
- $this.closest('li').remove();
- if($ul.find('li').length == 0) $ul.closest('.section').remove();
- });
- }
- });
- };
- window.toggleFeedback = function(obj)
- {
- if(storyType == 'requirement') return false;
- const $this = $(obj);
- const source = $this.val();
- if(!source) return;
- $('.feedbackBox').toggleClass('hidden', !feedbackSource.includes(source));
- }
- window.loadBranchModule = function(productID)
- {
- const branch = $('[name=branch]').val();
- const moduleID = $('[name=module]').val();
- if(!branch) branch = 0;
- var moduleLink = $.createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=story&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=&extra=nodeleted¤tModuleID=' + moduleID);
- const $modulePicker = $('[name^=module]').zui('picker');
- $.getJSON(moduleLink, function(data)
- {
- $modulePicker.render({items: data.items})
- $modulePicker.$.setValue(moduleID);
- });
- };
- window.loadProductPlans = function(productID, branch)
- {
- if(typeof(branch) == 'undefined') branch = 0;
- if(!branch) branch = 0;
- let params = config.currentMethod == 'create' ? 'unexpired,noclosed' : '';
- let planLink = $.createLink('product', 'ajaxGetPlans', 'productID=' + productID + '&branch=' + branch + '¶ms=' + params + '&skipParent=true');
- let $planIdBox = $('div[data-name="plan"] #planIdBox');
- $.get(planLink, function(data)
- {
- let items = JSON.parse(data);
- let $inputGroup = $planIdBox.closest('.input-group');
- $inputGroup.html("<span id='planIdBox'><div class='picker-box' id='plan'></div></span>")
- new zui.Picker('#planIdBox #plan', {items: items, name: 'plan', defaultValue: ''});
- if(items.length == 0)
- {
- $inputGroup.append('<a class="btn btn-default" type="button" data-size="lg" data-toggle="modal" href="' + $.createLink('productplan', 'create', 'productID=' + productID + '&branch=' + branch) + '"><i class="icon icon-plus"></i></a>');
- $inputGroup.append(`<button class="refresh btn" type="button" onclick="window.loadProductPlans(${productID},${branch})"><i class="icon icon-refresh"></i></button>`);
- }
- })
- };
- window.loadBranch = function()
- {
- var branch = $('[name=branch]').val();
- var productID = $('[name=product]').val();
- if(typeof(branch) == 'undefined') branch = 0;
- if($('[name=roadmap]').length)
- {
- window.loadProductRoadmaps(productID, branch);
- }
- else
- {
- window.loadProductPlans(productID, branch);
- }
- window.loadBranchModule(productID);
- };
- window.setModuleAndPlanByBranch = function(e)
- {
- const $branch = $(e.target);
- const branchID = $branch.val();
- let $row = $branch.closest('tr');
- var moduleLink = $.createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=story&branch=' + branchID + '&rootModuleID=0&returnType=html&fieldID=&extra=nodeleted');
- while($row.length)
- {
- const $modulePicker = $row.find('[name^=module]').zui('picker');
- const moduleID = $row.find('[name^=module]').val();
- $.getJSON(moduleLink, function(data)
- {
- $modulePicker.render({items: data.items})
- $modulePicker.$.setValue(moduleID);
- });
- $row = $row.next('tr');
- if(!$row.find('td[data-name="module"][data-ditto="on"]').length) break;
- }
- var planLink = $.createLink('productPlan', 'ajaxGetProductPlans', 'productID=' + productID + '&branch=' + branchID);
- let $rows = $branch.closest('tr');
- while($rows.length)
- {
- const $planPicker = $rows.find('[name^=plan]').zui('picker');
- const planID = $rows.find('[name^=plan]').val();
- $.getJSON(planLink, function(data)
- {
- $planPicker.render({items: data})
- $planPicker.$.setValue(planID);
- });
- $rows = $rows.next('tr');
- if(!$rows.find('td[data-name="plan"][data-ditto="on"]').length) break;
- }
- }
- window.setSourceNote = function(e)
- {
- const $row = $(e.target).closest('tr');
- const $sourceNote = $row.find('[data-name="sourceNote"]').closest('td');
- renderSourceNote($sourceNote, e.target.value);
- }
- function renderSourceNote($sourceNote, source, sourceNote)
- {
- const $row = $sourceNote.closest('tr');
- const index = $row.attr('data-index');
- const sourceName = $sourceNote.find('input').attr('name');
- if(source === undefined) source = $row.find('[name^="source"]').val();
- if(sourceNote === undefined) sourceNote = '';
- if(source == 'researchreport')
- {
- const sourceNoteID = `sourceNote_${index}`;
- $sourceNote.html(`<div class='form-group-wrapper picker-box' id=${sourceNoteID}></div>`);
- $.getJSON($.createLink('story', 'ajaxGetSourceNote'), function(sourceNoteItems)
- {
- $sourceNotePicker = new zui.Picker(`#${sourceNoteID}`, {items: sourceNoteItems, name: sourceName, defaultValue: sourceNote});
- });
- }
- else
- {
- $sourceNote.html(`<input class="form-control form-batch-input" type="text" autocomplete="off" name=${sourceName} id="sourceNote" data-name="sourceNote">`);
- }
- }
|