import ngModule from '../../module'; class Controller { constructor($http, $scope, $state, $translate, vnApp) { this.$http = $http; this.$scope = $scope; this.$state = $state; this.$translate = $translate; this.vnApp = vnApp; } $onInit() { this.data.registerChild(this); } $onChanges() { this.ticket.option = 1; } onStepChange(state) { return true; } onSubmit() { if (!this.ticket.option) return this.vnApp.showError( this.$translate.instant('Choose an option') ); let query = `/ticket/api/tickets/${this.ticket.id}/componentUpdate`; let data = { agencyModeFk: this.ticket.agencyModeFk, addressFk: this.ticket.addressFk, warehouseFk: this.ticket.warehouseFk, shipped: this.ticket.shipped, landed: this.ticket.landed, option: this.ticket.option }; this.$http.post(query, data).then(res => { if (res.data) { this.$state.go('ticket.card.summary', {id: this.$state.params.id}); this.card.reload(); } }); } } Controller.$inject = ['$http', '$scope', '$state', '$translate', 'vnApp']; ngModule.component('vnTicketDataStepThree', { template: require('./step-three.html'), controller: Controller, bindings: { ticket: '<' }, require: { card: '^vnTicketCard', data: '^vnTicketData' } });