From 915bb464cbb30783661e826ad1651c38ad8dbd79 Mon Sep 17 00:00:00 2001 From: nelo Date: Mon, 16 Jan 2017 13:09:15 +0100 Subject: [PATCH] activar/desactivar clientes --- @salix/core/src/switch/switch.mdl.js | 2 +- .../crud/src/client/descriptor/descriptor.js | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/@salix/core/src/switch/switch.mdl.js b/@salix/core/src/switch/switch.mdl.js index c88b1d996d..13cd5c5d5e 100644 --- a/@salix/core/src/switch/switch.mdl.js +++ b/@salix/core/src/switch/switch.mdl.js @@ -15,7 +15,7 @@ export function factory() { className: DEFAULT_CLASS, label: "" } - } + }; } _module.factory(NAME, factory); diff --git a/@salix/crud/src/client/descriptor/descriptor.js b/@salix/crud/src/client/descriptor/descriptor.js index e01a64c18c..a8ccfc23b3 100644 --- a/@salix/crud/src/client/descriptor/descriptor.js +++ b/@salix/crud/src/client/descriptor/descriptor.js @@ -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);