mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 13:26:08 +00:00
a lot of changes
This commit is contained in:
@@ -190,6 +190,10 @@ export class EditEventPage implements OnInit {
|
||||
})
|
||||
}, 1000);
|
||||
|
||||
ngOnChanges(changes: any): void {
|
||||
this.loadedEventAttachments = this.postEvent?.Attachments
|
||||
}
|
||||
|
||||
close() {
|
||||
this.modalController.dismiss();
|
||||
}
|
||||
@@ -421,7 +425,7 @@ export class EditEventPage implements OnInit {
|
||||
this.isEventEdited = true;
|
||||
|
||||
|
||||
await this.saveDocument()
|
||||
/* await this.saveDocument() */
|
||||
|
||||
this.goBack();
|
||||
}
|
||||
@@ -595,6 +599,7 @@ export class EditEventPage implements OnInit {
|
||||
|
||||
|
||||
this.loadedEventAttachments.push(ApplicationIdDocumentToSave)
|
||||
this.postEvent.Attachments = this.loadedEventAttachments;
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
@@ -20,6 +20,7 @@ import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ChatMethodsService } from 'src/app/services/chat/chat-methods.service';
|
||||
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { ProcessesService } from 'src/app/services/processes.service';
|
||||
|
||||
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
|
||||
parse: {
|
||||
@@ -59,8 +60,8 @@ export class NewEventPage implements OnInit {
|
||||
|
||||
postEvent: Event;
|
||||
eventBody: EventBody;
|
||||
segment:string = "true";
|
||||
profile:string;
|
||||
segment: string = "true";
|
||||
profile: string;
|
||||
eventAttendees: EventPerson[];
|
||||
selectedSegment: string;
|
||||
selectedDate: Date;
|
||||
@@ -73,10 +74,10 @@ export class NewEventPage implements OnInit {
|
||||
taskParticipants: any = [];
|
||||
taskParticipantsCc: any = [];
|
||||
|
||||
documents:SearchList[] = [];
|
||||
documents: SearchList[] = [];
|
||||
|
||||
loggeduser: LoginUserRespose;
|
||||
members:any;
|
||||
members: any;
|
||||
CalendarName;
|
||||
SessionStore = SessionStore;
|
||||
|
||||
@@ -88,7 +89,7 @@ export class NewEventPage implements OnInit {
|
||||
autoStartTime;
|
||||
autoEndTime;
|
||||
CalendarNamesOptions = ['Oficial', 'Pessoal']
|
||||
roomId:string;
|
||||
roomId: string;
|
||||
globalEnd = new Date('1999')
|
||||
environment = environment
|
||||
|
||||
@@ -101,12 +102,13 @@ export class NewEventPage implements OnInit {
|
||||
public ThemeService: ThemeService,
|
||||
private platform: Platform,
|
||||
private chatMethodService: ChatMethodsService,
|
||||
private hhtpErrorHandle: HttpErrorHandle
|
||||
private hhtpErrorHandle: HttpErrorHandle,
|
||||
private processeService: ProcessesService
|
||||
) {
|
||||
this.loggeduser = SessionStore.user;
|
||||
this.postEvent = new Event();
|
||||
this.postEvent.EventRecurrence = {Type:'-1'};
|
||||
this.eventBody = { BodyType : "1", Text : ""};
|
||||
this.postEvent.EventRecurrence = { Type: '-1' };
|
||||
this.eventBody = { BodyType: "1", Text: "" };
|
||||
this.postEvent.Body = this.eventBody;
|
||||
|
||||
this.roomId = this.navParams.get('roomId');
|
||||
@@ -121,9 +123,9 @@ export class NewEventPage implements OnInit {
|
||||
// this.taskParticipants = [];
|
||||
}
|
||||
|
||||
if(!this.CalendarName) {
|
||||
if (!this.CalendarName) {
|
||||
console.log('true', this.eventService.calendarNamesAry.includes('Meu calendario'))
|
||||
if(this.eventService.calendarNamesAry.includes('Meu calendario')) {
|
||||
if (this.eventService.calendarNamesAry.includes('Meu calendario')) {
|
||||
this.CalendarName = 'Meu calendario';
|
||||
console.log(this.eventService.calendarNamesAry)
|
||||
} else {
|
||||
@@ -136,7 +138,7 @@ export class NewEventPage implements OnInit {
|
||||
|
||||
this.getRecurrenceTypes();
|
||||
|
||||
if(this.selectedSegment != "Combinada"){
|
||||
if (this.selectedSegment != "Combinada") {
|
||||
this.postEvent = {
|
||||
EventId: '',
|
||||
Subject: '',
|
||||
@@ -155,10 +157,10 @@ export class NewEventPage implements OnInit {
|
||||
Organizer: '',
|
||||
Category: 'Reunião',
|
||||
HasAttachments: false,
|
||||
EventRecurrence: {Type:'-1',LastOccurrence:this.autoEndTime},
|
||||
EventRecurrence: { Type: '-1', LastOccurrence: this.autoEndTime },
|
||||
};
|
||||
}
|
||||
else{
|
||||
else {
|
||||
this.postEvent = {
|
||||
EventId: '',
|
||||
Subject: '',
|
||||
@@ -177,15 +179,15 @@ export class NewEventPage implements OnInit {
|
||||
Organizer: '',
|
||||
Category: 'Reunião',
|
||||
HasAttachments: false,
|
||||
EventRecurrence: {Type:'-1',LastOccurrence:this.autoEndTime},
|
||||
EventRecurrence: { Type: '-1', LastOccurrence: this.autoEndTime },
|
||||
};
|
||||
}
|
||||
|
||||
window.onresize = (event) => {
|
||||
if( window.innerWidth >= 1024) {
|
||||
if (window.innerWidth >= 1024) {
|
||||
this.modalController.dismiss();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
this.setDefaultTime()
|
||||
|
||||
@@ -199,8 +201,8 @@ export class NewEventPage implements OnInit {
|
||||
}
|
||||
|
||||
myInterval = setInterval(() => {
|
||||
document.querySelectorAll('.ngx-mat-timepicker input').forEach((e :any) => {
|
||||
if(e) {
|
||||
document.querySelectorAll('.ngx-mat-timepicker input').forEach((e: any) => {
|
||||
if (e) {
|
||||
e.disabled = true;
|
||||
}
|
||||
})
|
||||
@@ -221,8 +223,8 @@ export class NewEventPage implements OnInit {
|
||||
const minutes = date.getMinutes();
|
||||
date.setSeconds(0);
|
||||
|
||||
if(minutes % 15 != 0) {
|
||||
|
||||
if (minutes % 15 != 0) {
|
||||
|
||||
if (minutes > 45) {
|
||||
date.setMinutes(60)
|
||||
} else if (minutes > 30) {
|
||||
@@ -233,65 +235,65 @@ export class NewEventPage implements OnInit {
|
||||
date.setMinutes(15)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return date
|
||||
}
|
||||
|
||||
roundTimeQuarterHourPlus15(date:Date) {
|
||||
roundTimeQuarterHourPlus15(date: Date) {
|
||||
const _date = new Date(date);
|
||||
const minutes = _date .getMinutes();
|
||||
_date .setMinutes(minutes + 15)
|
||||
return _date
|
||||
const minutes = _date.getMinutes();
|
||||
_date.setMinutes(minutes + 15)
|
||||
return _date
|
||||
}
|
||||
|
||||
|
||||
setStartDate() {
|
||||
if(!this.postEvent.StartDate) {
|
||||
if (!this.postEvent.StartDate) {
|
||||
this.postEvent.StartDate = this.roundTimeQuarterHour();
|
||||
}
|
||||
}
|
||||
|
||||
setEndDate(){
|
||||
if(!this.postEvent.EndDate) {
|
||||
setEndDate() {
|
||||
if (!this.postEvent.EndDate) {
|
||||
this.postEvent.EndDate = this.postEvent.StartDate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getRecurrenceTypes() {
|
||||
this.eventService.getRecurrenceTypes().subscribe( res => {
|
||||
|
||||
this.eventService.getRecurrenceTypes().subscribe(res => {
|
||||
|
||||
this.recurringTypes = res;
|
||||
});
|
||||
}
|
||||
|
||||
onSelectedRecurringChanged(ev:any) {
|
||||
onSelectedRecurringChanged(ev: any) {
|
||||
|
||||
this.calculetedLastOccurrence(ev);
|
||||
|
||||
if(ev.length > 1) {
|
||||
|
||||
|
||||
if (ev.length > 1) {
|
||||
|
||||
this.selectedRecurringType = ev.filter(data => data != '-1');
|
||||
}
|
||||
if(ev.length == 0) {
|
||||
if (ev.length == 0) {
|
||||
this.selectedRecurringType = "-1";
|
||||
}
|
||||
}
|
||||
|
||||
calculetedLastOccurrence(type:number){
|
||||
calculetedLastOccurrence(type: number) {
|
||||
// console.log(type);
|
||||
var valor;
|
||||
var valor;
|
||||
var opcao: boolean;
|
||||
if (type == 0) {
|
||||
valor = 7;
|
||||
opcao = true;
|
||||
} else if(type == 1){
|
||||
} else if (type == 1) {
|
||||
valor = 30;
|
||||
opcao = true;
|
||||
} else if(type == 2){
|
||||
} else if (type == 2) {
|
||||
valor = 1;
|
||||
opcao = false;
|
||||
}else if(type == 3){
|
||||
} else if (type == 3) {
|
||||
valor = 5;
|
||||
opcao = false;
|
||||
}
|
||||
@@ -299,28 +301,28 @@ export class NewEventPage implements OnInit {
|
||||
}
|
||||
|
||||
|
||||
defineLastOccurrence(valor:number, opcao:boolean){
|
||||
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.getFullYear() + valor,
|
||||
time.getMonth(),
|
||||
time.getDate(),
|
||||
time.getHours(),
|
||||
time.getMinutes()
|
||||
);
|
||||
this.postEvent.EventRecurrence.LastOccurrence = time;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
runValidation() {
|
||||
this.validateFrom = true;
|
||||
if(new Date(this.postEvent.StartDate).getTime() > new Date(this.postEvent.EndDate).getTime()){
|
||||
this.validateFrom = true;
|
||||
if (new Date(this.postEvent.StartDate).getTime() > new Date(this.postEvent.EndDate).getTime()) {
|
||||
this.toastService._badRequest("A data de fim não pode ser inferior a data de início do evento")
|
||||
}
|
||||
}
|
||||
@@ -328,7 +330,7 @@ export class NewEventPage implements OnInit {
|
||||
|
||||
get dateValid() {
|
||||
if (window.innerWidth <= 800) {
|
||||
return this.postEvent.StartDate < this.postEvent.EndDate? ['ok']: []
|
||||
return this.postEvent.StartDate < this.postEvent.EndDate ? ['ok'] : []
|
||||
} else {
|
||||
return ['ok']
|
||||
}
|
||||
@@ -347,7 +349,7 @@ export class NewEventPage implements OnInit {
|
||||
CalendarName: new FormControl(this.postEvent.CalendarName, [
|
||||
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
|
||||
]),
|
||||
Categories: new FormControl(this.postEvent.Category, [
|
||||
@@ -356,76 +358,83 @@ export class NewEventPage implements OnInit {
|
||||
participantes: new FormControl(this.taskParticipants, [
|
||||
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
|
||||
]),
|
||||
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
openInicio() {
|
||||
let input: any = document.querySelector('#new-inicio')
|
||||
if(input) {
|
||||
|
||||
if (input) {
|
||||
|
||||
input.click()
|
||||
}
|
||||
}
|
||||
|
||||
openFim() {
|
||||
let input: any = document.querySelector('#new-fim')
|
||||
if(input) {
|
||||
if (input) {
|
||||
input.click()
|
||||
}
|
||||
}
|
||||
|
||||
openLastOccurrence() {
|
||||
let input: any = document.querySelector('#last-occurrence')
|
||||
if(input) {
|
||||
if (input) {
|
||||
input.click()
|
||||
}
|
||||
}
|
||||
|
||||
async save() {
|
||||
|
||||
this.injectValidation()
|
||||
this.runValidation()
|
||||
|
||||
if(this.Form.invalid) {
|
||||
if (this.Form.invalid) {
|
||||
return false
|
||||
}
|
||||
|
||||
if(this.documents.length >= 0) {
|
||||
if (this.documents.length >= 0) {
|
||||
this.postEvent.HasAttachments = true;
|
||||
}
|
||||
if(this.selectedRecurringType != '-1') {
|
||||
if (this.selectedRecurringType != '-1') {
|
||||
this.postEvent.EventRecurrence.Type = this.selectedRecurringType;
|
||||
}
|
||||
|
||||
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
|
||||
|
||||
let eventId: any;
|
||||
let eventId: any;
|
||||
|
||||
const loader = this.toastService.loading()
|
||||
const loader = this.toastService.loading()
|
||||
|
||||
try {
|
||||
|
||||
const CalendarId = this.selectedCalendarId()
|
||||
this.postEvent.CalendarId = CalendarId
|
||||
|
||||
if(this.loggeduser.Profile == 'MDGPR') {
|
||||
|
||||
if (this.loggeduser.Profile == 'MDGPR') {
|
||||
|
||||
eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
|
||||
this.hhtpErrorHandle.httpsSucessMessagge('new event')
|
||||
|
||||
}
|
||||
else if(this.loggeduser.Profile == 'PR') {
|
||||
|
||||
else if (this.loggeduser.Profile == 'PR') {
|
||||
|
||||
const CalendarId = this.selectedCalendarId()
|
||||
this.postEvent.CalendarId = CalendarId
|
||||
|
||||
eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
|
||||
this.hhtpErrorHandle.httpsSucessMessagge('new event')
|
||||
|
||||
} else if (this.loggeduser.Profile == 'SGGPR') {
|
||||
|
||||
|
||||
this.saveAproveEvent();
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
const CalendarId = this.selectedCalendarId()
|
||||
@@ -433,50 +442,54 @@ export class NewEventPage implements OnInit {
|
||||
|
||||
eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
|
||||
this.hhtpErrorHandle.httpsSucessMessagge('new event')
|
||||
|
||||
|
||||
}
|
||||
|
||||
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
|
||||
return {
|
||||
SourceTitle: e.Assunto,
|
||||
ParentId: eventId,
|
||||
Source: '1',
|
||||
SourceId: e.Id,
|
||||
ApplicationId: e.ApplicationType.toString(),
|
||||
Id: '',
|
||||
Link: '',
|
||||
SerialNumber: ''
|
||||
};
|
||||
});
|
||||
//foi adicionado este if para não ter de fazer muitas alterações sobre a criação dos eventos. Deve ser refatorado
|
||||
if (this.loggeduser.Profile != 'SGGPR') {
|
||||
|
||||
await DocumentToSave.forEach( async (attachments, i) => {
|
||||
try {
|
||||
await this.attachmentsService.setEventAttachmentById(attachments).toPromise();
|
||||
} catch(error) {
|
||||
|
||||
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
|
||||
return {
|
||||
SourceTitle: e.Assunto,
|
||||
ParentId: eventId,
|
||||
Source: '1',
|
||||
SourceId: e.Id,
|
||||
ApplicationId: e.ApplicationType.toString(),
|
||||
Id: '',
|
||||
Link: '',
|
||||
SerialNumber: ''
|
||||
};
|
||||
});
|
||||
|
||||
await DocumentToSave.forEach(async (attachments, i) => {
|
||||
try {
|
||||
await this.attachmentsService.setEventAttachmentById(attachments).toPromise();
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
let data1 = {
|
||||
"subject": this.postEvent.Subject,
|
||||
"start": this.postEvent.StartDate,
|
||||
"end": this.postEvent.EndDate,
|
||||
"venue": this.postEvent.Location,
|
||||
"id": eventId,
|
||||
"calendarId": CalendarId
|
||||
}
|
||||
|
||||
});
|
||||
if (this.roomId) {
|
||||
this.chatMethodService.sendMessage(this.roomId, data1);
|
||||
}
|
||||
|
||||
let data1 = {
|
||||
"subject": this.postEvent.Subject,
|
||||
"start": this.postEvent.StartDate,
|
||||
"end": this.postEvent.EndDate,
|
||||
"venue": this.postEvent.Location,
|
||||
"id": eventId,
|
||||
"calendarId": CalendarId
|
||||
this.hhtpErrorHandle.httpsSucessMessagge('new event');
|
||||
let data = Object.assign(this.postEvent, { id: eventId })
|
||||
this.modalController.dismiss(data);
|
||||
}
|
||||
|
||||
if(this.roomId) {
|
||||
this.chatMethodService.sendMessage(this.roomId, data1);
|
||||
}
|
||||
|
||||
this.hhtpErrorHandle.httpsSucessMessagge('new event');
|
||||
let data = Object.assign(this.postEvent,{id:eventId})
|
||||
this.modalController.dismiss(data);
|
||||
|
||||
} catch (error) {
|
||||
this.hhtpErrorHandle.httpStatusHandle(error)
|
||||
this.hhtpErrorHandle.httpStatusHandle(error)
|
||||
} finally {
|
||||
loader.remove()
|
||||
}
|
||||
@@ -484,7 +497,7 @@ export class NewEventPage implements OnInit {
|
||||
}
|
||||
|
||||
|
||||
selectedCalendarId () {
|
||||
selectedCalendarId() {
|
||||
|
||||
if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial'] && this.postEvent.CalendarName == 'Oficial') {
|
||||
return this.eventService.calendarNamesType[this.CalendarName]['OficialId']
|
||||
@@ -502,18 +515,18 @@ export class NewEventPage implements OnInit {
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
if(this.eventService.calendarNamesType[this.CalendarName]?.['Oficial'] && this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) {
|
||||
|
||||
if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial'] && this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) {
|
||||
|
||||
this.CalendarNamesOptions = ['Oficial', 'Pessoal']
|
||||
|
||||
|
||||
} else if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial']) {
|
||||
this.CalendarNamesOptions = ['Oficial']
|
||||
this.postEvent.CalendarName = 'Oficial'
|
||||
|
||||
|
||||
} else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) {
|
||||
this.CalendarNamesOptions = ['Pessoal']
|
||||
this.postEvent.CalendarName = 'Pessoal'
|
||||
|
||||
|
||||
} else {
|
||||
this.CalendarNamesOptions = ['Oficial', 'Pessoal']
|
||||
}
|
||||
@@ -525,7 +538,7 @@ export class NewEventPage implements OnInit {
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: AttendeesPageModal,
|
||||
componentProps: {
|
||||
componentProps: {
|
||||
adding: this.adding,
|
||||
taskParticipants: this.taskParticipants,
|
||||
taskParticipantsCc: this.taskParticipantsCc
|
||||
@@ -538,9 +551,9 @@ export class NewEventPage implements OnInit {
|
||||
|
||||
modal.onDidDismiss().then((data) => {
|
||||
|
||||
if(data) {
|
||||
if (data) {
|
||||
data = data['data'];
|
||||
if(data) {
|
||||
if (data) {
|
||||
|
||||
const newAttendees: EventPerson[] = data['taskParticipants'];
|
||||
const newAttendeesCC: EventPerson[] = data['taskParticipantsCc'];
|
||||
@@ -589,8 +602,8 @@ export class NewEventPage implements OnInit {
|
||||
}
|
||||
});
|
||||
|
||||
modal.onDidDismiss().then((res)=>{
|
||||
if(res){
|
||||
modal.onDidDismiss().then((res) => {
|
||||
if (res) {
|
||||
const data = res.data;
|
||||
this.documents.push(data.selected);
|
||||
}
|
||||
@@ -601,19 +614,219 @@ export class NewEventPage implements OnInit {
|
||||
|
||||
removeAttachment(index: number) {
|
||||
|
||||
this.documents = this.documents.filter( (e, i) => index != i);
|
||||
this.documents = this.documents.filter((e, i) => index != i);
|
||||
|
||||
}
|
||||
|
||||
checkRoleInArray() {
|
||||
for (let index = 0; index < this.eventService.calendarNamesAry.length; index++) {
|
||||
console.log('ROLE1', this.eventService.calendarNamesAry[index])
|
||||
|
||||
|
||||
}
|
||||
|
||||
for (let index = 0; index < this.eventService.calendarRole.length; index++) {
|
||||
console.log('ROLE2',this.eventService.calendarRole[index])
|
||||
|
||||
console.log('ROLE2', this.eventService.calendarRole[index])
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Deve ser removido posteriormente
|
||||
async saveAproveEvent() {
|
||||
|
||||
console.log(this.postEvent)
|
||||
console.log(this.postEvent.CalendarName)
|
||||
console.log(this.CalendarName)
|
||||
console.log(this.eventService.calendarNamesAry)
|
||||
const CalendarId = this.selectedCalendarId()
|
||||
|
||||
let selectedCalendar
|
||||
try {
|
||||
selectedCalendar = this.eventService.calendarNamesAry.find(calendar => calendar.Fullname === this.CalendarName)
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
console.log('selectedCalendar', selectedCalendar)
|
||||
|
||||
if (selectedCalendar) {
|
||||
if (selectedCalendar.Role = 'Presidente da República') {
|
||||
let loader = this.toastService.loading();
|
||||
|
||||
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
|
||||
return {
|
||||
SourceTitle: e.Assunto,
|
||||
ParentId: "AGD_" + this.loggeduser.UserName + "_" + this.processeService.generateInstaceFormatDate(),
|
||||
Source: '1',
|
||||
SourceId: e.Id,
|
||||
ApplicationId: e.ApplicationType.toString(),
|
||||
Id: '',
|
||||
Link: '',
|
||||
SerialNumber: ''
|
||||
};
|
||||
});
|
||||
|
||||
let body = this.eventToaproveBody(this.postEvent, CalendarId, this.loggeduser.RoleID, this.loggeduser.UserId, DocumentToSave);
|
||||
await this.processeService.createEventToAprove(this.postEvent.CalendarName, 'pr', body).subscribe((id) => {
|
||||
loader.remove()
|
||||
this.modalController.dismiss();
|
||||
this.hhtpErrorHandle.httpsSucessMessagge('new event to aprove')
|
||||
|
||||
|
||||
|
||||
|
||||
/* DocumentToSave.forEach((attachments, i) => {
|
||||
this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => {
|
||||
if (DocumentToSave.length == (i + 1)) {
|
||||
this.afterSave();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (DocumentToSave.length == 0) {
|
||||
this.afterSave();
|
||||
} */
|
||||
|
||||
}, (error) => {
|
||||
loader.remove()
|
||||
this.hhtpErrorHandle.httpStatusHandle(error)
|
||||
});
|
||||
|
||||
|
||||
|
||||
} else if (selectedCalendar.Role = 'Ministro e Director do Gabinete do PR') {
|
||||
let loader = this.toastService.loading();
|
||||
|
||||
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
|
||||
return {
|
||||
SourceTitle: e.Assunto,
|
||||
ParentId: "AGD_" + this.loggeduser.UserName + "_" + this.processeService.generateInstaceFormatDate(),
|
||||
Source: '1',
|
||||
SourceId: e.Id,
|
||||
ApplicationId: e.ApplicationType.toString(),
|
||||
Id: '',
|
||||
Link: '',
|
||||
SerialNumber: ''
|
||||
};
|
||||
});
|
||||
|
||||
let body = this.eventToaproveBody(this.postEvent, CalendarId, this.loggeduser.RoleID, this.loggeduser.UserId, DocumentToSave);
|
||||
await this.processeService.createEventToAprove(this.postEvent.CalendarName, 'md', body).subscribe((id) => {
|
||||
loader.remove()
|
||||
this.modalController.dismiss();
|
||||
this.hhtpErrorHandle.httpsSucessMessagge('new event to aprove')
|
||||
|
||||
|
||||
|
||||
/* DocumentToSave.forEach((attachments, i) => {
|
||||
this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => {
|
||||
if (DocumentToSave.length == (i + 1)) {
|
||||
this.afterSave();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (DocumentToSave.length == 0) {
|
||||
this.afterSave();
|
||||
} */
|
||||
|
||||
}, (error) => {
|
||||
loader.remove()
|
||||
this.hhtpErrorHandle.httpStatusHandle(error)
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!selectedCalendar && this.CalendarName == "Meu calendario") {
|
||||
console.log('SG generic')
|
||||
this.postEvent.CalendarName
|
||||
|
||||
const CalendarId = this.selectedCalendarId()
|
||||
let loader = this.toastService.loading();
|
||||
|
||||
this.postEvent.CalendarId = CalendarId
|
||||
|
||||
this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe(
|
||||
(id) => {
|
||||
loader.remove();
|
||||
|
||||
const eventId: any = id;
|
||||
|
||||
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
|
||||
return {
|
||||
SourceTitle: e.Assunto,
|
||||
ParentId: eventId,
|
||||
Source: '1',
|
||||
SourceId: e.Id,
|
||||
ApplicationId: e.ApplicationType.toString(),
|
||||
Id: '',
|
||||
Link: '',
|
||||
SerialNumber: ''
|
||||
};
|
||||
});
|
||||
|
||||
DocumentToSave.forEach((attachments, i) => {
|
||||
this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => {
|
||||
if (DocumentToSave.length == (i + 1)) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (DocumentToSave.length == 0) {
|
||||
}
|
||||
|
||||
this.hhtpErrorHandle.httpsSucessMessagge('new event')
|
||||
let data = {
|
||||
"subject": this.postEvent.Subject,
|
||||
"start": this.postEvent.StartDate,
|
||||
"end": this.postEvent.EndDate,
|
||||
"venue": this.postEvent.Location,
|
||||
"id": id,
|
||||
"calendarId": CalendarId
|
||||
}
|
||||
if (this.roomId) {
|
||||
this.chatMethodService.sendMessage(this.roomId, data);
|
||||
}
|
||||
|
||||
let dataa = Object.assign(this.postEvent, { id: eventId })
|
||||
this.modalController.dismiss(dataa);
|
||||
}, (error) => {
|
||||
|
||||
loader.remove()
|
||||
this.hhtpErrorHandle.httpStatusHandle(error)
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Deve ser removido posteriormente
|
||||
eventToaproveBody(event, calendarId, role, userId, attachments) {
|
||||
let toAproveObject = {
|
||||
"EventProcess": {
|
||||
"Body": event.Body,
|
||||
"Location": event.Location,
|
||||
"Subject": event.Subject,
|
||||
"StartDate": event.StartDate,
|
||||
"EndDate": event.EndDate,
|
||||
"Status": "Active",
|
||||
"IsAllDayEvent": event.IsRecurring,
|
||||
"EventType": event.EventType,
|
||||
"ParticipantsList": event.Attendees,
|
||||
"EventRecurrence": event.EventRecurrence,
|
||||
"HasAttachments": event.HasAttachments,
|
||||
"CalendarId": calendarId,
|
||||
"Role": role,
|
||||
"wxUserID": userId,
|
||||
"TimeZone": "W. Central Africa Standard Time"
|
||||
},
|
||||
"Attachments": attachments,
|
||||
"InstanceID": "AGD_" + this.loggeduser.UserName + "_" + this.processeService.generateInstaceFormatDate()
|
||||
}
|
||||
|
||||
return toAproveObject;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user