mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
create event from attachment
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<!-- *ngIf="p.userRole('PR')" -->
|
||||
<!-- *ngIf="p.role(['PR','MD']).permissionAnyOf(['view','edit'])" -->
|
||||
|
||||
<label >Convocar Reunião</label><br>
|
||||
<label >Convocar Reunião ..</label><br>
|
||||
<i style="margin-top: -3px; font-size: 15px;" > Campos marcados com * são obrigatórios</i>
|
||||
</div>
|
||||
</div>
|
||||
@@ -21,7 +21,7 @@
|
||||
<div *ngIf="Form && validateFrom" >
|
||||
<div *ngIf="Form.get('Subject').invalid " class="input-errror-message">
|
||||
<!-- <div *ngIf="Form.get('Subject').errors?.required">
|
||||
|
||||
|
||||
</div> -->
|
||||
<div *ngIf="Form.get('Subject').errors?.minlength">
|
||||
O campo deve ter pelo menos 4 caracteres.
|
||||
@@ -35,15 +35,15 @@
|
||||
<ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
|
||||
</div>
|
||||
<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" (selectionChange)="changeAgenda()">
|
||||
|
||||
|
||||
<!-- <mat-option *ngFor="let calendars of _eventService.calendarNamesAry; let i = index" value="{{calendars}}">
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars == 'Presidente da República'"> {{ environment.agendaPR}} </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars == 'Ministro e Director do Gabinete do PR'"> {{ environment.agendaVP}} </div>
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars != 'Ministro e Director do Gabinete do PR' && calendars != 'Presidente da República'"> Agenda do {{calendars}} </div>
|
||||
|
||||
|
||||
<div *ngIf="calendars == 'Meu calendario'"> Minha agenda </div> -->
|
||||
<mat-option *ngFor="let calendars of _eventService.calendarNamesAry" value="{{calendars.Fullname || calendars}}">
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role == 'Presidente da República'"> {{ environment.agendaPR}} </div>
|
||||
@@ -51,14 +51,34 @@
|
||||
<div *ngIf="calendars != 'Meu calendario' && calendars.Role != 'Ministro e Director do Gabinete do PR' && calendars.Role != 'Presidente da República'"> Agenda do {{calendars.Fullname}} </div>
|
||||
<div *ngIf="calendars == 'Meu calendario'"> Minha agenda </div>
|
||||
</mat-option>
|
||||
|
||||
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
|
||||
</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 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)]="postData.CalendarName" >
|
||||
<mat-option *ngFor="let calendars of CalendarNamesOptions" value="{{calendars}}">
|
||||
Agenda {{ calendars }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-div width-100">
|
||||
<div class="ion-item-class-2 width-100">
|
||||
<div class="ion-icon-class">
|
||||
@@ -73,7 +93,7 @@
|
||||
<!-- <div *ngIf="Form && validateFrom" >
|
||||
<div *ngIf="Form.get('Location').invalid " class="input-errror-message">
|
||||
<div *ngIf="Form.get('Location').errors?.required">
|
||||
|
||||
|
||||
</div>
|
||||
<div *ngIf="Form.get('Location').errors?.minlength">
|
||||
O campo deve ter pelo menos 4 caracteres.
|
||||
@@ -83,18 +103,32 @@
|
||||
|
||||
|
||||
|
||||
<div class="container-div">
|
||||
<div class="ion-item-class-2">
|
||||
<div *ngIf="(sharedCalendar | async) as calendarData" 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" >
|
||||
<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">
|
||||
<div *ngIf="utils.hasPrCalendar(calendarData) && !hasChangeCalendar " style="margin-bottom: -20px;">PR</div>
|
||||
<div *ngIf="selectedUserCalendar == sessionStore.user.UserId && !hasChangeCalendar && sessionStore.user.Profile != 'PR' " style="margin-bottom: -20px;">
|
||||
Minha agenda
|
||||
</div>
|
||||
|
||||
<mat-select [(value)]="selectedUserCalendar" (selectionChange)="changeAgenda();changeSegmentCalendar()">
|
||||
|
||||
<mat-option *ngFor="let calendars of calendarData" value="{{calendars.wxUserId}}">
|
||||
|
||||
<div *ngIf="calendars.roleId == RoleIdService.PRES">PR </div>
|
||||
<div *ngIf="calendars.roleId == RoleIdService.MD && calendars.roleId != sessionStore.user.RoleID">AGENDA DO MDGPR</div>
|
||||
<div *ngIf="calendars.roleId != RoleIdService.MD && calendars.roleId != RoleIdService.PRES && calendars.wxFullName && calendars.wxUserId != sessionStore.user.UserId"> Agenda do {{calendars.wxFullName}} </div>
|
||||
<div *ngIf="calendars.wxUserId == sessionStore.user.UserId && sessionStore.user.Profile != 'PR'">
|
||||
Minha agenda
|
||||
</div>
|
||||
|
||||
<mat-form-field floatLabel="never" appearance="none" class="d-md-block width-100">
|
||||
<mat-select placeholder="Selecione agenda" [(ngModel)]="postData.CalendarName" >
|
||||
<mat-option *ngFor="let calendars of CalendarNamesOptions" value="{{calendars}}">
|
||||
Agenda {{ calendars }}
|
||||
</mat-option>
|
||||
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
@@ -133,6 +167,78 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-div">
|
||||
<div>
|
||||
<ion-item>
|
||||
<ion-label>Todo dia</ion-label>
|
||||
<ion-checkbox [(ngModel)]="postData.IsAllDayEvent" (ionChange)="onCheckboxChange($event)"></ion-checkbox>
|
||||
</ion-item>
|
||||
</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-reapet.svg"></ion-icon>
|
||||
</div>
|
||||
<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" > -->
|
||||
<mat-select [(value)]="postData.EventRecurrence.frequency" >
|
||||
<mat-option value="never">
|
||||
Nunca
|
||||
</mat-option>
|
||||
<mat-option value="daily">
|
||||
Diário
|
||||
</mat-option>
|
||||
<mat-option value="weekly">
|
||||
Semanalmente
|
||||
</mat-option>
|
||||
<mat-option value="monthly">
|
||||
Mensal
|
||||
</mat-option>
|
||||
<mat-option value="yearly">
|
||||
Anual
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="postData.EventRecurrence.frequency != 'never'" class="container-div">
|
||||
<div class="ion-item-class-2 d-flex" >
|
||||
<div class="ion-icon-class">
|
||||
<ion-icon slot="start" src="assets/images/icons-reapet.svg"></ion-icon>
|
||||
</div>
|
||||
|
||||
<div class="ion-input-class flex-grow-1 justify-center align-center material-inputs materia-top" >
|
||||
|
||||
<mat-form-field appearance="none" class="date-hour-picker">
|
||||
<input matInput [ngxMatDatetimePicker]="picker1"
|
||||
placeholder="Data Fim de Recorrência*"
|
||||
[(ngModel)]="postData.EventRecurrence.until"
|
||||
[disabled]="disabled"
|
||||
>
|
||||
<mat-datepicker-toggle id="new-inicio" matSuffix [for]="picker1" ></mat-datepicker-toggle>
|
||||
<ngx-mat-datetime-picker #picker1
|
||||
[showSpinners]="showSpinners"
|
||||
[showSeconds]="showSeconds"
|
||||
[stepHour]="stepHour" [stepMinute]="stepMinute"
|
||||
[stepSecond]="stepSecond"
|
||||
[touchUi]="touchUi"
|
||||
[hideTime]="true"
|
||||
>
|
||||
</ngx-mat-datetime-picker>
|
||||
</mat-form-field>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-div">
|
||||
<div class="ion-item-class-2">
|
||||
<div class="ion-icon-class">
|
||||
@@ -194,7 +300,7 @@
|
||||
</div>
|
||||
<div class="ion-input-class flex-grow-1" [class.input-error]="Form?.get('dateOccurrence')?.invalid && validateFrom ">
|
||||
|
||||
|
||||
|
||||
<mat-form-field appearance="none" floatLabel="never" class="width-100" value="false" interface="action-sheet" required>
|
||||
<mat-select placeholder="Selecione repetição*"
|
||||
[(ngModel)]="EventRecurrenceType"
|
||||
@@ -316,7 +422,7 @@
|
||||
<ion-item>
|
||||
<ion-label>
|
||||
<p class="d-flex ion-justify-content-between">
|
||||
<span class="attach-title-item">{{document.Assunto}}</span>
|
||||
<span class="attach-title-item">{{document.Assunto || document.SourceName}}</span>
|
||||
<span class="app-name" *ngIf="!document.appName">{{ TaskService.attachmentAppName(document)}}</span>
|
||||
<span class="app-name" *ngIf="document.appName">{{document.appName}}</span>
|
||||
<span class="close-button text-black" (click)="removeAttachment(i)" >
|
||||
@@ -353,7 +459,7 @@
|
||||
<div class="buttons">
|
||||
<button class="btn-ok" shape="round" (click)="saveTask()">Gravar</button>
|
||||
<button class="btn-cancel" shape="round" (click)="close()">Cancelar</button>
|
||||
|
||||
|
||||
</div>
|
||||
</ion-footer>
|
||||
|
||||
|
||||
@@ -23,7 +23,13 @@ import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { TaskService } from 'src/app/services/task.service'
|
||||
import { ContactsService } from 'src/app/services/contacts.service';
|
||||
|
||||
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { Observable } from 'rxjs';
|
||||
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
|
||||
import { isHttpError } from 'src/app/services/http.service';
|
||||
import { RoleIdService } from 'src/app/services/role-id.service';
|
||||
import { Utils } from 'src/app/services/Repositorys/Agenda/utils';
|
||||
|
||||
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
|
||||
parse: {
|
||||
@@ -97,25 +103,32 @@ export class DocumentSetUpMeetingPage implements OnInit {
|
||||
eventPipe = new EventPipe()
|
||||
CalendarName;
|
||||
CalendarNameShow = true
|
||||
CalendarNamesOptions
|
||||
testeFormDefaul = "Eudes"
|
||||
environment = environment
|
||||
eventPersons: EventPerson[];
|
||||
contacts: EventPerson[];
|
||||
sharedCalendar: Observable<TableSharedCalendar[]>
|
||||
selectedUserCalendar:any;
|
||||
sessionStore = SessionStore;
|
||||
hasChangeCalendar = false
|
||||
eventRecurence = 'never';
|
||||
|
||||
CalendarNamesOptions = ['Oficial', 'Pessoal']
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
private router: Router,
|
||||
private navParams: NavParams,
|
||||
authService: AuthService,
|
||||
private toastService: ToastService,
|
||||
private calendarService: EventsService,
|
||||
private eventService: EventService,
|
||||
public ThemeService: ThemeService,
|
||||
public _eventService: EventsService,
|
||||
private httpErroHandle: HttpErrorHandle,
|
||||
public TaskService: TaskService,
|
||||
private contactsService: ContactsService,
|
||||
private agendaDataRepository: AgendaDataRepositoryService,
|
||||
public RoleIdService: RoleIdService,
|
||||
public utils: Utils,
|
||||
) {
|
||||
this.loggeduser = SessionStore.user;
|
||||
this.document = this.navParams.get('document')
|
||||
@@ -192,6 +205,14 @@ export class DocumentSetUpMeetingPage implements OnInit {
|
||||
|
||||
this.changeAgenda()
|
||||
|
||||
this.postData.EventRecurrence = {
|
||||
frequency: this.eventRecurence,
|
||||
until: "",
|
||||
Type: '' ,
|
||||
}
|
||||
|
||||
this.postData.IsAllDayEvent = false;
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -199,14 +220,36 @@ export class DocumentSetUpMeetingPage implements OnInit {
|
||||
this.setDefaultTime()
|
||||
this.getRecurrenceTypes();
|
||||
this.fetchContacts("")
|
||||
|
||||
|
||||
this.setCalendarByDefault(true)
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
clearInterval(this.myInterval)
|
||||
}
|
||||
|
||||
changeSegmentCalendar() {
|
||||
this.hasChangeCalendar = true
|
||||
}
|
||||
|
||||
|
||||
async changeAgenda() {
|
||||
|
||||
const result = await this.agendaDataRepository.geCalendars()
|
||||
|
||||
const selectedCalendar = result.find(e => e.wxUserId == this.selectedUserCalendar)
|
||||
|
||||
if(selectedCalendar) {
|
||||
if(selectedCalendar.shareType == 1) {
|
||||
this.CalendarNamesOptions = ['Oficial']
|
||||
} else if(selectedCalendar.shareType == 2) {
|
||||
this.CalendarNamesOptions = ['Pessoal']
|
||||
} else if (selectedCalendar.shareType == 3) {
|
||||
this.CalendarNamesOptions = ['Oficial', 'Pessoal']
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
myInterval = setInterval(() => {
|
||||
document.querySelectorAll('.ngx-mat-timepicker input').forEach((e: any) => {
|
||||
if (e) {
|
||||
@@ -279,34 +322,25 @@ export class DocumentSetUpMeetingPage implements OnInit {
|
||||
})
|
||||
}
|
||||
|
||||
changeAgenda() {
|
||||
async setCalendarByDefault(force) {
|
||||
if (!this.selectedUserCalendar || force) {
|
||||
|
||||
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.postData.CalendarName = 'Oficial'
|
||||
|
||||
} else if (this._eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) {
|
||||
this.CalendarNamesOptions = ['Pessoal']
|
||||
this.postData.CalendarName = 'Pessoal'
|
||||
const data = await this.agendaDataRepository.geCalendars()
|
||||
|
||||
const prObject = data.find(e => e?.roleId == 100000014)
|
||||
if(prObject) {
|
||||
this.selectedUserCalendar = prObject.wxUserId
|
||||
} else {
|
||||
this.CalendarNamesOptions = ['Oficial', 'Pessoal']
|
||||
this.selectedUserCalendar = SessionStore.user.UserId
|
||||
}
|
||||
}, 50)
|
||||
|
||||
this.changeAgenda()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
async saveTask() {
|
||||
@XTracerAsync({name:'document-setup-metting', bugPrint: true})
|
||||
async saveTask(tracing?: TracingType) {
|
||||
|
||||
if (this.loggeduser.Profile != 'PR') {
|
||||
this.injectValidation()
|
||||
@@ -314,49 +348,95 @@ export class DocumentSetUpMeetingPage implements OnInit {
|
||||
if (this.Form.invalid) return false
|
||||
}
|
||||
|
||||
let Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
|
||||
|
||||
let postEvent = {
|
||||
EventId: '',
|
||||
Subject: this.postData.Subject,
|
||||
Body: this.postData.Body.Text,
|
||||
Location: this.postData.Location,
|
||||
CalendarId: this.selectedCalendarId(),
|
||||
CalendarName: this.postData.CalendarName,
|
||||
StartDate: this.postData.StartDate,
|
||||
EndDate: this.postData.EndDate,
|
||||
EventType: 'Reunião',
|
||||
Attendees: Attendees,
|
||||
IsMeeting: false, //
|
||||
IsRecurring: this.postData.IsRecurring,
|
||||
AppointmentState: 0, //
|
||||
TimeZone: '', //
|
||||
Organizer: '', //
|
||||
Category: 'Reunião',
|
||||
HasAttachments: false,
|
||||
EventRecurrence: {
|
||||
Type: this.EventRecurrenceType,
|
||||
LastOccurrence: this.Occurrence,
|
||||
},
|
||||
Attachments: this.attachments,
|
||||
}
|
||||
this.postData.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
|
||||
|
||||
const laoder = this.toastService.loading();
|
||||
|
||||
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
|
||||
if(calendar.isOk()) {
|
||||
|
||||
const value = await this.agendaDataRepository.createEvent(this.postData, this.attachments, calendar.value, tracing, true)
|
||||
if(value.isOk()) {
|
||||
|
||||
this.eventService.create({ body: postEvent, calendar: this.postData.CalendarName }).subscribe(async (respose) => {
|
||||
laoder.remove();
|
||||
this.httpErroHandle.httpsSucessMessagge('new event');
|
||||
this.modalController.dismiss()
|
||||
}, (error) => {
|
||||
laoder.remove();
|
||||
this.httpErroHandle.httpStatusHandle(error)
|
||||
}, () => {
|
||||
laoder.remove();
|
||||
});
|
||||
} else {
|
||||
|
||||
if(!isHttpError(value.error)) {
|
||||
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #1')
|
||||
console.log(value.error)
|
||||
tracing.bugFlag()
|
||||
} else {
|
||||
this.httpErroHandle.httpStatusHandle(value.error.status)
|
||||
}
|
||||
console.log('create event error: ', value.error)
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.setAttribute('no', 'this.selectedUserCalendar')
|
||||
tracing.bugFlag()
|
||||
}
|
||||
|
||||
laoder.remove();
|
||||
|
||||
}
|
||||
|
||||
onCheckboxChange(event: any) {
|
||||
if (this.postData.IsAllDayEvent) {
|
||||
this.postData.IsAllDayEvent = this.postData.IsAllDayEvent;
|
||||
this.postData.StartDate = this.setAlldayTime(this.postData.StartDate)
|
||||
this.postData.EndDate = this.setAlldayTimeEndDate(this.postData.EndDate)
|
||||
|
||||
console.log('Recurso ativado!!');
|
||||
} else {
|
||||
this.postData.IsAllDayEvent = this.postData.IsAllDayEvent;
|
||||
this.postData.EndDate = this.setAlldayTimeEndDateNotAlday(this.postData.EndDate)
|
||||
console.log('Recurso desativado');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
setAlldayTime(timeToReturn) {
|
||||
let date: any = new Date(timeToReturn) || new Date();
|
||||
let newdate = new Date();
|
||||
date.setHours(0)
|
||||
date.setMinutes(0)
|
||||
date.setSeconds(0);
|
||||
|
||||
|
||||
return date
|
||||
}
|
||||
|
||||
setAlldayTimeEndDate(timeToReturn) {
|
||||
let date: any = new Date(timeToReturn) || new Date();
|
||||
let newdate = new Date();
|
||||
date.setHours(23)
|
||||
date.setMinutes(59)
|
||||
date.setSeconds(0);
|
||||
|
||||
|
||||
return date
|
||||
}
|
||||
|
||||
setAlldayTimeEndDateNotAlday(timeToReturn) {
|
||||
let date: any = new Date(timeToReturn) || new Date();
|
||||
let newdate = new Date();
|
||||
date.setHours(23)
|
||||
date.setMinutes(0)
|
||||
date.setSeconds(0);
|
||||
|
||||
|
||||
return date
|
||||
}
|
||||
|
||||
|
||||
async addParticipants() {
|
||||
|
||||
this.adding = "intervenient";
|
||||
|
||||
Reference in New Issue
Block a user