bugs solved

This commit is contained in:
Eudes Inácio
2024-02-29 09:58:08 +01:00
parent 71699c3c39
commit d59f772859
5 changed files with 89 additions and 72 deletions
@@ -244,6 +244,9 @@ export class DocumentSetUpMeetingPage implements OnInit {
runValidation() { runValidation() {
this.validateFrom = true this.validateFrom = true
if (new Date(this.postData.StartDate).getTime() > new Date(this.postData.EndDate).getTime()) {
this.toastService._badRequest("A data de fim não pode ser inferior a data de início do evento")
}
} }
get dateValid() { get dateValid() {
@@ -305,7 +308,7 @@ export class DocumentSetUpMeetingPage implements OnInit {
async saveTask() { async saveTask() {
if (this.loggeduser.Profile == 'MDGPR') { if (this.loggeduser.Profile != 'PR') {
this.injectValidation() this.injectValidation()
this.runValidation() this.runValidation()
if (this.Form.invalid) return false if (this.Form.invalid) return false
@@ -45,17 +45,17 @@ export class EditEventPage implements OnInit {
validateFrom = false validateFrom = false
postEvent: Event; postEvent: Event;
isRecurring:string; isRecurring: string;
isEventEdited: boolean; isEventEdited: boolean;
loadedEvent: Event; loadedEvent: Event;
eventBody: EventBody; eventBody: EventBody;
segment:string = "true"; segment: string = "true";
profile:string; profile: string;
eventAttendees: EventPerson[]; eventAttendees: EventPerson[];
selectedSegment: string; selectedSegment: string;
selectedDate: Date; selectedDate: Date;
initCalendarName: string; initCalendarName: string;
caller:string; caller: string;
recurringTypes: any; recurringTypes: any;
selectedRecurringType: any; selectedRecurringType: any;
@@ -68,7 +68,7 @@ export class EditEventPage implements OnInit {
public showSeconds = false; public showSeconds = false;
public touchUi = false; public touchUi = false;
public enableMeridian = false; public enableMeridian = false;
public endMinDate = new Date(new Date().getTime() + 15 * 60000).toISOString().slice(0,10) public endMinDate = new Date(new Date().getTime() + 15 * 60000).toISOString().slice(0, 10)
public maxDate: any; public maxDate: any;
public stepHour = 1; public stepHour = 1;
public stepMinute = 15; public stepMinute = 15;
@@ -107,18 +107,19 @@ export class EditEventPage implements OnInit {
this.isEventEdited = false; this.isEventEdited = false;
/* this.postEvent.EventRecurrence = { Type:'-1', LastOccurrence:''}; */ /* this.postEvent.EventRecurrence = { Type:'-1', LastOccurrence:''}; */
this.postEvent = this.navParams.get('event'); this.postEvent = this.navParams.get('event');
// console.log(this.postEvent); this.postEvent.StartDate = new Date(this.ajustMinuts(this.postEvent.StartDate))
this.postEvent.EndDate = new Date(this.ajustMinuts(this.postEvent.EndDate))
this.caller = this.navParams.get('caller'); this.caller = this.navParams.get('caller');
this.initCalendarName = this.postEvent.CalendarName; this.initCalendarName = this.postEvent.CalendarName;
for(const index in this.postEvent.Attendees) { for (const index in this.postEvent.Attendees) {
const user = this.postEvent.Attendees[index] const user = this.postEvent.Attendees[index]
const userData = this.contactsService.constacts.find(e => user.EmailAddress == e.EmailAddress) const userData = this.contactsService.constacts.find(e => user.EmailAddress == e.EmailAddress)
if(userData) { if (userData) {
this.postEvent.Attendees[index].UserType = userData.UserType this.postEvent.Attendees[index].UserType = userData.UserType
} }
@@ -126,20 +127,20 @@ export class EditEventPage implements OnInit {
if(this.postEvent){ if (this.postEvent) {
if( this.postEvent.Body){ if (this.postEvent.Body) {
if(typeof(this.postEvent.Body.Text) == 'string'){ if (typeof (this.postEvent.Body.Text) == 'string') {
this.postEvent.Body.Text = this.postEvent.Body.Text.replace(/<[^>]+>/g, ''); this.postEvent.Body.Text = this.postEvent.Body.Text.replace(/<[^>]+>/g, '');
} }
} }
} }
if(this.postEvent.Attendees == null) { if (this.postEvent.Attendees == null) {
this.taskParticipants = [] this.taskParticipants = []
} else { } else {
this.postEvent.Attendees.forEach(e =>{ this.postEvent.Attendees.forEach(e => {
if(e.IsRequired){ if (e.IsRequired) {
this.taskParticipants.push(e); this.taskParticipants.push(e);
} else { } else {
this.taskParticipantsCc.push(e); this.taskParticipantsCc.push(e);
@@ -147,7 +148,7 @@ export class EditEventPage implements OnInit {
}) })
} }
if(this.postEvent.IsRecurring == false) { if (this.postEvent.IsRecurring == false) {
this.isRecurring = "Não se repete"; this.isRecurring = "Não se repete";
} }
else { else {
@@ -165,12 +166,12 @@ export class EditEventPage implements OnInit {
window.onresize = (event) => { window.onresize = (event) => {
// if not mobile remove all component // if not mobile remove all component
if( window.innerWidth >= 1024) { if (window.innerWidth >= 1024) {
this.modalController.dismiss(); this.modalController.dismiss();
} }
} }
if(window.innerWidth > 800){ if (window.innerWidth > 800) {
this.showAttendees=true; this.showAttendees = true;
} }
this.getRecurrenceTypes(); this.getRecurrenceTypes();
@@ -185,8 +186,8 @@ export class EditEventPage implements OnInit {
} }
myInterval = setInterval(() => { myInterval = setInterval(() => {
document.querySelectorAll('.ngx-mat-timepicker input').forEach((e :any) => { document.querySelectorAll('.ngx-mat-timepicker input').forEach((e: any) => {
if(e) { if (e) {
e.disabled = true; e.disabled = true;
} }
}) })
@@ -202,11 +203,11 @@ export class EditEventPage implements OnInit {
goBack() { goBack() {
this.router.navigate(['/home',this.caller]); this.router.navigate(['/home', this.caller]);
} }
getRecurrenceTypes() { getRecurrenceTypes() {
this.eventsService.getRecurrenceTypes().subscribe(res=>{ this.eventsService.getRecurrenceTypes().subscribe(res => {
this.recurringTypes = res; this.recurringTypes = res;
}); });
@@ -217,7 +218,7 @@ export class EditEventPage implements OnInit {
const minutes = date.getMinutes(); const minutes = date.getMinutes();
date.setSeconds(0); date.setSeconds(0);
if(minutes % 15 != 0) { if (minutes % 15 != 0) {
if (minutes > 45) { if (minutes > 45) {
date.setMinutes(60) date.setMinutes(60)
@@ -234,40 +235,40 @@ export class EditEventPage implements OnInit {
return date return date
} }
roundTimeQuarterHourPlus15(date:Date) { roundTimeQuarterHourPlus15(date: Date) {
const _date = new Date(date); const _date = new Date(date);
const minutes = _date .getMinutes(); const minutes = _date.getMinutes();
_date .setMinutes(minutes + 15) _date.setMinutes(minutes + 15)
return _date return _date
} }
onSelectedRecurringChanged(ev?:any) { onSelectedRecurringChanged(ev?: any) {
this.calculetedLastOccurrence(ev); this.calculetedLastOccurrence(ev);
if(ev.length > 1){ if (ev.length > 1) {
this.selectedRecurringType = ev.filter(data => data != '-1'); this.selectedRecurringType = ev.filter(data => data != '-1');
} }
if(ev.length == 0){ if (ev.length == 0) {
this.selectedRecurringType = "-1"; this.selectedRecurringType = "-1";
} }
} }
calculetedLastOccurrence(type:number){ calculetedLastOccurrence(type: number) {
// console.log(type); // console.log(type);
var valor; var valor;
var opcao: boolean; var opcao: boolean;
if (type == 0) { if (type == 0) {
valor = 7; valor = 7;
opcao = true; opcao = true;
} else if(type == 1){ } else if (type == 1) {
valor = 30; valor = 30;
opcao = true; opcao = true;
} else if(type == 2){ } else if (type == 2) {
valor = 1; valor = 1;
opcao = false; opcao = false;
}else if(type == 3){ } else if (type == 3) {
valor = 5; valor = 5;
opcao = false; opcao = false;
} }
@@ -275,7 +276,7 @@ export class EditEventPage implements OnInit {
} }
defineLastOccurrence(valor:number, opcao:boolean){ defineLastOccurrence(valor: number, opcao: boolean) {
var time = new Date(this.postEvent.EndDate); var time = new Date(this.postEvent.EndDate);
if (opcao == true) { if (opcao == true) {
time.setDate(time.getDate() + valor); time.setDate(time.getDate() + valor);
@@ -317,10 +318,10 @@ export class EditEventPage implements OnInit {
IsRecurring: new FormControl(this.postEvent.IsRecurring, [ IsRecurring: new FormControl(this.postEvent.IsRecurring, [
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
]), ]),
Date: new FormControl(new Date(this.postEvent.StartDate).getTime() <= new Date(this.postEvent.EndDate).getTime()? 'ok': null,[ Date: new FormControl(new Date(this.postEvent.StartDate).getTime() <= new Date(this.postEvent.EndDate).getTime() ? 'ok' : null, [
Validators.required Validators.required
]), ]),
@@ -333,7 +334,7 @@ export class EditEventPage implements OnInit {
openInicio() { openInicio() {
let input: any = document.querySelector('#new-inicio') let input: any = document.querySelector('#new-inicio')
if(input) { if (input) {
input.click() input.click()
} }
@@ -341,14 +342,14 @@ export class EditEventPage implements OnInit {
openFim() { openFim() {
let input: any = document.querySelector('#new-fim') let input: any = document.querySelector('#new-fim')
if(input) { if (input) {
input.click() input.click()
} }
} }
openLastOccurrence() { openLastOccurrence() {
let input: any = document.querySelector('#last-occurrence') let input: any = document.querySelector('#last-occurrence')
if(input) { if (input) {
input.click() input.click()
} }
} }
@@ -359,8 +360,8 @@ export class EditEventPage implements OnInit {
this.injectValidation() this.injectValidation()
this.runValidation() this.runValidation()
if(this.Form.invalid) return false; if (this.Form.invalid) return false;
if(this.selectedRecurringType != '-1') { if (this.selectedRecurringType != '-1') {
this.postEvent.EventRecurrence.Type = this.selectedRecurringType; this.postEvent.EventRecurrence.Type = this.selectedRecurringType;
} }
@@ -371,14 +372,14 @@ export class EditEventPage implements OnInit {
this.postEvent.EventRecurrence.Type = this.selectedRecurringType; this.postEvent.EventRecurrence.Type = this.selectedRecurringType;
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { if (this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => { this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => {
if(window['reloadCalendar']) { if (window['reloadCalendar']) {
window['reloadCalendar']() window['reloadCalendar']()
} }
if(this.initCalendarName != this.postEvent.CalendarName) { if (this.initCalendarName != this.postEvent.CalendarName) {
let body = { let body = {
"EventId": this.postEvent.EventId, "EventId": this.postEvent.EventId,
@@ -386,7 +387,7 @@ export class EditEventPage implements OnInit {
} }
try { try {
await this.eventsService.changeAgenda(body).toPromise(); await this.eventsService.changeAgenda(body).toPromise();
} catch (error) {} } catch (error) { }
finally { finally {
} }
@@ -400,11 +401,11 @@ export class EditEventPage implements OnInit {
} else { } else {
this.eventsService.editEvent(this.postEvent, 2, 3, this.postEvent.CalendarId).subscribe(async () => { this.eventsService.editEvent(this.postEvent, 2, 3, this.postEvent.CalendarId).subscribe(async () => {
if(window['reloadCalendar']) { if (window['reloadCalendar']) {
window['reloadCalendar']() window['reloadCalendar']()
} }
if(this.initCalendarName != this.postEvent.CalendarName) { if (this.initCalendarName != this.postEvent.CalendarName) {
let body = { let body = {
"EventId": this.postEvent.EventId, "EventId": this.postEvent.EventId,
@@ -412,7 +413,7 @@ export class EditEventPage implements OnInit {
} }
try { try {
await this.eventsService.changeAgenda(body).toPromise(); await this.eventsService.changeAgenda(body).toPromise();
} catch (error) {} } catch (error) { }
finally { finally {
} }
@@ -440,11 +441,11 @@ export class EditEventPage implements OnInit {
try { try {
for( let e of this.loadedEventAttachments) { for (let e of this.loadedEventAttachments) {
const id: any = e.Id const id: any = e.Id
const remove = e['remove'] const remove = e['remove']
if ( id == 'add') { if (id == 'add') {
//data.selected //data.selected
const DocumentToSave = { const DocumentToSave = {
SourceTitle: e.SourceName, SourceTitle: e.SourceName,
@@ -459,7 +460,7 @@ export class EditEventPage implements OnInit {
// await this.attachmentsService.setEventAttachmentById(DocumentToSave).toPromise(); // await this.attachmentsService.setEventAttachmentById(DocumentToSave).toPromise();
} else if(remove) { } else if (remove) {
await this.attachmentsService.deleteEventAttachmentById(e.Id).toPromise() await this.attachmentsService.deleteEventAttachmentById(e.Id).toPromise()
} }
} }
@@ -477,8 +478,8 @@ export class EditEventPage implements OnInit {
} }
async openAttendees() { async openAttendees() {
if(window.innerWidth > 801) { if (window.innerWidth > 801) {
this.showAttendees=true; this.showAttendees = true;
} }
else { else {
const modal = await this.modalController.create({ const modal = await this.modalController.create({
@@ -496,18 +497,18 @@ export class EditEventPage implements OnInit {
modal.onDidDismiss().then((data) => { modal.onDidDismiss().then((data) => {
if(data){ if (data) {
data = data['data']; data = data['data'];
const newAttendees: EventPerson[] = data['taskParticipants']; const newAttendees: EventPerson[] = data['taskParticipants'];
const newAttendeesCC: EventPerson[] = data['taskParticipantsCc']; const newAttendeesCC: EventPerson[] = data['taskParticipantsCc'];
if(newAttendees.length) { if (newAttendees.length) {
this.setIntervenient(newAttendees); this.setIntervenient(newAttendees);
} else { } else {
this.setIntervenient([]); this.setIntervenient([]);
} }
if(newAttendeesCC) { if (newAttendeesCC) {
this.setIntervenientCC(newAttendeesCC); this.setIntervenientCC(newAttendeesCC);
} else { } else {
this.setIntervenientCC([]); this.setIntervenientCC([]);
@@ -539,7 +540,7 @@ export class EditEventPage implements OnInit {
this.openAttendees(); this.openAttendees();
} }
dynamicSetIntervenient({taskParticipants, taskParticipantsCc}){ dynamicSetIntervenient({ taskParticipants, taskParticipantsCc }) {
this.taskParticipants = taskParticipants; this.taskParticipants = taskParticipants;
this.taskParticipantsCc = taskParticipantsCc; this.taskParticipantsCc = taskParticipantsCc;
} }
@@ -547,11 +548,11 @@ export class EditEventPage implements OnInit {
getAttachments(eventId: string) { getAttachments(eventId: string) {
if(this.postEvent.HasAttachments) { if (this.postEvent.HasAttachments) {
this.attachmentsService.getAttachmentsById(eventId).subscribe(res=>{ this.attachmentsService.getAttachmentsById(eventId).subscribe(res => {
this.loadedEventAttachments = res; this.loadedEventAttachments = res;
},((erro) => { }, ((erro) => {
console.error('editgetAttchament', erro) console.error('editgetAttchament', erro)
})); }));
} }
@@ -563,8 +564,8 @@ export class EditEventPage implements OnInit {
const id: any = this.loadedEventAttachments[index].Id const id: any = this.loadedEventAttachments[index].Id
if(id == 'add') { if (id == 'add') {
this.loadedEventAttachments = this.loadedEventAttachments.filter((e,i)=> i!=index) this.loadedEventAttachments = this.loadedEventAttachments.filter((e, i) => i != index)
} else { } else {
this.loadedEventAttachments[index]['remove'] = true this.loadedEventAttachments[index]['remove'] = true
} }
@@ -583,8 +584,8 @@ export class EditEventPage implements OnInit {
} }
}); });
modal.onDidDismiss().then( async (res)=> { modal.onDidDismiss().then(async (res) => {
if(res) { if (res) {
const data = res.data; const data = res.data;
const ApplicationIdDocumentToSave: any = { const ApplicationIdDocumentToSave: any = {
@@ -617,7 +618,7 @@ export class EditEventPage implements OnInit {
setTimeout(() => { setTimeout(() => {
if(this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Oficial'] && this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Pessoal']) { if (this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Oficial'] && this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Pessoal']) {
this.CalendarNamesOptions = ['Oficial', 'Pessoal'] this.CalendarNamesOptions = ['Oficial', 'Pessoal']
@@ -635,4 +636,16 @@ export class EditEventPage implements OnInit {
}, 50) }, 50)
} }
ajustMinuts(string) {
var data = new Date(string);
if (data.getMinutes() === 59) {
data.setMinutes(0);
var novaString = data.toISOString().slice(0, 16).replace("T", " ");
return novaString;
} else {
return string;
}
}
} }
@@ -126,9 +126,6 @@ export class NewEventPage implements OnInit {
this.selectedDate = this.navParams.get('eventSelectedDate'); this.selectedDate = this.navParams.get('eventSelectedDate');
this.taskParticipants = this.navParams.get('attendees'); this.taskParticipants = this.navParams.get('attendees');
this.CalendarDate = this.navParams.get('CalendarDate') this.CalendarDate = this.navParams.get('CalendarDate')
this.postEvent.StartDate = this.navParams.get('DefaultStartDate')
this.postEvent.EndDate = this.navParams.get('DefaultEndDate')
console.log('end date', this.postEvent.EndDate)
} }
ngOnInit() { ngOnInit() {
@@ -219,6 +219,7 @@ export class ViewEventPage implements OnInit {
div.innerHTML = res.Body.Text div.innerHTML = res.Body.Text
res.Body.Text = div.innerText */ res.Body.Text = div.innerText */
this.loadedEvent = res; this.loadedEvent = res;
console.log('pass,',res)
this.setTimeZone() this.setTimeZone()
// this.addEventToDb(res); // this.addEventToDb(res);
@@ -258,6 +258,9 @@ export class BookMeetingModalPage implements OnInit {
runValidation() { runValidation() {
this.validateFrom = true this.validateFrom = true
if (new Date(this.dateStart).getTime() > new Date(this.dateEnd).getTime()) {
this.toastService._badRequest("A data de fim não pode ser inferior a data de início do evento")
}
} }
get dateValid() { get dateValid() {