import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ hoyuFakturApproval : service(), hoyuFakturApprovalData : service(), hoyuFakturApprovalListData : service(), attachmentData : service(), hoyuFakturApprovalAttachmentData : service(), session : service(), errors : service(), didValidate: false, rightActionInProgress: false, attachments: Array(), formConfig : { sourceSystemNo : { isEditable : true }, vehicleId : { isEditable : true }, fakturNo : { isEditable : true }, namaFaktur : { isEditable : true }, tanggalFakturIds : { isEditable : true }, jenisFaktur : { isEditable : true }, status : { isEditable : true }, tanggalFaktur : { isEditable : true }, noFakturIds : { isEditable : true }, namaEkspedisi : { isEditable : true }, noEkspedisi : { isEditable : true }, tanggalEkspedisi : { isEditable : true }, tanggalDo : { isEditable : true }, namaSalesman : { isEditable : true }, statusPrint : { isEditable : true }, statusRevisi : { isEditable : true }, inisiator : { isEditable : true }, revisionApprovalEscalationReason : { isEditable : true }, dibuatOleh : { isEditable : true }, tanggalDibuat : { isEditable : true }, catatan : { isEditable : true }, printProvince : { isEditable : true }, vinNo : { isEditable : true }, noRangka : { isEditable : true }, noMesin : { isEditable : true }, modelGroup : { isEditable : true }, modelVariant : { isEditable : true }, warna : { isEditable : true }, manufacturingCode : { isEditable : true }, kategori : { isEditable : true }, typeKaroseri : { isEditable : true }, karoseri : { isEditable : true }, pelanggaranWilayah : { isEditable : true }, dealerSaatIni : { isEditable : true }, pelanggaranWilayahDealer : { isEditable : true }, jenisBody : { isEditable : true }, namaCustomerPemesan : { isEditable : true }, namaFakturCustomerInformation : { isEditable : true }, namaFakturTercetak : { isEditable : true }, idCustomer : { isEditable : true }, alamatFaktur1 : { isEditable : true }, alamatFaktur2 : { isEditable : true }, alamatFaktur3 : { isEditable : true }, kodePos : { isEditable : true }, provinsi : { isEditable : true }, kotaKabupaten : { isEditable : true }, notes : { isEditable : true }, hoyuFakturApprovalList : { policeFakturApprovalList : { isEditable : true }, policeFakturId : { isEditable : true }, status : { isEditable : true }, approver : { isEditable : true }, approverDate : { isEditable : true }, approverLevel : { isEditable : true }, recordName : { isEditable : true }, currencyCode : { isEditable : true }, hoyuFakturApproval : { isEditable : true }, }, hoyuFakturApprovalAttachment : { attachment : { isEditable : true }, description : { isEditable : true }, hoyuFakturApproval : { isEditable : true }, }, }, init() { this._super(...arguments); var attachments = this.attachmentData.getList(); this.set("attachments", attachments); }, actions: { onChangeCombo(propertyName, itemCollection) { this.set(propertyName, itemCollection); }, async saveHoyuFakturApproval() { this.set("rightActionInProgress", true); this.get('model') .validate() .then(async ({ validations }) => { this.set('didValidate', true); if (validations.get('isValid')) { this.set('hoyuFakturApproval.model.isApprovalData', false); this.hoyuFakturApprovalData.save(this.hoyuFakturApproval.model).then(response => { if (response != undefined) { this.transitionToRoute('hoyu-faktur-approval.detail', response.id); } }) .catch((e) => { this.set("rightActionInProgress", false); this.set('errorMessages', this.errors.getErrorMessages(e)); }); } else { this.set("rightActionInProgress", false); } }); }, addRowData(modal_type) { if (modal_type == "hoyu-faktur-approval-list") { let data = this.hoyuFakturApprovalListData.createRecord(); this.hoyuFakturApproval.addRow(data, "hoyuFakturApprovalList"); } if (modal_type == "hoyu-faktur-approval-attachment") { let data = this.hoyuFakturApprovalAttachmentData.createRecord(); this.hoyuFakturApproval.addRow(data, "hoyuFakturApprovalAttachment"); } }, deleteRowData(modal_type, data) { if (modal_type == "hoyu-faktur-approval-list") { this.hoyuFakturApproval.deleteRow(data, "hoyuFakturApprovalList"); } if (modal_type == "hoyu-faktur-approval-attachment") { this.hoyuFakturApproval.deleteRow(data, "hoyuFakturApprovalAttachment"); } }, }, });