You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by an...@apache.org on 2016/03/28 10:48:16 UTC
[36/50] [abbrv] ignite git commit: IGNITE-843 Fixed bug with
ngModelName and implemented IGFS unique path validator.
IGNITE-843 Fixed bug with ngModelName and implemented IGFS unique path validator.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8c79a57a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8c79a57a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8c79a57a
Branch: refs/heads/ignite-2875
Commit: 8c79a57aae521c8da7c71a66c88cf9848e789760
Parents: efe4395
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Fri Mar 25 12:39:40 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Mar 25 12:39:40 2016 +0700
----------------------------------------------------------------------
.../form-field-java-class.directive.js | 6 ++-
.../modules/form/field/input/text.directive.js | 6 ++-
.../src/main/js/app/modules/form/form.module.js | 2 +
.../validator/igfs-path-unique.directive.js | 46 ++++++++++++++++++++
.../form/validator/property-unique.directive.js | 9 ++--
.../modules/form/validator/unique.directive.js | 3 +-
.../states/configuration/caches/query.jade | 2 +-
.../states/configuration/caches/store.jade | 4 +-
.../modules/states/configuration/igfs/misc.jade | 3 ++
9 files changed, 69 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8c79a57a/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.directive.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.directive.js b/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.directive.js
index 0f13343..8c469ea 100644
--- a/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.directive.js
+++ b/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.directive.js
@@ -19,11 +19,13 @@ import template from './form-field-java-class.jade!';
export default ['igniteFormFieldJavaClass', ['IgniteFormGUID', (guid) => {
const link = (scope, el, attrs, [ngModel, form, label]) => {
- const {id, name} = scope;
+ const {id, ngModelName} = scope;
+
+ const name = ngModelName;
scope.id = id || guid();
scope.form = form;
- scope.name = scope.ngModelName + 'JavaClass';
+ scope.name = ngModelName + 'JavaClass';
scope.ngModel = ngModel;
Object.defineProperty(scope, 'field', {
http://git-wip-us.apache.org/repos/asf/ignite/blob/8c79a57a/modules/control-center-web/src/main/js/app/modules/form/field/input/text.directive.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/form/field/input/text.directive.js b/modules/control-center-web/src/main/js/app/modules/form/field/input/text.directive.js
index a9e7f81..0a3fa04 100644
--- a/modules/control-center-web/src/main/js/app/modules/form/field/input/text.directive.js
+++ b/modules/control-center-web/src/main/js/app/modules/form/field/input/text.directive.js
@@ -20,11 +20,13 @@ import './text.css!';
export default ['igniteFormFieldInputText', ['IgniteFormGUID', (guid) => {
const link = (scope, el, attrs, [ngModel, form, label]) => {
- const {id, name} = scope;
+ const {id, ngModelName} = scope;
+
+ const name = ngModelName;
scope.id = id || guid();
scope.form = form;
- scope.name = scope.ngModelName + 'TextInput';
+ scope.name = ngModelName + 'TextInput';
scope.ngModel = ngModel;
Object.defineProperty(scope, 'field', {
http://git-wip-us.apache.org/repos/asf/ignite/blob/8c79a57a/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 57a92fa..81c1d99 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,6 +40,7 @@ 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';
@@ -79,6 +80,7 @@ angular
.directive(...igniteFormGroupAdd)
.directive(...igniteFormGroupTooltip)
// Validators.
+.directive(...igfsPathUnique)
.directive(...ipaddress)
.directive(...javaKeywords)
.directive(...javaPackageSpecified)
http://git-wip-us.apache.org/repos/asf/ignite/blob/8c79a57a/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
new file mode 100644
index 0000000..7753c85
--- /dev/null
+++ b/modules/control-center-web/src/main/js/app/modules/form/validator/igfs-path-unique.directive.js
@@ -0,0 +1,46 @@
+/*
+ * 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/8c79a57a/modules/control-center-web/src/main/js/app/modules/form/validator/property-unique.directive.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/form/validator/property-unique.directive.js b/modules/control-center-web/src/main/js/app/modules/form/validator/property-unique.directive.js
index 3f06f7b..8eb70af 100644
--- a/modules/control-center-web/src/main/js/app/modules/form/validator/property-unique.directive.js
+++ b/modules/control-center-web/src/main/js/app/modules/form/validator/property-unique.directive.js
@@ -28,11 +28,14 @@ export default ['ignitePropertyUnique', ['$parse', ($parse) => {
return true;
const key = value.split('=')[0];
- const name = attrs.name;
+ const idx = _.findIndex(arr, (item) => item.split('=')[0] === key);
+
+ // In case of new element check all items.
+ if (attrs.name === 'new')
+ return idx < 0;
// Check for $index in case of editing in-place.
- return _.isNumber(scope.$index) &&
- !_.find(arr, (checkedVal, ix) => (name === 'new' || scope.$index !== ix) && checkedVal.split('=')[0] === key);
+ return (_.isNumber(scope.$index) && (idx < 0 || scope.$index === idx));
};
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/8c79a57a/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 905a595..451ff9d 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
@@ -27,11 +27,10 @@ export default ['igniteUnique', ['$parse', ($parse) => {
if (!arr || !arr.length)
return true;
- const name = attrs.name;
const idx = arr.indexOf(value);
// In case of new element check all items.
- if (name === 'new')
+ if (attrs.name === 'new')
return idx < 0;
// Check for $index in case of editing in-place.
http://git-wip-us.apache.org/repos/asf/ignite/blob/8c79a57a/modules/control-center-web/src/main/js/app/modules/states/configuration/caches/query.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/states/configuration/caches/query.jade b/modules/control-center-web/src/main/js/app/modules/states/configuration/caches/query.jade
index 1488238..6e2425d 100644
--- a/modules/control-center-web/src/main/js/app/modules/states/configuration/caches/query.jade
+++ b/modules/control-center-web/src/main/js/app/modules/states/configuration/caches/query.jade
@@ -62,7 +62,7 @@ form.panel.panel-default(name='query' novalidate)
span(ng-hide='field.edit')
a.labelFormField(ng-click='field.edit = true') {{ model }}
- span(ng-if='field.edit' ng-init='edit = model')
+ span(ng-if='field.edit' ng-init='#{field} = model')
+table-java-class-field(field, sqlFunctionClasses, valid, save, false)
+table-save-button(valid, save, false)
+unique-feedback(unique, uniqueTip)
http://git-wip-us.apache.org/repos/asf/ignite/blob/8c79a57a/modules/control-center-web/src/main/js/app/modules/states/configuration/caches/store.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/modules/states/configuration/caches/store.jade b/modules/control-center-web/src/main/js/app/modules/states/configuration/caches/store.jade
index 07185ae..e837b78 100644
--- a/modules/control-center-web/src/main/js/app/modules/states/configuration/caches/store.jade
+++ b/modules/control-center-web/src/main/js/app/modules/states/configuration/caches/store.jade
@@ -199,7 +199,7 @@ form.panel.panel-default(name='store' novalidate)
+hibernateField(hibernateProperties, field, valid, save, false)
+table-save-button(valid, save, false)
+error-feedback(unique, 'ignitePropertyUnique', tipUnique)
- +error-feedback(unique, 'ignitePropertyValueSpecified', tipPropertySpecified)
+ +error-feedback(prop, 'ignitePropertyValueSpecified', tipPropertySpecified)
.group-content(ng-repeat='field in group.add')
-var field = 'new'
@@ -212,7 +212,7 @@ form.panel.panel-default(name='store' novalidate)
+hibernateField(hibernateProperties, field, valid, save, true)
+table-save-button(valid, save, true)
+error-feedback(unique, 'ignitePropertyUnique', tipUnique)
- +error-feedback(unique, 'ignitePropertyValueSpecified', tipPropertySpecified)
+ +error-feedback(prop, 'ignitePropertyValueSpecified', tipPropertySpecified)
.group-content-empty(ng-if='!(#{hibernateProperties}.length) && !group.add.length')
| Not defined
http://git-wip-us.apache.org/repos/asf/ignite/blob/8c79a57a/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 4e8dd75..3428e2d 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,6 +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'
.col-sm-12
.col-sm-8
@@ -38,10 +39,12 @@ mixin pathModeEditor(newItem)
data-ng-model=path
enter-focus-next=mode
data-ng-required='true'
+ data-ignite-igfs-path-unique=pathModes
data-placeholder='Input path'
data-ignite-form-field-input-autofocus='true'
on-escape=reset
)
+ +error-feedback(unique, 'igfsPathUnique', 'Such path already exists!')
.col-sm-4
.tipField
+table-save-button(valid, save, newItem)