This commit is contained in:
tiago.kayaya
2021-07-12 16:39:55 +01:00
parent 756f053f1c
commit f457952220
2 changed files with 136 additions and 61 deletions
@@ -31,6 +31,9 @@ export class EditEventPage implements OnInit {
eventAttendees: EventPerson[];
// minDate: string;
loadedEventAttachments: Attachment[]=[];
recurringTypes: any;
selectedRecurringType: any;
public dateControlOccurrence = new FormControl(moment("DD MM YYYY hh"));
public date: any;
public disabled = false;
@@ -57,7 +60,7 @@ export class EditEventPage implements OnInit {
@Output() openAttendeesComponent = new EventEmitter<any>();
@Output() closeComponent = new EventEmitter<any>();
@Output() setIntervenient = new EventEmitter<any>();
@Output() setIntervenientCC = new EventEmitter<any>();
@Output() clearPostEvent = new EventEmitter<any>();
@@ -85,6 +88,9 @@ export class EditEventPage implements OnInit {
{ value: false, label: 'False' }
];
get dateOccurrence () {
return this.dateControlOccurrence.value
}
public listColors = ['primary', 'accent', 'warn'];
public stepHours = [1, 2, 3, 4, 5];
public stepMinutes = [1, 5, 10, 15, 20, 25];
@@ -96,13 +102,17 @@ export class EditEventPage implements OnInit {
public alertController: AlertController,
private attachmentsService: AttachmentsService,
private toastService: ToastService ) {
//this.dateControlOccurrence = this.postEvent.EventRecurrence.LastOccurrence;
}
ngOnInit() {
console.log(this.postEvent);
if(!this.restoreTemporaryData()) {
// clear
if(this.postEvent) {
if( this.postEvent.Body){
if(typeof(this.postEvent.Body.Text) == 'string'){
@@ -110,7 +120,7 @@ export class EditEventPage implements OnInit {
}
}
}
// attendees list
if(this.postEvent.Attendees != null) {
this.postEvent.Attendees.forEach(e =>{
@@ -119,17 +129,17 @@ export class EditEventPage implements OnInit {
} else {
this.taskParticipantsCc.push(e);
}
})
})
}
this.taskParticipants = removeDuplicate(this.taskParticipants);
this.taskParticipantsCc = removeDuplicate(this.taskParticipantsCc);
this.setIntervenient.emit(this.taskParticipants);
this.setIntervenientCC.emit(this.taskParticipantsCc);
this.isEventEdited = false;
if(this.postEvent.IsRecurring == false) {
this.isRecurring = "Não se repete";
}
@@ -140,9 +150,13 @@ export class EditEventPage implements OnInit {
this.getAttachments(this.postEvent.EventId);
this.restoreDatepickerData()
this.restoreDatepickerData();
this.getRecurrenceTypes();
setTimeout(() => {
this.selectedRecurringType = this.postEvent.EventRecurrence.Type.toString();
}, 1000);
}
close() {
this.closeComponent.emit();
this.setIntervenient.emit([]);
@@ -152,6 +166,24 @@ export class EditEventPage implements OnInit {
this.deleteTemporaryData();
}
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";
}
}
runValidation() {
this.validateFrom = true
@@ -221,7 +253,7 @@ export class EditEventPage implements OnInit {
this.clearPostEvent.emit();
this.deleteTemporaryData();
this.close();
this.saveDocument()
}
@@ -229,10 +261,10 @@ export class EditEventPage implements OnInit {
saveDocument() {
this.loadedEventAttachments.forEach((e)=>{
const id: any = e.Id
const remove = e['remove']
if ( id == 'add') {
//data.selected
const DocumentToSave = {
@@ -285,6 +317,7 @@ export class EditEventPage implements OnInit {
if (this.postEvent) {
this.postEvent.StartDate = this.dateStart
this.postEvent.EndDate = this.dateEnd
this.postEvent.EventRecurrence.LastOccurrence = this.dateOccurrence
}
}
@@ -296,7 +329,7 @@ export class EditEventPage implements OnInit {
}
saveTemporaryData() {
this.getDatepickerData()
window['temp.path:/home/agenda/edit-event.component.ts'] = {
@@ -307,7 +340,7 @@ export class EditEventPage implements OnInit {
}
restoreTemporaryData(): boolean {
const restoredData = window['temp.path:/home/agenda/edit-event.component.ts']
if(JSON.stringify(restoredData) != "{}" && undefined != restoredData){
@@ -317,11 +350,11 @@ export class EditEventPage implements OnInit {
this.restoreDatepickerData()
return true;
return true;
} else {
return false;
}
}
deleteTemporaryData(){
@@ -331,24 +364,24 @@ export class EditEventPage implements OnInit {
getAttachments(eventId: string){
this.attachmentsService.getAttachmentsById(eventId).subscribe(res=>{
this.loadedEventAttachments = res;
console.log('res', res);
console.log('res', res);
});
}
deleteAttachment(attachmentID: string, index) {
const id: any = this.loadedEventAttachments[index].Id
if(id == 'add') {
this.loadedEventAttachments = this.loadedEventAttachments.filter((e,i)=> i!=index)
} else {
this.loadedEventAttachments[index]['remove'] = true
}
}
async getDoc() {
const modal = await this.modalController.create({
component: SearchPage,