bugs solved

This commit is contained in:
Eudes Inácio
2024-06-11 11:23:38 +01:00
parent 05bbbd0242
commit 26c68fa7a2
10 changed files with 181 additions and 113 deletions
+3 -3
View File
@@ -70,16 +70,16 @@
<div *ngIf="environment.presidential"> <div *ngIf="environment.presidential">
<div *ngIf="calendars.roleId == RoleIdService.PRES">PR </div> <div *ngIf="calendars.roleId == RoleIdService.PRES">PR </div>
<div *ngIf="calendars.roleId == RoleIdService.MD && calendars.roleId != SessionStore.user.RoleID">MDGPR</div> <div *ngIf="calendars.roleId == RoleIdService.MD && calendars.roleId != SessionStore.user.RoleID">MDGPR</div>
<div *ngIf="calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES && calendars.wxFullName && calendars.wxUserId != SessionStore.user.UserId "> Agenda do {{calendars.wxFullName}} </div> <div *ngIf="calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES && calendars.wxFullName && calendars.wxUserId != SessionStore.user.UserId "> Agenda {{calendars.wxFullName}} </div>
<div *ngIf="calendars.wxUserId == SessionStore.user.UserId "> <div *ngIf="calendars.wxUserId == SessionStore.user.UserId ">
Minha agenda Minha agenda
</div> </div>
</div> </div>
<div *ngIf="environment.presidential"> <div *ngIf="!environment.presidential">
<div *ngIf="calendars.roleId == RoleIdService.PRES">{{ environment.agendaPR}} </div> <div *ngIf="calendars.roleId == RoleIdService.PRES">{{ environment.agendaPR}} </div>
<div *ngIf="calendars.roleId == RoleIdService.MD && calendars.roleId != SessionStore.user.RoleID">{{ environment.agendaVP}}</div> <div *ngIf="calendars.roleId == RoleIdService.MD && calendars.roleId != SessionStore.user.RoleID">{{ environment.agendaVP}}</div>
<div *ngIf="calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES && calendars.wxFullName && calendars.wxUserId != SessionStore.user.UserId "> Agenda do {{calendars.wxFullName}} </div> <div *ngIf="calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES && calendars.wxFullName && calendars.wxUserId != SessionStore.user.UserId "> Agenda {{calendars.wxFullName}} </div>
<div *ngIf="calendars.wxUserId == SessionStore.user.UserId "> <div *ngIf="calendars.wxUserId == SessionStore.user.UserId ">
Minha agenda Minha agenda
</div> </div>
@@ -86,13 +86,13 @@
<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" > -->
<mat-select [(value)]="postEvent.Category" > <mat-select [(value)]="postEvent.Category" >
<mat-option value="Reunião"> <mat-option value="Meeting">
Reunião Reunião
</mat-option> </mat-option>
<mat-option value="Viagem"> <mat-option value="Travel">
Viagem Viagem
</mat-option> </mat-option>
<mat-option value="Conferência"> <mat-option value="Conference">
Conferência Conferência
</mat-option> </mat-option>
<mat-option value="Encontro"> <mat-option value="Encontro">
@@ -188,17 +188,6 @@
<mat-form-field appearance="none" class="date-hour-picker"> <mat-form-field appearance="none" class="date-hour-picker">
<!-- <input matInput [matDatepicker]="picker1"
placeholder="Data Inicio*"
[(ngModel)]="postEvent.StartDate"
[disabled]="disabled"
>
<mat-datepicker-toggle id="new-inicio" matSuffix [for]="picker1"></mat-datepicker-toggle>
<mat-datepicker #picker1></mat-datepicker> -->
<input matInput [ngxMatDatetimePicker]="picker1" <input matInput [ngxMatDatetimePicker]="picker1"
placeholder="Data Inicio*" placeholder="Data Inicio*"
[(ngModel)]="postEvent.StartDate" [(ngModel)]="postEvent.StartDate"
@@ -222,16 +211,6 @@
<mat-form-field appearance="none" class="date-hour-picker"> <mat-form-field appearance="none" class="date-hour-picker">
<!-- <input matInput [matDatepicker]="picker1"
placeholder="Data Inicio*"
[(ngModel)]="postEvent.StartDate"
[disabled]="disabled"
>
<mat-datepicker-toggle id="new-inicio" matSuffix [for]="picker1"></mat-datepicker-toggle>
<mat-datepicker #picker1></mat-datepicker> -->
<input matInput [ngxMatDatetimePicker]="picker1" <input matInput [ngxMatDatetimePicker]="picker1"
placeholder="Data Inicio*" placeholder="Data Inicio*"
@@ -229,7 +229,7 @@ export class NewEventPage implements OnInit {
Organizer: '', Organizer: '',
Category: 'Reunião', Category: 'Reunião',
HasAttachments: false, HasAttachments: false,
EventRecurrence: { frequency: this.eventRecurence, until: this.autoEndTime, EventRecurrence: { frequency: this.eventRecurence, until: "",
Type: '' }, Type: '' },
}; };
} }
@@ -252,7 +252,7 @@ export class NewEventPage implements OnInit {
Organizer: '', Organizer: '',
Category: 'Reunião', Category: 'Reunião',
HasAttachments: false, HasAttachments: false,
EventRecurrence: { frequency: this.eventRecurence, until: this.autoEndTime, EventRecurrence: { frequency: this.eventRecurence, until: "",
Type: '' }, Type: '' },
}; };
} }
@@ -437,9 +437,9 @@ export class NewEventPage implements OnInit {
participantes: new FormControl(this.taskParticipants, [ participantes: new FormControl(this.taskParticipants, [
Validators.required Validators.required
]), ]),
dateOccurrence: new FormControl(this.postEvent.EventRecurrence.Type.toString() == '-1' ? ['ok'] : this.postEvent.EventRecurrence.LastOccurrence && new Date(this.postEvent.EventRecurrence.LastOccurrence).getTime() > new Date(this.postEvent.EndDate).getTime() ? 'ok' : null, [ /* dateOccurrence: new FormControl(this.postEvent.EventRecurrence.Type.toString() == '-1' ? ['ok'] : this.postEvent.EventRecurrence.LastOccurrence && new Date(this.postEvent.EventRecurrence.LastOccurrence).getTime() > new Date(this.postEvent.EndDate).getTime() ? 'ok' : null, [
Validators.required Validators.required
]), ]), */
}) })
@@ -472,11 +472,14 @@ export class NewEventPage implements OnInit {
this.injectValidation() this.injectValidation()
this.runValidation() this.runValidation()
console.log(new Date(this.postEvent.StartDate).getTime())
console.log(new Date(this.postEvent.EndDate).getTime())
console.log(new Date(this.postEvent.StartDate).getTime() < new Date(this.postEvent.EndDate).getTime() ? 'ok' : null)
if (this.Form.invalid) { if (this.Form.invalid) {
if (new Date(this.postEvent.StartDate).getTime() < new Date(this.postEvent.EndDate).getTime()) { /* if (new Date(this.postEvent.StartDate).getTime() < new Date(this.postEvent.EndDate).getTime()) {
this.toastService._badRequest("Data de inicio menor que a data de fim") this.toastService._badRequest("Data de inicio menor que a data de fim")
} } */
return false return false
} }
@@ -242,35 +242,73 @@ export class ViewEventPage implements OnInit {
} */ } */
deleteYesOrNo() { deleteYesOrNo() {
this.alertController.create({ if (this.loadedEvent.IsRecurring) {
header: 'Eliminar evento?', this.alertController.create({
message: '', header: 'Eliminar evento?',
buttons: [ message: '',
{ inputs: [
text: 'Sim', {
handler: () => { name: 'confirm',
this.deleteEvent(); type: 'checkbox',
label: 'Este evento tem recorrência, deseja eliminar a Sequência de eventos?',
value: 'confirm',
checked: false,
} }
}, ],
{ buttons: [
text: 'Não', {
handler: () => { text: 'Sim',
// sconsole.log('Let me think'); handler: (data) => {
if (data.includes('confirm')) {
this.deleteEvent(true);
} else {
this.deleteEvent(false);
}
}
},
{
text: 'Não',
handler: () => {
// sconsole.log('Let me think');
}
} }
} ]
] }).then(res => {
}).then(res => { res.present();
res.present(); });
}); } else {
this.alertController.create({
header: 'Eliminar evento?',
message: '',
buttons: [
{
text: 'Sim',
handler: (data) => {
this.deleteEvent(false);
}
},
{
text: 'Não',
handler: () => {
// sconsole.log('Let me think');
}
}
]
}).then(res => {
res.present();
});
}
} }
deleteEvent() { deleteEvent(deleteAll) {
const loader = this.toastService.loading() const loader = this.toastService.loading()
console.log(this.loadedEvent.EventId) console.log(this.loadedEvent.EventId)
this.agendaDataRepository.deleteEvent(this.loadedEvent.EventId).subscribe(async () => { this.agendaDataRepository.deleteEvent(this.loadedEvent.EventId,deleteAll).subscribe(async () => {
const alert = await this.alertController.create({ const alert = await this.alertController.create({
cssClass: 'my-custom-class', cssClass: 'my-custom-class',
header: 'Evento removido', header: 'Evento removido',
@@ -292,47 +330,47 @@ export class ViewEventPage implements OnInit {
/* if (this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { /* if (this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => { this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => {
const alert = await this.alertController.create({ const alert = await this.alertController.create({
cssClass: 'my-custom-class', cssClass: 'my-custom-class',
header: 'Evento removido', header: 'Evento removido',
buttons: ['OK'] buttons: ['OK']
}); });
setTimeout(() => { setTimeout(() => {
alert.dismiss(); alert.dismiss();
}, 1500); }, 1500);
this.goBack(); this.goBack();
this.httpErrorHandle.httpsSucessMessagge('delete event') this.httpErrorHandle.httpsSucessMessagge('delete event')
}, () => { }, }, () => { },
() => { () => {
loader.remove(); loader.remove();
}); });
} else { } else {
this.eventsService.genericDeleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName, this.loadedEvent.CalendarId).subscribe(async () => { this.eventsService.genericDeleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName, this.loadedEvent.CalendarId).subscribe(async () => {
const alert = await this.alertController.create({ const alert = await this.alertController.create({
cssClass: 'my-custom-class', cssClass: 'my-custom-class',
header: 'Evento removido', header: 'Evento removido',
buttons: ['OK'] buttons: ['OK']
}); });
setTimeout(() => { setTimeout(() => {
alert.dismiss(); alert.dismiss();
}, 1500); }, 1500);
this.goBack(); this.goBack();
this.httpErrorHandle.httpsSucessMessagge('delete event') this.httpErrorHandle.httpsSucessMessagge('delete event')
}, (error) => { }, (error) => {
this.httpErrorHandle.httpStatusHandle(error) this.httpErrorHandle.httpStatusHandle(error)
}, },
() => { () => {
loader.remove(); loader.remove();
}); });
} */ } */
} }
@@ -97,6 +97,7 @@ export class AgendaDataRepositoryService {
} }
createEvent(eventData: Event, CalendarName, documents) { createEvent(eventData: Event, CalendarName, documents) {
console.log('create repository 1',eventData)
let eventInput = { let eventInput = {
userId: CalendarName, userId: CalendarName,
@@ -104,20 +105,22 @@ export class AgendaDataRepositoryService {
subject: eventData.Subject, subject: eventData.Subject,
body: eventData.Body.Text, body: eventData.Body.Text,
location: eventData.Location, location: eventData.Location,
startDate: eventData.StartDate.toISOString(), startDate: this.utils.addOneHourToIsoString(eventData.StartDate.toISOString()),
endDate: eventData.EndDate.toISOString(), endDate: this.utils.addOneHourToIsoString(eventData.EndDate.toISOString()),
type: this.utils.calendarTypeSeleted(eventData.Category), type: this.utils.calendarTypeSeleted(eventData.Category),
category: this.utils.calendarCategorySeleted(eventData.CalendarName), category: this.utils.calendarCategorySeleted(eventData.CalendarName),
attendees: this.utils.attendeesAdded(eventData.Attendees), attendees: this.utils.attendeesAdded(eventData.Attendees),
attachments: this.utils.documentAdded(documents), attachments: this.utils.documentAdded(documents),
recurrence: { recurrence: {
frequency: this.utils.eventRecurence(eventData.EventRecurrence.frequency), frequency: this.utils.eventRecurence(eventData.EventRecurrence.frequency),
until: eventData.EndDate.toISOString(), until:((eventData.EventRecurrence.until === "") ? this.utils.addOneHourToIsoString(eventData.EndDate.toISOString()) : eventData.EventRecurrence.until),
}, },
organizerId: SessionStore.user.UserId, organizerId: SessionStore.user.UserId,
isAllDayEvent: eventData.IsAllDayEvent, isAllDayEvent: eventData.IsAllDayEvent,
} }
console.log('create repository 2',eventInput)
return this.agendaDataService.createEvent(eventInput) return this.agendaDataService.createEvent(eventInput)
} }
@@ -152,8 +155,8 @@ export class AgendaDataRepositoryService {
return this.agendaDataService.addEventAttachment(id, { attachments: this.utils.documentAdded(attachmentData) }); return this.agendaDataService.addEventAttachment(id, { attachments: this.utils.documentAdded(attachmentData) });
} }
deleteEvent(eventId) { deleteEvent(eventId,deleteAll) {
return this.agendaDataService.deleteEvent(eventId, false) return this.agendaDataService.deleteEvent(eventId, deleteAll)
} }
removeEventAttachment(eventId, attachmentData) { removeEventAttachment(eventId, attachmentData) {
@@ -67,8 +67,8 @@ export class EventMapper {
"DayOfWeek": null, "DayOfWeek": null,
"Month": null, "Month": null,
"LastOccurrence": null, "LastOccurrence": null,
"frequency": dto.eventRecurrence.frequency, "frequency": dto.eventRecurrence?.frequency,
"until": dto.eventRecurrence.until "until": dto.eventRecurrence?.until
}, },
"Attachments": dto.attachments.map( e => ({ "Attachments": dto.attachments.map( e => ({
"Id": e.id, "Id": e.id,
@@ -176,4 +176,12 @@ export class Utils {
} }
return selectedType[recurenceType]; return selectedType[recurenceType];
} }
addOneHourToIsoString(isoDateString) {
let date = new Date(isoDateString);
/* date.setHours(date.getHours()); */
let newIsoDateString = date.toISOString();
return newIsoDateString;
}
} }
@@ -102,13 +102,13 @@
<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" > -->
<mat-select [(value)]="postEvent.Category" > <mat-select [(value)]="postEvent.Category" >
<mat-option value="Reunião"> <mat-option value="Meeting">
Reunião Reunião
</mat-option> </mat-option>
<mat-option value="Viagem"> <mat-option value="Travel">
Viagem Viagem
</mat-option> </mat-option>
<mat-option value="Conferência"> <mat-option value="Conference">
Conferência Conferência
</mat-option> </mat-option>
<mat-option value="Encontro"> <mat-option value="Encontro">
@@ -207,7 +207,6 @@ export class NewEventPage implements OnInit {
} }
ngOnInit() { ngOnInit() {
console.log(' INTERVENIENTES', this.taskParticipants) console.log(' INTERVENIENTES', this.taskParticipants)
this.changeProfileService.registerCallback(() => { this.changeProfileService.registerCallback(() => {
this.initializeData() this.initializeData()
@@ -278,7 +277,7 @@ export class NewEventPage implements OnInit {
Category: 'Reunião', Category: 'Reunião',
HasAttachments: false, HasAttachments: false,
EventRecurrence: { EventRecurrence: {
frequency: this.eventRecurence, until: this.autoEndTime, frequency: this.eventRecurence, until: "",
Type: '' Type: ''
}, },
}; };
@@ -302,7 +301,7 @@ export class NewEventPage implements OnInit {
Organizer: '', Organizer: '',
Category: 'Reunião', Category: 'Reunião',
HasAttachments: false, HasAttachments: false,
EventRecurrence: { frequency: this.eventRecurence, until: this.autoEndTime, EventRecurrence: { frequency: this.eventRecurence, until: "",
Type: '' }, Type: '' },
} }
} }
@@ -595,6 +594,7 @@ export class NewEventPage implements OnInit {
}, ((error) => { }, ((error) => {
console.log('create event error: ', error) console.log('create event error: ', error)
loader.remove(); loader.remove();
this.hhtpErrorHandle.httpStatusHandle(error.status)
})); }));
@@ -92,7 +92,7 @@ export class ViewEventPage implements OnInit {
} }
toDateString(e) { toDateString(e) {
return new Date(e).toDateString() return new Date(e).toString()
} }
openOptions() { openOptions() {
@@ -140,19 +140,54 @@ export class ViewEventPage implements OnInit {
this.viewEventDetailDismiss.emit({ this.viewEventDetailDismiss.emit({
type: 'close' type: 'close'
}) })
console.log(res.error)
} }
} }
deleteYesOrNo() { deleteYesOrNo() {
this.alertController.create({ if (this.loadedEvent.IsRecurring) {
this.alertController.create({
header: 'Eliminar evento?',
message: '',
inputs: [
{
name: 'confirm',
type: 'checkbox',
label: 'Este evento tem recorrência, deseja eliminar a Sequência de eventos?',
value: 'confirm',
checked: false,
}
],
buttons: [
{
text: 'Sim',
handler: (data) => {
if (data.includes('confirm')) {
this.deleteEvent_v2(true);
} else {
this.deleteEvent_v2(false);
}
}
},
{
text: 'Não',
handler: () => {
}
}
]
}).then(res => {
res.present();
});
} else {
this.alertController.create({
header: 'Eliminar evento?', header: 'Eliminar evento?',
message: '', message: '',
buttons: [ buttons: [
{ {
text: 'Sim', text: 'Sim',
handler: () => { handler: () => {
this.deleteEvent_v2(); this.deleteEvent_v2(false);
} }
}, },
{ {
@@ -164,12 +199,14 @@ export class ViewEventPage implements OnInit {
}).then(res => { }).then(res => {
res.present(); res.present();
}); });
}
} }
deleteEvent_v2() { deleteEvent_v2(deleteAll) {
console.log(this.loadedEvent.EventId) console.log(this.loadedEvent.EventId)
const loader = this.toastService.loading() const loader = this.toastService.loading()
this.agendaDataRepository.deleteEvent(this.loadedEvent.EventId).subscribe(() => { this.agendaDataRepository.deleteEvent(this.loadedEvent.EventId,deleteAll).subscribe(() => {
console.log() console.log()
this.httpErrorHandle.httpsSucessMessagge('delete event') this.httpErrorHandle.httpsSucessMessagge('delete event')
this.close(); this.close();