mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
fix publication loaders
This commit is contained in:
@@ -75,7 +75,6 @@ export class PublicationsPage implements OnInit {
|
||||
) {
|
||||
this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
|
||||
this.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
|
||||
this.skeletonLoader = true;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -147,14 +146,9 @@ export class PublicationsPage implements OnInit {
|
||||
this.skeletonLoader = true;
|
||||
this.getFromDB()
|
||||
this.publications.GetPublicationFolderList().subscribe(async res => {
|
||||
|
||||
|
||||
|
||||
let publicationsEventFolderList = new Array();
|
||||
let publicationsTravelFolderList = new Array();
|
||||
|
||||
res.forEach(data => {
|
||||
let folder: PublicationFolder = {
|
||||
|
||||
const folders: any = res.map((data): PublicationFolder => {
|
||||
return {
|
||||
ProcessId: data.ProcessId,
|
||||
Description: data.Description,
|
||||
Detail: data.Detail,
|
||||
@@ -162,24 +156,14 @@ export class PublicationsPage implements OnInit {
|
||||
DateEnd: data.DateEnd,
|
||||
ActionType: data.ActionType,
|
||||
}
|
||||
|
||||
this.addActionToDB(folder)
|
||||
|
||||
if (data.ActionType == "Evento") {
|
||||
|
||||
publicationsEventFolderList.push(folder);
|
||||
}
|
||||
else {
|
||||
|
||||
publicationsTravelFolderList.push(folder);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
this.publicationsEventFolderList = folders.filter((e)=>e.ActionType == 'Evento')
|
||||
this.publicationsTravelFolderList = folders.filter((e)=>e.ActionType != 'Evento')
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
await this.storage.set('actionsEvents', publicationsEventFolderList);
|
||||
await this.storage.set('actionsViagens', publicationsTravelFolderList);
|
||||
await this.storage.set('actionsEvents', this.publicationsEventFolderList);
|
||||
await this.storage.set('actionsViagens', this.publicationsTravelFolderList);
|
||||
this.getFromDB()
|
||||
} else {
|
||||
this.getFromDB()
|
||||
@@ -190,7 +174,6 @@ export class PublicationsPage implements OnInit {
|
||||
this.loadList = false
|
||||
|
||||
}, (error) => {
|
||||
// this.getFromDB();
|
||||
this.showLoader = false;
|
||||
this.skeletonLoader = false;
|
||||
this.loadList = false
|
||||
@@ -217,16 +200,28 @@ export class PublicationsPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getPublicationFolderMap(events: any):PublicationFolder[] {
|
||||
return events.map((data) : PublicationFolder => {
|
||||
return {
|
||||
ProcessId: data.ProcessId,
|
||||
Description: data.Description,
|
||||
Detail: data.Detail,
|
||||
DateBegin: data.DateBegin,
|
||||
DateEnd: data.DateEnd,
|
||||
ActionType: data.ActionType,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getFromDB() {
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
this.publicationsEventFolderList = new Array();
|
||||
this.publicationsTravelFolderList = new Array();
|
||||
this.storage.get('actionsEvents').then((events = []) => {
|
||||
|
||||
if(Array.isArray(events)) {
|
||||
events.forEach(data => {
|
||||
let folder: PublicationFolder = {
|
||||
const folders: PublicationFolder[] = events.map((data) : PublicationFolder => {
|
||||
return {
|
||||
ProcessId: data.ProcessId,
|
||||
Description: data.Description,
|
||||
Detail: data.Detail,
|
||||
@@ -234,18 +229,18 @@ export class PublicationsPage implements OnInit {
|
||||
DateEnd: data.DateEnd,
|
||||
ActionType: data.ActionType,
|
||||
}
|
||||
|
||||
this.publicationsEventFolderList.push(folder);
|
||||
this.showLoader = false;
|
||||
});
|
||||
|
||||
this.showLoader = false;
|
||||
this.publicationsEventFolderList = folders
|
||||
}
|
||||
|
||||
});
|
||||
this.storage.get('actionsViagens').then((viagens = []) => {
|
||||
|
||||
if(Array.isArray(viagens)) {
|
||||
viagens.forEach(data => {
|
||||
let folder: PublicationFolder = {
|
||||
const folders: PublicationFolder[] = viagens.map((data): PublicationFolder => {
|
||||
return {
|
||||
ProcessId: data.ProcessId,
|
||||
Description: data.Description,
|
||||
Detail: data.Detail,
|
||||
@@ -253,23 +248,18 @@ export class PublicationsPage implements OnInit {
|
||||
DateEnd: data.DateEnd,
|
||||
ActionType: data.ActionType,
|
||||
}
|
||||
|
||||
this.publicationsTravelFolderList.push(folder);
|
||||
this.showLoader = false;
|
||||
});
|
||||
|
||||
this.publicationsTravelFolderList = folders
|
||||
this.showLoader = false;
|
||||
}
|
||||
|
||||
});
|
||||
} else {
|
||||
this.sqliteservice.getAllActions().then((actions: any[] = []) => {
|
||||
|
||||
|
||||
|
||||
this.publicationsEventFolderList = new Array();
|
||||
this.publicationsTravelFolderList = new Array();
|
||||
|
||||
actions.forEach(data => {
|
||||
let folder: PublicationFolder = {
|
||||
const folders: any = actions.map((data): PublicationFolder => {
|
||||
return {
|
||||
ProcessId: data.ProcessId,
|
||||
Description: data.Description,
|
||||
Detail: data.Detail,
|
||||
@@ -277,16 +267,12 @@ export class PublicationsPage implements OnInit {
|
||||
DateEnd: data.DateEnd,
|
||||
ActionType: data.ActionType,
|
||||
}
|
||||
|
||||
if (data.ActionType == "Evento") {
|
||||
this.publicationsEventFolderList.push(folder);
|
||||
}
|
||||
else {
|
||||
this.publicationsTravelFolderList.push(folder);
|
||||
}
|
||||
this.showLoader = false;
|
||||
});
|
||||
|
||||
this.publicationsEventFolderList = folders.filter((e)=>e.ActionType == 'Evento')
|
||||
this.publicationsTravelFolderList = folders.filter((e)=>e.ActionType != 'Evento')
|
||||
this.showLoader = false;
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user