criar evento com recorrencia

This commit is contained in:
tiago.kayaya
2021-07-12 14:32:43 +01:00
parent d68a89e7c9
commit aa3a2e0420
4 changed files with 185 additions and 131 deletions
@@ -149,6 +149,9 @@ export class NewEventPage implements OnInit {
} }
}; };
console.log(this.postEvent);
} }
close(){ close(){
@@ -58,7 +58,7 @@
<div class="ion-icon-class"> <div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon> <ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
</div> </div>
<div class="ion-input-class flex-grow-1 d-flex justify-center align-center material-inputs materia-top "> <div class="ion-input-class flex-grow-1 justify-center align-center material-inputs ">
<mat-form-field appearance="none" class="width-100" color="ion-color-secondary" placeholder="Selecione agenda"> <mat-form-field appearance="none" class="width-100" color="ion-color-secondary" placeholder="Selecione agenda">
<mat-select [(value)]="postEvent.CalendarName" > <mat-select [(value)]="postEvent.CalendarName" >
@@ -80,7 +80,7 @@
<div class="ion-icon-class"> <div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon> <ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon>
</div> </div>
<div class="ion-input-class flex-grow-1 d-flex justify-center align-center material-inputs materia-top"> <div class="ion-input-class flex-grow-1 justify-center align-center material-inputs">
<mat-form-field appearance="none" class="width-100" placeholder="Sample Type" required> <mat-form-field appearance="none" class="width-100" placeholder="Sample Type" required>
<!-- <input matInput type="text" > --> <!-- <input matInput type="text" > -->
@@ -112,7 +112,7 @@
<!-- <!--
[className]="Form?.get('Subject')?.invalid ? 'input-error ion-input-class flex-grow-1' : 'ion-input-class ion-input-class flex-grow-1' " [className]="Form?.get('Subject')?.invalid ? 'input-error ion-input-class flex-grow-1' : 'ion-input-class ion-input-class flex-grow-1' "
--> -->
<div class="ion-input-class flex-grow-1" > <div class="ion-input-class flex-grow-1 justify-center align-center material-inputs materia-top">
<mat-form-field class="date-hour-picker"> <mat-form-field class="date-hour-picker">
<input matInput [ngxMatDatetimePicker]="picker1" <input matInput [ngxMatDatetimePicker]="picker1"
@@ -144,7 +144,7 @@
<!-- <!--
[className]="Form?.get('Subject')?.invalid ? 'input-error ion-input-class flex-grow-1' : 'ion-input-class ion-input-class flex-grow-1' " [className]="Form?.get('Subject')?.invalid ? 'input-error ion-input-class flex-grow-1' : 'ion-input-class ion-input-class flex-grow-1' "
--> -->
<div (click)="openFim()" class="ion-input-class flex-grow-1" > <div (click)="openFim()" class="ion-input-class flex-grow-1 justify-center align-center materia-top">
<mat-form-field class="date-hour-picker"> <mat-form-field class="date-hour-picker">
<input matInput [ngxMatDatetimePicker]="fim" <input matInput [ngxMatDatetimePicker]="fim"
@@ -168,20 +168,43 @@
</div> </div>
</div> </div>
<div class="container-div">
<!-- <div class="container-div width-100">
<div class="ion-item-class-2">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-refresh.svg"></ion-icon>
</div>
<div class="ion-input-class" [class.input-error]="Form?.get('Categories')?.invalid && validateFrom ">
<ion-select placeholder="Selecione a repetição*"
[(ngModel)]="selectedRecurringType"
(ngModelChange)="onSelectedRecurringChanged($event)"
interface="action-sheet"
Cancel-text="Cancelar" required>
<ion-select-option *ngFor="let recurring of recurringTypes" value="{{recurring.Code}}">{{recurring.Description}}</ion-select-option>
</ion-select>
</div>
</div>
</div> -->
<div class="container-div width-100">
<div class="ion-item-class-2 d-flex"> <div class="ion-item-class-2 d-flex">
<div class="ion-icon-class"> <div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-refresh.svg"></ion-icon> <ion-icon slot="start" src="assets/images/icons-refresh.svg"></ion-icon>
</div> </div>
<div class="ion-input-class flex-grow-1 d-flex justify-center align-center material-inputs materia-top"> <div class="ion-input-class flex-grow-1">
<mat-form-field appearance="none" floatLabel="never" class="width-100" value="false" interface="action-sheet" required> <mat-form-field appearance="none" floatLabel="never" class="width-100" value="false" interface="action-sheet" required>
<mat-select placeholder="Selecione repetição*" [(ngModel)]="postEvent.IsRecurring"> <mat-select placeholder="Selecione repetição*"
<mat-option value="false"> [(ngModel)]="postEvent.EventRecurrence.Type"
Não se repete (ngModelChange)="onSelectedRecurringChanged($event)">
</mat-option> <mat-option
<mat-option value="true"> *ngFor="let recurring of recurringTypes" value="{{recurring.Code}}"
Repete >
{{recurring.Description}}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
@@ -66,6 +66,8 @@ export class NewEventPage implements OnInit {
public stepMinute = 5; public stepMinute = 5;
public stepSecond = 5; public stepSecond = 5;
public color: ThemePalette = 'primary'; public color: ThemePalette = 'primary';
recurringTypes: any;
selectedRecurringType: any;
@Input() profile:string; @Input() profile:string;
@Input() selectedSegment: string; @Input() selectedSegment: string;
@@ -138,7 +140,7 @@ export class NewEventPage implements OnInit {
ngOnInit() { ngOnInit() {
this.getRecurrenceTypes();
if(!this.restoreTemporaryData()){ if(!this.restoreTemporaryData()){
// clear // clear
@@ -173,7 +175,7 @@ export class NewEventPage implements OnInit {
Organizer: '', Organizer: '',
Categories: ['Reunião'], Categories: ['Reunião'],
HasAttachments: false, HasAttachments: false,
EventRecurrence: null, EventRecurrence: {Type:'-1'},
}; };
} }
else{ else{
@@ -195,7 +197,7 @@ export class NewEventPage implements OnInit {
Organizer: '', Organizer: '',
Categories: ['Reunião'], Categories: ['Reunião'],
HasAttachments: false, HasAttachments: false,
EventRecurrence: null, EventRecurrence: {Type:'-1'},
}; };
} }
@@ -221,7 +223,8 @@ export class NewEventPage implements OnInit {
this.date = new Date(2021,9,4,5,6,7); this.date = new Date(2021,9,4,5,6,7);
this.getDatepickerData() this.getDatepickerData()
this.injectValidation() this.injectValidation();
} }
runValidation() { runValidation() {
@@ -303,6 +306,24 @@ export class NewEventPage implements OnInit {
this.setIntervenientCC.emit([]); this.setIntervenientCC.emit([]);
} }
getRecurrenceTypes() {
this.eventService.getRecurrenceTypes().subscribe(res=>{
console.log(res);
this.recurringTypes = res;
});
}
onSelectedRecurringChanged(ev:any){
console.log(ev);
if(ev.length > 1){
console.log(ev.filter(data => data != '-1'));
this.postEvent.EventRecurrence.Type = ev.filter(data => data != '-1');
}
if(ev.length == 0){
this.postEvent.EventRecurrence.Type = "-1";
}
}
getDatepickerData() { getDatepickerData() {
if (this.postEvent) { if (this.postEvent) {
this.postEvent.StartDate = this.dateStart this.postEvent.StartDate = this.dateStart
@@ -332,6 +353,9 @@ export class NewEventPage implements OnInit {
if(this.documents.length >= 0) { if(this.documents.length >= 0) {
this.postEvent.HasAttachments = true; this.postEvent.HasAttachments = true;
} }
if(this.selectedRecurringType != '-1'){
/* this.postEvent.EventRecurrence.Type = this.selectedRecurringType; */
}
if(this.loggeduser.Profile == 'MDGPR') { if(this.loggeduser.Profile == 'MDGPR') {
// console.log('MD - Aqui'); // console.log('MD - Aqui');
@@ -342,7 +366,10 @@ export class NewEventPage implements OnInit {
console.log(this.postEvent); console.log(this.postEvent);
let loader = this.toastService.loading() let loader = this.toastService.loading();
console.log(this.postEvent);
this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe( this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe(
async (id) => { async (id) => {
@@ -391,6 +418,7 @@ export class NewEventPage implements OnInit {
this.showLoader = false this.showLoader = false
this.toastService.badRequest('Evento não criado') this.toastService.badRequest('Evento não criado')
}); });
loader.remove();
} }
else if(this.loggeduser.Profile == 'PR') { else if(this.loggeduser.Profile == 'PR') {
console.log('PR - Aqui'); console.log('PR - Aqui');