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; this.ticket.hasToBeUnrouted = true; } onStepChange(state) { return true; } onSubmit() { if (!this.ticket.option) { return this.vnApp.showError( this.$translate.instant('Choose an option') ); } let query = `/api/tickets/${this.ticket.id}/componentUpdate`; let params = { clientId: this.ticket.clientFk, agencyModeId: this.ticket.agencyModeFk, addressId: this.ticket.addressFk, zoneId: this.ticket.zoneFk, warehouseId: this.ticket.warehouseFk, companyId: this.ticket.companyFk, shipped: this.ticket.shipped, landed: this.ticket.landed, isDeleted: this.ticket.isDeleted, hasToBeUnrouted: this.ticket.hasToBeUnrouted, option: this.ticket.option }; this.$http.post(query, params).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('vnTicketBasicDataStepThree', { template: require('./index.html'), controller: Controller, bindings: { ticket: '<' }, require: { card: '^vnTicketCard', data: '^vnTicketBasicData' } });