Merge branches 'master' and 'master' of ssh://git.verdnatura.es:/var/lib/git/salix

This commit is contained in:
Juan Ferrer Toribio 2017-01-16 15:30:31 +01:00
commit 93cd67a551
4 changed files with 29 additions and 3 deletions

View File

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

View File

@ -18,4 +18,3 @@
</vn-vertical>
</vn-card>
</form>
<vn-confirm-client client="create.model" client-old="create.model" state="create.state"></vn-confirm-client>

View File

@ -7,11 +7,12 @@ export const COMPONENT = {
controllerAs: "create",
controller: function($http, $state) {
this.submit = function() {
this.model.active = true;
$http.post('/client/api/Clients', this.model).then(
json => $state.go('clientCard.basicData', {id: json.data.id})
);
};
}
};
COMPONENT.controller.$inject = ["$http", "$state"];
COMPONENT.controller.$inject = ['$http', '$state'];
module.component(NAME, COMPONENT);

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);