import { DocumentIsogd } from "isogd-document-rest"; class DocumentRequisitesEditController { private document: DocumentIsogd; private chapters: any[]; private selectedChapter: any; private documentTypes: any[]; private selectedDocumentTypes: any[]; private selectedDocumentType: any; private documentOrgs: any[]; private selectedDocumentOrg: any; private documentStatuses: any[]; private selectedDocumentStatus: any; private selectedDocumentOrgs: any[]; private notFoundDocStatuses: string[]; private documentTypeChanged: (params: any) => void; $onInit() { this.selectedDocumentOrgs = this.documentOrgs; if (this.selectedDocumentType) this.onDocumentTypeChange(); } onChapterChange() { this.document.reestr = this.selectedChapter.code; if (this.selectedChapter && this.selectedChapter.doc && this.selectedChapter.doc.length > 0) { this.selectedDocumentTypes = this.selectedChapter.doc; } else { this.selectedDocumentTypes = this.documentTypes; } this.selectedDocumentType = undefined; this.selectedDocumentOrgs = this.documentOrgs; } onDocumentTypeChange() { this.document.documentType = this.selectedDocumentType.docCode; this.document.documentTypeValue = this.selectedDocumentType.docName; this.selectedDocumentOrgs = []; this.documentOrgs.forEach(i => { if (this.selectedDocumentType.org && ~this.selectedDocumentType.org.indexOf(i.orgCode)) this.selectedDocumentOrgs.push(i); }); this.documentTypeChanged({ type: this.selectedDocumentType }); } isChangeQueue() { let registrationStatus = this.document.registration ? this.document.registration.registrationStatus : null; return registrationStatus === 'CHANGE_QUEUE'; } changeDocumentOrganization() { this.document.documentRequisites.documentOrganizationCode = undefined; this.selectedDocumentOrg = undefined } onDocumentOrgChange() { this.document.documentRequisites.documentOrganization = this.selectedDocumentOrg ? this.selectedDocumentOrg.shortName : null; this.document.documentRequisites.documentOrganizationCode = this.selectedDocumentOrg ? this.selectedDocumentOrg.orgCode : null; } onDocumentStatusChange() { this.document.documentRequisites.documentStatusCode = this.selectedDocumentStatus.statusCode; this.document.documentRequisites.documentStatusValue = this.selectedDocumentStatus.statusName; this.document.documentRequisites.documentStatusColor = this.selectedDocumentStatus.statusColor[0]; } } export const DocumentRequisitesEditComponent: angular.IComponentOptions = { controller: DocumentRequisitesEditController, template: require('./documentRequisitesEdit.html'), bindings: { document: "<", chapters: "<", selectedChapter: "<", documentTypes: "<", selectedDocumentType: "<", selectedDocumentTypes: "<", documentOrgs: "<", selectedDocumentOrg: "<", documentStatuses: "<", selectedDocumentStatus: "<", notFoundDocStatuses: "<", documentTypeChanged: "&" } };