* [task#130461,doing,1h] move before submit js in batchEdit.
This commit is contained in:
@@ -17,63 +17,12 @@ jsVar('users', $users);
|
||||
jsVar('teams', $teams);
|
||||
jsVar('currentUser', $app->user->account);
|
||||
jsVar('moduleGroup', $moduleGroup);
|
||||
|
||||
$beforeSubmit = null;
|
||||
$childTasks = json_encode($childTasks);
|
||||
$nonStoryChildTasks = json_encode($nonStoryChildTasks);
|
||||
$tasksJsVar = json_encode($tasks);
|
||||
if(!empty($nonStoryChildTasks))
|
||||
{
|
||||
$beforeSubmit = jsRaw("() =>
|
||||
{
|
||||
const \$taskBatchForm = $('#taskBatchEditForm{$executionID}');
|
||||
const childTasks = $childTasks;
|
||||
const nonStoryChildTasks = $nonStoryChildTasks;
|
||||
const \$taskBatchFormTrs = \$taskBatchForm.find('tbody tr');
|
||||
const tasks = $tasksJsVar;
|
||||
|
||||
var confirmID = '';
|
||||
var tipAll = true;
|
||||
for(let i = 0; i < \$taskBatchFormTrs.length; i++)
|
||||
{
|
||||
const \$currentTr = $(\$taskBatchFormTrs[i]);
|
||||
const taskID = \$currentTr.find('.form-batch-control[data-name=id]').find('input[name^=id]').val();
|
||||
const storyID = \$currentTr.find('.form-batch-control[data-name=story]').find('input[name^=story]').val();
|
||||
|
||||
if(tasks[taskID].story == storyID) continue;
|
||||
if(!storyID && tasks[taskID].parent <= 0) continue;
|
||||
if(tasks[taskID].parent > 0)
|
||||
{
|
||||
if(storyID) confirmID = confirmID.replace('ID' + taskID + ', ', '');
|
||||
continue;
|
||||
}
|
||||
if(typeof childTasks[taskID] != 'object' || typeof nonStoryChildTasks[taskID] != 'object') continue;
|
||||
|
||||
const nonStoryChildTaskIdList = Object.keys(nonStoryChildTasks[taskID]);
|
||||
if(nonStoryChildTaskIdList.length == 0) continue;
|
||||
|
||||
if(tipAll) tipAll = Object.keys(childTasks[taskID]).length == nonStoryChildTaskIdList.length;
|
||||
|
||||
for(let j = 0; j < nonStoryChildTaskIdList.length; j++) confirmID += 'ID' + nonStoryChildTaskIdList[j].toString() + ', ';
|
||||
}
|
||||
if(confirmID.length == 0) return true;
|
||||
|
||||
if(confirmID.endsWith(', ')) confirmID = confirmID.slice(0, -2);
|
||||
|
||||
let confirmTip = tipAll ? '{$lang->task->syncStoryToAllChildrenTip}' : '{$lang->task->syncStoryToChildrenTip}';
|
||||
confirmTip = confirmTip.replace('%s', confirmID);
|
||||
zui.Modal.confirm(confirmTip).then((res) =>
|
||||
{
|
||||
\$taskBatchForm.find('[name=syncChildren]').remove();
|
||||
\$taskBatchForm.append('<input type=\"hidden\" name=\"syncChildren\" value=\"' + (res ? '1' : '0') + '\" />');
|
||||
|
||||
const formData = new FormData(\$taskBatchForm[0]);
|
||||
const confirmURL = \$taskBatchForm.attr('action');
|
||||
$.ajaxSubmit({url: confirmURL, data: formData});
|
||||
});
|
||||
return false;
|
||||
}");
|
||||
}
|
||||
jsVar('executionID', $executionID);
|
||||
jsVar('childTasks', $childTasks);
|
||||
jsVar('nonStoryChildTasks', $nonStoryChildTasks);
|
||||
jsVar('tasks', $tasks);
|
||||
jsVar('syncStoryToAllChildrenTip', $lang->task->syncStoryToAllChildrenTip);
|
||||
jsVar('syncStoryToChildrenTip', $lang->task->syncStoryToChildrenTip);
|
||||
|
||||
/* ====== Define the page structure with zin widgets ====== */
|
||||
formBatchPanel
|
||||
@@ -83,7 +32,7 @@ formBatchPanel
|
||||
set::data(array_values($tasks)),
|
||||
set::onRenderRow(jsRaw('renderRowData')),
|
||||
set::customFields(array('list' => $customFields, 'show' => explode(',', $showFields), 'key' => 'batchEditFields')),
|
||||
!empty($nonStoryChildTasks) ? set::ajax(array('beforeSubmit' => $beforeSubmit)) : null,
|
||||
set::ajax(array('beforeSubmit' => jsRaw('clickSubmit'))),
|
||||
set::formID('taskBatchEditForm' . $executionID),
|
||||
formBatchItem
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user