- {{document.Assunto}}
+ {{document.Assunto || document.SourceName}}
{{ TaskService.attachmentAppName(document)}}
{{document.appName}}
@@ -353,7 +459,7 @@
-
+
diff --git a/src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts b/src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts
index ef6a05478..0293ca6a4 100644
--- a/src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts
+++ b/src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts
@@ -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
+ 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";
diff --git a/src/app/pages/agenda/new-event/new-event.page.html b/src/app/pages/agenda/new-event/new-event.page.html
index ed6d185a3..1a311a6d8 100644
--- a/src/app/pages/agenda/new-event/new-event.page.html
+++ b/src/app/pages/agenda/new-event/new-event.page.html
@@ -298,35 +298,6 @@