mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
add model
This commit is contained in:
@@ -15,7 +15,7 @@ import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
||||
import { ChangeProfileService } from 'src/app/services/change-profile.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { TaskService } from 'src/app/services/task.service'
|
||||
import { TaskService } from 'src/app/services/task.service';
|
||||
@Component({
|
||||
selector: 'app-events',
|
||||
templateUrl: './events.page.html',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, NavigationEnd } from '@angular/router';
|
||||
import { ModalController, Platform } from '@ionic/angular';
|
||||
import { ModalController } from '@ionic/angular';
|
||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||
import { PublicationsService } from 'src/app/services/publications.service';
|
||||
import { NewActionPage } from './new-action/new-action.page';
|
||||
@@ -11,12 +11,9 @@ import { Publication } from 'src/app/models/publication';
|
||||
import { ActionsOptionsPage } from 'src/app/shared/popover/actions-options/actions-options.page';
|
||||
import { EditActionPage } from './edit-action/edit-action.page';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { ActionModel, PublicationModel } from 'src/app/models/beast-orm';
|
||||
import { ActionModel } from 'src/app/models/beast-orm';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -65,11 +62,7 @@ export class PublicationsPage implements OnInit {
|
||||
private animationController: AnimationController,
|
||||
private publications: PublicationsService,
|
||||
private toastService: ToastService,
|
||||
private sqliteservice: SqliteService,
|
||||
private backgroundservice: BackgroundService,
|
||||
private platform: Platform,
|
||||
public ThemeService: ThemeService,
|
||||
private storage: Storage,
|
||||
public p: PermissionService,
|
||||
|
||||
) {
|
||||
@@ -146,18 +139,29 @@ export class PublicationsPage implements OnInit {
|
||||
this.publications.GetPublicationFolderList().subscribe(async res => {
|
||||
this.showLoader = false;
|
||||
const folders: PublicationFolder[] = this.getPublicationFolderMap(res)
|
||||
|
||||
|
||||
|
||||
this.publicationsEventFolderList = folders.filter((e)=>e.ActionType == 'Evento')
|
||||
this.publicationsTravelFolderList = folders.filter((e)=>e.ActionType != 'Evento')
|
||||
|
||||
ActionModel.create(folders)
|
||||
|
||||
await this.storage.set('actionsEvents', this.publicationsEventFolderList);
|
||||
await this.storage.set('actionsViagens', this.publicationsTravelFolderList);
|
||||
|
||||
|
||||
this.showLoader = false;
|
||||
|
||||
(async ()=> {
|
||||
|
||||
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)
|
||||
})
|
||||
|
||||
for (let ActionModelToDelete of notPresentOnTheRequest) {
|
||||
ActionModelToDelete.delete()
|
||||
}
|
||||
|
||||
// console.log({created, stored, folders, toDeletes})
|
||||
|
||||
})()
|
||||
|
||||
|
||||
}, (error) => {
|
||||
this.showLoader = false;
|
||||
this.getFromDB()
|
||||
@@ -165,14 +169,6 @@ export class PublicationsPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
// addActionToDB(folder) {
|
||||
// if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
// } else {
|
||||
// this.sqliteservice.addactions(folder);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
getPublicationFolderMap(events: any):PublicationFolder[] {
|
||||
return events.map((data) : PublicationFolder => {
|
||||
return {
|
||||
@@ -186,27 +182,12 @@ export class PublicationsPage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
getFromDB() {
|
||||
this.storage.get('actionsEvents').then((events = []) => {
|
||||
|
||||
if(Array.isArray(events)) {
|
||||
const folders: PublicationFolder[] = this.getPublicationFolderMap(events)
|
||||
async getFromDB() {
|
||||
|
||||
const folders: PublicationFolder[] = await ActionModel.all()
|
||||
this.showLoader = false;
|
||||
this.publicationsEventFolderList = folders
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
async editAction(folderId?: string) {
|
||||
|
||||
@@ -15,8 +15,6 @@ import { ToastService } from 'src/app/services/toast.service';
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { PublicationModel } from 'src/app/models/beast-orm';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-publications',
|
||||
templateUrl: './view-publications.page.html',
|
||||
@@ -44,7 +42,6 @@ export class ViewPublicationsPage implements OnInit {
|
||||
private publications: PublicationsService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private router: Router,
|
||||
private sqliteservice: SqliteService,
|
||||
private backgroundservice: BackgroundService,
|
||||
public ThemeService: ThemeService,
|
||||
private toastService: ToastService,
|
||||
|
||||
Reference in New Issue
Block a user