ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject incubator-ignite git commit: IGNITE-843: Fixed table items duplicates check.
Date Fri, 17 Jul 2015 19:29:38 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 ca8a48b6d -> f92109a91


IGNITE-843: Fixed table items duplicates check.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f92109a9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f92109a9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f92109a9

Branch: refs/heads/ignite-843
Commit: f92109a914686e4e442f81a9545ff3e12d8fcd5a
Parents: ca8a48b
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Sat Jul 18 02:29:26 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Sat Jul 18 02:29:26 2015 +0700

----------------------------------------------------------------------
 .../nodejs/controllers/caches-controller.js     | 39 +++++++++++++++++---
 .../nodejs/controllers/clusters-controller.js   | 29 ++++++++++++++-
 .../nodejs/controllers/common-module.js         | 12 +++---
 .../nodejs/controllers/metadata-controller.js   | 39 +++++++++++++++++---
 .../nodejs/views/includes/controls.jade         |  2 +-
 5 files changed, 103 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f92109a9/modules/web-control-center/nodejs/controllers/caches-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/controllers/caches-controller.js b/modules/web-control-center/nodejs/controllers/caches-controller.js
index 138fc38..c7ba8de 100644
--- a/modules/web-control-center/nodejs/controllers/caches-controller.js
+++ b/modules/web-control-center/nodejs/controllers/caches-controller.js
@@ -21,7 +21,6 @@ controlCenterModule.controller('cachesController', ['$scope', '$http', '$common'
 
         $scope.tableSimpleNewItem = $table.tableSimpleNewItem;
         $scope.tableSimpleNewItemActive = $table.tableSimpleNewItemActive;
-        $scope.tableSimpleValid = $table.tableSimpleValid;
         $scope.tableSimpleSave = $table.tableSimpleSave;
         $scope.tableSimpleSaveVisible = $table.tableSimpleSaveVisible;
         $scope.tableSimpleStartEdit = $table.tableSimpleStartEdit;
@@ -127,13 +126,43 @@ controlCenterModule.controller('cachesController', ['$scope', '$http',
'$common'
             return false;
         };
 
-        $scope.tablePairValid = function (item, field, keyCls, valCls) {
+        $scope.tableSimpleValid = function (item, field, fx, index) {
             var model = item[field.model];
 
-            if ($common.isDefined(model) && _.findIndex(model, function (pair) {return
pair.keyClass == keyCls}) >= 0) {
-                $common.showError('Indexed type with such key class already exists!');
+            if ($common.isDefined(model)) {
+                var idx = _.indexOf(model, fx);
 
-                return false;
+                // Found itself.
+                if (index > 0 && index == idx)
+                    return true;
+
+                // Found duplicate.
+                if (idx >= 0) {
+                    $common.showError('SQL function such class name already exists!');
+
+                    return false;
+                }
+            }
+
+            return true;
+        };
+
+        $scope.tablePairValid = function (item, field, keyCls, valCls, index) {
+            var model = item[field.model];
+
+            if ($common.isDefined(model)) {
+                var idx = _.findIndex(model, function (pair) {return pair.keyClass == keyCls});
+
+                // Found itself.
+                if (index > 0 && index == idx)
+                    return true;
+
+                // Found duplicate.
+                if (idx >= 0) {
+                    $common.showError('Indexed type with such key class already exists!');
+
+                    return false;
+                }
             }
 
             return true;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f92109a9/modules/web-control-center/nodejs/controllers/clusters-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/controllers/clusters-controller.js b/modules/web-control-center/nodejs/controllers/clusters-controller.js
index 426ac51..5ac470d 100644
--- a/modules/web-control-center/nodejs/controllers/clusters-controller.js
+++ b/modules/web-control-center/nodejs/controllers/clusters-controller.js
@@ -21,7 +21,6 @@ controlCenterModule.controller('clustersController', ['$scope', '$http',
'$commo
 
         $scope.tableSimpleNewItem = $table.tableSimpleNewItem;
         $scope.tableSimpleNewItemActive = $table.tableSimpleNewItemActive;
-        $scope.tableSimpleValid = $table.tableSimpleValid;
         $scope.tableSimpleSave = $table.tableSimpleSave;
         $scope.tableSimpleSaveVisible = $table.tableSimpleSaveVisible;
         $scope.tableSimpleStartEdit = $table.tableSimpleStartEdit;
@@ -97,6 +96,34 @@ controlCenterModule.controller('clustersController', ['$scope', '$http',
'$commo
             {value: 'JdkMarshaller', label: 'JdkMarshaller'}
         ];
 
+        $scope.tableSimpleValid = function (item, field, val, index) {
+            var model = $common.getModel(item, field)[field.model];
+
+            if ($common.isDefined(model)) {
+                var idx = _.indexOf(model, val);
+
+                // Found itself.
+                if (index >= 0 && index == idx)
+                    return true;
+
+                // Found duplicate.
+                if (idx >= 0) {
+                    var msg = 'Such IP address already exists!';
+
+                    if (field.model == 'regions')
+                        msg = 'Such region already exists!';
+                    if (field.model == 'zones')
+                        msg = 'Such zone already exists!';
+
+                    $common.showError(msg);
+
+                    return false;
+                }
+            }
+
+            return true;
+        };
+
         $scope.clusters = [];
 
         $http.get('/models/clusters.json')

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f92109a9/modules/web-control-center/nodejs/controllers/common-module.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/controllers/common-module.js b/modules/web-control-center/nodejs/controllers/common-module.js
index 28eb2d7..e6bb10f 100644
--- a/modules/web-control-center/nodejs/controllers/common-module.js
+++ b/modules/web-control-center/nodejs/controllers/common-module.js
@@ -235,8 +235,11 @@ controlCenterModule.service('$table', ['$common', function ($common)
{
         tableSimpleNewItemActive: function (field) {
             return tableSimple.name == field.model && tableSimple.editIndex <
0;
         },
+        tableSimpleValid: function(item, field, newValue, index) {
+            return $common.isDefined(item) && $common.isDefined(field) &&
$common.isDefined(newValue);
+        },
         tableSimpleSave: function (valueValid, item, field, newValue, index) {
-            if (valueValid(newValue)) {
+            if (valueValid(item, field, newValue, index)) {
                 tableSimpleReset();
                 tablePairReset();
 
@@ -250,9 +253,6 @@ controlCenterModule.service('$table', ['$common', function ($common) {
                     model(item, field)[field.model][index] = newValue;
             }
         },
-        tableSimpleValid: function(newValue) {
-            return true;
-        },
         tableSimpleSaveVisible: function(newValue) {
             return $common.isDefined(newValue) && newValue.trim().length > 0;
         },
@@ -289,11 +289,11 @@ controlCenterModule.service('$table', ['$common', function ($common)
{
         tablePairNewItemActive: function (field) {
             return tablePair.name == field.model && tablePair.editIndex < 0;
         },
-        tablePairValid: function(item, field, newKey, newValue) {
+        tablePairValid: function(item, field, newKey, newValue, index) {
             return $common.isDefined(item) && $common.isDefined(newKey) &&
$common.isDefined(newValue);
         },
         tablePairSave: function (pairValid, item, field, newKey, newValue, index) {
-            if (pairValid(item, field, newKey, newValue)) {
+            if (pairValid(item, field, newKey, newValue, index)) {
                 tableSimpleReset();
                 tablePairReset();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f92109a9/modules/web-control-center/nodejs/controllers/metadata-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/controllers/metadata-controller.js b/modules/web-control-center/nodejs/controllers/metadata-controller.js
index 1ebbc9d..9f10f49 100644
--- a/modules/web-control-center/nodejs/controllers/metadata-controller.js
+++ b/modules/web-control-center/nodejs/controllers/metadata-controller.js
@@ -21,7 +21,6 @@ controlCenterModule.controller('metadataController', ['$scope', '$http',
'$commo
 
         $scope.tableSimpleNewItem = $table.tableSimpleNewItem;
         $scope.tableSimpleNewItemActive = $table.tableSimpleNewItemActive;
-        $scope.tableSimpleValid = $table.tableSimpleValid;
         $scope.tableSimpleSave = $table.tableSimpleSave;
         $scope.tableSimpleSaveVisible = $table.tableSimpleSaveVisible;
         $scope.tableSimpleStartEdit = $table.tableSimpleStartEdit;
@@ -315,13 +314,43 @@ controlCenterModule.controller('metadataController', ['$scope', '$http',
'$commo
                 });
         };
 
-        $scope.tablePairValid = function (item, field, name, clsName) {
+        $scope.tableSimpleValid = function (item, field, name, index) {
             var model = item[field.model];
 
-            if ($common.isDefined(model) && _.findIndex(model, function (pair) {return
pair.name == name}) >= 0) {
-                $common.showError('Field with such name already exists!');
+            if ($common.isDefined(model)) {
+                var idx = _.indexOf(model, name);
 
-                return false;
+                // Found itself.
+                if (index > 0 && index == idx)
+                    return true;
+
+                // Found duplicate.
+                if (idx >= 0) {
+                    $common.showError('Field with such name already exists!');
+
+                    return false;
+                }
+            }
+
+            return true;
+        };
+
+        $scope.tablePairValid = function (item, field, name, clsName, index) {
+            var model = item[field.model];
+
+            if ($common.isDefined(model)) {
+                var idx = _.findIndex(model, function (pair) {return pair.name == name});
+
+                // Found itself.
+                if (index > 0 && index == idx)
+                    return true;
+
+                // Found duplicate.
+                if (idx >= 0) {
+                    $common.showError('Field with such name already exists!');
+
+                    return false;
+                }
             }
 
             return true;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f92109a9/modules/web-control-center/nodejs/views/includes/controls.jade
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/views/includes/controls.jade b/modules/web-control-center/nodejs/views/includes/controls.jade
index a32a9fa..546c4bf 100644
--- a/modules/web-control-center/nodejs/views/includes/controls.jade
+++ b/modules/web-control-center/nodejs/views/includes/controls.jade
@@ -128,7 +128,7 @@ mixin details-row
                                 .input-tip.form-group.has-feedback
                                     input.form-control(name='{{detail.model}}.edit' type='text'
ng-model='curValue' placeholder='{{detail.placeholder}}')&attributes(customValidators)
                                     +ico-exclamation('{{detail.model}}.edit', 'ipaddress',
'Invalid address, see help for format description.')
-            button.btn.btn-primary.fieldButton(ng-disabled='!newValue || #{detailMdl}.indexOf(newValue)
>= 0' ng-click='tableSimpleSave(tableSimpleValid, backupItem, detail, newValue, -1)') Add
+            button.btn.btn-primary.fieldButton(ng-disabled='!newValue' ng-click='tableSimpleSave(tableSimpleValid,
backupItem, detail, newValue, -1)') Add
             +tipField('detail.tip')
             .input-tip.form-group.has-feedback
                 input.form-control(name='{{detail.model}}' type='text' ng-model='newValue'
ng-focus='tableSimpleNewItem(detail)' placeholder='{{detail.placeholder}}')&attributes(customValidators)


Mime
View raw message