From 73936183bb88c446c512f8161307a3912b52d5e9 Mon Sep 17 00:00:00 2001 From: jamessspanggg Date: Mon, 20 Jan 2020 23:20:14 +0800 Subject: [PATCH] Refactor to individual functions --- .../views/data-table/data-table-view.js | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/main/webapp/modules/core/scripts/views/data-table/data-table-view.js b/main/webapp/modules/core/scripts/views/data-table/data-table-view.js index 3b172a768..7e5d6a6fb 100644 --- a/main/webapp/modules/core/scripts/views/data-table/data-table-view.js +++ b/main/webapp/modules/core/scripts/views/data-table/data-table-view.js @@ -765,34 +765,12 @@ DataTableView.prototype._createMenuForAllColumns = function(elmt) { { label: $.i18n('core-views/fill-down'), id: "core/fill-down", - click: function() { - for (var i = 0; i < theProject.columnModel.columns.length; i++) { - Refine.postCoreProcess( - "fill-down", - { - columnName: theProject.columnModel.columns[i].name - }, - null, - { modelsChanged: true } - ); - } - } + click: doAllFillDown }, { label: $.i18n('core-views/blank-down'), id: "core/blank-down", - click: function() { - for (var i = 0; i < theProject.columnModel.columns.length; i++) { - Refine.postCoreProcess( - "blank-down", - { - columnName: theProject.columnModel.columns[i].name - }, - null, - { modelsChanged: true } - ); - } - } + click: doAllBlankDown } ] }, @@ -896,6 +874,32 @@ DataTableView.prototype._createSortingMenu = function(elmt) { MenuSystem.createAndShowStandardMenu(items, elmt, { horizontal: false }); }; +var doAllFillDown = function() { + for (var i = 0; i < theProject.columnModel.columns.length; i++) { + Refine.postCoreProcess( + "fill-down", + { + columnName: theProject.columnModel.columns[i].name + }, + null, + { modelsChanged: true } + ); + } +}; + +var doAllBlankDown = function() { + for (var i = 0; i < theProject.columnModel.columns.length; i++) { + Refine.postCoreProcess( + "blank-down", + { + columnName: theProject.columnModel.columns[i].name + }, + null, + { modelsChanged: true } + ); + } +}; + DataTableView.prototype._updateCell = function(rowIndex, cellIndex, cell) { var rows = theProject.rowModel.rows;