You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by an...@apache.org on 2017/06/16 15:05:33 UTC
syncope git commit: [SYNCOPE-1093] Disable select2search fields when
no data is available. This closes #46
Repository: syncope
Updated Branches:
refs/heads/master 10a95705f -> eec50af7a
[SYNCOPE-1093] Disable select2search fields when no data is available. This closes #46
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/eec50af7
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/eec50af7
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/eec50af7
Branch: refs/heads/master
Commit: eec50af7a26d87e88a5ce8b3f45e7b96d6bd8cb9
Parents: 10a9570
Author: Matteo Alessandroni <ma...@tirasa.net>
Authored: Fri Jun 16 16:19:53 2017 +0200
Committer: Andrea Patricelli <an...@apache.org>
Committed: Fri Jun 16 17:04:52 2017 +0200
----------------------------------------------------------------------
.../resources/META-INF/resources/app/index.html | 1 +
.../resources/app/js/directives/auxClasses.js | 1 -
.../resources/app/js/directives/groups.js | 3 +-
.../app/js/directives/validateDropdowns.js | 65 ++++++++++++++++++++
.../app/js/validator/validationExecutor.js | 8 +--
.../resources/app/views/auxClasses.html | 3 +-
.../META-INF/resources/app/views/groups.html | 3 +-
.../META-INF/resources/app/views/resources.html | 4 +-
8 files changed, 77 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec50af7/client/enduser/src/main/resources/META-INF/resources/app/index.html
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/index.html b/client/enduser/src/main/resources/META-INF/resources/app/index.html
index 21a7984..8a465d4 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/index.html
+++ b/client/enduser/src/main/resources/META-INF/resources/app/index.html
@@ -118,6 +118,7 @@ under the License.
<script src="js/directives/auxClasses.js"></script>
<script src="js/directives/validate.js"></script>
<script src="js/directives/validationMessage.js"></script>
+ <script src="js/directives/validateDropdowns.js"></script>
<script src="js/directives/fileInput.js"></script>
<!--validator-->
<script src="js/validator/validationRules.js"></script>
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec50af7/client/enduser/src/main/resources/META-INF/resources/app/js/directives/auxClasses.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/auxClasses.js b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/auxClasses.js
index 99a6c1e..e4bf6ff 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/auxClasses.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/auxClasses.js
@@ -33,7 +33,6 @@ angular.module('self')
if (!$scope.user.auxClasses) {
$scope.user.auxClasses = new Array();
}
- $scope.auxClassDisabled = false;
};
$scope.addAuxClass = function (item, model) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec50af7/client/enduser/src/main/resources/META-INF/resources/app/js/directives/groups.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/groups.js b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/groups.js
index 52b1d0c..330b1a4 100644
--- a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/groups.js
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/groups.js
@@ -32,9 +32,8 @@ angular.module('self')
if (!$scope.user.memberships) {
$scope.user.memberships = new Array();
}
- $scope.groupDisabled = false
};
-
+
$scope.addGroup = function (item, model) {
var membership = item;
$scope.user.memberships.push({"rightKey": membership.rightKey, "groupName": membership.groupName});
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec50af7/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validateDropdowns.js
----------------------------------------------------------------------
diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validateDropdowns.js b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validateDropdowns.js
new file mode 100644
index 0000000..fee11e9
--- /dev/null
+++ b/client/enduser/src/main/resources/META-INF/resources/app/js/directives/validateDropdowns.js
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+'use strict';
+
+//Live validation
+angular.module('SyncopeEnduserApp').
+ directive('validateDropdown', ['$timeout', function ($timeout) {
+
+ return {
+ restrict: 'A',
+ require: 'ngModel',
+ replace: true,
+
+ link: function ($scope, $elem, attrs, ngModel) {
+
+ $scope.dynamicform = $scope.$eval(attrs.dynamicForm);
+ var dropdownSelectName = attrs.validateDropdown;
+
+ var realmTemp;
+ var isGroups = dropdownSelectName === "groups";
+ if (isGroups) {
+ realmTemp = $scope.user.realm;
+ }
+
+ // enable / disable input according to available values
+ $scope.$watch(attrs.dynamicForm + "." + dropdownSelectName, function (newValues) {
+ // disable input element when no data is available (groups, resources, etc...)
+ if (newValues && newValues.length > 0) {
+ $scope.$parent.inputDisabled = false;
+ } else {
+ $scope.$parent.inputDisabled = true;
+ }
+ // to solve some graphical rerendering issues
+ $timeout(function () {
+ $elem.trigger('click');
+ }, 100);
+
+ // remove selected groups when realm changes
+ if (isGroups && realmTemp !== $scope.user.realm) {
+ $scope.dynamicform.selectedGroups = [];
+ realmTemp = $scope.user.realm;
+ }
+ });
+
+ }
+
+ };
+ }]);
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec50af7/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 e391a29..cdb3f17 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
@@ -34,14 +34,12 @@ angular.module('SyncopeEnduserApp')
});
currentForm.$setSubmitted();
if ($.isEmptyObject(currentForm.$error)) {
- return true
- }
- else {
+ return true;
+ } else {
scope.showError("Data are invalid: please correct accordingly", scope.notification);
return false;
}
- }
- else
+ } else
return true;
};
return validationExecutor;
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec50af7/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 9383f38..a6017bb 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
@@ -18,8 +18,9 @@ under the License.
-->
<div ng-init='init()'>
<ui-select on-select="addAuxClass($item, $model)" on-remove="removeAuxClass($item, $model)" multiple
+ validate-dropdown="auxClasses" dynamic-form="dynamicForm"
ng-model="dynamicForm.selectedAuxClasses" theme="select2" class="attribute-ui-select"
- ng-disabled="{{auxClassDisabled}}">
+ ng-disabled="inputDisabled">
<ui-select-match placeholder="{{'AUXILIARY_CLASSES_PLACEHOLDER'| translate}}" class="ui-select-match">
{{$item}}
</ui-select-match>
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec50af7/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 72fedf1..ef77ae1 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
@@ -18,8 +18,9 @@ under the License.
-->
<div ng-init='init()'>
<ui-select on-select="addGroup($item, $model)" on-remove="removeGroup($item, $model)" multiple
+ validate-dropdown="groups" dynamic-form="dynamicForm"
ng-model="dynamicForm.selectedGroups" theme="select2" class="attribute-ui-select"
- ng-disabled="{{groupDisabled}}">
+ ng-disabled="inputDisabled">
<ui-select-match placeholder="{{'GROUPS_PLACEHOLDER'| translate}}" class="ui-select-match">
{{$item.groupName}}
</ui-select-match>
http://git-wip-us.apache.org/repos/asf/syncope/blob/eec50af7/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 4aee069..23158d0 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
@@ -17,7 +17,9 @@ specific language governing permissions and limitations
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">
+ validate-dropdown="resources" dynamic-form="dynamicForm"
+ ng-model="dynamicForm.selectedResources" theme="select2" class="attribute-ui-select"
+ ng-disabled="inputDisabled">
<ui-select-match placeholder="{{'RESOURCES_PLACEHOLDER'|translate}}" 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>