ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject [01/14] ignite git commit: IGNITE-843 Refactored unique directives to single directive.
Date Thu, 31 Mar 2016 07:27:39 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-2875 692567187 -> dde08f391


 IGNITE-843 Refactored unique directives to single directive.


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

Branch: refs/heads/ignite-2875
Commit: 3b40bd766bdb48193a351c31d799e09f4cdb403a
Parents: cadbc5f
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Mon Mar 28 16:38:22 2016 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Mon Mar 28 16:38:22 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/app/modules/form/form.module.js |  2 -
 .../validator/igfs-path-unique.directive.js     | 46 --------------------
 .../modules/form/validator/unique.directive.js  |  7 ++-
 .../modules/states/configuration/igfs/misc.jade |  7 +--
 .../src/main/js/controllers/common-module.js    |  2 +-
 .../src/main/js/controllers/igfs-controller.js  |  4 --
 6 files changed, 10 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3b40bd76/modules/control-center-web/src/main/js/app/modules/form/form.module.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/form/form.module.js b/modules/control-center-web/src/main/js/app/modules/form/form.module.js
index 81c1d99..57a92fa 100644
--- a/modules/control-center-web/src/main/js/app/modules/form/form.module.js
+++ b/modules/control-center-web/src/main/js/app/modules/form/form.module.js
@@ -40,7 +40,6 @@ import igniteFormGroupAdd from './group/add.directive';
 import igniteFormGroupTooltip from './group/tooltip.directive';
 
 // Validators.
-import igfsPathUnique from './validator/igfs-path-unique.directive';
 import ipaddress from './validator/ipaddress.directive';
 import javaKeywords from './validator/java-keywords.directive';
 import javaPackageSpecified from './validator/java-package-specified.directive';
@@ -80,7 +79,6 @@ angular
 .directive(...igniteFormGroupAdd)
 .directive(...igniteFormGroupTooltip)
 // Validators.
-.directive(...igfsPathUnique)
 .directive(...ipaddress)
 .directive(...javaKeywords)
 .directive(...javaPackageSpecified)

http://git-wip-us.apache.org/repos/asf/ignite/blob/3b40bd76/modules/control-center-web/src/main/js/app/modules/form/validator/igfs-path-unique.directive.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/form/validator/igfs-path-unique.directive.js
b/modules/control-center-web/src/main/js/app/modules/form/validator/igfs-path-unique.directive.js
deleted file mode 100644
index 7753c85..0000000
--- a/modules/control-center-web/src/main/js/app/modules/form/validator/igfs-path-unique.directive.js
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-export default ['igniteIgfsPathUnique', ['$parse', ($parse) => {
-    const link = (scope, el, attrs, [ngModel]) => {
-        if (typeof attrs.igniteIgfsPathUnique === 'undefined' || !attrs.igniteIgfsPathUnique)
-            return;
-
-        ngModel.$validators.igniteIgfsPathUnique = (value) => {
-            const arr = $parse(attrs.igniteIgfsPathUnique)(scope);
-
-            // Return true in case if array not exist, array empty.
-            if (!value || !arr || !arr.length)
-                return true;
-
-            const idx = _.findIndex(arr, (item) => item.path === value);
-
-            // In case of new element check all items.
-            if (attrs.name === 'newPath')
-                return idx < 0;
-
-            // Check for $index in case of editing in-place.
-            return (_.isNumber(scope.$index) && (idx < 0 || scope.$index === idx));
-        };
-    };
-
-    return {
-        restrict: 'A',
-        link,
-        require: ['ngModel']
-    };
-}]];

