define date of last occurrence on agenda new and edit function

This commit is contained in:
EQUILIBRIUM\hirondino.van-dunem
2022-06-14 14:23:17 +01:00
parent 125fd51cee
commit c965f0b548
2 changed files with 82 additions and 0 deletions
@@ -365,6 +365,8 @@ export class NewEventPage implements OnInit {
onSelectedRecurringChanged(ev:any){
this.calculetedLastOccurrence(ev);
if(ev.length > 1){
this.postEvent.EventRecurrence.Type = ev.filter(data => data != '-1');
@@ -374,8 +376,45 @@ export class NewEventPage implements OnInit {
}
}
calculetedLastOccurrence(type:number){
console.log(type);
var valor;
var opcao: boolean;
if (type == 0) {
valor = 7;
opcao = true;
} else if(type == 1){
valor = 30;
opcao = true;
} else if(type == 2){
valor = 1;
opcao = false;
}else if(type == 3){
valor = 5;
opcao = false;
}
this.defineLastOccurrence(valor, opcao);
}
defineLastOccurrence(valor:number, opcao:boolean){
var time = new Date(this.postEvent.EndDate);
if (opcao == true) {
time.setDate(time.getDate() + valor);
this.postEvent.EventRecurrence.LastOccurrence = time;
} else {
time = new Date(
time.getFullYear() + valor,
time.getMonth(),
time.getDate(),
time.getHours(),
time.getMinutes()
);
this.postEvent.EventRecurrence.LastOccurrence = time;
}
}
async save() {
this.injectValidation()