2020-11-30 16:08:29 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2020-12-10 11:22:06 +01:00
|
|
|
import { Router, NavigationEnd } from '@angular/router';
|
2021-06-30 15:01:07 +01:00
|
|
|
import { ModalController, PopoverController } from '@ionic/angular';
|
2020-12-09 12:10:19 +01:00
|
|
|
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
|
|
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
|
|
|
import { PublicationsService } from 'src/app/services/publications.service';
|
2020-12-01 17:22:45 +01:00
|
|
|
import { NewActionPage } from './new-action/new-action.page';
|
2020-12-09 12:10:19 +01:00
|
|
|
import { ViewPublicationsPage } from './view-publications/view-publications.page';
|
2020-11-30 16:08:29 +01:00
|
|
|
|
2020-12-15 19:37:42 +01:00
|
|
|
import { Animation, AnimationController } from '@ionic/angular';
|
|
|
|
|
import { LoadingController } from '@ionic/angular';
|
|
|
|
|
import { LoadingService } from 'src/app/services/loading.service';
|
2021-04-08 11:55:44 +01:00
|
|
|
import { Publication } from 'src/app/models/publication';
|
2021-06-30 15:01:07 +01:00
|
|
|
import { ActionsOptionsPage } from 'src/app/shared/popover/actions-options/actions-options.page';
|
2020-12-15 19:37:42 +01:00
|
|
|
|
|
|
|
|
|
2020-11-30 16:08:29 +01:00
|
|
|
@Component({
|
|
|
|
|
selector: 'app-publications',
|
|
|
|
|
templateUrl: './publications.page.html',
|
|
|
|
|
styleUrls: ['./publications.page.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class PublicationsPage implements OnInit {
|
2020-12-10 11:22:06 +01:00
|
|
|
showLoader: boolean;
|
2020-12-11 15:09:53 +01:00
|
|
|
publicationFolder: PublicationFolder;
|
2021-04-08 11:55:44 +01:00
|
|
|
publication: Publication;
|
2020-11-30 16:08:29 +01:00
|
|
|
|
2020-12-09 12:10:19 +01:00
|
|
|
publicationFolderList: PublicationFolder[];
|
|
|
|
|
publicationsEventFolderList: PublicationFolder[];
|
|
|
|
|
publicationsTravelFolderList: PublicationFolder[];
|
|
|
|
|
|
2020-12-10 11:22:06 +01:00
|
|
|
theDate:any;
|
2020-12-11 15:09:53 +01:00
|
|
|
theEndDate:any;
|
2020-12-10 11:22:06 +01:00
|
|
|
customDate:any;
|
|
|
|
|
months: string[];
|
|
|
|
|
days:string[];
|
|
|
|
|
|
2021-03-12 14:38:55 +01:00
|
|
|
|
|
|
|
|
desktopComponent: any = {
|
|
|
|
|
showViewPublication: false,
|
2021-03-15 16:47:16 +01:00
|
|
|
showAddNewPublication: false,
|
2021-03-16 12:14:46 +01:00
|
|
|
showPublicationDetail: false,
|
2021-06-30 16:15:54 +01:00
|
|
|
showAddActions: false,
|
|
|
|
|
showEditActions: false
|
2021-03-12 14:38:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
folderId: string;
|
2021-03-16 14:35:52 +01:00
|
|
|
// data set from child component
|
2021-03-15 12:06:06 +01:00
|
|
|
publicationType: any;
|
2021-03-15 16:47:16 +01:00
|
|
|
publicationId: string;
|
2021-03-12 14:38:55 +01:00
|
|
|
|
2021-03-16 14:35:52 +01:00
|
|
|
// from publication details
|
2021-04-08 11:55:44 +01:00
|
|
|
//publication: object;
|
2021-06-17 16:43:18 +01:00
|
|
|
hideRefreshBtn = true;
|
2021-03-16 14:35:52 +01:00
|
|
|
|
2020-12-09 12:10:19 +01:00
|
|
|
constructor(
|
2020-12-10 11:22:06 +01:00
|
|
|
private router: Router,
|
2020-12-09 12:10:19 +01:00
|
|
|
private modalController: ModalController,
|
2020-12-15 19:37:42 +01:00
|
|
|
private animationController: AnimationController,
|
|
|
|
|
private loading: LoadingService,
|
2020-12-09 12:10:19 +01:00
|
|
|
private publications: PublicationsService,
|
2021-06-30 15:01:07 +01:00
|
|
|
private popoverController:PopoverController,
|
2021-01-29 16:25:03 +01:00
|
|
|
) {
|
2020-12-10 11:22:06 +01:00
|
|
|
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"];
|
2021-01-29 16:25:03 +01:00
|
|
|
|
2020-12-10 11:22:06 +01:00
|
|
|
}
|
2020-11-30 16:08:29 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2020-12-10 11:22:06 +01:00
|
|
|
this.router.events.forEach((event) => {
|
|
|
|
|
if(event instanceof NavigationEnd && event.url == this.router.url) {
|
|
|
|
|
this.getActions();
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-06-17 16:43:18 +01:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
2020-12-10 11:22:06 +01:00
|
|
|
}
|
2021-06-17 16:43:18 +01:00
|
|
|
|
2021-06-17 16:12:56 +01:00
|
|
|
doRefresh(event) {
|
|
|
|
|
this.getActions();
|
2020-12-10 11:22:06 +01:00
|
|
|
|
|
|
|
|
setTimeout(() => {
|
2021-06-17 16:12:56 +01:00
|
|
|
event.target.complete();
|
|
|
|
|
}, 250);
|
2020-12-09 12:10:19 +01:00
|
|
|
}
|
|
|
|
|
|
2021-05-05 16:08:38 +01:00
|
|
|
get windowInnerWidth(): number {
|
|
|
|
|
return window.innerWidth
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-09 12:10:19 +01:00
|
|
|
getActions(){
|
2020-12-15 19:37:42 +01:00
|
|
|
this.showLoader = true;
|
2020-12-09 12:10:19 +01:00
|
|
|
this.publications.GetPublicationFolderList().subscribe(res=>{
|
|
|
|
|
this.publicationFolderList = res;
|
|
|
|
|
console.log(res);
|
2020-12-11 15:09:53 +01:00
|
|
|
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);
|
|
|
|
|
}
|
2020-12-17 11:39:50 +01:00
|
|
|
this.showLoader = false;
|
2020-12-11 15:09:53 +01:00
|
|
|
});
|
2020-12-09 12:10:19 +01:00
|
|
|
});
|
2020-11-30 16:08:29 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-03 14:56:53 +01:00
|
|
|
async AddPublicationFolder(item?:any) {
|
2021-03-15 12:06:06 +01:00
|
|
|
|
|
|
|
|
this.closeDesktopComponent();
|
2021-03-17 11:12:20 +01:00
|
|
|
if(window.innerWidth <= 1024){
|
|
|
|
|
|
2021-03-16 12:14:46 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: NewActionPage,
|
|
|
|
|
componentProps:{
|
|
|
|
|
item: item,
|
|
|
|
|
},
|
2021-04-14 15:27:50 +01:00
|
|
|
cssClass: 'new-action modal modal-desktop',
|
2021-03-16 12:14:46 +01:00
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then(()=>{
|
2021-06-17 16:12:56 +01:00
|
|
|
this.getActions();
|
2021-03-16 12:14:46 +01:00
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.desktopComponent.showAddActions = true;
|
|
|
|
|
}
|
2021-03-15 12:06:06 +01:00
|
|
|
|
2021-03-16 12:14:46 +01:00
|
|
|
|
2020-12-01 17:22:45 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-18 11:01:02 +01:00
|
|
|
goToPublicationsList(folderId: string){
|
|
|
|
|
if( window.innerWidth <= 800){
|
|
|
|
|
this.router.navigate(['/home/publications',folderId]);
|
|
|
|
|
} else {
|
|
|
|
|
this.closeDesktopComponent();
|
|
|
|
|
this.folderId = folderId
|
|
|
|
|
this.desktopComponent.showViewPublication = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-03 15:13:23 +01:00
|
|
|
async viewPublications(folderId: string) {
|
2020-12-15 19:37:42 +01:00
|
|
|
|
2021-02-18 12:44:35 +01:00
|
|
|
const enterAnimation = (baseEl: any) => {
|
2020-12-15 19:37:42 +01:00
|
|
|
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');
|
|
|
|
|
}
|
2021-02-18 12:44:35 +01:00
|
|
|
|
2020-12-15 19:37:42 +01:00
|
|
|
|
2021-03-15 12:06:06 +01:00
|
|
|
this.closeDesktopComponent();
|
2021-03-12 14:38:55 +01:00
|
|
|
|
|
|
|
|
// OpenModal
|
2021-04-14 15:27:50 +01:00
|
|
|
if( window.innerWidth <= 800){
|
2021-03-12 14:38:55 +01:00
|
|
|
/* let item = this.publicationFolderList; */
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ViewPublicationsPage,
|
2021-04-29 19:46:40 +01:00
|
|
|
//enterAnimation,
|
|
|
|
|
//leaveAnimation,
|
2021-03-12 14:38:55 +01:00
|
|
|
componentProps:{
|
|
|
|
|
folderId:folderId,
|
|
|
|
|
},
|
2021-04-14 15:27:50 +01:00
|
|
|
cssClass: 'new-action modal modal-desktop',
|
2021-03-12 14:38:55 +01:00
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss();
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// open angular component
|
|
|
|
|
this.folderId = folderId
|
2021-03-17 09:01:24 +01:00
|
|
|
this.desktopComponent.showViewPublication = true;
|
2021-03-12 14:38:55 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-17 09:01:24 +01:00
|
|
|
}
|
2021-03-17 10:03:39 +01:00
|
|
|
|
|
|
|
|
// called from publications details
|
|
|
|
|
// Emittter
|
2021-03-17 09:01:24 +01:00
|
|
|
goBackToViewPublications(){
|
|
|
|
|
|
|
|
|
|
this.closeDesktopComponent();
|
|
|
|
|
this.desktopComponent.showViewPublication = true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-17 10:03:39 +01:00
|
|
|
// called from publications details
|
|
|
|
|
// Emitters
|
2021-03-17 09:01:24 +01:00
|
|
|
goBackToPubications(){
|
|
|
|
|
this.closeDesktopComponent();
|
|
|
|
|
this.desktopComponent.showViewPublication = true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-17 10:03:39 +01:00
|
|
|
// called from edit publication (Emitters only)
|
|
|
|
|
// Emitters
|
2021-03-17 09:01:24 +01:00
|
|
|
async goBacktoPublicationDetails(){
|
|
|
|
|
this.closeDesktopComponent();
|
|
|
|
|
this.desktopComponent.showPublicationDetail = true;
|
2021-03-12 14:38:55 +01:00
|
|
|
|
2020-12-09 12:10:19 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-17 10:57:16 +01:00
|
|
|
// add new publication or edit publicaton
|
2021-03-16 14:35:52 +01:00
|
|
|
async addNewPublication({publicationType, folderId, publication}){
|
2021-03-15 12:06:06 +01:00
|
|
|
|
|
|
|
|
this.closeDesktopComponent();
|
|
|
|
|
|
|
|
|
|
// propr to add new publication
|
|
|
|
|
this.publicationType = publicationType;
|
2021-03-17 10:57:16 +01:00
|
|
|
// edit publication will send null
|
|
|
|
|
if (folderId != undefined) {
|
|
|
|
|
this.folderId = folderId;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-16 14:35:52 +01:00
|
|
|
this.publication = publication;
|
2021-03-15 12:06:06 +01:00
|
|
|
|
|
|
|
|
this.desktopComponent.showAddNewPublication = true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 16:47:16 +01:00
|
|
|
async openPublicationDetails(publicationId: string){
|
|
|
|
|
|
|
|
|
|
this.publicationId = publicationId;
|
|
|
|
|
|
|
|
|
|
this.closeDesktopComponent();
|
|
|
|
|
this.desktopComponent.showPublicationDetail = true;
|
|
|
|
|
|
|
|
|
|
}
|
2021-07-01 14:30:44 +01:00
|
|
|
|
|
|
|
|
async updateDesktopComponent(e?:any){
|
|
|
|
|
this.getActions();
|
|
|
|
|
}
|
2021-03-17 09:01:24 +01:00
|
|
|
|
2021-03-15 12:06:06 +01:00
|
|
|
|
2021-03-15 16:47:16 +01:00
|
|
|
async closeDesktopComponent (xx?: any){
|
2021-03-15 12:06:06 +01:00
|
|
|
|
|
|
|
|
this.desktopComponent = {
|
|
|
|
|
showViewPublication: false,
|
2021-03-15 16:47:16 +01:00
|
|
|
showAddNewPublication: false,
|
2021-03-16 12:14:46 +01:00
|
|
|
showPublicationDetail: false,
|
|
|
|
|
showAddActions: false,
|
2021-06-30 16:26:35 +01:00
|
|
|
showEditActions: false,
|
2021-03-15 12:06:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-30 15:48:37 +01:00
|
|
|
async openOptions(id?: string) {
|
2021-07-01 09:36:17 +01:00
|
|
|
this.folderId = id;
|
2021-06-30 15:48:37 +01:00
|
|
|
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: '1', right: '-100%' },
|
|
|
|
|
{ offset: 1, opacity: '1', right: '0px' }
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return this.animationController.create()
|
|
|
|
|
.addElement(baseEl)
|
|
|
|
|
.easing('ease-out')
|
|
|
|
|
.duration(500)
|
|
|
|
|
.addAnimation([backdropAnimation, wrapperAnimation]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const leaveAnimation = (baseEl: any) => {
|
|
|
|
|
return enterAnimation(baseEl).direction('reverse');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
enterAnimation,
|
|
|
|
|
leaveAnimation,
|
2021-06-30 15:01:07 +01:00
|
|
|
component: ActionsOptionsPage,
|
2021-06-30 15:48:37 +01:00
|
|
|
cssClass: 'model profile-modal search-submodal',
|
2021-06-30 15:01:07 +01:00
|
|
|
componentProps: {
|
2021-06-30 15:48:37 +01:00
|
|
|
id: id,
|
2021-06-30 15:01:07 +01:00
|
|
|
},
|
|
|
|
|
//translucent: true
|
|
|
|
|
});
|
2021-06-30 16:12:47 +01:00
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then(res =>{
|
|
|
|
|
if(res['data']=='edit'){
|
2021-07-01 14:30:44 +01:00
|
|
|
this.closeDesktopComponent();
|
2021-06-30 16:15:54 +01:00
|
|
|
this.desktopComponent.showEditActions = true;
|
2021-06-30 16:12:47 +01:00
|
|
|
}
|
|
|
|
|
});
|
2021-06-30 15:01:07 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-15 12:06:06 +01:00
|
|
|
}
|