Commit a8526333 authored by fabio martelli's avatar fabio martelli
Browse files

Fix for choreography unsubscription

parent 280de168
......@@ -197,7 +197,7 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
$scope.dynamicForm.groups = new Array();
for (var i in response.groups) {
$scope.dynamicForm.groups.push({"rightKey": response.groups[i].key, "groupName": response.groups[i].name});
}
}
for (var i in response.choreographies) {
$scope.dynamicForm.choreographies.push({"rightKey": response.choreographies[i].key, "groupName": response.choreographies[i].name});
}
......@@ -317,24 +317,34 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
var removeUserSchemas = function (anyTypeClass, group) {
//removing plain groupSchemas
// console.log("remove schemas");
// console.log("start: $scope.dynamicForm.groupSchemas", $scope.dynamicForm.groupSchemas);
for (var i = 0; i < $scope.dynamicForm.groupSchemas.length; i++) {
// console.log("iterazione ", i);
// console.log("1 $scope.dynamicForm.groupSchemas[i]", $scope.dynamicForm.groupSchemas[i]);
if ($scope.dynamicForm.groupSchemas[i] === group) {
console.log("eliminazione di ", $scope.dynamicForm.groupSchemas[i]);
$scope.dynamicForm.groupSchemas.splice(i, 1);
i--;
}
}
console.log("result: $scope.dynamicForm.groupSchemas", $scope.dynamicForm.groupSchemas);
//removing plain schemas
for (var i = 0; i < $scope.dynamicForm.plainSchemas.length; i++) {
if ((anyTypeClass && $scope.dynamicForm.plainSchemas[i].anyTypeClass === anyTypeClass)
|| (group && $scope.dynamicForm.plainSchemas[i].key.includes(group + '#'))) {
//cleaning both form and user model
delete $scope.user.plainAttrs[$scope.dynamicForm.plainSchemas[i].key];
$scope.dynamicForm.plainSchemas.splice(i, 1);
i--;
}
}
console.log("2.$scope.user.plainAttrs", $scope.user.plainAttrs);
console.log("2.$scope.dynamicForm.plainSchemas", $scope.dynamicForm.plainSchemas);
//removing derived schemas
for (var i = 0; i < $scope.dynamicForm.derSchemas.length; i++) {
if ((anyTypeClass && $scope.dynamicForm.derSchemas[i].anyTypeClass === anyTypeClass)
......@@ -375,7 +385,8 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
$scope.$on('groupRemoved', function (event, group) {
if (group)
removeUserSchemas(null, group);
console.log("remove group", group);
removeUserSchemas(null, group);
});
if ($scope.createMode) {
......@@ -427,6 +438,9 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l
$scope.showError("Error: " + (errorMessage || response), $scope.notification);
});
} else {
console.log("groupAdded", $scope.dynamicForm.groupSchemas);
console.log("user", user);
console.log("user plainattrs", user.plainAttrs);
UserSelfService.update(wrappedUser, $scope.captchaInput.value).then(function (response) {
console.debug("Updated user: ", response);
AuthService.logout().then(function (response) {
......
......@@ -47,9 +47,9 @@ angular.module('self')
};
$scope.getIndex = function (selectedChoreography) {
var choreographyIndex = $scope.user.memberships.map(function (groupName) {
return groupName;
}).indexOf(selectedChoreography);
var choreographyIndex = $scope.user.memberships.map(function (membership) {
return membership.groupName;
}).indexOf(selectedChoreography.groupName);
return choreographyIndex;
};
}
......
......@@ -17,6 +17,8 @@ limitations under the License.
<type form="dynamicForm" user="user"></type>
</div>
<div id="attribute" class="form-group row">
<button id="save" ng-show="!createMode" type="button" class="btn btn-default pull-right" ng-click="finish()">{{'FINISH'| translate}}</button>
<button id="save" ng-show="createMode && endReached" type="button" class="btn btn-default pull-right" ng-click="finish()">{{'FINISH'| translate}}</button>
<navigation-buttons ng-show="createMode" base="create" current="type" wizard="{{wizard}}"></navigation-buttons>
<navigation-buttons ng-show="!createMode" base="update" current="type" wizard="{{wizard}}"></navigation-buttons>
<div class="pull-left">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment