mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
define date of last occurrence on agenda new and edit function
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user