Files
doneit-web/.angular/cache/14.2.12/babel-webpack/ba553d2c76aa78ead38143109040015a.json
T
Eudes Inácio 53b71ea16f its working
2023-06-30 09:54:21 +01:00

1 line
28 KiB
JSON

{"ast":null,"code":"import _asyncToGenerator from \"C:/Users/eudes.inacio/GabineteDigital/gabinete-digital-fo/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { __decorate } from \"tslib\";\nimport __NG_CLI_RESOURCE__0 from \"./view-publications.page.html?ngResource\";\nimport __NG_CLI_RESOURCE__1 from \"./view-publications.page.scss?ngResource\";\nimport { Component, Input, Output, EventEmitter } from '@angular/core';\nimport { ModalController } from '@ionic/angular';\nimport { PublicationFolder } from 'src/app/models/publicationfolder';\nimport { PublicationsService } from 'src/app/services/publications.service';\nimport { NewPublicationPage } from 'src/app/pages/publications/new-publication/new-publication.page';\nimport { PublicationPipe } from 'src/app/pipes/publication.pipe';\nimport { ThemeService } from 'src/app/services/theme.service';\nimport { ToastService } from 'src/app/services/toast.service';\nimport { EditActionPage } from 'src/app/pages/publications/edit-action/edit-action.page';\nimport { Storage } from '@ionic/storage';\nimport { PermissionService } from 'src/app/services/permission.service';\nimport { HttpErrorHandle } from 'src/app/services/http-error-handle.service';\nlet ViewPublicationsPage = class ViewPublicationsPage {\n constructor(modalController, publications, ThemeService, toastService, storage, p, httpErrorHandle) {\n this.modalController = modalController;\n this.publications = publications;\n this.ThemeService = ThemeService;\n this.toastService = toastService;\n this.storage = storage;\n this.p = p;\n this.httpErrorHandle = httpErrorHandle;\n this.publicationList = {};\n this.publicationItem = {};\n this.getpublication = [];\n this.addNewPublication = new EventEmitter();\n this.editPublication = new EventEmitter();\n this.openPublicationDetails = new EventEmitter();\n this.goBackToViewPublications = new EventEmitter();\n this.closeDesktopComponent = new EventEmitter();\n this.goBacktoPublicationDetails = new EventEmitter();\n this.getActions = new EventEmitter();\n this.publicationPipe = new PublicationPipe();\n this.doRefresh = event => {\n this.getPublicationDetail();\n this.getPublicationsIds();\n };\n this.createPublicationList();\n }\n ngOnInit() {\n if (typeof this.folderId == 'object') {\n this.folderId = this.folderId['ProcessId'];\n }\n this.createPublicationList();\n window['app-view-publications-page-doRefresh'] = this.doRefresh;\n this.getFromDB();\n }\n ngOnChanges(changes) {\n if (typeof this.folderId == 'object') {\n this.folderId = this.folderId['ProcessId'];\n }\n if (!this.publicationList[this.folderId]) {\n this.publicationItem[this.folderId] = new PublicationFolder();\n }\n this.createPublicationList();\n this.getFromDB();\n this.getPublicationDetail();\n this.getPublicationsIds();\n }\n createPublicationList(folderId = this.folderId) {\n if (!this.publicationList[this.folderId]) {\n this.publicationList[this.folderId] = [];\n }\n if (!this.publicationItem[this.folderId]) {\n this.publicationItem[this.folderId] = new PublicationFolder();\n }\n }\n close() {\n this.closeDesktopComponent.emit();\n }\n getPublicationDetail() {\n const folderId = this.folderId;\n this.publications.GetPresidentialAction(folderId).subscribe(res => {\n this.publicationItem[folderId] = res;\n this.storage.set(folderId + \"name\", res);\n }, error => {\n this.showLoader = false;\n // this.httpErroHandle.httpStatusHandle(error)\n });\n }\n\n getPublicationsIds() {\n var _this = this;\n return _asyncToGenerator(function* () {\n _this.showLoader = true;\n const folderId = _this.folderId;\n try {\n const publicationIds = yield _this.publications.GetPublicationsList(folderId).toPromise();\n _this.createPublicationList(folderId);\n let loadLater = [];\n for (let publicationId of publicationIds) {\n if (!_this.publicationIsPresent(publicationId, folderId)) {\n yield _this.loadPublication(publicationId, folderId);\n } else {\n loadLater.push(publicationId);\n }\n }\n for (let publicationId of loadLater) {\n yield _this.loadPublication(publicationId, folderId);\n }\n _this.showLoader = false;\n _this.storage.set(folderId, _this.publicationList[folderId]);\n _this.getpublication = _this.publicationList[folderId];\n } catch (error) {\n _this.showLoader = false;\n }\n })();\n }\n publicationIsPresent(publicationId, folderId) {\n return this.publicationList[folderId].find(e => e.DocumentId == publicationId);\n }\n publicationFind(publicationId, folderId) {\n return this.publicationList[folderId].find(e => e.DocumentId == publicationId);\n }\n publicationFindIndex(publicationId, folderId) {\n return this.publicationList[folderId].findIndex(e => e.DocumentId == publicationId);\n }\n loadPublication(publicationId, folderId) {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n let Publication = yield _this2.publications.GetPublicationById(publicationId).toPromise();\n let publicationDetails = _this2.publicationPipe.itemList(Publication);\n const findIndex = _this2.publicationFindIndex(publicationId, folderId);\n const found = _this2.publicationIsPresent(publicationId, folderId);\n if (!found) {\n _this2.publicationList[folderId].push(publicationDetails);\n // PublicationModel.create(publicationDetails)\n } else {\n _this2.publicationList[folderId][findIndex] = publicationDetails;\n }\n })();\n }\n getFromDB() {\n const folderId = this.folderId;\n this.storage.get(folderId).then(viewPublications => {\n this.publicationList[folderId] = viewPublications;\n });\n this.storage.get(folderId + \"name\").then(viewPublications => {\n this.publicationItem[folderId] = viewPublications;\n });\n }\n // getPublications() {\n // this.showLoader = true;\n // const folderId = this.folderId\n // this.publicationList = new Array();\n // this.publications.GetPublications(folderId).subscribe(async res=> {\n // res.forEach(element => {\n // let item: Publication = this.publicationPipe.itemList(element)\n // this.publicationList.push(item);\n // });\n // this.showLoader = false;\n // await this.storage.remove(folderId);\n // await this.storage.set(folderId, this.publicationList);\n // //this.getFromDB();\n // },\n // (error)=>{\n // if(error.status == '404') {\n // this.error = 'Sem publicações disponíveis!';\n // this.publicationList= [];\n // }\n // this.showLoader = false;\n // })\n // }\n AddPublication(publicationType, folderId) {\n var _this3 = this;\n return _asyncToGenerator(function* () {\n if (window.innerWidth < 701) {\n const modal = yield _this3.modalController.create({\n component: NewPublicationPage,\n componentProps: {\n publicationType: publicationType,\n folderId: folderId\n },\n cssClass: 'new-publication modal modal-desktop',\n backdropDismiss: false\n });\n yield modal.present();\n modal.onDidDismiss().then(() => {\n _this3.doRefresh(event);\n });\n } else {\n _this3.addNewPublication.emit({\n publicationType: publicationType,\n folderId: folderId\n });\n }\n })();\n }\n openEditPublication(folderId) {\n var _this4 = this;\n return _asyncToGenerator(function* () {\n if (window.innerWidth < 701) {\n const modal = yield _this4.modalController.create({\n component: EditActionPage,\n componentProps: {\n folderId: folderId\n },\n cssClass: 'new-action modal modal-desktop',\n backdropDismiss: true\n });\n yield modal.present();\n modal.onDidDismiss().then(() => {\n // Do nothing\n });\n } else {\n _this4.editPublication.emit(folderId);\n }\n })();\n }\n deletePublication(folderId) {\n var _this5 = this;\n return _asyncToGenerator(function* () {\n const loader = _this5.toastService.loading();\n try {\n yield _this5.publications.DeletePresidentialAction(folderId).toPromise();\n _this5.httpErrorHandle.httpsSucessMessagge('Eliminar Acção');\n } catch (error) {\n _this5.httpErrorHandle.httpStatusHandle(error);\n } finally {\n loader.remove();\n }\n _this5.close();\n _this5.getActions.emit();\n })();\n }\n viewPublicationDetail(publicationId) {\n var _this6 = this;\n return _asyncToGenerator(function* () {\n // if( window.innerWidth <= 1024) {\n // const modal = await this.modalController.create({\n // component: PublicationDetailPage,\n // componentProps:{\n // publicationId: publicationId,\n // },\n // cssClass: 'publication-detail modal modal-desktop',\n // //backdropDismiss: false\n // });\n // await modal.present();\n // modal.onDidDismiss().then(()=>{\n // this.doRefresh(event);\n // });\n // } else {\n // // open publication details\n // this.openPublicationDetails.emit(publicationId);\n // }\n _this6.openPublicationDetails.emit(publicationId);\n })();\n }\n};\nViewPublicationsPage.ctorParameters = () => [{\n type: ModalController\n}, {\n type: PublicationsService\n}, {\n type: ThemeService\n}, {\n type: ToastService\n}, {\n type: Storage\n}, {\n type: PermissionService\n}, {\n type: HttpErrorHandle\n}];\nViewPublicationsPage.propDecorators = {\n folderId: [{\n type: Input\n }],\n addNewPublication: [{\n type: Output\n }],\n editPublication: [{\n type: Output\n }],\n openPublicationDetails: [{\n type: Output\n }],\n goBackToViewPublications: [{\n type: Output\n }],\n closeDesktopComponent: [{\n type: Output\n }],\n goBacktoPublicationDetails: [{\n type: Output\n }],\n getActions: [{\n type: Output\n }]\n};\nViewPublicationsPage = __decorate([Component({\n selector: 'app-view-publications',\n template: __NG_CLI_RESOURCE__0,\n styles: [__NG_CLI_R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sB,CAAC5D,IAAI,CAACY,aAAa,CAAC;IAAC;EAElD;;;;;;;;;;;;;;;;;;;UA7QCjD;EAAK;;UACLC;EAAM;;UACNA;EAAM;;UACNA;EAAM;;UACNA;EAAM;;UACNA;EAAM;;UACNA;EAAM;;UACNA;EAAM;;AAhBIa,oBAAoB,eALhCf,SAAS,CAAC;EACTmG,QAAQ,EAAE,uBAAuB;EACjCC,8BAA4C;;CAE7C,CAAC,GACWrF,oBAAoB;SAApBA,oBAAoB","names":["Component","Input","Output","EventEmitter","ModalController","PublicationFolder","PublicationsService","NewPublicationPage","PublicationPipe","ThemeService","ToastService","EditActionPage","Storage","PermissionService","HttpErrorHandle","ViewPublicationsPage","constructor","modalController","publications","toastService","storage","p","httpErrorHandle","event","getPublicationDetail","getPublicationsIds","createPublicationList","ngOnInit","folderId","window","doRefresh","getFromDB","ngOnChanges","changes","publicationList","publicationItem","close","closeDesktopComponent","emit","GetPresidentialAction","subscribe","res","set","error","showLoader","_this","publicationIds","GetPublicationsList","toPromise","loadLater","publicationId","publicationIsPresent","loadPublication","push","getpublication","find","e","DocumentId","publicationFind","publicationFindIndex","findIndex","Publication","_this2","GetPublicationById","publicationDetails","publicationPipe","itemList","found","get","then","viewPublications","AddPublication","publicationType","innerWidth","modal","_this3","create","component","componentProps","cssClass","backdropDismiss","present","onDidDismiss","addNewPublication","openEditPublication","_this4","editPublication","deletePublication","loader","_this5","loading","DeletePresidentialAction","httpsSucessMessagge","httpStatusHandle","remove","getActions","viewPublicationDetail","_this6","openPublicationDetails","selector","template"],"sourceRoot":"","sources":["C:\\Users\\eudes.inacio\\GabineteDigital\\gabinete-digital-fo\\src\\app\\shared\\publication\\view-publications\\view-publications.page.ts"],"sourcesContent":["import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';\r\nimport { ModalController } from '@ionic/angular';\r\nimport { Publication } from 'src/app/models/publication';\r\nimport { PublicationFolder } from 'src/app/models/publicationfolder';\r\nimport { PublicationsService } from 'src/app/services/publications.service';\r\n\r\nimport { NewPublicationPage } from 'src/app/pages/publications/new-publication/new-publication.page';\r\nimport { PublicationPipe } from 'src/app/pipes/publication.pipe';\r\nimport { ThemeService } from 'src/app/services/theme.service'\r\nimport { ToastService } from 'src/app/services/toast.service';\r\nimport { EditActionPage } from 'src/app/pages/publications/edit-action/edit-action.page';\r\nimport { Storage } from '@ionic/storage';\r\nimport { PermissionService } from 'src/app/services/permission.service';\r\nimport { HttpErrorHandle } from 'src/app/services/http-error-handle.service';\r\nimport { PublicationModel } from 'src/app/models/beast-orm';\r\n\r\n@Component({\r\n selector: 'app-view-publications',\r\n templateUrl: './view-publications.page.html',\r\n styleUrls: ['./view-publications.page.scss'],\r\n})\r\nexport class ViewPublicationsPage implements OnInit {\r\n showLoader: boolean;\r\n loading: any;\r\n\r\n publicationList: {[key: string]: Publication[] } = {};\r\n publicationItem: {[key: string]: PublicationFolder } = {};\r\n getpublication = [];\r\n error: any;\r\n\r\n @Input() folderId: any;\r\n @Output() addNewPublication = new EventEmitter<any>();\r\n @Output() editPublication = new EventEmitter<any>();\r\n @Output() openPublicationDetails= new EventEmitter<any>();\r\n @Output() goBackToViewPublications = new EventEmitter();\r\n @Output() closeDesktopComponent = new EventEmitter<any>();\r\n @Output() goBacktoPublicationDetails = new EventEmitter<any>();\r\n @Output() getActions= new EventEmitter<any>();\r\n\r\n publicationPipe = new PublicationPipe()\r\n\r\n constructor(\r\n private modalController: ModalController,\r\n private publications: PublicationsService,\r\n public ThemeService: ThemeService,\r\n private toastService: ToastService,\r\n private storage: Storage,\r\n public p:PermissionService,\r\n private httpErrorHandle: HttpErrorHandle\r\n ) {\r\n this.createPublicationList()\r\n }\r\n\r\n ngOnInit() {\r\n if(typeof(this.folderId) == 'object') {\r\n this.folderId = this.folderId['ProcessId']\r\n }\r\n\r\n this.createPublicationList()\r\n\r\n window['app-view-publications-page-doRefresh'] = this.doRefresh\r\n\r\n this.getFromDB();\r\n }\r\n\r\n ngOnChanges(changes: any): void {\r\n\r\n if(typeof(this.folderId) == 'object') {\r\n this.folderId = this.folderId['ProcessId']\r\n }\r\n\r\n if(!this.publicationList[this.folderId]) {\r\n this.publicationItem[this.folderId] = new PublicationFolder();\r\n }\r\n\r\n this.createPublicationList()\r\n\r\n this.getFromDB();\r\n\r\n this.getPublicationDetail();\r\n this.getPublicationsIds();\r\n\r\n\r\n }\r\n\r\n\r\n createPublicationList(folderId = this.folderId) {\r\n if(!this.publicationList[this.folderId]) {\r\n this.publicationList[this.folderId] = []\r\n }\r\n if(!this.publicationItem[this.folderId]) {\r\n this.publicationItem[this.folderId] = new PublicationFolder();\r\n }\r\n\r\n }\r\n\r\n doRefresh =(event) => {\r\n\r\n this.getPublicationDetail();\r\n this.getPublicationsIds();\r\n }\r\n\r\n close() {\r\n this.closeDesktopComponent.emit();\r\n }\r\n\r\n getPublicationDetail() {\r\n const folderId = this.folderId\r\n this.publications.GetPresidentialAction(folderId).subscribe(res=>{\r\n this.publicationItem[folderId] = res\r\n this.storage.set(folderId+\"name\", res)\r\n }, (error) => {\r\n this.showLoader = false;\r\n // this.httpErroHandle.httpStatusHandle(error)\r\n });\r\n }\r\n\r\n async getPublicationsIds() {\r\n\r\n this.showLoader = true;\r\n const folderId = this.folderId\r\n\r\n try {\r\n const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise();\r\n \r\n this.createPublicationList(folderId)\r\n let loadLater = []\r\n for (let publicationId of publicationIds) {\r\n\r\n if(!this.publicationIsPresent(publicationId, folderId)) {\r\n await this.loadPublication(publicationId, folderId)\r\n\r\n } else {\r\n loadLater.push(publicationId)\r\n }\r\n }\r\n\r\n for( let publicationId of loadLater) {\r\n await this.loadPublication(publicationId, folderId)\r\n }\r\n \r\n this.showLoader = false;\r\n \r\n this.storage.set(folderId, this.publicationList[folderId]);\r\n this.getpublication = this.publicationList[folderId];\r\n } catch(error) {\r\n this.showLoader = false;\r\n }\r\n\r\n }\r\n\r\n publicationIsPresent(publicationId, folderId) {\r\n return this.publicationList[folderId].find( e => e.DocumentId == publicationId )\r\n }\r\n publicationFind(publicationId, folderId) {\r\n return this.publicationList[folderId].find( e => e.DocumentId == publicationId )\r\n }\r\n publicationFindIndex(publicationId, folderId) {\r\n return this.publicationList[folderId].findIndex( e => e.DocumentId == publicationId )\r\n }\r\n\r\n async loadPublication(publicationId, folderId) {\r\n let Publication = await this.publications.GetPublicationById(publicationId).toPromise();\r\n let publicationDetails: Publication = this.publicationPipe.itemList(Publication)\r\n \r\n const findIndex = this.publicationFindIndex(publicationId, folderId)\r\n const found = this.publicationIsPresent(publicationId, folderId)\r\n if(!found) {\r\n this.publicationList[folderId].push(publicationDetails)\r\n // PublicationModel.create(publicationDetails)\r\n } else {\r\n this.publicationList[folderId][findIndex] = publicationDetails\r\n }\r\n \r\n }\r\n\r\n getFromDB() {\r\n const folderId = this.folderId\r\n this.storage.get(folderId).then((viewPublications) => {\r\n this.publicationList[folderId] = viewPublications\r\n })\r\n this.storage.get(folderId+\"name\").then((viewPublications) => {\r\n this.publicationItem[folderId] = viewPublications\r\n })\r\n }\r\n\r\n // getPublications() {\r\n // this.showLoader = true;\r\n // const folderId = this.folderId\r\n // this.publicationList = new Array();\r\n // this.publications.GetPublications(folderId).subscribe(async res=> {\r\n\r\n // res.forEach(element => {\r\n // let item: Publication = this.publicationPipe.itemList(element)\r\n // this.publicationList.push(item);\r\n // });\r\n\r\n // this.showLoader = false;\r\n // await this.storage.remove(folderId);\r\n // await this.storage.set(folderId, this.publicationList);\r\n // //this.getFromDB();\r\n \r\n // },\r\n // (error)=>{\r\n // if(error.status == '404') {\r\n // this.error = 'Sem publicações disponíveis!';\r\n // this.publicationList= [];\r\n // }\r\n\r\n // this.showLoader = false;\r\n\r\n // })\r\n\r\n // }\r\n\r\n async AddPublication(publicationType:any, folderId:any) {\r\n\r\n if( window.innerWidth < 701) {\r\n const modal = await this.modalController.create({\r\n component: NewPublicationPage,\r\n componentProps:{\r\n publicationType: publicationType,\r\n folderId: folderId,\r\n },\r\n cssClass: 'new-publication modal modal-desktop',\r\n backdropDismiss: false\r\n });\r\n await modal.present();\r\n modal.onDidDismiss().then(()=>{\r\n this.doRefresh(event);\r\n });\r\n } else {\r\n this.addNewPublication.emit({\r\n publicationType: publicationType,\r\n folderId: folderId\r\n })\r\n }\r\n\r\n }\r\n\r\n async openEditPublication(folderId?:any){\r\n\r\n if( window.innerWidth < 701) {\r\n const modal = await this.modalController.create({\r\n component: EditActionPage,\r\n componentProps: {\r\n folderId: folderId,\r\n },\r\n cssClass: 'new-action modal modal-desktop',\r\n backdropDismiss: true\r\n });\r\n await modal.present();\r\n modal.onDidDismiss().then(() => {\r\n // Do nothing\r\n });\r\n }\r\n else {\r\n this.editPublication.emit(folderId);\r\n }\r\n }\r\n\r\n async deletePublication(folderId?:any) {\r\n const loader = this.toastService.loading();\r\n try {\r\n await this.publications.DeletePresidentialAction(folderId).toPromise();\r\n this.httpErrorHandle.httpsSucessMessagge('Eliminar Acção')\r\n } catch (error) {\r\n this.httpErrorHandle.httpStatusHandle(error)\r\n }\r\n finally {\r\n loader.remove()\r\n }\r\n this.close();\r\n this.getActions.emit();\r\n }\r\n\r\n async viewPublicationDetail(publicationId:string) {\r\n\r\n\r\n // if( window.innerWidth <= 1024) {\r\n // const modal = await this.modalController.create({\r\n // component: PublicationDetailPage,\r\n // componentProps:{\r\n // publicationId: publicationId,\r\n // },\r\n // cssClass: 'publication-detail modal modal-desktop',\r\n // //backdropDismiss: false\r\n // });\r\n // await modal.present();\r\n // modal.onDidDismiss().then(()=>{\r\n // this.doRefresh(event);\r\n // });\r\n // } else {\r\n // // open publication details\r\n // this.openPublicationDetails.emit(publicationId);\r\n // }\r\n\r\n this.openPublicationDetails.emit(publicationId);\r\n\r\n }\r\n\r\n}\r\n"]},"metadata":{},"sourceType":"module"}