mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
update actions
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user