Skip to content

Commit

Permalink
Merge pull request #192 from gctools-outilsgc/calendar-poc
Browse files Browse the repository at this point in the history
Calendar poc
  • Loading branch information
doug0102 authored Mar 15, 2024
2 parents f06e807 + cebb45c commit 61256c1
Show file tree
Hide file tree
Showing 47 changed files with 2,924 additions and 1,041 deletions.
52 changes: 36 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"@angular/router": "^17.0.8",
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0",
"angular-auth-oidc-client": "^14.1.5",
"angular-auth-oidc-client": "^17.0.0",
"date-fns": "^2.30.0",
"lorem-ipsum": "^2.0.8",
"ngx-editor": "^15.3.0",
"ngx-infinite-scroll": "^17.0.0",
Expand Down
5 changes: 5 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import { TypescriptLoader } from './core/helpers/typescript-loader';
import { SharedModule } from './shared/shared.module';
import { EventsComponent } from './features/events/events.component';
import { GroupsComponent } from './features/groups/groups.component';
import { registerLocaleData } from '@angular/common';
import localeFr from '@angular/common/locales/fr';

registerLocaleData(localeFr);

@NgModule({
declarations: [AppComponent, EventsComponent, GroupsComponent],
Expand All @@ -35,6 +39,7 @@ import { GroupsComponent } from './features/groups/groups.component';
deps: [HttpClient],
},
isolate: false,
extend: true
}),
NgxTranslateRoutesModule.forRoot({
enableRouteTranslate: true,
Expand Down
4 changes: 4 additions & 0 deletions src/app/core/models/location.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ export class Location {
this.province = province;
this.country = country;
}

toString(): string {
return `${this.address}, ${this.city}, ${this.province}`
}
}
12 changes: 9 additions & 3 deletions src/app/core/services/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { LoremIpsum } from 'lorem-ipsum';
import { GroupService } from './group.service';
import { IListService } from '../interfaces/list-service.interface';
import { EventCardComponent } from 'src/app/features/events/components/event-card/event-card.component';
import { addDays, addHours } from 'date-fns';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -80,7 +81,7 @@ export class EventService implements IListService {
}

private generateRandomEventItem(): Event {
const event = new Event('0', 'Event Title', 'Display Picture', new Date(), 'Organizer', new Location('Address', 'City', 'Province'));
const event = new Event();

event.id = this.id.toString();
event.title = this.randomTitle();
Expand All @@ -90,7 +91,8 @@ export class EventService implements IListService {
event.author = this.peopleService.people[this.id];
event.group = this.groupService.groups[this.id];
event.startDate = this.randomDate();
event.endDate = this.randomDate();
event.endDate = addDays(event.startDate, this.randomRange(0, 7));
event.endDate = addHours(event.endDate, this.randomRange(2, 6));
event.image = this.randomImage();
event.displayPicture = this.randomDisplayPicture();
event.organizer = this.randomOrganizer();
Expand Down Expand Up @@ -128,7 +130,7 @@ export class EventService implements IListService {
}

private randomEventType(): string {
const eventTypes: string[] = ['In Person', 'Workshop', 'Conference', 'Roundtable', 'Charity Event'];
const eventTypes: string[] = ['In Person', 'Hybrid', 'Online'];
return eventTypes[Math.floor(Math.random() * eventTypes.length)];
}

Expand Down Expand Up @@ -177,4 +179,8 @@ export class EventService implements IListService {
const organizers: string[] = ['TBS', 'ESDC', 'CRA', 'SSC', 'NRCC'];
return organizers[Math.floor(Math.random() * organizers.length)];
}

private randomRange(min: number, max: number) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
}
16 changes: 16 additions & 0 deletions src/app/core/services/resize.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { ResizeService } from './resize.service';

describe('ResizeService', () => {
let service: ResizeService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ResizeService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
19 changes: 19 additions & 0 deletions src/app/core/services/resize.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Injectable, EventEmitter } from '@angular/core';

@Injectable({
providedIn: 'root'
})
export class ResizeService {

resizeEvent: EventEmitter<Event> = new EventEmitter();

constructor() {
this.setupResizeListener();
}

private setupResizeListener(): void {
window.addEventListener('resize', (event) => {
this.resizeEvent.emit(event);
});
}
}
151 changes: 151 additions & 0 deletions src/app/features/calendar/calendar.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<div class="gcc-calendar-wrapper" [ngClass]="{'loading': loading}">

<div class="header">

<!-- Left Actions-->
<div class="left-actions">

<!-- Add Event -->
<app-button theme="black"
matButtonType="mat-icon-button"
[tooltip]="'Add Event' | translate"
[tooltipDirection]="TooltipDirection.Above"
[ariaLabel]="'Add Event'"
[disabled]="loading"
[clickFunc]="toggleEventForm">
<i class="fa-solid fa-calendar-plus fa-lg"></i>
</app-button>

<!-- Search -->
<app-button theme="black"
matButtonType="mat-icon-button"
[tooltip]="searchActive ? ('Close Search' | translate) : ('Search' | translate)"
[tooltipDirection]="TooltipDirection.Above"
[ariaLabel]="searchActive ? ('Close Search' | translate) : ('Search' | translate)"
[disabled]="loading"
[clickFunc]="toggleSearch">
<i [ngClass]="searchActive ? 'fa-xmark' : 'fa-magnifying-glass'"
class="fa-solid fa-lg">
</i>
</app-button>
</div>

<!-- Middle Actions-->
<div class="middle-actions">

<!-- Nav Previous-->
<app-button theme="black"
matButtonType="mat-icon-button"
[tooltip]="translations.calendar.controls.previous.title_month | translate"
[tooltipDirection]="TooltipDirection.Left"
[ariaLabel]="translations.calendar.controls.previous.aria_month | translate"
[disabled]="loading"
(click)="navigateCalendar(-1)">
<i class="fa-solid fa-angle-left fa-lg"></i>
</app-button>

<!-- Date -->
<span>{{ date | localizedDate : 'MMMM YYYY' | titlecase }}</span>

<!-- Nav Next -->
<app-button theme="black"
matButtonType="mat-icon-button"
[tooltip]="translations.calendar.controls.next.title_month | translate"
[tooltipDirection]="TooltipDirection.Right"
[ariaLabel]="translations.calendar.controls.next.aria_month | translate"
[disabled]="loading"
(click)="navigateCalendar(1)">
<i class="fa-solid fa-angle-right fa-lg"></i>
</app-button>
</div>

<!-- Right Actions -->
<div class="right-actions">

<!-- Filter -->
<!-- <app-button theme="black"
matButtonType="mat-icon-button"
[tooltip]="'TODO' | translate"
[tooltipDirection]="TooltipDirection.Above"
[ariaLabel]="'TODO' | translate"
[disabled]="loading">
<i class="fa-solid fa-ellipsis-vertical fa-lg"></i>
</app-button> -->
</div>
</div>

<!-- Search -->
<app-calendar-search *ngIf="searchActive"
[date]="date"
[events]="events">
</app-calendar-search>

<div>
<!-- Days of the Week -->
<div class="weekdays">
@for (weekday of weekdays; track $index) {
<div class="day" [class.today]="weekday.isToday">
{{ weekday.title | translate }}
</div>
}
</div>

<div class="calendar" [ngStyle]="calendarStyle">
<!-- Previous Month's Days -->
@for (day of datesPaddingPre; track $index) {
<app-calendar-day [calendarDate]="day"
[outsideOfMonth]="true"
[loading]="loading"
(dayClick)="dayClick(day)">
</app-calendar-day>
}
<!-- Current Month's Days -->
@for (day of dates; track $index) {
<app-calendar-day [calendarDate]="day"
[active]="$index === activeDayIndex"
[loading]="loading"
(dayClick)="dayClick(day)">
</app-calendar-day>
}
<!-- Next Month's Days -->
@for (day of datesPaddingPost; track $index) {
<app-calendar-day [calendarDate]="day"
[outsideOfMonth]="true"
[loading]="loading"
(dayClick)="dayClick(day)">
</app-calendar-day>
}
</div>
</div>
</div>

<!-- Events -->
<app-calendar-events *ngIf="activeDayIndex > -1 && !loading"
[calendarDate]="dates[activeDayIndex]"
(eventEdit)="editEvent($event)"
(eventDelete)="deleteEvent($event)">
</app-calendar-events>

<!-- Event Form -->
<mat-card *ngIf="eventFormActive && !loading" class="event-form">

<app-event-form [form]="eventFormGroup"
[model]="eventFormData">
</app-event-form>

<div class="actions">
<!-- Save -->
<app-button theme="secondary-2"
[disabled]="loading || !eventFormValid()"
[clickFunc]="saveEventForm">
{{ editEventId ? (translations.forms.save | translate) : (translations.forms.create | translate) }}
</app-button>

<!-- Cancel -->
<app-button theme="secondary-2"
[disabled]="loading"
[clickFunc]="toggleEventForm">
Cancel
</app-button>
</div>
</mat-card>
Loading

0 comments on commit 61256c1

Please sign in to comment.