mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
offline angenda and actions
This commit is contained in:
@@ -13,6 +13,8 @@ import { EditActionPage } from './edit-action/edit-action.page';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { PublicationEventFolderStorage } from 'src/app/store/publication-event-folder.service';
|
||||
import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-folder.service';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { synchro } from 'src/app/services/socket/synchro.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-publications',
|
||||
@@ -28,11 +30,11 @@ export class PublicationsPage implements OnInit {
|
||||
actionsListStorage: PublicationFolder[] = new Array();
|
||||
publicationsTravelFolderList: PublicationFolder[];
|
||||
|
||||
theDate:any;
|
||||
theEndDate:any;
|
||||
customDate:any;
|
||||
theDate: any;
|
||||
theEndDate: any;
|
||||
customDate: any;
|
||||
months: string[];
|
||||
days:string[];
|
||||
days: string[];
|
||||
|
||||
publicationEventFolderStorage = PublicationEventFolderStorage
|
||||
publicationTravelFolderService = PublicationTravelFolderStore
|
||||
@@ -61,41 +63,33 @@ export class PublicationsPage implements OnInit {
|
||||
private modalController: ModalController,
|
||||
private animationController: AnimationController,
|
||||
private publications: PublicationsService,
|
||||
private toastService: ToastService
|
||||
) {
|
||||
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() {
|
||||
|
||||
const pathname = window.location.pathname
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if(event instanceof NavigationEnd && event.url == pathname) {
|
||||
this.getActions();
|
||||
}
|
||||
});
|
||||
|
||||
this.hideRefreshButton();
|
||||
private toastService: ToastService,
|
||||
private sqliteservice: SqliteService
|
||||
) {
|
||||
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"];
|
||||
}
|
||||
|
||||
hideRefreshButton(){
|
||||
ngOnInit() {
|
||||
this.getFromDB();
|
||||
}
|
||||
|
||||
hideRefreshButton() {
|
||||
window.onresize = (event) => {
|
||||
if( window.innerWidth < 801) {
|
||||
if (window.innerWidth < 801) {
|
||||
this.hideRefreshBtn = false;
|
||||
this.showSlidingOptions = false;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.hideRefreshBtn = true;
|
||||
this.showSlidingOptions = true;
|
||||
}
|
||||
}
|
||||
if(window.innerWidth < 801){
|
||||
if (window.innerWidth < 801) {
|
||||
this.hideRefreshBtn = false;
|
||||
this.showSlidingOptions = false;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.hideRefreshBtn = true;
|
||||
this.showSlidingOptions = true;
|
||||
}
|
||||
@@ -120,12 +114,15 @@ export class PublicationsPage implements OnInit {
|
||||
|
||||
getDate(date) {
|
||||
this.theDate = new Date(date);
|
||||
return this.theDate.getDate() +" de " + ( this.months[this.theDate.getMonth()])+" de " +this.theDate.getFullYear()
|
||||
return this.theDate.getDate() + " de " + (this.months[this.theDate.getMonth()]) + " de " + this.theDate.getFullYear()
|
||||
}
|
||||
|
||||
getActions() {
|
||||
this.showLoader = true;
|
||||
this.publications.GetPublicationFolderList().subscribe(res=>{
|
||||
this.publications.GetPublicationFolderList().subscribe(res => {
|
||||
|
||||
console.log('accoes', res)
|
||||
this.sqliteservice.addactions(res);
|
||||
|
||||
this.publicationsEventFolderList = new Array();
|
||||
this.publicationsTravelFolderList = new Array();
|
||||
@@ -140,46 +137,87 @@ export class PublicationsPage implements OnInit {
|
||||
ActionType: data.ActionType,
|
||||
}
|
||||
|
||||
if(data.ActionType == "Evento") {
|
||||
if (data.ActionType == "Evento") {
|
||||
this.publicationsEventFolderList.push(folder);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.publicationsTravelFolderList.push(folder);
|
||||
}
|
||||
this.showLoader = false;
|
||||
|
||||
this.publicationEventFolderStorage.reset(this.publicationsEventFolderList)
|
||||
this.publicationTravelFolderService.reset(this.publicationsTravelFolderList)
|
||||
/* this.publicationEventFolderStorage.reset(this.publicationsEventFolderList)
|
||||
this.publicationTravelFolderService.reset(this.publicationsTravelFolderList) */
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
async editAction(folderId?: string){
|
||||
getFromDB() {
|
||||
|
||||
if (synchro.connected === true) {
|
||||
const pathname = window.location.pathname
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if (event instanceof NavigationEnd && event.url == pathname) {
|
||||
this.getActions();
|
||||
}
|
||||
});
|
||||
|
||||
this.hideRefreshButton();
|
||||
} else {
|
||||
this.sqliteservice.getAllActions().then((actions: any[]) => {
|
||||
|
||||
this.publicationsEventFolderList = new Array();
|
||||
this.publicationsTravelFolderList = new Array();
|
||||
|
||||
actions.forEach(data => {
|
||||
let folder: PublicationFolder = {
|
||||
ProcessId: data.ProcessId,
|
||||
Description: data.Description,
|
||||
Detail: data.Detail,
|
||||
DateBegin: data.DateBegin,
|
||||
DateEnd: data.DateEnd,
|
||||
ActionType: data.ActionType,
|
||||
}
|
||||
|
||||
if (data.ActionType == "Evento") {
|
||||
this.publicationsEventFolderList.push(folder);
|
||||
}
|
||||
else {
|
||||
this.publicationsTravelFolderList.push(folder);
|
||||
}
|
||||
this.showLoader = false;
|
||||
});
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async editAction(folderId?: string) {
|
||||
const modal = await this.modalController.create({
|
||||
component: EditActionPage,
|
||||
componentProps:{
|
||||
componentProps: {
|
||||
folderId: folderId,
|
||||
},
|
||||
cssClass: 'new-action modal modal-desktop',
|
||||
backdropDismiss: true
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then(()=>{
|
||||
modal.onDidDismiss().then(() => {
|
||||
this.getActions();
|
||||
});
|
||||
//this.refreshing()
|
||||
}
|
||||
|
||||
async deleteAction(id?: string){
|
||||
async deleteAction(id?: string) {
|
||||
|
||||
const loader = this.toastService.loading();
|
||||
|
||||
try {
|
||||
await this.publications.DeletePresidentialAction(id).toPromise();
|
||||
this.toastService.successMessage()
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
this.toastService.badRequest()
|
||||
}
|
||||
finally {
|
||||
@@ -189,21 +227,21 @@ export class PublicationsPage implements OnInit {
|
||||
this.refreshing()
|
||||
}
|
||||
|
||||
async AddPublicationFolder(item?:any) {
|
||||
async AddPublicationFolder(item?: any) {
|
||||
|
||||
this.closeDesktopComponent();
|
||||
if(window.innerWidth <= 1024) {
|
||||
if (window.innerWidth <= 1024) {
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: NewActionPage,
|
||||
componentProps:{
|
||||
componentProps: {
|
||||
item: item,
|
||||
},
|
||||
cssClass: 'new-action modal modal-desktop',
|
||||
backdropDismiss: false
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then(()=>{
|
||||
modal.onDidDismiss().then(() => {
|
||||
this.getActions();
|
||||
});
|
||||
} else {
|
||||
@@ -212,12 +250,12 @@ export class PublicationsPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
goToPublicationsList(folderId: string){
|
||||
goToPublicationsList(folderId: string) {
|
||||
this.folderId = folderId
|
||||
this.idSelected = folderId;
|
||||
|
||||
if( window.innerWidth <= 800){
|
||||
this.router.navigate(['/home/publications',folderId]);
|
||||
if (window.innerWidth <= 800) {
|
||||
this.router.navigate(['/home/publications', folderId]);
|
||||
} else {
|
||||
this.closeDesktopComponent();
|
||||
this.folderId = folderId
|
||||
@@ -256,14 +294,14 @@ export class PublicationsPage implements OnInit {
|
||||
this.closeDesktopComponent();
|
||||
|
||||
// OpenModal
|
||||
if( window.innerWidth <= 800){
|
||||
if (window.innerWidth <= 800) {
|
||||
/* let item = this.publicationFolderList; */
|
||||
const modal = await this.modalController.create({
|
||||
component: ViewPublicationsPage,
|
||||
//enterAnimation,
|
||||
//leaveAnimation,
|
||||
componentProps:{
|
||||
folderId:folderId,
|
||||
componentProps: {
|
||||
folderId: folderId,
|
||||
},
|
||||
cssClass: 'new-action modal modal-desktop',
|
||||
backdropDismiss: false
|
||||
@@ -281,7 +319,7 @@ export class PublicationsPage implements OnInit {
|
||||
|
||||
// called from publications details
|
||||
// Emittter
|
||||
goBackToViewPublications(){
|
||||
goBackToViewPublications() {
|
||||
|
||||
this.closeDesktopComponent();
|
||||
this.desktopComponent.showViewPublication = true;
|
||||
@@ -289,21 +327,21 @@ export class PublicationsPage implements OnInit {
|
||||
|
||||
// called from publications details
|
||||
// Emitters
|
||||
goBackToPubications(){
|
||||
goBackToPubications() {
|
||||
this.closeDesktopComponent();
|
||||
this.desktopComponent.showViewPublication = true;
|
||||
}
|
||||
|
||||
// called from edit publication (Emitters only)
|
||||
// Emitters
|
||||
async goBacktoPublicationDetails(){
|
||||
async goBacktoPublicationDetails() {
|
||||
this.closeDesktopComponent();
|
||||
this.desktopComponent.showPublicationDetail = true;
|
||||
|
||||
}
|
||||
|
||||
// add new publication or edit publicaton
|
||||
async addNewPublication({publicationType, folderId, publication}){
|
||||
async addNewPublication({ publicationType, folderId, publication }) {
|
||||
|
||||
this.closeDesktopComponent();
|
||||
|
||||
@@ -319,7 +357,7 @@ export class PublicationsPage implements OnInit {
|
||||
this.desktopComponent.showAddNewPublication = true;
|
||||
}
|
||||
|
||||
async openPublicationDetails(publicationId: string){
|
||||
async openPublicationDetails(publicationId: string) {
|
||||
|
||||
this.publicationId = publicationId;
|
||||
|
||||
@@ -328,11 +366,11 @@ export class PublicationsPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
async updateDesktopComponent(e?:any){
|
||||
async updateDesktopComponent(e?: any) {
|
||||
this.getActions();
|
||||
}
|
||||
|
||||
async closeDesktopComponent (xx?: any){
|
||||
async closeDesktopComponent(xx?: any) {
|
||||
|
||||
this.desktopComponent = {
|
||||
showViewPublication: false,
|
||||
@@ -380,10 +418,10 @@ export class PublicationsPage implements OnInit {
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then(res => {
|
||||
if(res['data']=='edit') {
|
||||
if (res['data'] == 'edit') {
|
||||
this.closeDesktopComponent();
|
||||
this.desktopComponent.showEditActions = true;
|
||||
} else if (res['data']=='delete') {
|
||||
} else if (res['data'] == 'delete') {
|
||||
setTimeout(() => {
|
||||
this.getActions();
|
||||
}, 1000)
|
||||
|
||||
Reference in New Issue
Block a user