diff --git a/module/execution/control.php b/module/execution/control.php index df8c2733c8..eade9f97a4 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1264,6 +1264,13 @@ class execution extends control $customFields[$field] = $field == 'lifetime' ? $this->lang->execution->type : str_replace($this->lang->executionCommon, $this->lang->execution->common, $this->lang->execution->$field); } + $parentIdList = array(); + foreach($executions as $execution) + { + if($execution->parent == 0) continue; + $parentIdList[] = $execution->parent; + } + $this->view->customFields = $customFields; $this->view->showFields = $this->config->execution->custom->batchEditFields; $this->view->title = $this->lang->execution->batchEdit; @@ -1275,6 +1282,7 @@ class execution extends control $this->view->qdUsers = $qdUsers; $this->view->rdUsers = $rdUsers; $this->view->from = $this->app->tab; + $this->view->parents = $this->execution->getByIdList($parentIdList); $this->display(); } diff --git a/module/execution/js/batchedit.ui.js b/module/execution/js/batchedit.ui.js index aa2475aecc..27e0eca8ca 100644 --- a/module/execution/js/batchedit.ui.js +++ b/module/execution/js/batchedit.ui.js @@ -1,16 +1,17 @@ window.renderRowData = function($row, index, row) { - if(row.type == 'stage') + if(row.type == 'stage' || row.attribute != '') { + const parentType = row.grade > 1 && parents[row.parent] ? parents[row.parent].attribute : ''; /* If is stage, modify lifetime to attribute. */ - let stageItems = []; for(let key in stageList) stageItems.push({value: key, text: stageList[key]}); $row.find('[data-name="lifetime"]').find('.picker-box').on('inited', function(e, info) { let $attribute = info[0]; - $attribute.render({items: stageItems, required: true, name: 'attribute'}); + $attribute.render({items: stageItems, required: true, name: 'attribute', disabled: row.grade > 1 && parentType != 'mix'}); + $(e.target).attr('data-parent', row.parent); }); } @@ -51,3 +52,23 @@ window.changeProject = function(e) }); } } + +window.changeAttribute = function(e) +{ + const $attribute = $(e.target); + const attribute = $attribute.val(); + const parentID = $attribute.closest('tr').find('input[name^=id]').val(); + $('[data-parent="' + parentID + '"]').each(function() + { + const $attributePicker = $(this).find('input[name^=attribute]').zui('picker'); + if(attribute == 'mix') + { + $attributePicker.render({disabled: false}); + } + else + { + $attributePicker.render({disabled: true}); + $attributePicker.$.setValue(attribute); + } + }) +} diff --git a/module/execution/ui/batchedit.html.php b/module/execution/ui/batchedit.html.php index 668230bac1..7fa6e51ba9 100644 --- a/module/execution/ui/batchedit.html.php +++ b/module/execution/ui/batchedit.html.php @@ -16,6 +16,7 @@ $showMethod = $app->tab == 'project' && isset($project) && ($project->model == ' jsVar('weekend', $config->execution->weekend); jsVar('stageList', $lang->stage->typeList); jsVar('confirmSync', $lang->execution->confirmSync); +jsVar('parents', $parents); formBatchPanel ( @@ -28,6 +29,7 @@ formBatchPanel on::change('[data-name="project"]', 'changeProject'), on::change('[data-name="begin"]', "computeWorkDays($(e.target).attr('name'))"), on::change('[data-name="end"]', "computeWorkDays($(e.target).attr('name'))"), + on::change('[data-name="attribute"]', 'changeAttribute'), formBatchItem ( set::name('id'), @@ -62,10 +64,10 @@ formBatchPanel ( set::name('type'), set::label($lang->execution->method), - set::control('picker'), + set::control(array('type' => 'picker', 'required' => true)), set::items($lang->execution->typeList), set::disabled(true), - set::width('80px') + set::width('100px') ) : null, $setCode ? formBatchItem (