From 5b060642036e92e97d14f9926b9e49e29257fd43 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Fri, 10 Mar 2023 14:30:50 +0100 Subject: [PATCH] update actions --- .../view-publications.page.ts | 72 +++++++++++++------ .../view-publications.page.ts | 67 ++++++++++++----- version/git-version.ts | 12 ++-- 3 files changed, 105 insertions(+), 46 deletions(-) diff --git a/src/app/pages/publications/view-publications/view-publications.page.ts b/src/app/pages/publications/view-publications/view-publications.page.ts index 75971806c..7c5715daf 100644 --- a/src/app/pages/publications/view-publications/view-publications.page.ts +++ b/src/app/pages/publications/view-publications/view-publications.page.ts @@ -52,16 +52,12 @@ export class ViewPublicationsPage implements OnInit { private httpErroHandle: HttpErrorHandle, private storage: Storage,) { - if(!this.publicationList[this.folderId]) { - this.publicationList[this.folderId] = [] - this.publicationItem[this.folderId] = new PublicationFolder(); - } + this.createPublicationList() this.getFromDB(); this.activatedRoute.paramMap.subscribe(params => { - if (params["params"]) { this.folderId = params["params"].folderId; // @@ -76,12 +72,8 @@ export class ViewPublicationsPage implements OnInit { if (typeof (this.folderId) == 'object') { this.folderId = this.folderId['ProcessId'] } - - if(!this.publicationList[this.folderId]) { - this.publicationList[this.folderId] = [] - this.publicationItem[this.folderId] = new PublicationFolder(); - } + this.createPublicationList() this.getFromDB(); //this.testForkJoin() @@ -96,7 +88,6 @@ export class ViewPublicationsPage implements OnInit { //this.testForkJoin() }) - } ngOnChanges() { @@ -105,14 +96,21 @@ export class ViewPublicationsPage implements OnInit { this.folderId = this.folderId['ProcessId'] } - if(!this.publicationList[this.folderId]) { - this.publicationList[this.folderId] = [] - this.publicationItem[this.folderId] = new PublicationFolder(); - } + this.createPublicationList() this.getFromDB(); } + + createPublicationList(folderId = this.folderId) { + if(!this.publicationList[folderId]) { + this.publicationList[folderId] = [] + } + if(!this.publicationItem[folderId]) { + this.publicationItem[folderId] = new PublicationFolder(); + } + } + doRefresh = (event) => { //setTimeout(() => { //this.testForkJoin() @@ -164,18 +162,22 @@ export class ViewPublicationsPage implements OnInit { try { const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise(); - + + this.createPublicationList(folderId) + let loadLater = [] for (let publicationId of publicationIds) { - let Publication = await this.publications.GetPublicationById(publicationId).toPromise(); - let publicationDetails: Publication = this.publicationPipe.itemList(Publication) - - const found = this.publicationList[folderId].find( e => e.DocumentId == publicationId ) - if(!found) { - PublicationModel.create(publicationDetails) - this.publicationList[folderId].push(publicationDetails) + if(!this.publicationIsPresent(publicationId, folderId)) { + await this.loadPublication(publicationId, folderId) + + } else { + loadLater.push(publicationId) } } + + for( let publicationId of loadLater) { + await this.loadPublication(publicationId, folderId) + } this.showLoader = false; @@ -187,6 +189,30 @@ export class ViewPublicationsPage implements OnInit { } + publicationIsPresent(publicationId, folderId) { + return this.publicationList[folderId].find( e => e.DocumentId == publicationId ) + } + publicationFind(publicationId, folderId) { + return this.publicationList[folderId].find( e => e.DocumentId == publicationId ) + } + publicationFindIndex(publicationId, folderId) { + return this.publicationList[folderId].findIndex( e => e.DocumentId == publicationId ) + } + + async loadPublication(publicationId, folderId) { + let Publication = await this.publications.GetPublicationById(publicationId).toPromise(); + let publicationDetails: Publication = this.publicationPipe.itemList(Publication) + + const findIndex = this.publicationFindIndex(publicationId, folderId) + const found = this.publicationIsPresent(publicationId, folderId) + if(!found) { + this.publicationList[folderId].push(publicationDetails) + } else { + this.publicationList[folderId][findIndex] = publicationDetails + } + + } + async AddPublication(publicationType: any, folderId: any) { const modal = await this.modalController.create({ component: NewPublicationPage, diff --git a/src/app/shared/publication/view-publications/view-publications.page.ts b/src/app/shared/publication/view-publications/view-publications.page.ts index a26b3936d..e5579fb3a 100644 --- a/src/app/shared/publication/view-publications/view-publications.page.ts +++ b/src/app/shared/publication/view-publications/view-publications.page.ts @@ -48,10 +48,7 @@ export class ViewPublicationsPage implements OnInit { public p:PermissionService, private httpErrorHandle: HttpErrorHandle ) { - if(!this.publicationList[this.folderId]) { - this.publicationList[this.folderId] = [] - this.publicationItem[this.folderId] = new PublicationFolder(); - } + this.createPublicationList() } ngOnInit() { @@ -59,10 +56,7 @@ export class ViewPublicationsPage implements OnInit { this.folderId = this.folderId['ProcessId'] } - if(!this.publicationList[this.folderId]) { - this.publicationList[this.folderId] = [] - this.publicationItem[this.folderId] = new PublicationFolder(); - } + this.createPublicationList() window['app-view-publications-page-doRefresh'] = this.doRefresh @@ -76,10 +70,11 @@ export class ViewPublicationsPage implements OnInit { } if(!this.publicationList[this.folderId]) { - this.publicationList[this.folderId] = [] this.publicationItem[this.folderId] = new PublicationFolder(); } + this.createPublicationList() + this.getFromDB(); this.getPublicationDetail(); @@ -88,6 +83,17 @@ export class ViewPublicationsPage implements OnInit { } + + createPublicationList(folderId = this.folderId) { + if(!this.publicationList[this.folderId]) { + this.publicationList[this.folderId] = [] + } + if(!this.publicationItem[this.folderId]) { + this.publicationItem[this.folderId] = new PublicationFolder(); + } + + } + doRefresh =(event) => { this.getPublicationDetail(); @@ -118,18 +124,22 @@ export class ViewPublicationsPage implements OnInit { try { const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise(); - + + this.createPublicationList(folderId) + let loadLater = [] for (let publicationId of publicationIds) { - let Publication = await this.publications.GetPublicationById(publicationId).toPromise(); - let publicationDetails: Publication = this.publicationPipe.itemList(Publication) - - const found = this.publicationList[folderId].find( e => e.DocumentId == publicationId ) - if(!found) { - /* PublicationModel.create(publicationDetails) */ - this.publicationList[folderId].push(publicationDetails) + if(!this.publicationIsPresent(publicationId, folderId)) { + await this.loadPublication(publicationId, folderId) + + } else { + loadLater.push(publicationId) } } + + for( let publicationId of loadLater) { + await this.loadPublication(publicationId, folderId) + } this.showLoader = false; @@ -139,7 +149,30 @@ export class ViewPublicationsPage implements OnInit { this.showLoader = false; } + } + publicationIsPresent(publicationId, folderId) { + return this.publicationList[folderId].find( e => e.DocumentId == publicationId ) + } + publicationFind(publicationId, folderId) { + return this.publicationList[folderId].find( e => e.DocumentId == publicationId ) + } + publicationFindIndex(publicationId, folderId) { + return this.publicationList[folderId].findIndex( e => e.DocumentId == publicationId ) + } + + async loadPublication(publicationId, folderId) { + let Publication = await this.publications.GetPublicationById(publicationId).toPromise(); + let publicationDetails: Publication = this.publicationPipe.itemList(Publication) + + const findIndex = this.publicationFindIndex(publicationId, folderId) + const found = this.publicationIsPresent(publicationId, folderId) + if(!found) { + this.publicationList[folderId].push(publicationDetails) + } else { + this.publicationList[folderId][findIndex] = publicationDetails + } + } getFromDB() { diff --git a/version/git-version.ts b/version/git-version.ts index 7d588a0d2..06f40ae70 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "a25b8ba40", - "SHA": "a25b8ba40f25c50166eebfe285a91d8f00543a5d", + "shortSHA": "e11a66d9c", + "SHA": "e11a66d9c2a6230e4bd16e4e73c3a0f9edf8a6f7", "branch": "no_bug_movemente", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Fri Mar 10 11:41:44 2023 +0100'", - "lastCommitMessage": "fix chat", - "lastCommitNumber": "4859", + "lastCommitTime": "'Fri Mar 10 11:47:53 2023 +0100'", + "lastCommitMessage": "fix merge", + "lastCommitNumber": "4865", "change": "", - "changeStatus": "On branch no_bug_movemente\nAll conflicts fixed but you are still merging.\n (use \"git commit\" to conclude merge)\n\nChanges to be committed:\n\tmodified: src/app/modals/add-note/add-note.page.html\n\tmodified: src/app/models/beast-orm.ts\n\tmodified: src/app/pages/chat/group-messages/group-messages.page.ts\n\tmodified: src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.html\n\tmodified: src/app/pages/gabinete-digital/despachos/despachos.page.html\n\tmodified: src/app/pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.page.html\n\tmodified: src/app/pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.page.ts\n\tmodified: src/app/pages/gabinete-digital/diplomas-assinar/diplomas-assinar.page.html\n\tmodified: src/app/pages/gabinete-digital/diplomas-gerar/diplomas-gerar.page.html\n\tmodified: src/app/pages/gabinete-digital/diplomas-gerar/diplomas-gerar/diplomas-gerar.page.html\n\tmodified: src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.html\n\tmodified: src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts\n\tmodified: src/app/pages/gabinete-digital/expediente/expediente.page.ts\n\tmodified: src/app/pages/gabinete-digital/expedientes-pr/expediente-pr/expediente-pr.page.html\n\tmodified: src/app/pages/gabinete-digital/expedientes-pr/expedientes-pr.page.html\n\tmodified: src/app/pages/gabinete-digital/pedidos/pedidos.page.html\n\tmodified: src/app/pages/gabinete-digital/pendentes/pendentes.page.html\n\tmodified: src/app/pages/login/login.page.ts\n\tmodified: src/app/pages/publications/new-publication/new-publication.page.ts\n\tmodified: src/app/services/auth.service.ts\n\tmodified: src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.html\n\tmodified: src/app/shared/gabinete-digital/expedients/expedients.page.ts\n\tmodified: src/app/shared/popover/chat-popover/chat-popover.page.ts\n\tmodified: src/app/shared/popover/deploma-options/deploma-options.page.html\n\tmodified: src/app/shared/popover/opts-expediente/opts-expediente.page.ts\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.ts\n\tmodified: src/environments/environment.prod.ts\n\tmodified: version/git-version.ts", + "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/pages/publications/view-publications/view-publications.page.ts\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.ts", "changeAuthor": "peter.maquiran" } \ No newline at end of file