This commit is contained in:
tiago.kayaya
2021-07-14 15:23:45 +01:00
parent 732fff2025
commit 9a39b767dd
18 changed files with 196 additions and 146 deletions
@@ -50,25 +50,16 @@ export class EditEventToApproveComponent implements OnInit {
public stepHour = 1;
public stepMinute = 5;
public stepSecond = 5;
public dateControlStart = new FormControl(moment("DD MM YYYY hh"));
public dateControlEnd = new FormControl(moment("DD MM YYYY hh"));
recurringTypes: any;
selectedRecurringType: any;
showLoader = false
get dateStart () {
return this.dateControlStart.value
}
get dateEnd () {
return this.dateControlEnd.value
}
@ViewChild('picker') picker: any;
@ViewChild('fim') fim: any;
@ViewChild('inicio') inicio: any;
@ViewChild('picker1') picker1: any;
serialNumber: string
loadedAttachments: Attachment[]= []
@@ -77,6 +68,8 @@ export class EditEventToApproveComponent implements OnInit {
taskStartDate: "",
workflowInstanceDataFields:{
Body: "",
OccurrenceType: '',
LastOccurrence: '',
IsRecurring: false,
ParticipantsList: [],
Agenda: '',
@@ -128,41 +121,55 @@ export class EditEventToApproveComponent implements OnInit {
this.isEventEdited = false;
this.dateControlStart = new FormControl(moment(new Date()));
this.dateControlEnd = new FormControl(moment(new Date()));
}
ngOnInit() {
this.getTask()
console.log('HERE');
this.getRecurrenceTypes();
this.selectedRecurringType = this.eventProcess.workflowInstanceDataFields.OccurrenceType;
setTimeout(() => {
this.selectedRecurringType = this.eventProcess.workflowInstanceDataFields.OccurrenceType;
console.log(this.selectedRecurringType);
}, 1000);
}
async getTask() {
const result = await this.processes.GetTask(this.serialNumber).subscribe( result =>{
const result = await this.processes.GetTask(this.serialNumber).toPromise();
console.log(result);
this.eventProcess = result
this.restoreDatepickerData()
// description
let body : any =this.eventProcess.workflowInstanceDataFields.Body.replace(/<[^>]+>/g, '')
this.eventProcess.workflowInstanceDataFields.Body = body
this.Location = this.eventProcess.workflowInstanceDataFields.Location
this.InstanceId = this.eventProcess.workflowInstanceDataFields.InstanceId
this.getAttachments()
try {
this.getAttachments()
} catch (error) {
}
if(this.eventProcess.workflowInstanceDataFields.IsRecurring == false) {
this.isRecurring = "Não se repete";
}
else {
this.isRecurring = "Repete";
}
this.eventProcess.workflowInstanceDataFields.ParticipantsList.forEach(e => {
if(e.IsRequired) {
this.taskParticipants.push(e);
@@ -170,27 +177,51 @@ export class EditEventToApproveComponent implements OnInit {
this.taskParticipantsCc.push(e);
}
})
})
/* }) */
}
getRecurrenceTypes() {
this.eventsService.getRecurrenceTypes().subscribe(res=>{
console.log(res);
this.recurringTypes = res;
});
}
onSelectedRecurringChanged(ev:any){
/* console.log(ev);
if(ev.length > 1){
console.log(ev.filter(data => data != '-1'));
this.selectedRecurringType = ev.filter(data => data != '-1');
}
if(ev.length == 0){
this.selectedRecurringType = "-1";
} */
}
openLastOccurrence() {
let input: any = document.querySelector('#last-occurrence')
if(input) {
input.click()
}
}
close() {
this.modalController.dismiss();
}
save() {
save() {
// set dates to eventProcess object
this.getDatepickerData()
this.taskParticipantsCc.forEach(e=>{
e.IsRequired = false
})
this.eventProcess.workflowInstanceDataFields.ParticipantsList = this.taskParticipants.concat(this.taskParticipantsCc)
this.eventProcess.workflowInstanceDataFields.ParticipantsList.forEach(e=>{
if(e.hasOwnProperty('$type')) {
delete e.$type
}
@@ -205,18 +236,22 @@ export class EditEventToApproveComponent implements OnInit {
IsRecurring: this.eventProcess.workflowInstanceDataFields.IsRecurring,
Location: this.eventProcess.workflowInstanceDataFields.Location,
Subject: this.eventProcess.workflowInstanceDataFields.Subject,
serialNumber: this.eventProcess.serialNumber,
SerialNumber: this.eventProcess.serialNumber,
StartDate: this.eventProcess.workflowInstanceDataFields.StartDate,
MDEmail: this.eventProcess.workflowInstanceDataFields.MDEmail,
MDName: this.eventProcess.workflowInstanceDataFields.MDName,
Message: this.eventProcess.workflowInstanceDataFields.Message,
EventRecurrence: {
Type: this.eventProcess.workflowInstanceDataFields.OccurrenceType,
LastOccurrence: this.eventProcess.workflowInstanceDataFields.LastOccurrence,
},
ParticipantsList: this.eventProcess.workflowInstanceDataFields.ParticipantsList,
Private: false,
ReviewUserComment: ''
}
console.log(event);
this.eventsService.postEventToApproveEdit(event).subscribe(()=>{
this.toastService.successMessage('Evento editado');
}, error =>{
@@ -244,7 +279,7 @@ export class EditEventToApproveComponent implements OnInit {
})
this.modalController.dismiss();
//this.modalController.dismiss();
}
@@ -261,11 +296,11 @@ export class EditEventToApproveComponent implements OnInit {
cssClass: 'attendee modal modal-desktop',
backdropDismiss: false
});
await modal.present();
modal.onDidDismiss().then((data) => {
if(data){
data = data['data'];
@@ -285,7 +320,7 @@ export class EditEventToApproveComponent implements OnInit {
this.taskParticipants = data;
this.postEvent.Attendees = data;
}
setIntervenientCC(data) {
this.taskParticipantsCc = data;
}
@@ -297,7 +332,7 @@ export class EditEventToApproveComponent implements OnInit {
}
addParticipantsCC(){
this.adding = 'CC'
this.openAttendees();
}
@@ -339,7 +374,7 @@ export class EditEventToApproveComponent implements OnInit {
await modal.present();
modal.onDidDismiss().then( async (res)=>{
if(res){
const data: SearchDocument = res.data.selected;
const DocumentToSave: any = {
@@ -370,18 +405,7 @@ export class EditEventToApproveComponent implements OnInit {
});
}
restoreDatepickerData() {
this.dateControlStart = new FormControl(moment(new Date(this.eventProcess.workflowInstanceDataFields.StartDate)));
this.dateControlEnd = new FormControl(moment(new Date(this.eventProcess.workflowInstanceDataFields.EndDate)));
}
getDatepickerData() {
this.eventProcess.workflowInstanceDataFields.StartDate = this.dateStart
this.eventProcess.workflowInstanceDataFields.EndDate = this.dateEnd
}
}
}