From 40e2b73e7c7c9a39c38031da082c8cbe185adf5e Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Thu, 1 Mar 2018 14:48:02 +0100 Subject: [PATCH] tarea #105 in progress --- client/client/src/summary/client-summary.js | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/client/client/src/summary/client-summary.js b/client/client/src/summary/client-summary.js index 0557c418f..4109b1b77 100644 --- a/client/client/src/summary/client-summary.js +++ b/client/client/src/summary/client-summary.js @@ -1,7 +1,31 @@ import ngModule from '../module'; +class ClientSummary { + constructor($http) { + this.$http = $http; + } + getRelations() { + let filter = { + include: ['account', 'salesPerson', 'province'] + }; + let url = `/client/api/Clients/${this.client.id}?filter=${JSON.stringify(filter)}`; + + this.$http.get(encodeURIComponent(url)).then(res => { + if (res.data) + this.client = res.data; + }); + } + $onChanges(changesObj) { + if (this.client && this.client.id && !this.client.salesPerson) { + this.getRelations(); + } + } +} +ClientSummary.$inject = ['$http']; + ngModule.component('vnClientSummary', { template: require('./client-summary.html'), + controller: ClientSummary, bindings: { client: '<' }