You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by gi...@apache.org on 2016/02/15 17:13:02 UTC

[1/2] syncope git commit: [SYNCOPE-719] A notification error appears in case of form errors

Repository: syncope
Updated Branches:
  refs/heads/master 2ecd96f10 -> 7d0b602ee


[SYNCOPE-719] A notification error appears in case of form errors


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/7d0b602e
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/7d0b602e
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/7d0b602e

Branch: refs/heads/master
Commit: 7d0b602eebb898e7154ca4a2edcf3d404c329798
Parents: 454af56
Author: giacomolm <gi...@hotmail.it>
Authored: Mon Feb 15 17:12:27 2016 +0100
Committer: giacomolm <gi...@hotmail.it>
Committed: Mon Feb 15 17:12:44 2016 +0100

----------------------------------------------------------------------
 .../resources/META-INF/resources/app/js/app.js  | 21 +++++++++++++++++---
 .../resources/app/js/directives/validate.js     |  5 +++--
 .../app/js/directives/validationMessage.js      | 12 ++++++++---
 .../resources/app/js/util/genericUtil.js        |  2 +-
 .../app/js/validator/validationExecutor.js      | 21 +++++++++++++-------
 5 files changed, 45 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/7d0b602e/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/app.js b/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
index a8f7120..57b45ef 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/app.js
@@ -254,7 +254,7 @@ app.run(['$rootScope', '$location', '$cookies', '$state',
         $state.go(toState);
       }
     });
