mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
fix
This commit is contained in:
@@ -2,6 +2,8 @@ import { Injectable } from '@angular/core';
|
||||
import { PublicationFolder } from '../models/publicationfolder';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { Publication } from '../models/publication';
|
||||
import { PublicationsService } from '../services/publications.service';
|
||||
import { PublicationPipe } from 'src/app/pipes/publication.pipe';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -14,9 +16,15 @@ export class PublicationFolderService {
|
||||
restoreFolder: {} = {}
|
||||
|
||||
keyName: string
|
||||
|
||||
showLoader = true
|
||||
publicationPipe = new PublicationPipe()
|
||||
getpublication = [];
|
||||
|
||||
|
||||
constructor(
|
||||
private storage: Storage,
|
||||
private publications: PublicationsService,
|
||||
) {}
|
||||
|
||||
|
||||
@@ -31,6 +39,7 @@ export class PublicationFolderService {
|
||||
|
||||
getFromDB(folderId: any) {
|
||||
|
||||
|
||||
if(!this.restoreFolder[folderId]) {
|
||||
|
||||
this.storage.get(folderId).then((viewPublications) => {
|
||||
@@ -69,11 +78,8 @@ export class PublicationFolderService {
|
||||
const findIndex = this.publicationFindIndex(publicationId, folderId)
|
||||
const found = this.publicationIsPresent(publicationId, folderId)
|
||||
if(!found) {
|
||||
console.log('push',folderId, Publication)
|
||||
this.publicationList[folderId].push(Publication)
|
||||
} else {
|
||||
|
||||
console.log('update',folderId, Publication)
|
||||
this.publicationList[folderId][findIndex] = Publication
|
||||
}
|
||||
}
|
||||
@@ -88,6 +94,108 @@ export class PublicationFolderService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getPublicationDetail(folderId) {
|
||||
|
||||
this.publications.GetPresidentialAction(folderId).subscribe(res => {
|
||||
this.FolderDetails[folderId] = res
|
||||
this.storage.set(folderId+"name", res)
|
||||
}, (error) => {
|
||||
this.showLoader = false;
|
||||
// this.httpErroHandle.httpStatusHandle(error)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async getPublicationsIds(folderId) {
|
||||
|
||||
this.showLoader = true;
|
||||
|
||||
try {
|
||||
const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise();
|
||||
|
||||
this.createPublicationList(folderId)
|
||||
let loadLater = []
|
||||
for (let publicationId of publicationIds) {
|
||||
|
||||
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;
|
||||
|
||||
this.storage.set(folderId, this.publicationList[folderId]);
|
||||
this.getpublication = this.publicationList[folderId];
|
||||
} catch(error) {
|
||||
this.showLoader = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
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 setPublication(publicationId, folderId, publicationDetails: 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 getPublication(publicationId, folderId, publicationDetails: Publication) {
|
||||
|
||||
|
||||
const findIndex = this.publicationFindIndex(publicationId, folderId)
|
||||
const found = this.publicationIsPresent(publicationId, folderId)
|
||||
if(!found) {
|
||||
this.publicationList[folderId].push(publicationDetails)
|
||||
} else {
|
||||
return this.publicationList[folderId][findIndex]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
getLocalPublication (folderId, publicationId) {
|
||||
|
||||
if(this.publicationList[folderId]) {
|
||||
|
||||
this.publicationList[folderId].filter( e=> e.ProcessId == publicationId || e.DocumentId == publicationId);
|
||||
|
||||
return this.publicationList[folderId].filter( e => e.ProcessId == publicationId || e.DocumentId == publicationId)?.[0]
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user