Add angular material inputs

This commit is contained in:
Peter Maquiran
2021-06-23 15:39:45 +01:00
parent 6a182cb962
commit 2ef12efa54
21 changed files with 622 additions and 330 deletions
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { EventBody } from 'src/app/models/eventbody.model';
import { EventPerson } from 'src/app/models/eventperson.model';
@@ -9,6 +9,10 @@ import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
import { SearchPage } from 'src/app/pages/search/search.page';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { Attachment } from 'src/app/models/attachment.model';
import { ToastService } from 'src/app/services/toast.service';
import { FormControl } from '@angular/forms';
import * as moment from 'moment';
@Component({
selector: 'app-edit-event',
templateUrl: './edit-event.page.html',
@@ -24,9 +28,21 @@ export class EditEventPage implements OnInit {
eventBody: EventBody;
segment:string = "true";
eventAttendees: EventPerson[];
minDate: string;
// minDate: string;
loadedEventAttachments: Attachment[];
public date: any;
public disabled = false;
public showSpinners = true;
public showSeconds = false;
public touchUi = false;
public enableMeridian = false;
public minDate: any;
public maxDate: any;
public stepHour = 1;
public stepMinute = 5;
public stepSecond = 5;
@Input() taskParticipants: EventPerson[];
@Input() taskParticipantsCc: EventPerson[];
@Input() profile:string;
@@ -41,15 +57,41 @@ export class EditEventPage implements OnInit {
@Output() setIntervenientCC = new EventEmitter<any>();
@Output() clearPostEvent = new EventEmitter<any>();
public dateControlStart = new FormControl(moment("DD MM YYYY hh"));
public dateControlEnd = new FormControl(moment("DD MM YYYY hh"));
showLoader = false
get dateStart () {
return this.dateControlStart.value
}
get dateEnd () {
return this.dateControlEnd.value
}
@ViewChild('picker') picker: any;
@ViewChild('fim') fim: any;
@ViewChild('inicio') inicio: any;
@ViewChild('picker1') picker1: any;
public options = [
{ value: true, label: 'True' },
{ value: false, label: 'False' }
];
public listColors = ['primary', 'accent', 'warn'];
public stepHours = [1, 2, 3, 4, 5];
public stepMinutes = [1, 5, 10, 15, 20, 25];
public stepSeconds = [1, 5, 10, 15, 20, 25];
constructor(
private modalController: ModalController,
private eventsService: EventsService,
public alertController: AlertController,
private attachmentsService: AttachmentsService,
) {
private toastService: ToastService ) {
}
ngOnInit() {
@@ -94,11 +136,11 @@ export class EditEventPage implements OnInit {
this.getAttachments(this.postEvent.EventId);
this.restoreDatepickerData()
}
close(){
close() {
this.closeComponent.emit();
this.setIntervenient.emit([]);
this.setIntervenientCC.emit([]);
@@ -107,25 +149,30 @@ export class EditEventPage implements OnInit {
this.deleteTemporaryData();
}
async save() {
async save(){
this.getDatepickerData()
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
this.showLoader = true
await this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => {
this.showLoader = false
const alert = await this.alertController.create({
cssClass: 'my-custom-class',
header: 'Evento actualizado',
buttons: ['OK']
});
this.toastService.successMessage()
setTimeout(()=>{
alert.dismiss();
}, 1500);
},
error => {
this.showLoader = false
this.toastService.badRequest()
});
this.clearPostEvent.emit();
@@ -157,8 +204,25 @@ export class EditEventPage implements OnInit {
}
saveTemporaryData(){
getDatepickerData() {
if (this.postEvent) {
this.postEvent.StartDate = this.dateStart
this.postEvent.EndDate = this.dateEnd
}
}
restoreDatepickerData() {
if (this.postEvent) {
this.dateControlStart = new FormControl(moment(this.postEvent.StartDate));
this.dateControlEnd = new FormControl(moment(this.postEvent.EndDate));
}
}
saveTemporaryData() {
this.getDatepickerData()
window['temp.path:/home/agenda/edit-event.component.ts'] = {
postEvent: this.postEvent,
eventBody: this.eventBody,
@@ -166,8 +230,8 @@ export class EditEventPage implements OnInit {
}
}
restoreTemporaryData(): boolean{
restoreTemporaryData(): boolean {
const restoredData = window['temp.path:/home/agenda/edit-event.component.ts']
if(JSON.stringify(restoredData) != "{}" && undefined != restoredData){
@@ -175,6 +239,8 @@ export class EditEventPage implements OnInit {
this.eventBody = restoredData.eventBody
this.segment = restoredData.segment
this.restoreDatepickerData()
return true;
} else {
return false;