http://git-wip-us.apache.org/repos/asf/ignite/blob/3b40bd76/modules/control-center-web/src/main/js/app/modules/form/validator/unique.directive.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/form/validator/unique.directive.js
b/modules/control-center-web/src/main/js/app/modules/form/validator/unique.directive.js
index 451ff9d..d816fb6 100644
--- a/modules/control-center-web/src/main/js/app/modules/form/validator/unique.directive.js
+++ b/modules/control-center-web/src/main/js/app/modules/form/validator/unique.directive.js
@@ -20,6 +20,9 @@ export default ['igniteUnique', ['$parse', ($parse) => {
         if (typeof attrs.igniteUnique === 'undefined' || !attrs.igniteUnique)
             return;
 
+        const isNew = _.startsWith(attrs.name, 'new');
+        const property = attrs.igniteUniqueProperty;
+
         ngModel.$validators.igniteUnique = (value) => {
             const arr = $parse(attrs.igniteUnique)(scope);
 
@@ -27,10 +30,10 @@ export default ['igniteUnique', ['$parse', ($parse) => {
             if (!arr || !arr.length)
                 return true;
 
-            const idx = arr.indexOf(value);
+            const idx = _.findIndex(arr, (item) => (property ? item[property] : item)
=== value);
 
             // In case of new element check all items.
-            if (attrs.name === 'new')
+            if (isNew)
                 return idx < 0;
 
             // Check for $index in case of editing in-place.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3b40bd76/modules/control-center-web/src/main/js/app/modules/states/configuration/igfs/misc.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/states/configuration/igfs/misc.jade
b/modules/control-center-web/src/main/js/app/modules/states/configuration/igfs/misc.jade
index 3428e2d..c3e8c29 100644
--- a/modules/control-center-web/src/main/js/app/modules/states/configuration/igfs/misc.jade
+++ b/modules/control-center-web/src/main/js/app/modules/states/configuration/igfs/misc.jade
@@ -28,7 +28,7 @@ mixin pathModeEditor(newItem)
     -var valid = pathModesForm + '.' + path + '.$valid && ' + pathModesForm + '.'
+ mode + '.$valid'
     -var item = '{path:' + path + ', mode: ' + mode  + '}'
     -var save = pathModes + (newItem ? '.push(' + item + ')' : '[$index] = ' + item)
-    -var unique = pathModesForm + '.' + path + '.$error.igniteIgfsPathUnique'
+    -var unique = pathModesForm + '.' + path + '.$error.igniteUnique'
 
     .col-sm-12
         .col-sm-8
@@ -39,12 +39,13 @@ mixin pathModeEditor(newItem)
                 data-ng-model=path
                 enter-focus-next=mode
                 data-ng-required='true'
-                data-ignite-igfs-path-unique=pathModes
+                data-ignite-unique=pathModes
+                data-ignite-unique-property='path'
                 data-placeholder='Input path'
                 data-ignite-form-field-input-autofocus='true'
                 on-escape=reset
             )
-                +error-feedback(unique, 'igfsPathUnique', 'Such path already exists!')
+                +unique-feedback(unique, 'Such path already exists!')
         .col-sm-4
             .tipField
                 +table-save-button(valid, save, newItem)

http://git-wip-us.apache.org/repos/asf/ignite/blob/3b40bd76/modules/control-center-web/src/main/js/controllers/common-module.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/common-module.js b/modules/control-center-web/src/main/js/controllers/common-module.js
index 5543783..0fff237 100644
--- a/modules/control-center-web/src/main/js/controllers/common-module.js
+++ b/modules/control-center-web/src/main/js/controllers/common-module.js
@@ -1892,7 +1892,7 @@ consoleModule.directive('onEnter', function ($timeout) {
             }
         });
 
-        // Removes bound events in the element itself when the scope is destroyed
+        // Removes bound events in the element itself when the scope is destroyed.
         scope.$on('$destroy', function () {
             elem.off('keydown keypress');
         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/3b40bd76/modules/control-center-web/src/main/js/controllers/igfs-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/igfs-controller.js b/modules/control-center-web/src/main/js/controllers/igfs-controller.js
index 44ba0ec..2263940 100644
--- a/modules/control-center-web/src/main/js/controllers/igfs-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/igfs-controller.js
@@ -166,10 +166,6 @@ consoleModule.controller('igfsController', [
             };
         }
 
-        $scope.zzz = function () {
-            console.log("TEST on enter!")
-        };
-
         // Add new IGFS.
         $scope.createItem = function (id) {
             $timeout(function () {


Mime
View raw message