Skip to content

Commit

Permalink
- support for querying group events from ramblers walks manager
Browse files Browse the repository at this point in the history
- first iteration is to display all event types on the walks page
  • Loading branch information
nbarrett committed Oct 11, 2024
1 parent faddc3d commit d0e01cb
Show file tree
Hide file tree
Showing 21 changed files with 229 additions and 157 deletions.
10 changes: 10 additions & 0 deletions projects/ngx-ramblers/src/app/assets/styles/colours.sass
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ $confirm-hover: #eb0c35
&:hover
color: #ff3e43

.group-walk
font-size: 1.5em
color: $admin-color
align-content: center

.group-event
font-size: 1.5em
color: $ramblers-colour-rosycheeks
align-content: center

.ramblers
color: $admin-color
&:hover
Expand Down
24 changes: 21 additions & 3 deletions projects/ngx-ramblers/src/app/models/ramblers-walks-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface RamblersWalksApiResponse extends ApiResponse {
response?: RamblersWalkResponse[];
}

export enum WalkType {
export enum RamblersEventType {
GROUP_WALK = "group-walk",
GROUP_EVENT = "group-event",
WELLBEING_WALK = "wellbeing-walk"
Expand Down Expand Up @@ -84,7 +84,7 @@ export interface WalkLeader {
}

export interface GroupWalk {
item_type: WalkType;
item_type: RamblersEventType;
id: string;
title: string;
group_code: string;
Expand All @@ -95,6 +95,23 @@ export interface GroupWalk {
start_date_time: string;
end_date_time: string;
meeting_date_time: string;
event_organiser?: {
name: string;
telephone: string;
has_email: boolean;
is_overridden: boolean;
email_form: string;
},
location?: {
latitude: number;
longitude: number;
grid_reference_6: string;
grid_reference_8: string;
grid_reference_10: string;
postcode: string;
description: string;
w3w: string;
};
start_location: {
latitude: number;
longitude: number;
Expand Down Expand Up @@ -156,7 +173,8 @@ export interface GroupListRequest {
groups: string[];
}

export interface WalkListRequest {
export interface EventsListRequest {
types: RamblersEventType[];
ids?: string[];
rawData?: boolean;
limit?: number;
Expand Down
4 changes: 3 additions & 1 deletion projects/ngx-ramblers/src/app/models/walk.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { WalkAccessMode } from "./walk-edit-mode.model";
import { WalkEventType } from "./walk-event-type.model";
import { WalkEvent } from "./walk-event.model";
import { WalkVenue } from "./walk-venue.model";
import { Media, Metadata, WalkLeader } from "./ramblers-walks-manager";
import { Media, Metadata, RamblersEventType, WalkLeader } from "./ramblers-walks-manager";

export interface GoogleMapsConfig {
apiKey: string;
Expand Down Expand Up @@ -46,6 +46,7 @@ export interface WalkAscent {
export interface Walk extends Identifiable {
contactName?: string;
walkType?: WalkType;
eventType: RamblersEventType;
briefDescriptionAndStartPoint?: string;
contactEmail?: string;
contactId?: string;
Expand Down Expand Up @@ -83,6 +84,7 @@ export interface Walk extends Identifiable {
startLocation?: string;
media?: Media[];
additionalDetails?: string;
organiser?: string;
}

export interface RiskAssessmentRecord {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
margin-top: 25px

.card-img-fixed-height
height: 300px
height: 350px
object-fit: cover
border-radius: 6px
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<fa-icon *ngIf="!justCopied()" container="body" [tooltip]="tooltipPreCopy"
(click)="copyToClipboard(value)" [icon]="icon"
class="fa-icon mr-1 pointer"></fa-icon>
<ng-content></ng-content>
<ng-content/>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import last from "lodash-es/last";
import { ModalOptions } from "ngx-bootstrap/modal";
import { NgxLoggerLevel } from "ngx-logger";
import { Observable } from "rxjs";
import { CommitteeFile } from "../../models/committee.model";
import { CommitteeFile, GroupEventType, groupEventTypeFor } from "../../models/committee.model";
import { Confirm } from "../../models/ui-actions";
import { ValueOrDefaultPipe } from "../../pipes/value-or-default.pipe";
import { CommitteeConfigService } from "../../services/committee/commitee-config.service";
Expand All @@ -16,6 +16,8 @@ import { Logger, LoggerFactory } from "../../services/logger-factory.service";
import { MemberLoginService } from "../../services/member/member-login.service";
import { AlertInstance } from "../../services/notifier.service";
import { UrlService } from "../../services/url.service";
import { Walk } from "../../models/walk.model";
import { RamblersEventType } from "../../models/ramblers-walks-manager";

@Injectable({
providedIn: "root"
Expand Down Expand Up @@ -120,4 +122,19 @@ export class CommitteeDisplayService {
}
}

ramblersEventType(walk: Walk): RamblersEventType {
return walk?.eventType || RamblersEventType.GROUP_WALK;
}

groupEventType(walk: Walk): GroupEventType {
switch (this.ramblersEventType(walk)) {
case RamblersEventType.GROUP_WALK:
return groupEventTypeFor("walk");
case RamblersEventType.GROUP_EVENT:
return groupEventTypeFor("socialEvent");
case RamblersEventType.WELLBEING_WALK:
return groupEventTypeFor("walk");
}
}

}
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import difference from "lodash-es/difference";
import { NgxLoggerLevel } from "ngx-logger";
import { AlertMessage, AlertTarget } from "../../../models/alert-target.model";
import { NamedEvent, NamedEventType } from "../../../models/broadcast.model";
import { DateValue } from "../../../models/date.model";
import { Walk } from "../../../models/walk.model";
import { DisplayDateAndTimePipe } from "../../../pipes/display-date-and-time.pipe";
import { DisplayDatePipe } from "../../../pipes/display-date.pipe";
import { DisplayDayPipe } from "../../../pipes/display-day.pipe";
import { SearchFilterPipe } from "../../../pipes/search-filter.pipe";
import { BroadcastService } from "../../../services/broadcast-service";
import { DateUtilsService } from "../../../services/date-utils.service";
import { Logger, LoggerFactory } from "../../../services/logger-factory.service";
import { MemberLoginService } from "../../../services/member/member-login.service";
import { AlertInstance, NotifierService } from "../../../services/notifier.service";
import { UrlService } from "../../../services/url.service";
import { WalkEventService } from "../../../services/walks/walk-event.service";
import { WalkNotificationService } from "../../../services/walks/walk-notification.service";
import { WalksQueryService } from "../../../services/walks/walks-query.service";
import { WalksReferenceService } from "../../../services/walks/walks-reference-data.service";
import { WalksService } from "../../../services/walks/walks.service";
import { WalkDisplayService } from "../walk-display.service";
import { DisplayDatesAndTimesPipe } from "../../../pipes/display-dates-and-times.pipe";
import { StringUtilsService } from "../../../services/string-utils.service";
import uniq from "lodash-es/uniq";
import { DisplayDatesPipe } from "../../../pipes/display-dates.pipe";
import { RamblersEventType } from "../../../models/ramblers-walks-manager";

@Component({
selector: "app-walk-add-slots",
Expand All @@ -48,16 +42,9 @@ export class WalkAddSlotsComponent implements OnInit {
constructor(
private walksService: WalksService,
private memberLoginService: MemberLoginService,
private walksNotificationService: WalkNotificationService,
private display: WalkDisplayService,
private displayDay: DisplayDayPipe,
private displayDate: DisplayDatePipe,
private stringUtilsService: StringUtilsService,
private displayDates: DisplayDatesPipe,
private displayDatesAndTimes: DisplayDatesAndTimesPipe,
private searchFilterPipe: SearchFilterPipe,
private displayDateAndTime: DisplayDateAndTimePipe,
private route: ActivatedRoute,
private walksQueryService: WalksQueryService,
private dateUtils: DateUtilsService,
private notifierService: NotifierService,
Expand Down Expand Up @@ -86,6 +73,7 @@ export class WalkAddSlotsComponent implements OnInit {
createSlots(requiredSlots: number[], message: AlertMessage) {
this.requiredWalkSlots = requiredSlots.map(date => {
const walk: Walk = {
eventType: RamblersEventType.GROUP_WALK,
walkDate: date,
ramblersPublish: true,
events: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { WalksReferenceService } from "../../services/walks/walks-reference-data
import { CommitteeReferenceData } from "../../services/committee/committee-reference-data";
import { CommitteeConfigService } from "../../services/committee/commitee-config.service";
import { Observable, ReplaySubject } from "rxjs";
import { StringUtilsService } from "../../services/string-utils.service";
import { RamblersEventType } from "../../models/ramblers-walks-manager";

@Injectable({
providedIn: "root"
Expand All @@ -49,14 +51,15 @@ export class WalkDisplayService {
private memberLoginService: MemberLoginService,
private router: Router,
private urlService: UrlService,
protected stringUtils: StringUtilsService,
private route: ActivatedRoute,
private sanitiser: DomSanitizer,
private walkEventService: WalkEventService,
private walksReferenceService: WalksReferenceService,
private walksQueryService: WalksQueryService,
private committeeConfig: CommitteeConfigService,
loggerFactory: LoggerFactory) {
this.logger = loggerFactory.createLogger(WalkDisplayService, NgxLoggerLevel.OFF);
this.logger = loggerFactory.createLogger(WalkDisplayService, NgxLoggerLevel.ERROR);
this.applyConfig();
this.refreshCachedData();
this.logger.debug("this.memberLoginService", this.memberLoginService.loggedInMember());
Expand Down Expand Up @@ -296,4 +299,16 @@ export class WalkDisplayService {
allowAdminEdits() {
return this.memberLoginService.allowWalkAdminEdits();
}

eventType(walk: Walk): string {
return walk?.eventType || RamblersEventType.GROUP_WALK;
}

eventTypeTitle(walk: Walk): string {
return this.stringUtils.asTitle(walk?.eventType) || "Walk";
}

isWalk(walk: Walk): boolean {
return !walk?.eventType || walk.eventType === RamblersEventType.GROUP_WALK;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { NgxLoggerLevel } from "ngx-logger";
import { Subscription } from "rxjs";
import { AlertTarget } from "../../../models/alert-target.model";
import { DisplayedWalk, EventType, Walk } from "../../../models/walk.model";
import { DisplayDatePipe } from "../../../pipes/display-date.pipe";
import { DateUtilsService } from "../../../services/date-utils.service";
import { Logger, LoggerFactory } from "../../../services/logger-factory.service";
import { AlertInstance, NotifierService } from "../../../services/notifier.service";
import { WalksReferenceService } from "../../../services/walks/walks-reference-data.service";
import { WalksService } from "../../../services/walks/walks.service";
import { WalkDisplayService } from "../walk-display.service";
import { RamblersEventType } from "../../../models/ramblers-walks-manager";

@Component({
selector: "app-walk-edit-full-page",
Expand All @@ -21,7 +20,6 @@ export class WalkEditFullPageComponent implements OnInit, OnDestroy {
private logger: Logger;
public displayedWalk: DisplayedWalk;
public notifyTarget: AlertTarget = {};
private notify: AlertInstance;
pageTitle: string;
private subscriptions: Subscription[] = [];

Expand All @@ -30,19 +28,18 @@ export class WalkEditFullPageComponent implements OnInit, OnDestroy {
private walksReferenceService: WalksReferenceService,
private dateUtils: DateUtilsService,
private display: WalkDisplayService,
private notifierService: NotifierService,
displayDate: DisplayDatePipe, loggerFactory: LoggerFactory) {
this.logger = loggerFactory.createLogger(WalkEditFullPageComponent, NgxLoggerLevel.OFF);
loggerFactory: LoggerFactory) {
this.logger = loggerFactory.createLogger(WalkEditFullPageComponent, NgxLoggerLevel.ERROR);
}

ngOnInit() {
this.logger.debug("ngOnInit");
this.notify = this.notifierService.createAlertInstance(this.notifyTarget);
this.subscriptions.push(this.route.paramMap.subscribe((paramMap: ParamMap) => {
if (paramMap.has("add")) {
this.displayedWalk = {
walkAccessMode: WalksReferenceService.walkAccessModes.add,
walk: {
eventType: RamblersEventType.GROUP_WALK,
walkType: this.display.walkTypes[0],
walkDate: this.dateUtils.momentNowNoTime().valueOf(),
events: []
Expand All @@ -56,7 +53,7 @@ export class WalkEditFullPageComponent implements OnInit, OnDestroy {
this.logger.debug("querying walk-id", walkId);
this.walksService.getById(walkId)
.then((walk: Walk) => {
this.logger.debug("found walk", walk);
this.logger.info("found walk", walk);
this.displayedWalk = this.display.toDisplayedWalk(walk);
if (this.displayedWalk.latestEventType) {
this.setStatus(this.displayedWalk.latestEventType.eventType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { MailMessagingConfig } from "../../../models/mail.model";
import { MeetupService } from "../../../services/meetup.service";
import { WalkNotification } from "../../../models/walk-notification.model";
import { MeetupDescriptionComponent } from "../../../notifications/walks/templates/meetup/meetup-description.component";
import { RamblersEventType } from "../../../models/ramblers-walks-manager";

@Component({
selector: "app-walk-edit",
Expand Down Expand Up @@ -333,6 +334,7 @@ export class WalkEditComponent implements OnInit, OnDestroy {
walkAccessMode: WalksReferenceService.walkAccessModes.add,
latestEventType: null,
walk: {
eventType: RamblersEventType.GROUP_WALK,
walkType: this.display.walkTypes[0],
walkDate: this.dateUtils.momentNowNoTime().valueOf(),
events: []
Expand Down Expand Up @@ -642,7 +644,7 @@ export class WalkEditComponent implements OnInit, OnDestroy {
switch (eventType.eventType) {
case EventType.AWAITING_LEADER: {
const walkDate = this.displayedWalk.walk.walkDate;
this.displayedWalk.walk = pick(this.displayedWalk.walk, ["id", "events", "walkDate"]);
this.displayedWalk.walk = pick(this.displayedWalk.walk, ["id", "events", "walkDate", "eventType"]);
this.displayedWalk.walk.riskAssessment = [];
return this.notify.success({
title: "Walk details reset for " + this.displayDate.transform(walkDate),
Expand Down
Loading

0 comments on commit d0e01cb

Please sign in to comment.