-    
+
     $rootScope.spinner = {
       active: false,
       on: function () {
@@ -306,14 +306,25 @@ app.controller('ApplicationController', ['$scope', '$rootScope', 'InfoService',
       $scope.notification.options.position["top"] = 20;
       $scope.showSuccess = function (message, component) {
         if (!$scope.notificationExists(message)) {
+          //forcing scrollTo since kendo doesn't disable scrollTop if pinned is true
+          window.scrollTo(0, 0);
           component.options.autoHideAfter = 3000;
           component.show(message, "success");
         }
       }
       $scope.showError = function (message, component) {
         if (!$scope.notificationExists(message)) {
+          //forcing scrollTo since kendo doesn't disable scrollTop if pinned is true
+          window.scrollTo(0, 0);
           component.options.autoHideAfter = 0;
-          component.show(message, "error");          
+          component.show(message, "error");
+        }
+      }
+      $scope.hideError = function (message, component) {
+        var popup;
+        if (popup = $scope.notificationExists(message)) {
+          popup.hide = true;
+          popup.close();
         }
       }
       $scope.notificationExists = function (message) {
@@ -323,7 +334,7 @@ app.controller('ApplicationController', ['$scope', '$rootScope', 'InfoService',
           pendingNotifications.each(function (idx, element) {
             var popup = $(element).data("kendoPopup");
             if (!popup.hide && popup.wrapper.html().indexOf(message) > -1) {
-              result = true;
+              result = popup;
               return false; //breaking the each and storing the real result
             }
           });
@@ -365,6 +376,10 @@ app.controller('ApplicationController', ['$scope', '$rootScope', 'InfoService',
       $scope.$on('xhrStarted', function (event, next, current) {
         $scope.hideNotifications(0);
       });
+      //Intercepting hide popup errors event
+      $scope.$on('hideErrorMessage', function (event, popupMessage) {
+        $scope.hideError(popupMessage, $scope.notification);
+      });
     }
   }]);
 app.factory('AuthenticationHelper', ['$q', '$rootScope',

http://git-wip-us.apache.org/repos/asf/syncope/blob/7d0b602e/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validate.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validate.js b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validate.js
index 514d110..e3526b3 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validate.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validate.js
@@ -25,9 +25,10 @@ angular.module('SyncopeEnduserApp').
           return {
             require: 'ngModel',
             link: function (scope, elem, attrs, ngModel) {
-              scope.$watch(attrs.ngModel, function (value) {                
+              scope.$watch(attrs.ngModel, function (value) {
                 //trigger the live validation only if user interacts with the input
-                if (scope.validationEnabled && !ngModel.$pristine) {
+                var validationEnabled = scope.validationEnabled || scope.$root.validationEnabled;
+                if (validationEnabled && !ngModel.$pristine) {
                   //broadcasting from root scope element validity
                   scope.$root.$broadcast(attrs.name, {errors: ngModel.$error});
                 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/7d0b602e/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validationMessage.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validationMessage.js b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validationMessage.js
index 0e3ba6c..3fc8b33 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validationMessage.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validationMessage.js
@@ -20,18 +20,24 @@
 'use strict';
 
 angular.module('SyncopeEnduserApp').
-        directive('validationMessage', function ($templateRequest, $compile) {
+        directive('validationMessage', function () {
           return {
             templateUrl: 'views/validationMessage.html',
             scope: {
               "name": "@",
               "template": "@"
             },
+            require: '^form',
             replace: false,
-            link: function (scope, el, attrs) {
+            link: function (scope, el, attrs, formCtrl) {
+              var popupMessage = "Data are invalid: please correct accordingly";
               //listener
               scope.$on(attrs.name, function (el, errors) {
                 scope.errors = errors;
+                //hide popup error message if there aren't errors
+                if ($.isEmptyObject(formCtrl.$error)) {
+                  scope.$emit("hideErrorMessage", popupMessage);
+                }
               });
             }
           };
@@ -62,7 +68,7 @@ angular.module('SyncopeEnduserApp').
                   });
                 }
               }
-              else{
+              else {
                 ngswitch.append("<div ng-switch-default>{{key}} validation rule is not satisfied</div>")
               }
               $compile(ngswitch)(scope);

http://git-wip-us.apache.org/repos/asf/syncope/blob/7d0b602e/client/enduser/src/main/resources/META-INF/resources/app/js/util/genericUtil.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/util/genericUtil.js b/client/enduser/src/main/resources/META-INF/resources/app/js/util/genericUtil.js
index c671f32..c698ebf 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/util/genericUtil.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/util/genericUtil.js
@@ -44,7 +44,7 @@ angular.module('SyncopeEnduserApp')
               return null;
             };
 
-            genericUtil.getEnclosingForm = function (element, scope) {
+            genericUtil.getEnclosingForm = function (element) {
               var form = $(element).closest('form');
               if (form.length) {
                 return form[0];

http://git-wip-us.apache.org/repos/asf/syncope/blob/7d0b602e/client/enduser/src/main/resources/META-INF/resources/app/js/validator/validationExecutor.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/validator/validationExecutor.js b/client/enduser/src/main/resources/META-INF/resources/app/js/validator/validationExecutor.js
index db4e4cb..e391a29 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/validator/validationExecutor.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/validator/validationExecutor.js
@@ -23,19 +23,26 @@ angular.module('SyncopeEnduserApp')
           function (GenericUtil) {
 
             var validationExecutor = {};
-            
-            validationExecutor.validate = function (form, scope) {              
-              if(scope.validationEnabled){
-                var currentForm = scope[form.name] || scope[form.$name];              
+
+            validationExecutor.validate = function (form, scope) {
+              if (scope.validationEnabled) {
+                var currentForm = scope[form.name] || scope[form.$name];
                 angular.forEach(currentForm.$error, function (field) {
-                  for (var i in field) {                  
+                  for (var i in field) {
                     scope.$root.$broadcast(field[i].$name, {errors: field[i].$error});
                   }
                 });
                 currentForm.$setSubmitted();
-                return $.isEmptyObject(currentForm.$error);
+                if ($.isEmptyObject(currentForm.$error)) {
+                  return true
+                }
+                else {
+                  scope.showError("Data are invalid: please correct accordingly", scope.notification);
+                  return false;
+                }
               }
-              else return true;
+              else
+                return true;
             };
             return validationExecutor;
           }]);
\ No newline at end of file


[2/2] syncope git commit: Upgrading Angular to 1.5.0

Posted by gi...@apache.org.
Upgrading Angular to 1.5.0


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/454af561
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/454af561
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/454af561

Branch: refs/heads/master
Commit: 454af56189ae01d061eda672d5392980e285a508
Parents: 2ecd96f
Author: giacomolm <gi...@hotmail.it>
Authored: Mon Feb 15 09:59:59 2016 +0100
Committer: giacomolm <gi...@hotmail.it>
Committed: Mon Feb 15 17:12:44 2016 +0100

----------------------------------------------------------------------
 .../resources/META-INF/resources/app/views/auxClasses.html     | 6 ++++--
 .../main/resources/META-INF/resources/app/views/groups.html    | 6 ++++--
 .../main/resources/META-INF/resources/app/views/resources.html | 4 ++--
 pom.xml                                                        | 2 +-
 4 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/454af561/client/enduser/src/main/resources/META-INF/resources/app/views/auxClasses.html
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/views/auxClasses.html b/client/enduser/src/main/resources/META-INF/resources/app/views/auxClasses.html
index 5b46de3..d9bfbc1 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/views/auxClasses.html
+++ b/client/enduser/src/main/resources/META-INF/resources/app/views/auxClasses.html
@@ -20,8 +20,10 @@ under the License.
   <ui-select on-select="addAuxClass($item, $model)" on-remove="removeAuxClass($item, $model)" multiple
              ng-model="dynamicForm.selectedAuxClasses" theme="select2" class="attribute-ui-select" 
              ng-disabled="{{auxClassDisabled}}">
-    <ui-select-match placeholder="Click to select auxiliary class...">{{$item}}</ui-select-match>
-    <ui-select-choices repeat="auxClass in dynamicForm.auxClasses">
+    <ui-select-match placeholder="Click to select auxiliary class..." class="ui-select-match">
+      {{$item}}
+    </ui-select-match>
+    <ui-select-choices repeat="auxClass in dynamicForm.auxClasses" class="ui-select-choices">
       <div ng-bind-html="auxClass | highlight: $select.search"></div>
     </ui-select-choices>
   </ui-select>

http://git-wip-us.apache.org/repos/asf/syncope/blob/454af561/client/enduser/src/main/resources/META-INF/resources/app/views/groups.html
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/views/groups.html b/client/enduser/src/main/resources/META-INF/resources/app/views/groups.html
index 97e7205..03f728f 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/views/groups.html
+++ b/client/enduser/src/main/resources/META-INF/resources/app/views/groups.html
@@ -20,9 +20,11 @@ under the License.
   <ui-select on-select="addGroup($item, $model)" on-remove="removeGroup($item, $model)" multiple
              ng-model="dynamicForm.selectedGroups" theme="select2" class="attribute-ui-select" 
              ng-disabled="{{groupDisabled}}">
-    <ui-select-match placeholder="Click to select groups...">{{$item.groupName}}</ui-select-match>
+    <ui-select-match placeholder="Click to select groups..." class="ui-select-match">
+      {{$item.groupName}}
+    </ui-select-match>
     <ui-select-choices repeat="group in dynamicForm.groups | propsFilter: {selected: dynamicForm.selectedGroups} 
-                       track by group.rightKey">
+                       track by group.rightKey" class="ui-select-choices">
       <div ng-bind-html="group.groupName | highlight: $select.search"></div>
     </ui-select-choices>
   </ui-select>

http://git-wip-us.apache.org/repos/asf/syncope/blob/454af561/client/enduser/src/main/resources/META-INF/resources/app/views/resources.html
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/views/resources.html b/client/enduser/src/main/resources/META-INF/resources/app/views/resources.html
index 04f04e1..8072f05 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/views/resources.html
+++ b/client/enduser/src/main/resources/META-INF/resources/app/views/resources.html
@@ -18,8 +18,8 @@ under the License.
 -->
 <ui-select on-select="addResource($item, $model)" on-remove="removeResource($item, $model)" multiple
            ng-model="dynamicForm.selectedResources" theme="select2" class="attribute-ui-select">
-  <ui-select-match placeholder="Select resource...">{{$item}}</ui-select-match>
-  <ui-select-choices repeat="resource in dynamicForm.resources">
+  <ui-select-match placeholder="Select resource..." class="ui-select-match">{{$item}}</ui-select-match>
+  <ui-select-choices repeat="resource in dynamicForm.resources" class="ui-select-choices">
     <div ng-bind-html="resource | highlight: $select.search"></div>
   </ui-select-choices>
 </ui-select>

http://git-wip-us.apache.org/repos/asf/syncope/blob/454af561/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1557bca..d7b12c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -391,7 +391,7 @@ under the License.
     <wicket.version>7.2.0</wicket.version>
     <wicket-jqueryui.version>7.2.0</wicket-jqueryui.version>
     
-    <angular.version>1.4.9</angular.version>
+    <angular.version>1.5.0</angular.version>
     <angular-ui-router.version>0.2.17</angular-ui-router.version>
     <angular-ui-bootstrap.version>1.1.1-1</angular-ui-bootstrap.version>
     <angular-ui-select.version>0.13.1</angular-ui-select.version>