criar evento com recorrencia

This commit is contained in:
tiago.kayaya
2021-07-12 14:32:43 +01:00
parent d68a89e7c9
commit aa3a2e0420
4 changed files with 185 additions and 131 deletions
@@ -28,7 +28,7 @@
</div>
</div>
</div>
<div class="container-div">
<div class="ion-item-class-2 d-flex">
<div class="ion-icon-class">
@@ -39,9 +39,9 @@
<ion-input type="text" placeholder="Localização*" [(ngModel)]="postEvent.Location"></ion-input>
</div>
</div>
</div>
<div *ngIf="Form && validateFrom" >
<div *ngIf="Form.get('Location').invalid " class="input-errror-message">
<div *ngIf="Form.get('Location').errors?.required">
@@ -52,13 +52,13 @@
</div>
</div>
</div>
<div class="container-div">
<div class="ion-item-class-2 d-flex">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
</div>
<div class="ion-input-class flex-grow-1 d-flex justify-center align-center material-inputs materia-top ">
<div class="ion-input-class flex-grow-1 justify-center align-center material-inputs ">
<mat-form-field appearance="none" class="width-100" color="ion-color-secondary" placeholder="Selecione agenda">
<mat-select [(value)]="postEvent.CalendarName" >
@@ -80,7 +80,7 @@
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon>
</div>
<div class="ion-input-class flex-grow-1 d-flex justify-center align-center material-inputs materia-top">
<div class="ion-input-class flex-grow-1 justify-center align-center material-inputs">
<mat-form-field appearance="none" class="width-100" placeholder="Sample Type" required>
<!-- <input matInput type="text" > -->
@@ -109,23 +109,23 @@
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
</div>
<!--
<!--
[className]="Form?.get('Subject')?.invalid ? 'input-error ion-input-class flex-grow-1' : 'ion-input-class ion-input-class flex-grow-1' "
-->
<div class="ion-input-class flex-grow-1" >
<div class="ion-input-class flex-grow-1 justify-center align-center material-inputs materia-top">
<mat-form-field class="date-hour-picker">
<input matInput [ngxMatDatetimePicker]="picker1"
placeholder="Choose a date"
<input matInput [ngxMatDatetimePicker]="picker1"
placeholder="Choose a date"
[formControl]="dateControlStart"
[min]="minDate"
[disabled]="disabled"
>
<mat-datepicker-toggle id="new-inicio" matSuffix [for]="picker1"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #picker1
[showSpinners]="showSpinners"
<ngx-mat-datetime-picker #picker1
[showSpinners]="showSpinners"
[showSeconds]="showSeconds"
[stepHour]="stepHour" [stepMinute]="stepMinute"
[stepHour]="stepHour" [stepMinute]="stepMinute"
[stepSecond]="stepSecond"
[touchUi]="touchUi"
>
@@ -135,29 +135,29 @@
</div>
</div>
</div>
<div class="container-div">
<div class="ion-item-class-2 d-flex">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
</div>
<!--
<!--
[className]="Form?.get('Subject')?.invalid ? 'input-error ion-input-class flex-grow-1' : 'ion-input-class ion-input-class flex-grow-1' "
-->
<div (click)="openFim()" class="ion-input-class flex-grow-1" >
<div (click)="openFim()" class="ion-input-class flex-grow-1 justify-center align-center materia-top">
<mat-form-field class="date-hour-picker">
<input matInput [ngxMatDatetimePicker]="fim"
placeholder="Choose a date"
<input matInput [ngxMatDatetimePicker]="fim"
placeholder="Choose a date"
[formControl]="dateControlEnd"
[min]="endMinDate"
[disabled]="disabled"
>
<mat-datepicker-toggle id="new-fim" matSuffix [for]="fim"></mat-datepicker-toggle>
<ngx-mat-datetime-picker #fim
[showSpinners]="showSpinners"
<ngx-mat-datetime-picker #fim
[showSpinners]="showSpinners"
[showSeconds]="showSeconds"
[stepHour]="stepHour" [stepMinute]="stepMinute"
[stepHour]="stepHour" [stepMinute]="stepMinute"
[stepSecond]="stepSecond"
[touchUi]="touchUi"
>
@@ -167,21 +167,44 @@
</div>
</div>
</div>
<div class="container-div">
<!-- <div class="container-div width-100">
<div class="ion-item-class-2">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-refresh.svg"></ion-icon>
</div>
<div class="ion-input-class" [class.input-error]="Form?.get('Categories')?.invalid && validateFrom ">
<ion-select placeholder="Selecione a repetição*"
[(ngModel)]="selectedRecurringType"
(ngModelChange)="onSelectedRecurringChanged($event)"
interface="action-sheet"
Cancel-text="Cancelar" required>
<ion-select-option *ngFor="let recurring of recurringTypes" value="{{recurring.Code}}">{{recurring.Description}}</ion-select-option>
</ion-select>
</div>
</div>
</div> -->
<div class="container-div width-100">
<div class="ion-item-class-2 d-flex">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-refresh.svg"></ion-icon>
</div>
<div class="ion-input-class flex-grow-1 d-flex justify-center align-center material-inputs materia-top">
<div class="ion-input-class flex-grow-1">
<mat-form-field appearance="none" floatLabel="never" class="width-100" value="false" interface="action-sheet" required>
<mat-select placeholder="Selecione repetição*" [(ngModel)]="postEvent.IsRecurring">
<mat-option value="false">
Não se repete
</mat-option>
<mat-option value="true">
Repete
<mat-select placeholder="Selecione repetição*"
[(ngModel)]="postEvent.EventRecurrence.Type"
(ngModelChange)="onSelectedRecurringChanged($event)">
<mat-option
*ngFor="let recurring of recurringTypes" value="{{recurring.Code}}"
>
{{recurring.Description}}
</mat-option>
</mat-select>
</mat-form-field>
@@ -189,7 +212,7 @@
</div>
</div>
</div>
<div *ngIf="Form && validateFrom" >
<div *ngIf="Form.get('participantes').invalid " class="input-errror-message">
<div *ngIf="Form.get('participantes').errors?.required">
@@ -204,7 +227,7 @@
<ion-icon slot="start" src="assets/images/icons-person.svg"></ion-icon>
</div>
<div class="ion-input-class-no-height flex-grow-1" [class.input-error]="Form?.get('participantes')?.invalid && validateFrom">
<div class="list-people">
<ion-item lines="none">
<ion-list>
@@ -220,7 +243,7 @@
</div>
</div>
</div>
<div class="container-div">
<div class="ion-item-class-2 d-flex">
<div class="ion-icon-class">
@@ -228,7 +251,7 @@
</div>
<div class="ion-input-class-no-height flex-grow-1" [class.input-error]="Form?.get('participantes')?.invalid && validateFrom">
<div class="list-people">
<ion-item lines="none">
<ion-list>
<ion-label *ngIf="taskParticipantsCc.length ==0" class="list-people-title">Com conhecimento</ion-label>
@@ -243,20 +266,20 @@
</div>
</div>
</div>
<div class="container-div">
<div class="ion-item-class-2 d-flex">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon>
</div>
<div class="ion-input-class-no-height flex-grow-1">
<ion-textarea [(ngModel)]="postEvent.Body.Text" placeholder="Detalhes" ></ion-textarea>
</div>
</div>
</div>
<div class="ion-item-container-no-border cursor-pointer" (click)="getDoc()">
<ion-label>
<div class="attach-icon">
@@ -264,28 +287,28 @@
</div>
<div class="attach-document">
<ion-label>Adicionar documentos</ion-label>
</div>
</div>
</ion-label>
</div>
<div class="list " *ngFor="let document of documents; let i = index" >
<div class="list " *ngFor="let document of documents; let i = index" >
<ion-list>
<ion-item>
<ion-label>
<p class="d-flex ion-justify-content-between">
<span class="attach-title-item">{{document.Assunto}}</span>
<span class="app-name">{{document.appName}}</span>
<p class="d-flex ion-justify-content-between">
<span class="attach-title-item">{{document.Assunto}}</span>
<span class="app-name">{{document.appName}}</span>
<span class="close-button text-black cursor-pointer" (click)="removeAttachment(i)" >
<ion-icon class="font-20" src="assets/images/icons-delete-25.svg"></ion-icon>
</span>
</p>
</p>
<p><span class="span-left">{{document.EntidadeOrganicaNome}}</span><span class="span-right"> {{document.Data | date: 'dd-MM-yy'}} </span></p>
</ion-label>
</ion-item>
</ion-list>
</div>
</div>
</div>
</div>
</ion-content>
<ion-footer class="ion-no-border px-20">
<ion-toolbar class="d-flex justify-space-between">
@@ -301,4 +324,4 @@
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-footer>
</ion-footer>
@@ -66,13 +66,15 @@ export class NewEventPage implements OnInit {
public stepMinute = 5;
public stepSecond = 5;
public color: ThemePalette = 'primary';
recurringTypes: any;
selectedRecurringType: any;
@Input() profile:string;
@Input() selectedSegment: string;
@Input() selectedDate: Date;
@Input() taskParticipants: EventPerson[] = [];
@Input() taskParticipantsCc: any = [];
@Output() setIntervenient = new EventEmitter<any>();
@Output() setIntervenientCC = new EventEmitter<any>();
@@ -122,7 +124,7 @@ export class NewEventPage implements OnInit {
constructor(
private modalController: ModalController,
private eventService: EventsService,
private eventService: EventsService,
private attachmentsService: AttachmentsService,
private toastService: ToastService,
private userService: AuthService,
@@ -137,23 +139,23 @@ export class NewEventPage implements OnInit {
}
ngOnInit() {
this.getRecurrenceTypes();
if(!this.restoreTemporaryData()){
// clear
this.postEvent = new Event();
this.eventBody = { BodyType : "1", Text : ""};
this.postEvent.Body = this.eventBody;
this.postEvent.Body = this.eventBody;
/* console.log(this.profile); */
let selectedStartdDate = this.selectedDate;
let selectedEndDate = new Date(this.selectedDate);
/* Set + 30minutes to seleted datetime */
selectedEndDate.setMinutes(this.selectedDate.getMinutes() + 30) ;
selectedEndDate.setMinutes(this.selectedDate.getMinutes() + 30) ;
if(this.selectedSegment != "Combinada"){
this.postEvent ={
EventId: '',
@@ -173,7 +175,7 @@ export class NewEventPage implements OnInit {
Organizer: '',
Categories: ['Reunião'],
HasAttachments: false,
EventRecurrence: null,
EventRecurrence: {Type:'-1'},
};
}
else{
@@ -195,7 +197,7 @@ export class NewEventPage implements OnInit {
Organizer: '',
Categories: ['Reunião'],
HasAttachments: false,
EventRecurrence: null,
EventRecurrence: {Type:'-1'},
};
}
@@ -206,7 +208,7 @@ export class NewEventPage implements OnInit {
} else {
this.taskParticipantsCc.push(e);
}
})
})
}
this.taskParticipants = removeDuplicate(this.taskParticipants);
@@ -221,7 +223,8 @@ export class NewEventPage implements OnInit {
this.date = new Date(2021,9,4,5,6,7);
this.getDatepickerData()
this.injectValidation()
this.injectValidation();
}
runValidation() {
@@ -292,7 +295,7 @@ export class NewEventPage implements OnInit {
}
});
}
close(){
this.deleteTemporaryData();
@@ -303,6 +306,24 @@ export class NewEventPage implements OnInit {
this.setIntervenientCC.emit([]);
}
getRecurrenceTypes() {
this.eventService.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.postEvent.EventRecurrence.Type = ev.filter(data => data != '-1');
}
if(ev.length == 0){
this.postEvent.EventRecurrence.Type = "-1";
}
}
getDatepickerData() {
if (this.postEvent) {
this.postEvent.StartDate = this.dateStart
@@ -332,6 +353,9 @@ export class NewEventPage implements OnInit {
if(this.documents.length >= 0) {
this.postEvent.HasAttachments = true;
}
if(this.selectedRecurringType != '-1'){
/* this.postEvent.EventRecurrence.Type = this.selectedRecurringType; */
}
if(this.loggeduser.Profile == 'MDGPR') {
// console.log('MD - Aqui');
@@ -340,9 +364,12 @@ export class NewEventPage implements OnInit {
this.showLoader = true;
console.log(this.postEvent);
let loader = this.toastService.loading()
let loader = this.toastService.loading();
console.log(this.postEvent);
this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe(
async (id) => {
@@ -365,10 +392,10 @@ export class NewEventPage implements OnInit {
SerialNumber: ''
};
});
await DocumentToSave.forEach((attachments, i) => {
this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) =>{
if(DocumentToSave.length == (i+1)){
this.afterSave();
}
@@ -376,7 +403,7 @@ export class NewEventPage implements OnInit {
});
if(DocumentToSave.length == 0){
this.afterSave();
@@ -386,11 +413,12 @@ export class NewEventPage implements OnInit {
},
error => {
loader.remove()
this.showLoader = false
this.toastService.badRequest('Evento não criado')
});
loader.remove();
}
else if(this.loggeduser.Profile == 'PR') {
console.log('PR - Aqui');
@@ -398,7 +426,7 @@ export class NewEventPage implements OnInit {
this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).subscribe(
(id) => {
console.log(id);
const eventId: any = id;
@@ -417,7 +445,7 @@ export class NewEventPage implements OnInit {
DocumentToSave.forEach((attachments, i) => {
this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) =>{
if(DocumentToSave.length == (i+1)){
this.afterSave();
}
@@ -465,7 +493,7 @@ export class NewEventPage implements OnInit {
async addParticipantsCc() {
this.saveTemporaryData();
this.openAttendeesComponent.emit({
type: "CC"
});
@@ -483,7 +511,7 @@ export class NewEventPage implements OnInit {
}
/**
*
*
* @description o pipeline já esta a funcionar tuda vez que nos fazer push na branch master e test o pipeline executa os teste, mas agora os teste temos que melhora para testar a app em tudos os pontos
* o pipeline já está a funcionar toda vez que nos fazer um push na branch master ou teste o pipeline executa os testes, mas agora os testes temos que melhorar para testar a app em todos os pontos
*/