From efd4c1c14cd66ae994a9731d384adf1b53a1bdbf Mon Sep 17 00:00:00 2001 From: chenfeiCF Date: Mon, 2 May 2016 11:51:21 +0800 Subject: [PATCH] * adjust code for batch create and edit mothod. --- module/bug/control.php | 26 ++++++++------------- module/bug/js/batchcreate.js | 1 + module/bug/js/batchedit.js | 19 +++++---------- module/bug/view/batchedit.html.php | 10 ++++---- module/story/control.php | 24 ++++++++----------- module/story/js/batchcreate.js | 2 ++ module/story/js/batchedit.js | 27 ++++++++------------- module/story/view/batchedit.html.php | 6 ++--- module/task/control.php | 19 ++++++--------- module/task/js/batchcreate.js | 2 ++ module/task/js/batchedit.js | 21 ++++++----------- module/task/view/batchedit.html.php | 6 ++--- module/testcase/control.php | 12 ++++------ module/testcase/js/batchcreate.js | 2 ++ module/testcase/js/batchedit.js | 26 +++++++-------------- module/testcase/view/batchedit.html.php | 2 +- module/user/js/batchcreate.js | 2 ++ module/user/js/batchedit.js | 31 ++++++++----------------- module/user/view/batchedit.html.php | 4 ++-- www/js/my.full.js | 11 +++++++++ 20 files changed, 106 insertions(+), 147 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 5eab2356d2..6d7d0d8ae2 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -612,7 +612,7 @@ class bug extends control /* Set plans. */ $plans = $this->loadModel('productplan')->getPairs($productID, $branch); - $plans['ditto'] = $this->lang->bug->ditto; + $plans = array('' => '', 'ditto' => $this->lang->bug->ditto) + $plans; /* Set product menu. */ $this->bug->setMenu($this->products, $productID, $branch); @@ -645,27 +645,21 @@ class bug extends control $this->view->showFields = $this->config->bug->custom->batchEditFields; /* Set users. */ - $users = $this->user->getPairs('nodeleted,devfirst'); - $users['ditto'] = $this->lang->bug->ditto; - - /* Set ditto option for users and type, severity, pri, resolution list. */ - $this->lang->bug->typeList['ditto'] = $this->lang->bug->ditto; - $this->lang->bug->priList['ditto'] = $this->lang->bug->ditto; - $this->lang->bug->resolutionList['ditto'] = $this->lang->bug->ditto; - $this->lang->bug->severityList['ditto'] = $this->lang->bug->ditto; - $this->lang->bug->statusList['ditto'] = $this->lang->bug->ditto; - $this->lang->bug->osList['ditto'] = $this->lang->bug->ditto; - $this->lang->bug->browserList['ditto'] = $this->lang->bug->ditto; + $users = $this->user->getPairs('nodeleted,devfirst'); + $users = array('' => '', 'ditto' => $this->lang->bug->ditto) + $users; /* Assign. */ $this->view->position[] = $this->lang->bug->common; $this->view->position[] = $this->lang->bug->batchEdit; $this->view->bugIDList = $bugIDList; $this->view->productID = $productID; - $this->view->typeList = $this->lang->bug->typeList; - $this->view->priList = (array)$this->lang->bug->priList; - $this->view->resolutionList = $this->lang->bug->resolutionList; - $this->view->severityList = (array)$this->lang->bug->severityList; + $this->view->severityList = array('ditto' => $this->lang->bug->ditto) + $this->lang->bug->severityList; + $this->view->typeList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->typeList; + $this->view->priList = array('0' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->priList; + $this->view->resolutionList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->resolutionList; + $this->view->statusList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->statusList; + $this->view->osList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->osList; + $this->view->browserList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $this->lang->bug->browserList; $this->view->bugs = $bugs; $this->view->branch = $branch; $this->view->users = $users; diff --git a/module/bug/js/batchcreate.js b/module/bug/js/batchcreate.js index 355e079f91..96f0618678 100644 --- a/module/bug/js/batchcreate.js +++ b/module/bug/js/batchcreate.js @@ -1,6 +1,7 @@ $(function() { $(".chosenBox select").chosen(defaultChosenOptions); + removeDitto();//Remove 'ditto' in first row. }) /** diff --git a/module/bug/js/batchedit.js b/module/bug/js/batchedit.js index 3b958af9c0..5d2884a08d 100644 --- a/module/bug/js/batchedit.js +++ b/module/bug/js/batchedit.js @@ -17,37 +17,30 @@ function setDuplicate(resolution, bugID) } } -$(function() -{ - $firstTr = $('.table-form').find('tbody tr:first'); - $firstTr.find('td select').each(function() - { - $(this).find("option[value='ditto']").remove(); - $(this).trigger("chosen:updated"); - }); -}) +$(document).ready(removeDitto());//Remove 'ditto' in first row. -$(document).on('click', '.chosen-with-drop', function(){oldValue = $(this).prev('select').val();}) +$(document).on('click', '.chosen-with-drop', function(){oldValue = $(this).prev('select').val();})//Save old value. +/* Set ditto value. */ $(document).on('change', 'select', function() { if($(this).val() == 'ditto') { var index = $(this).closest('td').index(); var row = $(this).closest('tr').index(); - var $tbody = $(this).closest('tr').parent(); + var tbody = $(this).closest('tr').parent(); if($(this).attr('name').indexOf('resolutions') != -1) { index = $(this).closest('tr').closest('td').index(); row = $(this).closest('tr').closest('td').parent().index(); - $tbody = $(this).closest('tr').closest('td').parent().parent(); + tbody = $(this).closest('tr').closest('td').parent().parent(); } var value = ''; for(i = row - 1; i >= 0; i--) { - value = $tbody.children('tr').eq(i).find('td').eq(index).find('select').val(); + value = tbody.children('tr').eq(i).find('td').eq(index).find('select').val(); if(value != 'ditto') break; } diff --git a/module/bug/view/batchedit.html.php b/module/bug/view/batchedit.html.php index f5ffab4336..acf769bfaa 100644 --- a/module/bug/view/batchedit.html.php +++ b/module/bug/view/batchedit.html.php @@ -53,8 +53,8 @@ $columns = count($visibleFields) + 2; loadModel('productplan')->getPairs($bugs[$bugID]->product, $branch); - $plans['ditto'] = $this->lang->story->ditto; + $plans = $this->loadModel('productplan')->getPairs($bugs[$bugID]->product, $branch); + $plans = array('' => '', 'ditto' => $this->lang->bug->ditto) + $plans; } /** * Remove designchange, newfeature, trackings from the typeList, because should be tracked in story or task. @@ -72,9 +72,9 @@ $columns = count($visibleFields) + 2; title, 'class=form-control');?> ' style='overflow:visible'>plan, "class='form-control chosen'");?> ' style='overflow:visible'>assignedTo, "class='form-control chosen'");?> - >bug->statusList, $bugs[$bugID]->status, 'class=form-control');?> - >bug->osList, $bugs[$bugID]->os, 'class=form-control');?> - >bug->browserList, $bugs[$bugID]->browser, 'class=form-control');?> + >status, 'class=form-control');?> + >os, 'class=form-control');?> + >browser, 'class=form-control');?> >keywords, 'class=form-control');?> ' style='overflow:visible'>resolvedBy, "class='form-control chosen'");?> > diff --git a/module/story/control.php b/module/story/control.php index 863c9d5a1b..89573e5b68 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -388,10 +388,10 @@ class story extends control $product = $this->product->getByID($productID); /* Set modules and productPlans. */ - $modules = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch); - $modules['ditto'] = $this->lang->story->ditto; - $productPlans = $this->productplan->getPairs($productID, $branch); - $productPlans['ditto'] = $this->lang->story->ditto; + $modules = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch); + $modules = array('ditto' => $this->lang->story->ditto) + $modules; + $productPlans = $this->productplan->getPairs($productID, $branch); + $productPlans = array('' => '', 'ditto' => $this->lang->story->ditto) + $productPlans; $this->view->modules = $modules; $this->view->productPlans = $productPlans; @@ -421,13 +421,9 @@ class story extends control $this->view->title = $this->lang->story->batchEdit; } - /* Set ditto option for users and pri, source, stage list. */ + /* Set ditto option for users. */ $users = $this->loadModel('user')->getPairs('nodeleted'); - $users['ditto'] = $this->lang->story->ditto; - $this->lang->story->priList['ditto'] = $this->lang->story->ditto; - $this->lang->story->sourceList['ditto'] = $this->lang->story->ditto; - $this->lang->story->stageList['ditto'] = $this->lang->story->ditto; - $this->lang->story->reasonList['ditto'] = $this->lang->story->ditto; + $users = array('' => '', 'ditto' => $this->lang->story->ditto) + $users; /* Set Custom*/ foreach(explode(',', $this->config->story->list->customBatchEditFields) as $field) $customFields[$field] = $this->lang->story->$field; @@ -443,10 +439,10 @@ class story extends control $this->view->position[] = $this->lang->story->common; $this->view->position[] = $this->lang->story->batchEdit; $this->view->users = $users; - $this->view->priList = (array)$this->lang->story->priList; - $this->view->sourceList = $this->lang->story->sourceList; - $this->view->reasonList = $this->lang->story->reasonList; - $this->view->stageList = $this->lang->story->stageList; + $this->view->priList = array('0' => '', 'ditto' => $this->lang->story->ditto) + $this->lang->story->priList; + $this->view->sourceList = array('' => '', 'ditto' => $this->lang->story->ditto) + $this->lang->story->sourceList; + $this->view->reasonList = array('' => '', 'ditto' => $this->lang->story->ditto) + $this->lang->story->reasonList; + $this->view->stageList = array('' => '', 'ditto' => $this->lang->story->ditto) + $this->lang->story->stageList; $this->view->productID = $productID; $this->view->storyIDList = $storyIDList; $this->view->branch = $branch; diff --git a/module/story/js/batchcreate.js b/module/story/js/batchcreate.js index 73d3b44a68..f24ca75ac0 100644 --- a/module/story/js/batchcreate.js +++ b/module/story/js/batchcreate.js @@ -1,3 +1,5 @@ +$(document).ready(removeDitto());//Remove 'ditto' in first row. + $(document).on('click', '.chosen-with-drop', function() { var select = $(this).prev('select'); diff --git a/module/story/js/batchedit.js b/module/story/js/batchedit.js index 396fc57f00..aa59c83cf7 100644 --- a/module/story/js/batchedit.js +++ b/module/story/js/batchedit.js @@ -25,37 +25,30 @@ function setDuplicateAndChild(resolution, storyID) } } -$(function() -{ - $firstTr = $('.table-form').find('tbody tr:first'); - $firstTr.find('td select').each(function() - { - $(this).find("option[value='ditto']").remove(); - $(this).trigger("chosen:updated"); - }); -}) +$(document).ready(removeDitto());//Remove 'ditto' in first row. -$(document).on('click', '.chosen-with-drop', function(){oldValue = $(this).prev('select').val();}) +$(document).on('click', '.chosen-with-drop', function(){oldValue = $(this).prev('select').val();})//Save old value. +/* Set ditto value. */ $(document).on('change', 'select', function() { if($(this).val() == 'ditto') { - var index = $(this).closest('td').index(); - var row = $(this).closest('tr').index(); - var $tbody = $(this).closest('tr').parent(); + var index = $(this).closest('td').index(); + var row = $(this).closest('tr').index(); + var tbody = $(this).closest('tr').parent(); if($(this).attr('name').indexOf('closedReasons') != -1) { - index = $(this).closest('tr').closest('td').index(); - row = $(this).closest('tr').closest('td').parent().index(); - $tbody = $(this).closest('tr').closest('td').parent().parent(); + index = $(this).closest('tr').closest('td').index(); + row = $(this).closest('tr').closest('td').parent().index(); + tbody = $(this).closest('tr').closest('td').parent().parent(); } var value = ''; for(i = row - 1; i >= 0; i--) { - value = $tbody.children('tr').eq(i).find('td').eq(index).find('select').val(); + value = tbody.children('tr').eq(i).find('td').eq(index).find('select').val(); if(value != 'ditto') break; } diff --git a/module/story/view/batchedit.html.php b/module/story/view/batchedit.html.php index 5a388aa2be..3d28812966 100644 --- a/module/story/view/batchedit.html.php +++ b/module/story/view/batchedit.html.php @@ -58,10 +58,10 @@ foreach(explode(',', $showFields) as $field) $product = $this->product->getByID($stories[$storyID]->product); $modules = $this->tree->getOptionMenu($stories[$storyID]->product, $viewType = 'story', 0, $branch); foreach($modules as $moduleID => $moduleName) $modules[$moduleID] = '/' . $product->name . $moduleName; - $modules['ditto'] = $this->lang->story->ditto; + $modules = array('ditto' => $this->lang->story->ditto) + $modules; - $productPlans = $this->productplan->getPairs($stories[$storyID]->product, $branch); - $productPlans['ditto'] = $this->lang->story->ditto; + $productPlans = $this->productplan->getPairs($stories[$storyID]->product, $branch); + $productPlans = array('' => '', 'ditto' => $this->lang->story->ditto) + $productPlans; } ?> diff --git a/module/task/control.php b/module/task/control.php index c8eebd7181..48d624b8ff 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -341,11 +341,11 @@ class task extends control $this->project->setMenu($this->project->getPairs(), $project->id); /* Set modules and members. */ - $modules = $this->tree->getTaskOptionMenu($projectID); - $modules['ditto'] = $this->lang->task->ditto; - $members = $this->project->getTeamMemberPairs($projectID, 'nodeleted'); + $modules = $this->tree->getTaskOptionMenu($projectID); + $modules = array('ditto' => $this->lang->task->ditto) + $modules; + $members = $this->project->getTeamMemberPairs($projectID, 'nodeleted'); + $members = array('' => '', 'ditto' => $this->lang->task->ditto) + $members; $members['closed'] = 'Closed'; - $members['ditto'] = $this->lang->task->ditto; $this->view->title = $project->name . $this->lang->colon . $this->lang->task->batchEdit; $this->view->position[] = html::a($this->createLink('project', 'browse', "project=$project->id"), $project->name); @@ -379,18 +379,13 @@ class task extends control $this->view->customFields = $customFields; $this->view->showFields = $this->config->task->custom->batchEditFields; - /* Set ditto option for pri, status and type list. */ - $this->lang->task->priList['ditto'] = $this->lang->task->ditto; - $this->lang->task->statusList['ditto'] = $this->lang->task->ditto; - $this->lang->task->typeList['ditto'] = $this->lang->task->ditto; - /* Assign. */ $this->view->position[] = $this->lang->task->common; $this->view->position[] = $this->lang->task->batchEdit; $this->view->projectID = $projectID; - $this->view->priList = (array)$this->lang->task->priList; - $this->view->statusList = $this->lang->task->statusList; - $this->view->typeList = $this->lang->task->typeList; + $this->view->priList = array('0' => '', 'ditto' => $this->lang->task->ditto) + $this->lang->task->priList; + $this->view->statusList = array('' => '', 'ditto' => $this->lang->task->ditto) + $this->lang->task->statusList; + $this->view->typeList = array('' => '', 'ditto' => $this->lang->task->ditto) + $this->lang->task->typeList; $this->view->taskIDList = $taskIDList; $this->view->tasks = $tasks; $this->view->projectName = isset($project) ? $project->name : ''; diff --git a/module/task/js/batchcreate.js b/module/task/js/batchcreate.js index 7aad224bf3..6ede43d55b 100755 --- a/module/task/js/batchcreate.js +++ b/module/task/js/batchcreate.js @@ -1,6 +1,8 @@ /* Remove width in defaultChosenOptions. */ delete defaultChosenOptions.width; +$(document).ready(removeDitto());//Remove 'ditto' in first row. + /* Get select of stories.*/ function setStories(moduleID, projectID, num) { diff --git a/module/task/js/batchedit.js b/module/task/js/batchedit.js index 6d83b04f51..7c4ad12144 100644 --- a/module/task/js/batchedit.js +++ b/module/task/js/batchedit.js @@ -1,27 +1,20 @@ -$(function() -{ - $firstTr = $('.table-form').find('tbody tr:first'); - $firstTr.find('td select').each(function() - { - $(this).find("option[value='ditto']").remove(); - $(this).trigger("chosen:updated"); - }); -}) +$(document).ready(removeDitto());//Remove 'ditto' in first row. -$(document).on('click', '.chosen-with-drop', function(){oldValue = $(this).prev('select').val();}) +$(document).on('click', '.chosen-with-drop', function(){oldValue = $(this).prev('select').val();})//Save old value. +/* Set ditto value. */ $(document).on('change', 'select', function() { if($(this).val() == 'ditto') { - var index = $(this).closest('td').index(); - var row = $(this).closest('tr').index(); - var $tbody = $(this).closest('tr').parent(); + var index = $(this).closest('td').index(); + var row = $(this).closest('tr').index(); + var tbody = $(this).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) { - value = $tbody.children('tr').eq(i).find('td').eq(index).find('select').val(); + value = tbody.children('tr').eq(i).find('td').eq(index).find('select').val(); if(value != 'ditto') break; } diff --git a/module/task/view/batchedit.html.php b/module/task/view/batchedit.html.php index d0a2a89537..52825b85a3 100755 --- a/module/task/view/batchedit.html.php +++ b/module/task/view/batchedit.html.php @@ -59,10 +59,10 @@ foreach(explode(',', $showFields) as $field) $prjInfo = $this->project->getById($tasks[$taskID]->project); $modules = $this->tree->getOptionMenu($tasks[$taskID]->project, $viewType = 'task'); foreach($modules as $moduleID => $moduleName) $modules[$moduleID] = '/' . $prjInfo->name. $moduleName; - $modules['ditto'] = $this->lang->task->ditto; + $modules = array('ditto' => $this->lang->task->ditto) + $modules; - $members = $this->project->getTeamMemberPairs($tasks[$taskID]->project, 'nodeleted'); - $members['ditto'] = $this->lang->task->ditto; + $members = $this->project->getTeamMemberPairs($tasks[$taskID]->project, 'nodeleted'); + $members = array('' => '', 'ditto' => $this->lang->task->ditto) + $members; } ?> diff --git a/module/testcase/control.php b/module/testcase/control.php index 4e52e4ba41..a28b8def44 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -569,8 +569,8 @@ class testcase extends control $this->testcase->setMenu($this->products, $productID, $branch); /* Set modules. */ - $modules = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0, $branch); - $modules['ditto'] = $this->lang->testcase->ditto; + $modules = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0, $branch); + $modules = array('ditto' => $this->lang->testcase->ditto) + $modules; $this->view->modules = $modules; $this->view->position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]); @@ -593,10 +593,6 @@ class testcase extends control $this->app->session->set('showSuhosinInfo', $showSuhosinInfo); if($showSuhosinInfo) $this->view->suhosinInfo = $this->lang->suhosinInfo; - /* Set pri and type list. */ - $this->lang->testcase->priList['ditto'] = $this->lang->testcase->ditto; - $this->lang->testcase->typeList['ditto'] = $this->lang->testcase->ditto; - /* Set custom. */ foreach(explode(',', $this->config->testcase->customBatchEditFields) as $field) $customFields[$field] = $this->lang->testcase->$field; $this->view->customFields = $customFields; @@ -607,8 +603,8 @@ class testcase extends control $this->view->position[] = $this->lang->testcase->batchEdit; $this->view->caseIDList = $caseIDList; $this->view->productID = $productID; - $this->view->priList = (array)$this->lang->testcase->priList; - $this->view->typeList = $this->lang->testcase->typeList; + $this->view->priList = array('ditto' => $this->lang->testcase->ditto) + $this->lang->testcase->priList; + $this->view->typeList = array('' => '', 'ditto' => $this->lang->testcase->ditto) + $this->lang->testcase->typeList; $this->view->cases = $cases; $this->display(); diff --git a/module/testcase/js/batchcreate.js b/module/testcase/js/batchcreate.js index 3c7234a16a..1c4bd40f02 100644 --- a/module/testcase/js/batchcreate.js +++ b/module/testcase/js/batchcreate.js @@ -1,5 +1,7 @@ $(document).ready(function() { + removeDitto();//Remove 'ditto' in first row. + $(document).on('click', '.chosen-with-drop', function() { var select = $(this).prev('select'); diff --git a/module/testcase/js/batchedit.js b/module/testcase/js/batchedit.js index d9b4259fcd..8a5fe3efcb 100644 --- a/module/testcase/js/batchedit.js +++ b/module/testcase/js/batchedit.js @@ -1,16 +1,3 @@ -$(function() -{ - $(".chosen").chosen(defaultChosenOptions); - - /* Remove ditto option of select in first row. */ - $firstTr = $('.table-form').find('tbody tr:first'); - $firstTr.find('td select').each(function() - { - $(this).find("option[value='ditto']").remove(); - $(this).trigger("chosen:updated"); - }); -}) - /** * Set duplicate field. * @@ -38,20 +25,23 @@ function setDuplicateAndChild(resolution, storyID) } } -$(document).on('click', '.chosen-with-drop', function(){oldValue = $(this).prev('select').val();}) +$(document).ready(removeDitto());//Remove 'ditto' in first row. +$(document).on('click', '.chosen-with-drop', function(){oldValue = $(this).prev('select').val();})//Save old value. + +/* Set ditto value. */ $(document).on('change', 'select', function() { if($(this).val() == 'ditto') { - var index = $(this).closest('td').index(); - var row = $(this).closest('tr').index(); - var $tbody = $(this).closest('tr').parent(); + var index = $(this).closest('td').index(); + var row = $(this).closest('tr').index(); + var tbody = $(this).closest('tr').parent(); var value = ''; for(i = row - 1; i >= 0; i--) { - value = $tbody.children('tr').eq(i).find('td').eq(index).find('select').val(); + value = tbody.children('tr').eq(i).find('td').eq(index).find('select').val(); if(value != 'ditto') break; } diff --git a/module/testcase/view/batchedit.html.php b/module/testcase/view/batchedit.html.php index f33b1b9349..4999606320 100644 --- a/module/testcase/view/batchedit.html.php +++ b/module/testcase/view/batchedit.html.php @@ -51,7 +51,7 @@ foreach(explode(',', $showFields) as $field) $product = $this->product->getByID($cases[$caseID]->product); $modules = $this->tree->getOptionMenu($cases[$caseID]->product, $viewType = 'case', $startModuleID = 0); foreach($modules as $moduleID => $moduleName) $modules[$moduleID] = '/' . $product->name . $moduleName; - $modules['ditto'] = $this->lang->testcase->ditto; + $modules = array('ditto' => $this->lang->testcase->ditto) + $modules; } ?> diff --git a/module/user/js/batchcreate.js b/module/user/js/batchcreate.js index d2858d1c9b..1780fe989c 100644 --- a/module/user/js/batchcreate.js +++ b/module/user/js/batchcreate.js @@ -21,6 +21,8 @@ function toggleCheck(obj, i) } } +$(document).ready(removeDitto());//Remove 'ditto' in first row. + $(document).on('click', '.chosen-with-drop', function() { var select = $(this).prev('select'); diff --git a/module/user/js/batchedit.js b/module/user/js/batchedit.js index 252897a815..5febd14950 100644 --- a/module/user/js/batchedit.js +++ b/module/user/js/batchedit.js @@ -1,34 +1,23 @@ -$(document).on('click', '.chosen-with-drop', function() -{ - var select = $(this).prev('select'); - if($(select).val() == 'ditto') - { - var index = $(select).closest('td').index(); - var row = $(select).closest('tr').index(); - var table = $(select).closest('tr').parent(); - var value = ''; - for(i = row - 1; i >= 0; i--) - { - value = $(table).find('tr').eq(i).find('td').eq(index).find('select').val(); - if(value != 'ditto') break; - } - $(select).val(value); - $(select).trigger("chosen:updated"); - } -}) -$(document).on('mousedown', 'select', function() +$(document).ready(removeDitto());//Remove 'ditto' in first row. + +/* Set ditto value. */ +$(document).on('change', 'select', function() { if($(this).val() == 'ditto') { var index = $(this).closest('td').index(); var row = $(this).closest('tr').index(); - var table = $(this).closest('tr').parent(); + var tbody = $(this).closest('tr').parent(); + var value = ''; for(i = row - 1; i >= 0; i--) { - value = $(table).find('tr').eq(i).find('td').eq(index).find('select').val(); + value = tbody.children('tr').eq(i).find('td').eq(index).find('select').val(); if(value != 'ditto') break; } + $(this).val(value); + $(this).trigger("chosen:updated"); + $(this).trigger("change"); } }) diff --git a/module/user/view/batchedit.html.php b/module/user/view/batchedit.html.php index 01c5f47968..5b965ac798 100644 --- a/module/user/view/batchedit.html.php +++ b/module/user/view/batchedit.html.php @@ -52,8 +52,8 @@ $minWidth = (count($visibleFields) > 7) ? 'w-120px' : ''; '> user->zipcode;?> - $lang->user->ditto)?> - user->roleList = $lang->user->roleList + array('ditto' => $lang->user->ditto)?> + $lang->user->ditto) + $depts;?> + user->roleList = array('' => '', 'ditto' => $lang->user->ditto) + $lang->user->roleList;?>