This commit is contained in:
Peter Maquiran
2022-05-12 16:54:11 +01:00
parent b8ccefc9e3
commit 53b107e83c
9 changed files with 191 additions and 135 deletions
+1 -1
View File
@@ -298,7 +298,7 @@
<div class="EventListBox-container" >
<div class="day EventListBox-day mt-10" >
{{ TimelineDayEvent(events.key)}}
{{ TimelineDayEvent(events.key) }}
</div>
<div *ngFor="let event of events.value" class="EventListBox" >
@@ -18,7 +18,7 @@
<ion-input autocomplete="on" autocorrect="on" spellcheck="true" placeholder="Assunto*" [(ngModel)]="postEvent.Subject"></ion-input>
</div>
<div class="container-div" *ngIf="loggeduser.Profile == 'MDGPR'">
<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>
@@ -26,13 +26,12 @@
<div class="ion-input-class flex-grow-1 justify-center align-center material-inputs " [class.input-error]="Form?.get('CalendarName')?.invalid && validateFrom ">
<mat-form-field appearance="none" class="width-100" color="ion-color-secondary" placeholder="Selecione agenda">
<mat-select [(value)]="CalendarName" >
<!-- <mat-select [(value)]="postEvent.CalendarName" > -->
<mat-option value="PR">
Calendário do Presidente da República
</mat-option>
<mat-option value="MDGPR">
Calendário do MDGPR
<mat-select [(value)]="CalendarName" (selectionChange)="changeAgenda()">
<mat-option *ngFor="let calendars of eventService.calendarNamesAry" value="{{calendars}}">
<div *ngIf="calendars != 'Meu calendario' "> Calendário de {{calendars}} </div>
<div *ngIf="calendars == 'Meu calendario'"> {{calendars}} </div>
</mat-option>
</mat-select>
@@ -62,11 +61,8 @@
<mat-form-field appearance="none" class="width-100" color="ion-color-secondary" placeholder="Selecione agenda">
<mat-select [(value)]="postEvent.CalendarName" >
<mat-option value="Oficial">
Oficial
</mat-option>
<mat-option value="Pessoal">
Pessoal
<mat-option *ngFor="let calendars of CalendarNamesOptions" value="{{calendars}}">
{{ calendars }}
</mat-option>
</mat-select>
</mat-form-field>
@@ -112,14 +108,6 @@
</div>
</div>
<!-- <div *ngIf="Form && validateFrom" >
<div *ngIf="Form.get('Categories').invalid " class="input-errror-message">
{{ postEvent.Category }}
<div *ngIf="Form.get('Categories').errors?.required">
Campo obrigatório.
</div>
</div>
</div> -->
<div class="container-div">
<div class="ion-item-class-2 d-flex" >
@@ -82,11 +82,12 @@ export class NewEventPage implements OnInit {
autoStartTime;
autoEndTime;
CalendarNamesOptions = ['Oficial', 'Pessoal']
constructor(
private modalController: ModalController,
private navParams: NavParams,
private eventService: EventsService,
public eventService: EventsService,
private attachmentsService: AttachmentsService,
private toastService: ToastService,
userService: AuthService,
@@ -297,23 +298,21 @@ export class NewEventPage implements OnInit {
try {
const CalendarId = this.selectedCalendarId()
if(this.loggeduser.Profile == 'MDGPR') {
eventId = await this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).toPromise();
eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
}
else if(this.loggeduser.Profile == 'PR') {
eventId = await this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).toPromise();
const CalendarId = this.selectedCalendarId()
eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
} else {
eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName).toPromise();
const CalendarId = this.selectedCalendarId()
eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
}
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
@@ -351,6 +350,44 @@ export class NewEventPage implements OnInit {
}
selectedCalendarId () {
if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial']) {
return this.eventService.calendarNamesType[this.CalendarName]['OficialId']
} else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) {
return this.eventService.calendarNamesType[this.CalendarName]['PessoalId']
} else {
return '11:11'
}
}
changeAgenda() {
setTimeout(() => {
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']
}
}, 50)
}
async openAttendees() {
const modal = await this.modalController.create({
+1 -1
View File
@@ -137,7 +137,7 @@ export class AuthService {
SessionStore.reset(session)
this.ValidatedUser = SessionStore.user;
console.log('!!!::!!===', this.ValidatedUser)
// console.log('!!!::!!===', this.ValidatedUser)
this.storageService.store(AuthConnstants.USER, response);
return true;
+50 -44
View File
@@ -55,6 +55,11 @@ export class EventsService {
userCalendarNameOwnPessoal = '';
calendarNames = {}
calendarNamesAry = []
calendarNamesType = {}
myCalendarNames = {}
constructor(
private http: HttpClient,
@@ -118,6 +123,10 @@ export class EventsService {
this.userCalendarNameOwnPessoal = '';
this.calendarIds = [];
this.calendarNames = {}
this.calendarNamesAry = []
this.calendarNamesType = {}
if (this.loggeduser) {
if (this.loggeduser.Profile == 'MDGPR') {
@@ -189,8 +198,6 @@ export class EventsService {
});
}
this.loggeduser.OwnerCalendars.forEach(calendar => {
if(!this.calendarIds.includes(calendar.OwnerUserId)) {
@@ -250,22 +257,42 @@ export class EventsService {
if(sharedCalendar?.OwnerUserId) {
this.GetCalendarName(sharedCalendar.OwnerUserId).subscribe((e)=> {
this.calendarNames[sharedCalendar.CalendarId] = e.FullName
this.myCalendarNames[sharedCalendar.CalendarId] = e.FullName
if(!this.calendarNamesAry.includes(e.FullName)) {
this.calendarNamesAry.push(e.FullName)
this.calendarNamesType[e.FullName] = {}
}
this.calendarNamesType[e.FullName][sharedCalendar.CalendarName] = true
this.calendarNamesType[e.FullName][sharedCalendar.CalendarName+'Id'] = sharedCalendar.CalendarId
})
}
}
for (let sharedCalendar of this.loggeduser.OwnerCalendars) {
if(sharedCalendar?.OwnerUserId) {
this.GetCalendarName(sharedCalendar.OwnerUserId).subscribe((e)=> {
this.calendarNames[sharedCalendar.CalendarId] = e.FullName
})
this.calendarNames[sharedCalendar.CalendarId] = 'Meu calendario'
if(!this.calendarNamesAry.includes('Meu calendario')) {
this.calendarNamesAry.push('Meu calendario')
this.calendarNamesType['Meu calendario'] = {}
}
this.calendarNamesType['Meu calendario'][sharedCalendar.CalendarName] = true
this.calendarNamesType['Meu calendario'][sharedCalendar.CalendarName+'Id'] = sharedCalendar.CalendarId
}
}
}
}
isMyCalendar(CalendarId) {
return this.myCalendarNames[CalendarId] || ""
}
getCalendarOwnNameByCalendarId(CalendarId) {
return this.calendarNames[CalendarId] || ""
}
@@ -787,7 +814,7 @@ export class EventsService {
postEventGeneric(event: Event, calendarName: string) {
postEventGeneric(event: Event, calendarName: string, CalendarId) {
const puturl = environment.apiURL + 'Calendar/PostEvent';
let params = new HttpParams();
@@ -795,48 +822,27 @@ export class EventsService {
let options: any;
const headers = [
this.headerSharedOficial,
this.headerSharedPessoal,
this.headerOwnPessoal,
this.headerOwnOficial
]
if(this.hasOwnCalendar) {
switch (calendarName) {
case 'Oficial':
options = {
headers: this.headerOwnOficial,
params: params
};
break;
case 'Pessoal':
options = {
headers: this.headerOwnPessoal,
params: params
};
break;
}
} else {
switch (calendarName) {
case 'Oficial':
options = {
headers: this.headerSharedOficial,
params: params
};
break;
case 'Pessoal':
options = {
headers: this.headerSharedPessoal,
params: params
};
break;
}
}
const header = headers.find((header)=> {
return header?.get('CalendarId')?.includes(CalendarId)
})
options = {
headers: header,
params: params
};
return this.http.post<string>(`${puturl}`, event, options)
}
deleteEvent(eventid: string, eventDeleteType: number, calendarName: string) {
let arrayReq = [];
let Object = {
@@ -28,8 +28,8 @@
</div>
</div>
</div>
<div class="container-div" *ngIf="loggeduser.Profile == 'MDGPR'">
<div class="container-div" (click)="changeAgenda()">
<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>
@@ -37,13 +37,11 @@
<div class="ion-input-class flex-grow-1 justify-center align-center material-inputs " [class.input-error]="Form?.get('CalendarName')?.invalid && validateFrom ">
<mat-form-field appearance="none" class="width-100" color="ion-color-secondary" placeholder="Selecione agenda">
<mat-select [(value)]="CalendarName" >
<!-- <mat-select [(value)]="postEvent.CalendarName" > -->
<mat-option value="PR">
Calendário do Presidente da República
</mat-option>
<mat-option value="MDGPR">
Calendário do MDGPR
<mat-select [(value)]="CalendarName" (selectionChange)="changeAgenda()">
<mat-option *ngFor="let calendars of eventService.calendarNamesAry" value="{{calendars}}">
<div *ngIf="calendars != 'Meu calendario' "> Calendário de {{calendars}} </div>
<div *ngIf="calendars == 'Meu calendario'"> {{calendars}} </div>
</mat-option>
</mat-select>
@@ -67,7 +65,7 @@
</div>
<div class="container-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>
@@ -76,12 +74,11 @@
<mat-form-field appearance="none" class="width-100" color="ion-color-secondary" placeholder="Selecione agenda">
<mat-select [(value)]="postEvent.CalendarName" >
<mat-option value="Oficial">
Oficial
</mat-option>
<mat-option value="Pessoal">
Pessoal
<mat-option *ngFor="let calendars of CalendarNamesOptions" value="{{calendars}}">
{{ calendars }}
</mat-option>
</mat-select>
</mat-form-field>
@@ -124,9 +121,6 @@
<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 justify-center align-center material-inputs materia-top" [class.input-error]="Form?.get('Date')?.invalid && validateFrom ">
<mat-form-field class="date-hour-picker">
@@ -181,23 +175,6 @@
</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">
@@ -210,7 +187,7 @@
[(ngModel)]="postEvent.EventRecurrence.Type"
(ngModelChange)="onSelectedRecurringChanged($event)">
<mat-option
*ngFor="let recurring of recurringTypes" value="{{recurring.Code}}"
*ngFor="let recurring of recurringTypes" value="{{recurring.Code}}"
>
{{recurring.Description}}
</mat-option>
@@ -248,13 +225,6 @@
</div>
</div>
<!-- <div *ngIf="Form && validateFrom" class="container-div width-100">
<div *ngIf="Form.get('participantes').invalid " class="input-errror-message">
<div *ngIf="Form.get('participantes').errors?.required">
Adicionar participante.
</div>
</div>
</div> -->
<div class="container-div width-100">
<div class="ion-item-class-2 d-flex">
@@ -113,10 +113,13 @@ export class NewEventPage implements OnInit {
showLoader = false
CalendarName;
CalendarNameShow = true
CalendarNamesOptions = ['Oficial', 'Pessoal']
constructor(
private modalController: ModalController,
private eventService: EventsService,
public eventService: EventsService,
private attachmentsService: AttachmentsService,
private toastService: ToastService,
private userService: AuthService,
@@ -131,13 +134,13 @@ export class NewEventPage implements OnInit {
let now = new Date();
if(now.getMinutes() <= 30){
if(now.getMinutes() <= 30) {
this.autoStartTime = new Date(now.setMinutes(30));
this.postEvent.StartDate = this.autoStartTime;
this.autoEndTime = new Date(this.autoStartTime.getTime() + 30 * 60000);
this.postEvent.EndDate = this.autoEndTime;
}
else{
else {
this.autoStartTime = new Date(now.setHours(now.getHours()+1));
this.autoStartTime = new Date(this.autoStartTime.setMinutes(0));
this.postEvent.StartDate = this.autoStartTime;
@@ -176,7 +179,7 @@ export class NewEventPage implements OnInit {
Organizer: '',
Category: 'Reunião',
HasAttachments: false,
EventRecurrence: {Type:'-1',LastOccurrence:this.autoEndTime},
EventRecurrence: { Type:'-1', LastOccurrence: this.autoEndTime },
};
}
else{
@@ -286,6 +289,33 @@ export class NewEventPage implements OnInit {
}
}
changeAgenda() {
this.CalendarNameShow = false
setTimeout(()=>{
this.CalendarNameShow = true
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']
}
}, 50)
}
openLastOccurrence() {
let input: any = document.querySelector('#last-occurrence')
if(input) {
@@ -362,12 +392,12 @@ export class NewEventPage implements OnInit {
}
if(this.loggeduser.Profile == 'MDGPR') {
const CalendarId = this.selectedCalendarId()
this.showLoader = true;
let loader = this.toastService.loading();
this.eventService.postEventMd(this.postEvent, this.postEvent.CalendarName).subscribe(
this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe(
async (id) => {
loader.remove()
this.showLoader = false
@@ -413,8 +443,9 @@ export class NewEventPage implements OnInit {
}
else if(this.loggeduser.Profile == 'PR') {
const CalendarId = this.selectedCalendarId()
this.eventService.postEventPr(this.postEvent, this.postEvent.CalendarName).subscribe(
this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe(
(id) => {
@@ -447,10 +478,15 @@ export class NewEventPage implements OnInit {
this.toastService.successMessage('Evento criado')
});
} else {
this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName).subscribe(
this.postEvent.CalendarName
const CalendarId = this.selectedCalendarId()
this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe(
(id) => {
const eventId: any = id;
const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
@@ -478,7 +514,22 @@ export class NewEventPage implements OnInit {
this.afterSave();
}
this.toastService.successMessage('Evento criado')
});
});
}
}
selectedCalendarId () {
if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial']) {
return this.eventService.calendarNamesType[this.CalendarName]['OficialId']
} else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) {
return this.eventService.calendarNamesType[this.CalendarName]['PessoalId']
} else {
return '11:11'
}
}
@@ -492,7 +543,7 @@ export class NewEventPage implements OnInit {
this.setIntervenientCC.emit([]);
}
removeAttachment(index: number){
removeAttachment(index: number) {
this.documents = this.documents.filter( (e, i) => index != i);
}
@@ -534,7 +585,6 @@ export class NewEventPage implements OnInit {
*/
restoreTemporaryData(): boolean {
const restoredData = window['temp.path:/home/agenda/new-event.component.ts']
if(JSON.stringify(restoredData) != "{}" && undefined != restoredData) {
@@ -551,7 +601,7 @@ export class NewEventPage implements OnInit {
}
}
deleteTemporaryData(){
deleteTemporaryData() {
window['temp.path:/home/agenda/new-event.component.ts'] = {}
}
@@ -52,7 +52,7 @@
</div>
<div class="d-flex justify-space-between">
<ion-label *ngIf="msg.delate == false" class="flex-0">{{msg.msg}} </ion-label>
<div *ngIf="msg.delate == false" class="message-box">{{msg.msg}} </div>
<ion-label *ngIf="msg.delate == true" class="flex-0">Apagou a mensagem</ion-label>
<ion-label class="float-status-all float-status" *ngIf="msg.u.username==sessionStore.user.UserName">
@@ -341,3 +341,8 @@ display: block;
border: 1px solid red !important;
overflow: auto;
}
.message-box {
flex: auto;
margin-right: 9px;
}