update actions

This commit is contained in:
Peter Maquiran
2023-03-10 14:30:50 +01:00
parent e11a66d9c2
commit 5b06064203
3 changed files with 105 additions and 46 deletions
@@ -52,16 +52,12 @@ export class ViewPublicationsPage implements OnInit {
private httpErroHandle: HttpErrorHandle, private httpErroHandle: HttpErrorHandle,
private storage: Storage,) { private storage: Storage,) {
if(!this.publicationList[this.folderId]) { this.createPublicationList()
this.publicationList[this.folderId] = []
this.publicationItem[this.folderId] = new PublicationFolder();
}
this.getFromDB(); this.getFromDB();
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
if (params["params"]) { if (params["params"]) {
this.folderId = params["params"].folderId; this.folderId = params["params"].folderId;
// //
@@ -76,12 +72,8 @@ export class ViewPublicationsPage implements OnInit {
if (typeof (this.folderId) == 'object') { if (typeof (this.folderId) == 'object') {
this.folderId = this.folderId['ProcessId'] this.folderId = this.folderId['ProcessId']
} }
if(!this.publicationList[this.folderId]) { this.createPublicationList()
this.publicationList[this.folderId] = []
this.publicationItem[this.folderId] = new PublicationFolder();
}
this.getFromDB(); this.getFromDB();
//this.testForkJoin() //this.testForkJoin()
@@ -96,7 +88,6 @@ export class ViewPublicationsPage implements OnInit {
//this.testForkJoin() //this.testForkJoin()
}) })
} }
ngOnChanges() { ngOnChanges() {
@@ -105,14 +96,21 @@ export class ViewPublicationsPage implements OnInit {
this.folderId = this.folderId['ProcessId'] this.folderId = this.folderId['ProcessId']
} }
if(!this.publicationList[this.folderId]) { this.createPublicationList()
this.publicationList[this.folderId] = []
this.publicationItem[this.folderId] = new PublicationFolder();
}
this.getFromDB(); this.getFromDB();
} }
createPublicationList(folderId = this.folderId) {
if(!this.publicationList[folderId]) {
this.publicationList[folderId] = []
}
if(!this.publicationItem[folderId]) {
this.publicationItem[folderId] = new PublicationFolder();
}
}
doRefresh = (event) => { doRefresh = (event) => {
//setTimeout(() => { //setTimeout(() => {
//this.testForkJoin() //this.testForkJoin()
@@ -164,18 +162,22 @@ export class ViewPublicationsPage implements OnInit {
try { try {
const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise(); const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise();
this.createPublicationList(folderId)
let loadLater = []
for (let publicationId of publicationIds) { 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) { if(!this.publicationIsPresent(publicationId, folderId)) {
PublicationModel.create(publicationDetails) await this.loadPublication(publicationId, folderId)
this.publicationList[folderId].push(publicationDetails)
} else {
loadLater.push(publicationId)
} }
} }
for( let publicationId of loadLater) {
await this.loadPublication(publicationId, folderId)
}
this.showLoader = false; 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) { async AddPublication(publicationType: any, folderId: any) {
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: NewPublicationPage, component: NewPublicationPage,
@@ -48,10 +48,7 @@ export class ViewPublicationsPage implements OnInit {
public p:PermissionService, public p:PermissionService,
private httpErrorHandle: HttpErrorHandle private httpErrorHandle: HttpErrorHandle
) { ) {
if(!this.publicationList[this.folderId]) { this.createPublicationList()
this.publicationList[this.folderId] = []
this.publicationItem[this.folderId] = new PublicationFolder();
}
} }
ngOnInit() { ngOnInit() {
@@ -59,10 +56,7 @@ export class ViewPublicationsPage implements OnInit {
this.folderId = this.folderId['ProcessId'] this.folderId = this.folderId['ProcessId']
} }
if(!this.publicationList[this.folderId]) { this.createPublicationList()
this.publicationList[this.folderId] = []
this.publicationItem[this.folderId] = new PublicationFolder();
}
window['app-view-publications-page-doRefresh'] = this.doRefresh window['app-view-publications-page-doRefresh'] = this.doRefresh
@@ -76,10 +70,11 @@ export class ViewPublicationsPage implements OnInit {
} }
if(!this.publicationList[this.folderId]) { if(!this.publicationList[this.folderId]) {
this.publicationList[this.folderId] = []
this.publicationItem[this.folderId] = new PublicationFolder(); this.publicationItem[this.folderId] = new PublicationFolder();
} }
this.createPublicationList()
this.getFromDB(); this.getFromDB();
this.getPublicationDetail(); 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) => { doRefresh =(event) => {
this.getPublicationDetail(); this.getPublicationDetail();
@@ -118,18 +124,22 @@ export class ViewPublicationsPage implements OnInit {
try { try {
const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise(); const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise();
this.createPublicationList(folderId)
let loadLater = []
for (let publicationId of publicationIds) { 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) { if(!this.publicationIsPresent(publicationId, folderId)) {
/* PublicationModel.create(publicationDetails) */ await this.loadPublication(publicationId, folderId)
this.publicationList[folderId].push(publicationDetails)
} else {
loadLater.push(publicationId)
} }
} }
for( let publicationId of loadLater) {
await this.loadPublication(publicationId, folderId)
}
this.showLoader = false; this.showLoader = false;
@@ -139,7 +149,30 @@ export class ViewPublicationsPage implements OnInit {
this.showLoader = false; 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() { getFromDB() {
+6 -6
View File
@@ -1,12 +1,12 @@
export let versionData = { export let versionData = {
"shortSHA": "a25b8ba40", "shortSHA": "e11a66d9c",
"SHA": "a25b8ba40f25c50166eebfe285a91d8f00543a5d", "SHA": "e11a66d9c2a6230e4bd16e4e73c3a0f9edf8a6f7",
"branch": "no_bug_movemente", "branch": "no_bug_movemente",
"lastCommitAuthor": "'Peter Maquiran'", "lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Fri Mar 10 11:41:44 2023 +0100'", "lastCommitTime": "'Fri Mar 10 11:47:53 2023 +0100'",
"lastCommitMessage": "fix chat", "lastCommitMessage": "fix merge",
"lastCommitNumber": "4859", "lastCommitNumber": "4865",
"change": "", "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 <file>...\" 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" "changeAuthor": "peter.maquiran"
} }