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
@@ -17,7 +17,7 @@ import { AuthService } from 'src/app/services/auth.service';
import {DateAdapter} from '@angular/material/core';
import * as _moment from 'moment';
import * as _rollupMoment from 'moment';
import {FormControl} from '@angular/forms';
import { FormControl } from '@angular/forms';
import { NgxMatDateFormats } from '@angular-material-components/datetime-picker';
import { ThemePalette } from '@angular/material/core';
@@ -52,7 +52,6 @@ const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
export class NewEventPage implements OnInit {
eventBody: EventBody;
segment:string = "true";
@@ -69,7 +68,6 @@ export class NewEventPage implements OnInit {
public stepSecond = 5;
public color: ThemePalette = 'primary';
@Input() profile:string;
@Input() selectedSegment: string;
@Input() selectedDate: Date;
@@ -93,7 +91,33 @@ export class NewEventPage implements OnInit {
loggeduser: User;
@ViewChild('picker') picker: any;
@ViewChild('fim') fim: any;
// @ViewChild('inicio') inicio: 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];
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
}
constructor(
private modalController: ModalController,
@@ -109,6 +133,9 @@ export class NewEventPage implements OnInit {
) {
this.dateAdapter.setLocale('pt');
this.loggeduser = userService.ValidatedUser;
this.dateControlStart = new FormControl(moment(new Date()));
this.dateControlEnd = new FormControl(moment(new Date()));
}
ngOnInit() {
@@ -136,7 +163,7 @@ export class NewEventPage implements OnInit {
Body: this.eventBody,
Location: '',
CalendarId: '',
CalendarName: '',
CalendarName: 'Oficial',
StartDate: selectedStartdDate,
EndDate: new Date(selectedEndDate),
EventType: 'Reunião',
@@ -194,45 +221,7 @@ export class NewEventPage implements OnInit {
this.date = new Date(2021,9,4,5,6,7);
}
public formGroup = new FormGroup({
date: new FormControl(null, [Validators.required]),
date2: new FormControl(null, [Validators.required])
})
public dateControl = new FormControl(new Date(2021,9,4,5,6,7));
public dateControlMinMax = new FormControl(new Date());
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];
toggleMinDate(evt: any) {
if (evt.checked) {
this._setMinDate();
} else {
this.minDate = null;
}
}
toggleMaxDate(evt: any) {
if (evt.checked) {
this._setMaxDate();
} else {
this.maxDate = null;
}
}
closePicker() {
this.picker.cancel();
this.getDatepickerData()
}
openInicio() {
@@ -250,19 +239,6 @@ export class NewEventPage implements OnInit {
}
}
private _setMinDate() {
const now = new Date();
this.minDate = new Date();
this.minDate.setDate(now.getDate() - 1);
}
private _setMaxDate() {
const now = new Date();
this.maxDate = new Date();
this.maxDate.setDate(now.getDate() + 1);
}
async getDoc(){
const modal = await this.modalController.create({
component: SearchPage,
@@ -292,8 +268,25 @@ export class NewEventPage implements OnInit {
this.setIntervenientCC.emit([]);
}
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, "DD MM YYYY hh:mm"));
this.dateControlEnd = new FormControl(moment(this.postEvent.EndDate, "DD MM YYYY hh:mm"));
}
}
async save(){
this.getDatepickerData()
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
if(this.documents.length >= 0) {
@@ -301,11 +294,16 @@ export class NewEventPage implements OnInit {
}
if(this.loggeduser.Profile == 'MDGPR') {
console.log('MD - Aqui');
console.log(this.postEvent);
// console.log('MD - Aqui');
// console.log(this.postEvent);
this.showLoader = true
this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe(
async (id) => {
this.showLoader = false
const eventId: any = id;
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
@@ -341,8 +339,9 @@ export class NewEventPage implements OnInit {
},
error => {
this.showLoader = false
this.toastService.badRequest('Evento não criado')
});
});
}
else if(this.loggeduser.Profile == 'PR') {
console.log('PR - Aqui');
@@ -388,6 +387,7 @@ export class NewEventPage implements OnInit {
}
afterSave() {
this.getDatepickerData()
this.deleteTemporaryData();
this.onAddEvent.emit(this.postEvent);
@@ -425,6 +425,7 @@ export class NewEventPage implements OnInit {
}
saveTemporaryData() {
this.getDatepickerData()
window['temp.path:/home/agenda/new-event.component.ts'] = {
postEvent: this.postEvent,
eventBody: this.eventBody,
@@ -433,6 +434,8 @@ export class NewEventPage implements OnInit {
}
restoreTemporaryData(): boolean {
const restoredData = window['temp.path:/home/agenda/new-event.component.ts']
if(JSON.stringify(restoredData) != "{}" && undefined != restoredData) {
@@ -440,8 +443,11 @@ export class NewEventPage implements OnInit {
this.eventBody = restoredData.eventBody
this.segment = restoredData.segment
// restore dater for date and hours picker
this.restoreDatepickerData()
return true;
} else {
return false;
}
}