ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [25/28] ignite git commit: IGNTIE-2723 fixed java class input - Fixes #532.
Date Thu, 03 Mar 2016 12:07:32 GMT
IGNTIE-2723 fixed java class input - Fixes #532.

Signed-off-by: Alexey Kuznetsov <akuznetsov@apache.org>


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

Branch: refs/heads/ignite-843-rc3
Commit: 877f4a446abef7e0118f65095767d8855188afc4
Parents: 53804c7
Author: Dmitriyff <dmitriyff@gmail.com>
Authored: Thu Mar 3 16:36:55 2016 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Thu Mar 3 16:36:55 2016 +0700

----------------------------------------------------------------------
 .../form-field-java-class.directive.js          | 46 ++++++++++++++++----
 .../form-field-java-class.jade                  | 38 ++++++++--------
 2 files changed, 58 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/877f4a44/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 d0f7254..659030e 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
@@ -18,19 +18,48 @@
 import template from './form-field-java-class.jade!';
 
 export default ['igniteFormFieldJavaClass', ['IgniteFormGUID', (guid) => {
-    const link = (scope, el, attrs, [form, label]) => {
+    const link = (scope, el, attrs, [ngModel, form, label]) => {
         const {id, name} = scope;
-        const field = form[name];
-
-        scope.form = form;
-        scope.field = field;
-        scope.label = label;
 
         label.for = scope.id = id || guid();
 
+        scope.form = form;
+        scope.label = label;
+        scope.ngModel = ngModel;
         scope.$watch('required', (required) => {
             label.required = required || false;
         });
+
+        form.$defaults = form.$defaults || {};
+        form.$defaults[name] = _.cloneDeep(scope.value);
+
+        const setAsDefault = () => {
+            if (!form.$pristine) return;
+
+            form.$defaults = form.$defaults || {};
+            form.$defaults[name] = _.cloneDeep(scope.value);
+        };
+
+        scope.$watch(() => form.$pristine, setAsDefault);
+        scope.$watch('value', setAsDefault);
+
+        scope.ngChange = function() {
+            ngModel.$setViewValue(scope.value);
+
+            if (JSON.stringify(scope.value) !== JSON.stringify(form.$defaults[name]))
+                ngModel.$setDirty();
+            else
+                ngModel.$setPristine();
+
+            if (ngModel.$valid)
+                el.find('input').addClass('ng-valid').removeClass('ng-invalid');
+            else
+                el.find('input').removeClass('ng-valid').addClass('ng-invalid');
+        };
+
+        ngModel.$render = function() {
+            scope.value = ngModel.$modelValue;
+        };
     };
 
     return {
@@ -38,11 +67,10 @@ export default ['igniteFormFieldJavaClass', ['IgniteFormGUID', (guid)
=> {
         scope: {
             id: '@',
             name: '@',
+            placeholder: '@',
             required: '=ngRequired',
             disabled: '=ngDisabled',
-            unique: '=igniteUnique',
 
-            ngModel: '=',
             ngBlur: '&',
 
             autofocus: '=igniteFormFieldInputAutofocus'
@@ -51,6 +79,6 @@ export default ['igniteFormFieldJavaClass', ['IgniteFormGUID', (guid) =>
{
         template,
         replace: true,
         transclude: true,
-        require: ['^form', '?^igniteFormField']
+        require: ['ngModel', '^form', '?^igniteFormField']
     };
 }]];

http://git-wip-us.apache.org/repos/asf/ignite/blob/877f4a44/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade
b/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade
index d8e5162..ae75c27 100644
--- a/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade
+++ b/modules/control-center-web/src/main/js/app/directives/form-field-java-class/form-field-java-class.jade
@@ -16,38 +16,42 @@
 
 mixin feedback(error, message)
     i.fa.fa-exclamation-triangle.form-control-feedback(
-        ng-if='!form[name].$pristine && form[name].$error.#{error}'
+        ng-if='!form[name+"JavaClass"].$pristine && form[name+"JavaClass"].$error.#{error}'
         bs-tooltip='"{{ label.name }} #{message}"'
         ignite-error='#{error}'
         ignite-error-message='{{ label.name }} #{message}'
     )
 
-div
-    ignite-form-field-input-text(
-        data-id='{{ id }}'
-        data-name='{{ name }}'
-        data-placeholder='Enter fully qualified class name'
+.input-tip
+    input.form-control(
+        id='{{ id }}'
+        name='{{ name }}JavaClass'
+        placeholder='Enter fully qualified class name'
+        type='text'
 
-        data-ng-model='ngModel'
+        data-ng-model='value'
+        data-ng-blur='ngBlur()'
+        data-ng-change='ngChange()'
         data-ng-required='required || false'
         data-ng-disabled='disabled || false'
+        data-ng-model-options='{debounce: 150}'
 
         data-java-keywords='true'
         data-java-identifier='true'
         data-java-package-specified='true'
         data-java-built-in-class='true'
-        
-        data-ignite-unique='unique'
-        data-ignite-form-field-input-autofocus='autofocus || false '
+
+        data-ignite-form-field-input-autofocus='autofocus || false'
 
         on-enter='onEnter()'
         on-escape='onEscape()'
-        data-ng-blur='ngBlur()'
     )
-        span(ng-transclude)
 
-        +feedback('javaPackageSpecified', 'does not have package specified')
-        +feedback('javaBuiltInClass', 'should not be the Java built-in class')
-        +feedback('javaKeywords', 'could not contains reserved Java keyword')
-        +feedback('javaIdentifier', 'is invalid Java identifier')
-        +feedback('required', 'could not be empty')
+    span(ng-transclude='')
+
+    +feedback('javaPackageSpecified', 'does not have package specified')
+    +feedback('javaBuiltInClass', 'should not be the Java built-in class')
+    +feedback('javaKeywords', 'could not contains reserved Java keyword')
+    +feedback('javaIdentifier', 'is invalid Java identifier')
+
+    +feedback('required', 'could not be empty!')


Mime
View raw message