From 7a19e22ea9ebf5f50e0ee36acb34f7f08d6b8cff Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 17 Aug 2023 10:09:21 +0800 Subject: [PATCH] * Adjust for batchedit page. --- module/my/js/todo.ui.js | 26 +++++++++++++++----------- module/todo/js/batchedit.ui.js | 29 +++++++++++++++++++++++++---- module/todo/ui/batchedit.html.php | 3 ++- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/module/my/js/todo.ui.js b/module/my/js/todo.ui.js index dfffcbd3c0..a289253b8a 100644 --- a/module/my/js/todo.ui.js +++ b/module/my/js/todo.ui.js @@ -41,18 +41,22 @@ window.setStatistics = function(element, checks) return zui.formatString(element.options.defaultSummary); } -window.generateHtml = function(event, options) +window.generateHtml = function(event) { - const dtable = zui.DTable.query(event.target); - const checkedList = dtable.$.getChecks(); - if(!checkedList.length) return; + try + { + const dtable = zui.DTable.query(event.target); + const checkedList = dtable.$.getChecks(); + if(!checkedList.length) return; - let html = "
"; - html += ""; - html += ""; - html += "
"; + let html = "
"; + html += ""; + html += ""; + html += "
"; - return {html}; + return {html}; + } + catch(error){} } diff --git a/module/todo/js/batchedit.ui.js b/module/todo/js/batchedit.ui.js index d931038e6f..2cbb8175eb 100644 --- a/module/todo/js/batchedit.ui.js +++ b/module/todo/js/batchedit.ui.js @@ -15,9 +15,10 @@ window.renderRowData = function($row, index, row) let $nameBox = $row.find('td[data-name="name"]'); $nameBox.html("
"); data = {}; - data.name = 'name'; - data.items = nameItems[row.type]; - data.defaultValue = row.objectID; + data.name = 'name'; + data.multiple = false; + data.items = nameItems[row.type]; + data.defaultValue = row.objectID; $nameBox.find('#name').picker(data); } } @@ -43,4 +44,24 @@ window.togglePending = function(e) { $(this).zui('picker').render({disabled: e.target.checked}); }); -} +}; + +window.changeType = function(e) +{ + const type = e.target.value; + const $tr = $(e.target).closest('tr'); + const index = $tr.find('.form-control-static[data-name="id"]').text() + const $nameBox = $tr.find('[data-name="name"]'); + + if(moduleList.indexOf(type) !== -1) + { + items = nameItems[type]; + $nameBox.html("
"); + $nameBox.find('#name').picker({items: items, name: 'name'}); + } + else + { + $nameBox.html($('#nameInputBox').html()); + $nameBox.find('input[name=name]').attr('name', 'name[' + index + ']').attr('id', 'name_' + index); + } +}; diff --git a/module/todo/ui/batchedit.html.php b/module/todo/ui/batchedit.html.php index ea613c6cec..e1ca84f347 100644 --- a/module/todo/ui/batchedit.html.php +++ b/module/todo/ui/batchedit.html.php @@ -33,6 +33,7 @@ $fnGenerateCustomizedFields = function() use ($showFields, $customFields) jsVar('nameItems', $nameItems); jsVar('timeItems', $timeItems); +jsVar('moduleList', $config->todo->moduleList); div ( @@ -71,7 +72,7 @@ formBatchPanel set::mode('edit'), set::data(array_values($editedTodos)), set::onRenderRow(jsRaw('renderRowData')), - on::change('[data-name="type"]', 'setNameCell'), + on::change('[data-name="type"]', 'changeType'), on::click('.time-check', "window.togglePending"), formBatchItem (