Añadido metodo en ticket card para que se actualicen datos del ticket

This commit is contained in:
gerard 2018-05-08 09:30:55 +02:00
parent c7f07d0548
commit 1460887ca2
3 changed files with 16 additions and 12 deletions

View File

@ -1,10 +1,9 @@
import ngModule from '../module'; import ngModule from '../module';
class TicketCard { class TicketCard {
constructor($http, $state, $timeout) { constructor($http, $state) {
this.$http = $http; this.$http = $http;
this.$state = $state; this.$state = $state;
this.$timeout = $timeout;
this.ticket = null; this.ticket = null;
} }
@ -25,7 +24,7 @@ class TicketCard {
} }
}, },
{ {
relation: 'ticketTracking', relation: 'tracking',
scope: { scope: {
fields: ['stateFk'], fields: ['stateFk'],
include: { include: {
@ -36,13 +35,11 @@ class TicketCard {
} }
] ]
}; };
this.$http.get(`/ticket/api/Tickets/${this.$state.params.id}?filter=${JSON.stringify(filter)}`) let json = encodeURIComponent(JSON.stringify(filter));
this.$http.get(`/ticket/api/Tickets/${this.$state.params.id}?filter=${json}`)
.then(res => { .then(res => {
if (res.data && res.data.id) { if (res.data)
this.$timeout(() => {
this.ticket = res.data; this.ticket = res.data;
});
}
} }
); );
} }
@ -50,8 +47,11 @@ class TicketCard {
$onInit() { $onInit() {
this._getTicket(); this._getTicket();
} }
reload() {
this._getTicket();
} }
TicketCard.$inject = ['$http', '$state', '$timeout']; }
TicketCard.$inject = ['$http', '$state'];
ngModule.component('vnTicketCard', { ngModule.component('vnTicketCard', {
template: require('./ticket-card.html'), template: require('./ticket-card.html'),

View File

@ -17,7 +17,7 @@
value="{{$ctrl.ticket.client.name}}"> value="{{$ctrl.ticket.client.name}}">
</vn-label-value> </vn-label-value>
<vn-label-value label="State" <vn-label-value label="State"
value="{{$ctrl.ticket.ticketTracking.state.name}}"> value="{{$ctrl.ticket.tracking.state.name}}">
</vn-label-value> </vn-label-value>
<vn-label-value label="Sales person" <vn-label-value label="Sales person"
value="{{$ctrl.ticket.client.salesPerson.firstName}} {{$ctrl.ticket.client.salesPerson.name}}"> value="{{$ctrl.ticket.client.salesPerson.firstName}} {{$ctrl.ticket.client.salesPerson.name}}">

View File

@ -14,6 +14,7 @@ class Controller {
onSubmit() { onSubmit() {
this.$.watcher.submit().then( this.$.watcher.submit().then(
() => { () => {
this.card.reload();
this.$state.go('ticket.card.tracking.index'); this.$state.go('ticket.card.tracking.index');
} }
); );
@ -23,5 +24,8 @@ Controller.$inject = ['$scope', '$state', 'vnApp', '$translate'];
ngModule.component('vnTicketTrackingEdit', { ngModule.component('vnTicketTrackingEdit', {
template: require('./edit.html'), template: require('./edit.html'),
controller: Controller controller: Controller,
require: {
card: '^vnTicketCard'
}
}); });