activar/desactivar clientes

This commit is contained in:
nelo 2017-01-16 13:09:15 +01:00
parent c2e91a63c6
commit 915bb464cb
2 changed files with 27 additions and 1 deletions

View File

@ -15,7 +15,7 @@ export function factory() {
className: DEFAULT_CLASS,
label: ""
}
}
};
}
_module.factory(NAME, factory);

View File

@ -8,6 +8,32 @@ export const COMPONENT = {
controllerAs: 'descriptor',
bindings: {
client: '<'
},
controller: function($http, $scope, copyObject) {
var self = this;
this.$onChanges = function(changes) {
if (this.client) {
this.copyClient();
}
};
$scope.$watch('descriptor.client.active', function(newValue, oldValue) {
if (self.client && self.clientOld && self.client.active !== self.clientOld.active) {
self.client.modify = "Active";
$http.put('/client/api/Clients', self.client).then(
json => {
self.client = json.data;
self.copyClient();
}
);
}
});
this.copyClient = function() {
this.clientOld = {};
copyObject(this.client, this.clientOld);
};
}
};
COMPONENT.controller.$inject = ['$http', '$scope', 'copyObject'];
module.component(NAME, COMPONENT);