define date of last occurrence on agenda new and edit function in mobile and tablet

This commit is contained in:
EQUILIBRIUM\hirondino.van-dunem
2022-06-22 16:35:47 +01:00
parent 4ffa969b04
commit 5501b4a583
5 changed files with 89 additions and 6 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
{
"server": {
"url": "http://192.168.0.95:8100"
"url": "http://192.168.0.57:8101",
"originalUrl": "http://192.168.0.95:8100"
}
}
@@ -68,6 +68,7 @@ export class EditEventPage implements OnInit {
public stepHour = 1;
public stepMinute = 5;
public stepSecond = 5;
currentDate = new Date();
loadedEventAttachments: Attachment[] = [];
taskParticipants: any = [];
@@ -98,7 +99,7 @@ export class EditEventPage implements OnInit {
this.isEventEdited = false;
/* this.postEvent.EventRecurrence = { Type:'-1', LastOccurrence:''}; */
this.postEvent = this.navParams.get('event');
console.log(this.postEvent);
this.caller = this.navParams.get('caller');
this.initCalendarName = this.postEvent.CalendarName;
@@ -172,6 +173,8 @@ export class EditEventPage implements OnInit {
onSelectedRecurringChanged(ev?:any) {
this.calculetedLastOccurrence(ev);
if(ev.length > 1){
this.selectedRecurringType = ev.filter(data => data != '-1');
@@ -181,6 +184,45 @@ export class EditEventPage 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;
}
}
runValidation() {
this.validateFrom = true
@@ -199,6 +199,8 @@ export class NewEventPage implements OnInit {
onSelectedRecurringChanged(ev:any) {
this.calculetedLastOccurrence(ev);
if(ev.length > 1) {
this.selectedRecurringType = ev.filter(data => data != '-1');
@@ -208,6 +210,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;
}
}
runValidation() {
this.validateFrom = true;
@@ -57,13 +57,12 @@
<ion-label>
<p>{{customDate}}</p>
<p>das {{loadedEvent.StartDate | date: 'HH:mm'}} às {{loadedEvent.EndDate | date: 'HH:mm'}}</p>
<p *ngIf="!loadedEvent.IsRecurring">(Não se repete)</p>
<p *ngIf="loadedEvent.IsRecurring">
<p>
<span *ngIf="loadedEvent.EventRecurrence.Type == 0">Diário</span>
<span *ngIf="loadedEvent.EventRecurrence.Type == 1">Semanal</span>
<span *ngIf="loadedEvent.EventRecurrence.Type == 2">Mensal</span>
<span *ngIf="loadedEvent.EventRecurrence.Type == 3">Anual</span>
<span *ngIf="loadedEvent.EventRecurrence.Type == -1">Nunca</span>
<span *ngIf="loadedEvent.EventRecurrence.Type == -1">(Não se repete)</span>
</p>
</ion-label>
</div>
@@ -129,7 +129,7 @@ export class EditEventPage implements OnInit {
this.postEvent.EventRecurrence.Type = this.postEvent.EventRecurrence.Type.toString();
this.postEvent.EventRecurrence.LastOccurrence = this.currentDate;
// this.postEvent.EventRecurrence.LastOccurrence = this.currentDate;
setTimeout(() => {
this.postEvent.EventRecurrence.Type = this.postEvent.EventRecurrence.Type.toString();