mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
278 lines
7.6 KiB
TypeScript
278 lines
7.6 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { Router, NavigationEnd } from '@angular/router';
|
|
import { ModalController } from '@ionic/angular';
|
|
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { PublicationsService } from 'src/app/services/publications.service';
|
|
import { NewActionPage } from './new-action/new-action.page';
|
|
import { ViewPublicationsPage } from './view-publications/view-publications.page';
|
|
|
|
import { Animation, AnimationController } from '@ionic/angular';
|
|
import { LoadingController } from '@ionic/angular';
|
|
import { LoadingService } from 'src/app/services/loading.service';
|
|
import { Publication } from 'src/app/models/publication';
|
|
|
|
|
|
@Component({
|
|
selector: 'app-publications',
|
|
templateUrl: './publications.page.html',
|
|
styleUrls: ['./publications.page.scss'],
|
|
})
|
|
export class PublicationsPage implements OnInit {
|
|
showLoader: boolean;
|
|
publicationFolder: PublicationFolder;
|
|
publication: Publication;
|
|
|
|
publicationFolderList: PublicationFolder[];
|
|
publicationsEventFolderList: PublicationFolder[];
|
|
publicationsTravelFolderList: PublicationFolder[];
|
|
|
|
theDate:any;
|
|
theEndDate:any;
|
|
customDate:any;
|
|
months: string[];
|
|
days:string[];
|
|
|
|
|
|
desktopComponent: any = {
|
|
showViewPublication: false,
|
|
showAddNewPublication: false,
|
|
showPublicationDetail: false,
|
|
showAddActions: false
|
|
}
|
|
|
|
folderId: string;
|
|
// data set from child component
|
|
publicationType: any;
|
|
publicationId: string;
|
|
|
|
// from publication details
|
|
//publication: object;
|
|
hideRefreshBtn = true;
|
|
|
|
constructor(
|
|
private router: Router,
|
|
private modalController: ModalController,
|
|
private animationController: AnimationController,
|
|
private loading: LoadingService,
|
|
private publications: PublicationsService,
|
|
) {
|
|
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"];
|
|
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.router.events.forEach((event) => {
|
|
if(event instanceof NavigationEnd && event.url == this.router.url) {
|
|
this.getActions();
|
|
}
|
|
});
|
|
|
|
this.hideRefreshButton();
|
|
}
|
|
|
|
hideRefreshButton(){
|
|
window.onresize = (event) => {
|
|
if( window.innerWidth < 801) {
|
|
this.hideRefreshBtn = false;
|
|
}
|
|
else{
|
|
this.hideRefreshBtn = true;
|
|
}
|
|
}
|
|
if(window.innerWidth < 801){
|
|
console.log('YASS');
|
|
this.hideRefreshBtn = false;
|
|
}
|
|
}
|
|
|
|
doRefresh(event) {
|
|
this.getActions();
|
|
|
|
setTimeout(() => {
|
|
event.target.complete();
|
|
}, 250);
|
|
}
|
|
|
|
get windowInnerWidth(): number {
|
|
return window.innerWidth
|
|
}
|
|
|
|
getActions(){
|
|
this.showLoader = true;
|
|
this.publications.GetPublicationFolderList().subscribe(res=>{
|
|
this.publicationFolderList = res;
|
|
console.log(res);
|
|
this.publicationsEventFolderList = new Array();
|
|
this.publicationsTravelFolderList = new Array();
|
|
res.forEach(data => {
|
|
this.theDate = new Date(data.DateBegin);
|
|
this.theEndDate = new Date(data.DateEnd);
|
|
let folder: PublicationFolder = {
|
|
ProcessId: data.ProcessId,
|
|
Description: data.Description,
|
|
Detail: data.Detail,
|
|
DateBegin: this.theDate.getDate() +" de " + ( this.months[this.theDate.getMonth()])+" de " +this.theDate.getFullYear(),
|
|
DateEnd: this.theEndDate.getDate() +" de " + ( this.months[this.theEndDate.getMonth()])+" de " +this.theEndDate.getFullYear(),
|
|
ActionType: data.ActionType,
|
|
}
|
|
if(data.ActionType == "Evento"){
|
|
this.publicationsEventFolderList.push(folder);
|
|
}
|
|
else{
|
|
this.publicationsTravelFolderList.push(folder);
|
|
}
|
|
this.showLoader = false;
|
|
});
|
|
});
|
|
}
|
|
|
|
async AddPublicationFolder(item?:any) {
|
|
|
|
this.closeDesktopComponent();
|
|
if(window.innerWidth <= 1024){
|
|
|
|
const modal = await this.modalController.create({
|
|
component: NewActionPage,
|
|
componentProps:{
|
|
item: item,
|
|
},
|
|
cssClass: 'new-action modal modal-desktop',
|
|
backdropDismiss: false
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss().then(()=>{
|
|
this.getActions();
|
|
});
|
|
} else {
|
|
this.desktopComponent.showAddActions = true;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
goToPublicationsList(folderId: string){
|
|
if( window.innerWidth <= 800){
|
|
this.router.navigate(['/home/publications',folderId]);
|
|
} else {
|
|
this.closeDesktopComponent();
|
|
this.folderId = folderId
|
|
this.desktopComponent.showViewPublication = true;
|
|
}
|
|
|
|
}
|
|
|
|
async viewPublications(folderId: string) {
|
|
|
|
const enterAnimation = (baseEl: any) => {
|
|
const backdropAnimation = this.animationController.create()
|
|
.addElement(baseEl.querySelector('ion-backdrop')!)
|
|
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
|
|
|
|
const wrapperAnimation = this.animationController.create()
|
|
.addElement(baseEl.querySelector('.modal-wrapper')!)
|
|
.keyframes([
|
|
{ offset: 0, opacity: '0', transform: 'scale(0)' },
|
|
{ offset: 1, opacity: '0.99', transform: 'scale(1)' }
|
|
]);
|
|
|
|
return this.animationController.create()
|
|
.addElement(baseEl)
|
|
.easing('ease-out')
|
|
.duration(500)
|
|
.addAnimation([backdropAnimation, wrapperAnimation]);
|
|
}
|
|
|
|
const leaveAnimation = (baseEl: any) => {
|
|
return enterAnimation(baseEl).direction('reverse');
|
|
}
|
|
|
|
|
|
this.closeDesktopComponent();
|
|
|
|
// OpenModal
|
|
if( window.innerWidth <= 800){
|
|
/* let item = this.publicationFolderList; */
|
|
const modal = await this.modalController.create({
|
|
component: ViewPublicationsPage,
|
|
//enterAnimation,
|
|
//leaveAnimation,
|
|
componentProps:{
|
|
folderId:folderId,
|
|
},
|
|
cssClass: 'new-action modal modal-desktop',
|
|
backdropDismiss: false
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss();
|
|
|
|
} else {
|
|
// open angular component
|
|
this.folderId = folderId
|
|
this.desktopComponent.showViewPublication = true;
|
|
}
|
|
|
|
}
|
|
|
|
// called from publications details
|
|
// Emittter
|
|
goBackToViewPublications(){
|
|
|
|
this.closeDesktopComponent();
|
|
this.desktopComponent.showViewPublication = true;
|
|
}
|
|
|
|
// called from publications details
|
|
// Emitters
|
|
goBackToPubications(){
|
|
this.closeDesktopComponent();
|
|
this.desktopComponent.showViewPublication = true;
|
|
}
|
|
|
|
// called from edit publication (Emitters only)
|
|
// Emitters
|
|
async goBacktoPublicationDetails(){
|
|
this.closeDesktopComponent();
|
|
this.desktopComponent.showPublicationDetail = true;
|
|
|
|
}
|
|
|
|
// add new publication or edit publicaton
|
|
async addNewPublication({publicationType, folderId, publication}){
|
|
|
|
this.closeDesktopComponent();
|
|
|
|
// propr to add new publication
|
|
this.publicationType = publicationType;
|
|
// edit publication will send null
|
|
if (folderId != undefined) {
|
|
this.folderId = folderId;
|
|
}
|
|
|
|
this.publication = publication;
|
|
|
|
this.desktopComponent.showAddNewPublication = true;
|
|
}
|
|
|
|
async openPublicationDetails(publicationId: string){
|
|
|
|
this.publicationId = publicationId;
|
|
|
|
this.closeDesktopComponent();
|
|
this.desktopComponent.showPublicationDetail = true;
|
|
|
|
}
|
|
|
|
|
|
async closeDesktopComponent (xx?: any){
|
|
|
|
this.desktopComponent = {
|
|
showViewPublication: false,
|
|
showAddNewPublication: false,
|
|
showPublicationDetail: false,
|
|
showAddActions: false,
|
|
}
|
|
}
|
|
|
|
} |