Event personification solved and event confirmation delete

This commit is contained in:
Eudes Inácio
2022-12-16 15:38:59 +01:00
11 changed files with 172 additions and 66 deletions
@@ -124,7 +124,7 @@
[disabled]="disabled"
[min]="currentDate"
>
<mat-datepicker-toggle id="new-inicio" matSuffix [for]="picker1"></mat-datepicker-toggle>
<mat-datepicker-toggle id="new-inicio" matSuffix [for]="picker1" (click)="setStartDate()"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #picker1
[showSpinners]="showSpinners"
[showSeconds]="showSeconds"
@@ -147,16 +147,17 @@
<!--
[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 justify-center align-center materia-top" [class.input-error]="Form?.get('Date')?.invalid && validateFrom ">
<div class="ion-input-class flex-grow-1 justify-center align-center materia-top" [class.input-error]="Form?.get('Date')?.invalid && validateFrom ">
<mat-form-field appearance="none" class="date-hour-picker">
<input matInput [ngxMatDatetimePicker]="fim"
placeholder="Data de fim*"
[(ngModel)]="postEvent.EndDate"
[disabled]="disabled"
[min]="currentDate"
[min]="postEvent.StartDate"
>
<mat-datepicker-toggle id="new-fim" matSuffix [for]="fim"></mat-datepicker-toggle>
<mat-datepicker-toggle id="new-fim" matSuffix [for]="fim" (click)="setEndDate()"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #fim
[showSpinners]="showSpinners"
[showSeconds]="showSeconds"
@@ -47,10 +47,10 @@ export class NewEventPage implements OnInit {
public touchUi = false;
public enableMeridian = false;
public stepHour = 1;
public stepMinute = 5;
public stepSecond = 5;
public stepMinute = 15;
public stepSecond = 15;
public color: ThemePalette = 'primary';
currentDate = new Date();
currentDate = this.roundTimeQuarterHour();
Form: FormGroup;
validateFrom = false
@@ -163,10 +163,7 @@ export class NewEventPage implements OnInit {
if( window.innerWidth >= 1024){
this.modalController.dismiss();
}
};
};
}
@@ -174,6 +171,43 @@ export class NewEventPage implements OnInit {
this.modalController.dismiss();
}
roundTimeQuarterHour() {
var timeToReturn = new Date();
var minutes = timeToReturn.getMinutes();
var hours = timeToReturn.getHours();
// console.log("MINUTOS: " +minutes);
// console.log("BEFORE MINUTES: " +(Math.round(minutes/15) * 15));
var m = (Math.round(minutes/15) * 15) % 60;
var h = minutes > 52 ? (hours === 23 ? 0 : ++hours) : hours;
if (m == 0) {
timeToReturn.setHours(h);
timeToReturn.setMinutes(m);
}else{
if(minutes > m){
m = m + 15;
timeToReturn.setHours(h);
timeToReturn.setMinutes(m);
}
}
console.log("AFTER MINUTES: " +m);
console.log("AFTER HOURS: " +h);
return timeToReturn;
}
setStartDate(){
this.postEvent.StartDate = this.roundTimeQuarterHour();
}
setEndDate(){
this.postEvent.EndDate = this.postEvent.StartDate;
}
getRecurrenceTypes() {
this.eventService.getRecurrenceTypes().subscribe( res => {
@@ -28,7 +28,7 @@
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="edit" slot="end" src="assets/images/icons-edit.svg" ></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="edit" slot="end" src="assets/images/theme/gov/icons-edit.svg" ></ion-icon>
</button>
<button class="btn-no-color" (click)="deleteEvent()">
<button class="btn-no-color" (click)="deleteYesOrNo()">
<ion-icon class="delete" name="trash-sharp"></ion-icon>
</button>
</div>
@@ -121,7 +121,7 @@
<div class="buttons">
<button (click)="editEvent()" full class="btn-ok" shape="round" >Editar</button>
<div class="solid"></div>
<button (click)="deleteEvent()" full class="btn-delete" shape="round" >Eliminar</button>
<button (click)="deleteYesOrNo()" full class="btn-delete" shape="round" >Eliminar</button>
</div>
</div>
@@ -230,6 +230,29 @@ export class ViewEventPage implements OnInit {
}
deleteYesOrNo() {
this.alertController.create({
header: 'Eliminar evento?',
message: '',
buttons: [
{
text: 'Não',
handler: () => {
console.log('Let me think');
}
},
{
text: 'Sim',
handler: () => {
this.deleteEvent();
}
}
]
}).then(res => {
res.present();
});
}
deleteEvent() {
const loader = this.toastService.loading()