This commit is contained in:
Peter Maquiran
2023-07-20 16:54:58 +01:00
parent 880f154ea2
commit 4d7c80a739
49 changed files with 1114 additions and 432 deletions
+41 -15
View File
@@ -13,7 +13,8 @@ import { EditActionPage } from './edit-action/edit-action.page';
import { ToastService } from 'src/app/services/toast.service';
import { ThemeService } from 'src/app/services/theme.service'
import { PermissionService } from 'src/app/services/permission.service';
import { ActionModel } from 'src/app/models/beast-orm';
import { Storage } from '@ionic/storage';
// import { ActionModel } from 'src/app/models/beast-orm';
@Component({
@@ -64,6 +65,7 @@ export class PublicationsPage implements OnInit {
private toastService: ToastService,
public ThemeService: ThemeService,
public p: PermissionService,
private storage: Storage,
) {
this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
@@ -141,25 +143,27 @@ export class PublicationsPage implements OnInit {
const folders: PublicationFolder[] = this.getPublicationFolderMap(res)
this.publicationsEventFolderList = folders.filter((e)=>e.ActionType == 'Evento')
await this.storage.set('actionsEvents', this.publicationsEventFolderList);
this.showLoader = false;
(async ()=> {
// (async ()=> {
const created = await ActionModel.create(folders)
const stored = await ActionModel.all()
// const created = await ActionModel.create(folders)
// const stored = await ActionModel.all()
const notPresentOnTheRequest: ActionModel[] = stored.filter(e => {
return !folders.find(b => e.ProcessId == b.ProcessId)
})
// const notPresentOnTheRequest: ActionModel[] = stored.filter(e => {
// return !folders.find(b => e.ProcessId == b.ProcessId)
// })
for (let ActionModelToDelete of notPresentOnTheRequest) {
ActionModelToDelete.delete()
}
// for (let ActionModelToDelete of notPresentOnTheRequest) {
// ActionModelToDelete.delete()
// }
// console.log({created, stored, folders, toDeletes})
// // console.log({created, stored, folders, toDeletes})
})()
// })()
}, (error) => {
@@ -184,9 +188,31 @@ export class PublicationsPage implements OnInit {
async getFromDB() {
const folders: PublicationFolder[] = await ActionModel.all()
this.showLoader = false;
this.publicationsEventFolderList = folders
//const folders: PublicationFolder[] = await ActionModel.all()
//this.showLoader = false;
// this.publicationsEventFolderList = folders
this.storage.get('actionsEvents').then((events = []) => {
if(Array.isArray(events)) {
const folders: PublicationFolder[] = this.getPublicationFolderMap(events)
this.showLoader = false;
this.publicationsEventFolderList = folders
}
});
this.storage.get('actionsViagens').then((viagens = []) => {
if(Array.isArray(viagens)) {
const folders: PublicationFolder[] = this.getPublicationFolderMap(viagens)
this.publicationsTravelFolderList = folders
this.showLoader = false;
}
});
}