From e85d9abdf98e835d1285080fb0d3cddf3049388e Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Mon, 6 Nov 2023 09:36:30 +0100 Subject: [PATCH 1/2] fix agenda --- src/app/pages/agenda/agenda.page.html | 40 +++++--- src/app/pages/agenda/agenda.page.ts | 48 ++++++--- src/app/services/agenda/list-box.service.ts | 102 +++++++++++++++----- 3 files changed, 133 insertions(+), 57 deletions(-) diff --git a/src/app/pages/agenda/agenda.page.html b/src/app/pages/agenda/agenda.page.html index d44521415..4bf9da3f0 100644 --- a/src/app/pages/agenda/agenda.page.html +++ b/src/app/pages/agenda/agenda.page.html @@ -4,7 +4,7 @@ - +
@@ -14,7 +14,7 @@ -
+
@@ -55,13 +55,13 @@ class="select-calendar"> - + - +
PR
MDGPR
-
Agenda do {{calendars.Fullname}}
+
Agenda do {{calendars.Fullname}}
+ + + +
+
- {{ TimelineDay(events.key)}}
{{ viewTitle }}
+ {{ TimelineDay(events.key)}}
{{ events.value[0].start | date: 'MMMM'}}
diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts index 23aa44e11..f90403029 100644 --- a/src/app/pages/agenda/agenda.page.ts +++ b/src/app/pages/agenda/agenda.page.ts @@ -271,16 +271,19 @@ export class AgendaPage implements OnInit { } if (realoadCounter != 0) { - if(this.currentMoth.rangeStartDate != null) { - - this.loadRangeEvents(this.currentMoth.rangeStartDate, this.currentMoth.rangeEndDate) - } else { - this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate); - } - - - this.updateEventListBox() } + + + this.calendar.currentDate = new Date(); + + try { + this.myCal.update(); + this.myCal.loadEvents(); + this.onDropDownScrollWeal() + } catch (e) { } + + this.updateEventListBox() + realoadCounter++; this.weekToShow() } @@ -735,7 +738,10 @@ export class AgendaPage implements OnInit { const selectedDay = momentG(this.eventSelectedDate, 'dd', 'pt'); if(this.TimelineMDList[selectedDay]) { - this.hasEventToday = true + if(momentG(new Date(this.TimelineMDList[selectedDay][0].start), 'MMMM', 'pt') == momentG(this.eventSelectedDate, 'MMMM', 'pt')) { + this.hasEventToday = true + } + } else { this.hasEventToday = false } @@ -763,10 +769,7 @@ export class AgendaPage implements OnInit { } catch (e) { } this.updateEventListBox() - } else { - - } - + } else {} } @@ -1150,10 +1153,8 @@ export class AgendaPage implements OnInit { // THIS LINE this.updateEventListBox(); - } - shoeEventDay(events: any[]) { if (this.segment == 'Combinado') { @@ -1171,3 +1172,18 @@ export class AgendaPage implements OnInit { } } + +function endOfMonth(myDate){ + let date = new Date(myDate); + date.setDate(1); // Avoids edge cases on the 31st day of some months + date.setMonth(date.getMonth() +1); + date.setDate(0); + date.setHours(23); + date.setMinutes(59); + date.setSeconds(59); + return date; +} + +const addDays = 5; +const endDateRange = endOfMonth(new Date(5)) +endDateRange.setDate(endDateRange.getDate() + addDays) diff --git a/src/app/services/agenda/list-box.service.ts b/src/app/services/agenda/list-box.service.ts index 5b9747fca..986327729 100644 --- a/src/app/services/agenda/list-box.service.ts +++ b/src/app/services/agenda/list-box.service.ts @@ -8,12 +8,12 @@ import { DateService } from '../date.service'; export class ListBoxService { height = "unset" - + constructor( private dateService: DateService ){} - + filterProfile(eventSource: EventListStore[] = [], profile: 'md' | 'pr' | 'all') { return eventSource.filter((e) => e.profile == profile) } @@ -21,7 +21,7 @@ export class ListBoxService { getEventInsideRange(eventSource: EventListStore[], rangeStartDate, randEndDate) { return eventSource.filter((e)=> { if(new Date(rangeStartDate).getTime() <= new Date(e.startTime).getTime() && - new Date(randEndDate).getTime() >= new Date(e.endTime).getTime()) { + new Date(randEndDate).getTime() >= new Date(e.endTime).getTime()) { return true } return false @@ -29,7 +29,7 @@ export class ListBoxService { } filterSegment(eventSource: EventListStore[], segment): EventListStore[] { - + return eventSource.filter( data => data.calendarName == segment) } @@ -39,17 +39,17 @@ export class ListBoxService { // // filter range // if(selectedDate) { - // eventSource = eventSource.filter(data => - // data.startTime.toLocaleDateString('pt') >= new Date(rangeStartDate).toLocaleDateString('pt') && + // eventSource = eventSource.filter(data => + // data.startTime.toLocaleDateString('pt') >= new Date(rangeStartDate).toLocaleDateString('pt') && // data.startTime.toLocaleDateString('pt') <= new Date(rangeStartDate).toLocaleDateString('pt') // ) // } if(segment!='Combinado') { - eventSource = this.filterSegment(eventSource, segment) + eventSource = this.filterSegment(eventSource, segment) } - + // if(profile != 'all') { // eventSource = this.filterProfile(eventSource, profile) // } @@ -59,8 +59,22 @@ export class ListBoxService { newStracture = this.encapsulation(eventSource); return this.display(newStracture, selectedDate) + + // console.log({daysObject}) + + // const daysStringNum = Object.keys(daysObject) + + // for(const day of daysStringNum) { + // daysObject[day] = daysObject[day].reverse() + // } + + + // daysObject = this.transformObjectKeyOrder(daysObject, daysStringNum) + + // return daysObject } + display(list: CustomCalendarEvent[], selectedDate) { let days = {}; @@ -74,8 +88,8 @@ export class ListBoxService { endTime: event.end }) - const day = this.dateService.getDay(event.start) - + const day = this.dateService.getDay(event.start) + event['manyDays'] = !this.dateService.isSameDate(event.start, event.end) event['todayOnly'] = this.dateService.isSameDate(event.start, event.end) @@ -94,28 +108,28 @@ export class ListBoxService { if (diffDays >= 1) { const StartEvent = this.transForm(event, {startMany: true, endMany: false, middle: false}) - + if(this.CanPush(event, selectedDate)) days[day].push(StartEvent) - + let i = 1; - + // create event between date - while (startDate.getFullYear() != endDate.getFullYear() || + while (startDate.getFullYear() != endDate.getFullYear() || startDate.getMonth() != endDate.getMonth() || startDate.getDate() != endDate.getDate()) { const newDate = startDate.setDate(startDate.getDate()+ i) - let otherDays = this.dateService.getDay(newDate) - + let otherDays = this.dateService.getDay(newDate) + event['other'] = true - + event.start = newDate if(!days.hasOwnProperty(otherDays)) { days[otherDays] = [] } - - if (!(startDate.getFullYear() != endDate.getFullYear() || + + if (!(startDate.getFullYear() != endDate.getFullYear() || startDate.getMonth() != endDate.getMonth() || startDate.getDate() != endDate.getDate())) { // last push @@ -128,7 +142,9 @@ export class ListBoxService { const EndEvent = this.transForm(event, {startMany: false,endMany: true, middle: true}) if(this.CanPush(event, selectedDate)) days[otherDays].push(EndEvent) } - + + days[otherDays] = days[otherDays].reverse() + } } else { @@ -143,7 +159,7 @@ export class ListBoxService { if(this.CanPush(event, selectedDate) && diffDays != 2) days[day].push(event) } - // + // }) @@ -162,9 +178,13 @@ export class ListBoxService { CanPush(event: any, selectedDate: Date) { - return new Date(event.start).getMonth() == selectedDate.getMonth() && - new Date(event.start).getFullYear() == selectedDate.getFullYear() && - new Date(event.start).getDate() >= selectedDate.getDate() + const limite = this.endOfMonth(selectedDate) + limite.setDate(limite.getDate() + 10) + + return new Date(event.start).getFullYear() >= selectedDate.getFullYear() && + new Date(event.start).getMonth() >= selectedDate.getMonth() && + new Date(event.start).getTime() >= selectedDate.getTime() && + new Date(event.start).getTime() <= limite.getTime() } encapsulation(eventsList:EventListStore[]): CustomCalendarEvent[] { @@ -173,7 +193,7 @@ export class ListBoxService { let events: CustomCalendarEvent[] = []; eventsList.forEach((element, eventIndex) => { - + events.push({ start: new Date(element.startTime), end: new Date(element.endTime), @@ -209,4 +229,36 @@ export class ListBoxService { }) } + + + transformObjectKeyOrder(originalObject, keyOrder) { + const transformedObject = {}; + + for (const key of keyOrder) { + if (originalObject.hasOwnProperty(key)) { + transformedObject[key] = originalObject[key]; + } + } + + // Include any remaining keys not in the specified order + for (const key in originalObject) { + if (!keyOrder.includes(key) && originalObject.hasOwnProperty(key)) { + transformedObject[key] = originalObject[key]; + } + } + + return transformedObject; + } + + + endOfMonth(myDate){ + let date = new Date(myDate); + date.setDate(1); // Avoids edge cases on the 31st day of some months + date.setMonth(date.getMonth() +1); + date.setDate(0); + date.setHours(23); + date.setMinutes(59); + date.setSeconds(59); + return date; + } } From 7f527729b1840eaf551b3afa73428061415ed673 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Mon, 6 Nov 2023 09:37:33 +0100 Subject: [PATCH 2/2] add version --- version/git-version.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/git-version.ts b/version/git-version.ts index 4c3d2bc5c..26b7ee4ca 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -5,7 +5,7 @@ export let versionData = { "lastCommitAuthor": "'Peter Maquiran'", "lastCommitTime": "'Thu Aug 31 12:00:52 2023 +0100'", "lastCommitMessage": "add attachments", - "lastCommitNumber": "569", + "lastCommitNumber": "1569", "change": "diff --git a/src/app/modals/create-process/create-process.page.ts b/src/app/modals/create-process/create-process.page.ts\nindex 6b58016d7..a27c5e424 100644\n--- a/src/app/modals/create-process/create-process.page.ts\n+++ b/src/app/modals/create-process/create-process.page.ts\n@@ -282,7 +282,8 @@ export class CreateProcessPage implements OnInit {\n const DocumentToSave = this.documents.map((e: any) => {\n return {\n ApplicationId: e.ApplicationType || e.ApplicationId,\n- SourceId: e.Id || e.DocId || e.SourceId\n+ SourceId: e.Id || e.DocId || e.SourceId,\n+ SourceName: e.Assunto || e.SourceName || e.Description,\n }\n });\n \ndiff --git a/src/app/modals/document-detail/document-detail.page.ts b/src/app/modals/document-detail/document-detail.page.ts\nindex 629d48c91..1bfcca6e3 100644\n--- a/src/app/modals/document-detail/document-detail.page.ts\n+++ b/src/app/modals/document-detail/document-detail.page.ts\n@@ -129,7 +129,7 @@ export class DocumentDetailPage implements OnInit {\n \n async viewDocumentModal() {\n \n- const selectedDoc = this.LoadedDocument.Documents[ this.dicIndex]\n+ const selectedDoc = this.LoadedDocument\n \n let task = {\n serialNumber: '',\n@@ -154,7 +154,7 @@ export class DocumentDetailPage implements OnInit {\n url: '',\n title_link: '',\n },\n- Document: this.LoadedDocument.Documents[ this.dicIndex],\n+ Document: this.LoadedDocument,\n applicationId: task.workflowInstanceDataFields.SourceSecFsID,\n docId: task.workflowInstanceDataFields.SourceID ,\n folderId: '',\n@@ -192,7 +192,8 @@ export class DocumentDetailPage implements OnInit {\n componentProps: {\n taskAction: taskAction,\n task: this.DocumentTask,\n- aplicationId: this.LoadedDocument.ApplicationId || this.LoadedDocument.ApplicationID\n+ aplicationId: this.LoadedDocument.ApplicationId || this.LoadedDocument.ApplicationID,\n+ document: this.LoadedDocument\n },\n cssClass: classs,\n });\n@@ -213,6 +214,7 @@ export class DocumentDetailPage implements OnInit {\n } else {\n classs = 'modal modal-desktop showAsideOptions'\n }\n+\n const modal = await this.modalController.create({\n component: DocumentSetUpMeetingPage,\n componentProps: {\n@@ -238,7 +240,8 @@ export class DocumentDetailPage implements OnInit {\n cssClass: 'exp-options',\n componentProps: {\n task: this.task,\n- LoadedDocument: this.LoadedDocument\n+ LoadedDocument: this.LoadedDocument,\n+ document: this.LoadedDocument,\n },\n translucent: true\n });\ndiff --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\nindex 8c68182d4..f7bb03bb0 100644\n--- a/src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts\n+++ b/src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts\n@@ -22,7 +22,7 @@ import { SessionStore } from 'src/app/store/session.service';\n import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';\n import { environment } from 'src/environments/environment';\n import { TaskService } from 'src/app/services/task.service'\n-\n+import { AttachmentsService } from 'src/app/services/attachments.service';\n \n const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {\n parse: {\n@@ -111,15 +111,47 @@ export class DocumentSetUpMeetingPage implements OnInit {\n public ThemeService: ThemeService,\n public _eventService: EventsService,\n private httpErroHandle: HttpErrorHandle,\n- public TaskService: TaskService\n+ public TaskService: TaskService,\n+ private attachmentsService: AttachmentsService,\n ) {\n this.loggeduser = SessionStore.user;\n this.document = this.navParams.get('document')\n \n- if(Array.isArray(this.document)) {\n- this.attachments = this.document\n- } else {\n- this.attachments = [this.document]\n+\n+ if(this.document) {\n+ console.log('this.document', this.document)\n+ if(Array.isArray(this.document)) {\n+ const docs: any = this.document\n+ for(let doc of docs ) {\n+ this.attachments.push({\n+ ApplicationId: (doc.ApplicationType || doc.ApplicationId), \n+ ApplicationType: (doc.ApplicationType || doc.ApplicationId),\n+ SourceId: (doc.Id || doc.DocId || doc.SourceId), \n+ Id: (doc.Id || doc.DocId || doc.SourceId), \n+ EntidadeOrganicaNome: (doc.Stakeholders || doc.sender || doc.EntidadeOrganicaNome ),\n+ Sender: (doc.Stakeholders || doc.sender || doc. EntidadeOrganicaNome ),\n+ Data: (doc.DocDate || doc.Data),\n+ DocDate: (doc.DocDate || doc.Data),\n+ Assunto: doc.Assunto || doc.SourceName || doc.Description,\n+ SourceName: doc.Assunto || doc.SourceName || doc.Description,\n+ } as any)\n+ }\n+ } else {\n+ const doc: any = this.document\n+ this.attachments.push({\n+ ApplicationId: (doc.ApplicationType || doc.ApplicationId), \n+ ApplicationType: (doc.ApplicationType || doc.ApplicationId),\n+ SourceId: (doc.Id || doc.DocId || doc.SourceId), \n+ Id: (doc.Id || doc.DocId || doc.SourceId), \n+ EntidadeOrganicaNome: (doc.Stakeholders || doc.sender || doc.EntidadeOrganicaNome ),\n+ Sender: (doc.Stakeholders || doc.sender || doc. EntidadeOrganicaNome ),\n+ Data: (doc.DocDate || doc.Data),\n+ DocDate: (doc.DocDate || doc.Data),\n+ Assunto: doc.Assunto || doc.SourceName || doc.Description,\n+ SourceName: doc.Assunto || doc.SourceName || doc.Description,\n+ } as any)\n+ }\n+\n }\n \n \n@@ -278,7 +310,7 @@ export class DocumentSetUpMeetingPage implements OnInit {\n let Attendees = this.taskParticipants.concat(this.taskParticipantsCc);\n \n if(this.document.Documents) {\n- this.document.Documents.forEach((e)=> {\n+ this.attachments.forEach((e: any)=> {\n this.docs.push({\n ApplicationId: e.ApplicationId || e.ApplicationType,\n Source: 1,\n@@ -287,14 +319,6 @@ export class DocumentSetUpMeetingPage implements OnInit {\n })\n })\n }\n- else{\n- this.docs.push({\n- ApplicationId: this.document.ApplicationId || this.document.ApplicationType,\n- Source: 1,\n- SourceId: this.document.DocId || this.document.docID || this.document.docId || this.document.SourceId || this.document.Id,\n- SourceName: this.document.Assunto\n- })\n- }\n \n let postEvent = {\n EventId: '',\n@@ -318,13 +342,14 @@ export class DocumentSetUpMeetingPage implements OnInit {\n Type: this.EventRecurrenceType,\n LastOccurrence: this.Occurrence,\n },\n- // Attachments: this.docs,\n+ Attachments: this.attachments,\n }\n \n const laoder = this.toastService.loading()\n \n this.eventService.create({ body: postEvent, calendar: this.postData.CalendarName }).subscribe(async (respose) => {\n laoder.remove();\n+ // this.saveAttachment()\n this.httpErroHandle.httpsSucessMessagge('new event');\n this.modalController.dismiss()\n }, (error) => {\n@@ -336,6 +361,17 @@ export class DocumentSetUpMeetingPage implements OnInit {\n \n }\n \n+ async saveAttachment() {\n+ this.attachments.forEach( async (attachments, i) => {\n+ try {\n+ await this.attachmentsService.setEventAttachmentById(attachments).toPromise();\n+ } catch(error) {\n+ \n+ }\n+\n+ });\n+ }\n+\n async addParticipants() {\n \n this.adding = \"intervenient\";\ndiff --git a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts\nindex 66826fc22..b9f20c744 100644\n--- a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts\n+++ b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts\n@@ -130,19 +130,37 @@ export class ExpedientTaskModalPage implements OnInit {\n \n \n if(this.document) {\n- const doc: any = this.document\n-\n- this.documents.push({\n- ApplicationId: (doc.ApplicationType || doc.ApplicationId), \n- ApplicationType: (doc.ApplicationType || doc.ApplicationId),\n- SourceId: (doc.Id || doc.DocId || doc.SourceId), \n- Id: (doc.Id || doc.DocId || doc.SourceId), \n- EntidadeOrganicaNome: (doc.sender || doc.SourceName || doc. EntidadeOrganicaNome),\n- Sender: (doc.sender || doc.SourceName || doc. EntidadeOrganicaNome),\n- Data: (doc.DocDate || doc.Data),\n- DocDate: (doc.DocDate || doc.Data),\n- Assunto: doc.Assunto,\n- } as any)\n+ \n+ if(Array.isArray(this.document)) {\n+ const docs: any = this.document\n+ for(let doc of docs ) {\n+ this.documents.push({\n+ ApplicationId: (doc.ApplicationType || doc.ApplicationId), \n+ ApplicationType: (doc.ApplicationType || doc.ApplicationId),\n+ SourceId: (doc.Id || doc.DocId || doc.SourceId), \n+ Id: (doc.Id || doc.DocId || doc.SourceId), \n+ EntidadeOrganicaNome: (doc.Stakeholders || doc.sender || doc.EntidadeOrganicaNome ),\n+ Sender: (doc.Stakeholders || doc.sender || doc. EntidadeOrganicaNome ),\n+ Data: (doc.DocDate || doc.Data),\n+ DocDate: (doc.DocDate || doc.Data),\n+ Assunto: doc.Assunto || doc.SourceName || doc.Description,\n+ } as any)\n+ }\n+ } else {\n+ const doc: any = this.document\n+ this.documents.push({\n+ ApplicationId: (doc.ApplicationType || doc.ApplicationId), \n+ ApplicationType: (doc.ApplicationType || doc.ApplicationId),\n+ SourceId: (doc.Id || doc.DocId || doc.SourceId), \n+ Id: (doc.Id || doc.DocId || doc.SourceId), \n+ EntidadeOrganicaNome: (doc.Stakeholders || doc.sender || doc.EntidadeOrganicaNome ),\n+ Sender: (doc.Stakeholders || doc.sender || doc. EntidadeOrganicaNome ),\n+ Data: (doc.DocDate || doc.Data),\n+ DocDate: (doc.DocDate || doc.Data),\n+ Assunto: doc.Assunto || doc.SourceName || doc.Description,\n+ } as any)\n+ }\n+\n }\n \n \ndiff --git a/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.html b/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.html\nindex 38fc8af46..b5a0f5b4e 100644\n--- a/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.html\n+++ b/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.html\n@@ -283,7 +283,7 @@\n \n \n Adicionar Intervenientes*\n- {{participant.Name}}\n+ {{participant.EmailAddress }}\n \n \n
\n@@ -306,7 +306,7 @@\n \n \n Adicionar Intervenientes\n- {{participant.Name}}\n+ {{participant.EmailAddress }}\n \n \n
\ndiff --git a/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html b/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html\nindex c306e743e..fe896ef2a 100644\n--- a/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html\n+++ b/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html\n@@ -225,7 +225,7 @@\n \n \n Adicionar Intervenientes*\n- {{participant.Name}}\n+ {{participant.EmailAddress}}\n \n \n
\n@@ -248,7 +248,7 @@\n \n \n Adicionar Intervenientes\n- {{participant.Name}}\n+ {{participant.EmailAddress }}\n \n \n
", "changeStatus": "On branch notification-header/feature\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/modals/profile/profile.page.html\n\tmodified: src/app/modals/profile/profile.page.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/app/shared/header/header.page.html\n\tmodified: src/app/shared/header/header.page.ts\n\tnew file: src/app/store/notification-holder.service.spec.ts\n\tnew file: src/app/store/notification-holder.service.ts\n\nChanges not staged for commit:\n (use \"git add ...\" to update what will be committed)\n (use \"git restore ...\" to discard changes in working directory)\n\tmodified: src/app/modals/create-process/create-process.page.ts\n\tmodified: src/app/modals/document-detail/document-detail.page.ts\n\tmodified: src/app/modals/document-set-up-meeting/document-set-up-meeting.page.ts\n\tmodified: src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.ts\n\tmodified: src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.html\n\tmodified: src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html", "changeAuthor": "peter.maquiran"