@sneat/extensions-schedulus-shared 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/index.js +2 -0
- package/esm2022/index.js.map +1 -0
- package/esm2022/lib/components/calendar/calendar-base.component.js +83 -0
- package/esm2022/lib/components/calendar/calendar-base.component.js.map +1 -0
- package/esm2022/lib/components/calendar/calendar-brief.component.js +57 -0
- package/esm2022/lib/components/calendar/calendar-brief.component.js.map +1 -0
- package/esm2022/lib/components/calendar/calendar-component-types.js +2 -0
- package/esm2022/lib/components/calendar/calendar-component-types.js.map +1 -0
- package/esm2022/lib/components/calendar/calendar-state.service.js +90 -0
- package/esm2022/lib/components/calendar/calendar-state.service.js.map +1 -0
- package/esm2022/lib/components/calendar/calendar.component.js +284 -0
- package/esm2022/lib/components/calendar/calendar.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-add-buttons/calendar-add-buttons.component.js +45 -0
- package/esm2022/lib/components/calendar/components/calendar-add-buttons/calendar-add-buttons.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-base.component.js +26 -0
- package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-base.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-card.component.js +67 -0
- package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-card.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-tab.component.js +74 -0
- package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-tab.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-title.component.js +27 -0
- package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-title.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-day/calendar-day.component.js +129 -0
- package/esm2022/lib/components/calendar/components/calendar-day/calendar-day.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-filter/calendar-filter.component.js +162 -0
- package/esm2022/lib/components/calendar/components/calendar-filter/calendar-filter.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-filter/calendar-filter.js +17 -0
- package/esm2022/lib/components/calendar/components/calendar-filter/calendar-filter.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-filter/contacts-filter.component.js +95 -0
- package/esm2022/lib/components/calendar/components/calendar-filter/contacts-filter.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-week/calendar-week-card.component.js +50 -0
- package/esm2022/lib/components/calendar/components/calendar-week/calendar-week-card.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-week/calendar-week-tab.component.js +18 -0
- package/esm2022/lib/components/calendar/components/calendar-week/calendar-week-tab.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-week/calendar-week-title.component.js +15 -0
- package/esm2022/lib/components/calendar/components/calendar-week/calendar-week-title.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-week/calendar-week.component.js +78 -0
- package/esm2022/lib/components/calendar/components/calendar-week/calendar-week.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/calendar-weekday/calendar-weekday.component.js +66 -0
- package/esm2022/lib/components/calendar/components/calendar-weekday/calendar-weekday.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/day-slot-item/day-slot-item.component.js +93 -0
- package/esm2022/lib/components/calendar/components/day-slot-item/day-slot-item.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/day-slot-item/slot-context-menu.component.js +324 -0
- package/esm2022/lib/components/calendar/components/day-slot-item/slot-context-menu.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/recurrings-tab/recurrings-tab.component.js +36 -0
- package/esm2022/lib/components/calendar/components/recurrings-tab/recurrings-tab.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/singles-tab/single-happenings-list.component.js +65 -0
- package/esm2022/lib/components/calendar/components/singles-tab/single-happenings-list.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/singles-tab/singles-tab.component.js +106 -0
- package/esm2022/lib/components/calendar/components/singles-tab/singles-tab.component.js.map +1 -0
- package/esm2022/lib/components/calendar/components/timing-badge/timing-badge.component.js +25 -0
- package/esm2022/lib/components/calendar/components/timing-badge/timing-badge.component.js.map +1 -0
- package/esm2022/lib/components/calendar/weekday.js +2 -0
- package/esm2022/lib/components/calendar/weekday.js.map +1 -0
- package/esm2022/lib/components/calendar-core.js +64 -0
- package/esm2022/lib/components/calendar-core.js.map +1 -0
- package/esm2022/lib/components/calendar-filter.service.js +28 -0
- package/esm2022/lib/components/calendar-filter.service.js.map +1 -0
- package/esm2022/lib/components/calendar-slots.js +30 -0
- package/esm2022/lib/components/calendar-slots.js.map +1 -0
- package/esm2022/lib/components/happening-base.component.js +188 -0
- package/esm2022/lib/components/happening-base.component.js.map +1 -0
- package/esm2022/lib/components/happening-card/happening-card.component.js +69 -0
- package/esm2022/lib/components/happening-card/happening-card.component.js.map +1 -0
- package/esm2022/lib/components/happening-component-base-params.js +37 -0
- package/esm2022/lib/components/happening-component-base-params.js.map +1 -0
- package/esm2022/lib/components/happening-form/happening-form.component.js +348 -0
- package/esm2022/lib/components/happening-form/happening-form.component.js.map +1 -0
- package/esm2022/lib/components/happening-form/happening-price-form/happening-price-modal.component.js +161 -0
- package/esm2022/lib/components/happening-form/happening-price-form/happening-price-modal.component.js.map +1 -0
- package/esm2022/lib/components/happening-form/happening-prices/happening-prices.component.js +142 -0
- package/esm2022/lib/components/happening-form/happening-prices/happening-prices.component.js.map +1 -0
- package/esm2022/lib/components/happening-participants/happening-participants.component.js +195 -0
- package/esm2022/lib/components/happening-participants/happening-participants.component.js.map +1 -0
- package/esm2022/lib/components/happening-slot-form/happening-slot-form.component.js +505 -0
- package/esm2022/lib/components/happening-slot-form/happening-slot-form.component.js.map +1 -0
- package/esm2022/lib/components/happening-slot-form/happening-slot-modal.component.js +140 -0
- package/esm2022/lib/components/happening-slot-form/happening-slot-modal.component.js.map +1 -0
- package/esm2022/lib/components/happening-slot-form/happening-slot-modal.service.js +47 -0
- package/esm2022/lib/components/happening-slot-form/happening-slot-modal.service.js.map +1 -0
- package/esm2022/lib/components/happening-slot-participants/happening-slot-participants.component.js +74 -0
- package/esm2022/lib/components/happening-slot-participants/happening-slot-participants.component.js.map +1 -0
- package/esm2022/lib/components/happening-slots/happening-slots.component.js +130 -0
- package/esm2022/lib/components/happening-slots/happening-slots.component.js.map +1 -0
- package/esm2022/lib/components/index.js +20 -0
- package/esm2022/lib/components/index.js.map +1 -0
- package/esm2022/lib/components/start-end-dates-range-form/start-end-dates-range-form.component.js +68 -0
- package/esm2022/lib/components/start-end-dates-range-form/start-end-dates-range-form.component.js.map +1 -0
- package/esm2022/lib/components/start-end-datetime-form/start-end-datetime-form.component.js +377 -0
- package/esm2022/lib/components/start-end-datetime-form/start-end-datetime-form.component.js.map +1 -0
- package/esm2022/lib/components/start-end-datetime-form/time-selector.component.js +92 -0
- package/esm2022/lib/components/start-end-datetime-form/time-selector.component.js.map +1 -0
- package/esm2022/lib/components/swipeable-base.component.js +112 -0
- package/esm2022/lib/components/swipeable-base.component.js.map +1 -0
- package/esm2022/lib/components/swipeable-ui.js +64 -0
- package/esm2022/lib/components/swipeable-ui.js.map +1 -0
- package/esm2022/lib/components/week.js +2 -0
- package/esm2022/lib/components/week.js.map +1 -0
- package/esm2022/lib/components/weekday-functions.js +13 -0
- package/esm2022/lib/components/weekday-functions.js.map +1 -0
- package/esm2022/lib/components/weekdays/weekdays-form-base.js +72 -0
- package/esm2022/lib/components/weekdays/weekdays-form-base.js.map +1 -0
- package/esm2022/lib/index.js +3 -0
- package/esm2022/lib/index.js.map +1 -0
- package/esm2022/lib/modals/happening-title-modal/happening-title-modal.component.js +87 -0
- package/esm2022/lib/modals/happening-title-modal/happening-title-modal.component.js.map +1 -0
- package/esm2022/lib/services/calendar-data-provider.js +271 -0
- package/esm2022/lib/services/calendar-data-provider.js.map +1 -0
- package/esm2022/lib/services/calendar-day.js +179 -0
- package/esm2022/lib/services/calendar-day.js.map +1 -0
- package/esm2022/lib/services/calendar-day.service.js +37 -0
- package/esm2022/lib/services/calendar-day.service.js.map +1 -0
- package/esm2022/lib/services/calendar-nav.service.js +36 -0
- package/esm2022/lib/services/calendar-nav.service.js.map +1 -0
- package/esm2022/lib/services/calendar-space.js +152 -0
- package/esm2022/lib/services/calendar-space.js.map +1 -0
- package/esm2022/lib/services/calendar-types.js +52 -0
- package/esm2022/lib/services/calendar-types.js.map +1 -0
- package/esm2022/lib/services/calendarium-services.module.js +16 -0
- package/esm2022/lib/services/calendarium-services.module.js.map +1 -0
- package/esm2022/lib/services/calendarium-space.service.js +16 -0
- package/esm2022/lib/services/calendarium-space.service.js.map +1 -0
- package/esm2022/lib/services/happening.service.js +225 -0
- package/esm2022/lib/services/happening.service.js.map +1 -0
- package/esm2022/lib/services/index.js +6 -0
- package/esm2022/lib/services/index.js.map +1 -0
- package/esm2022/sneat-extensions-schedulus-shared.js +5 -0
- package/esm2022/sneat-extensions-schedulus-shared.js.map +1 -0
- package/index.d.ts +1 -0
- package/lib/components/calendar/calendar-base.component.d.ts +23 -0
- package/lib/components/calendar/calendar-brief.component.d.ts +11 -0
- package/lib/components/calendar/calendar-component-types.d.ts +1 -0
- package/lib/components/calendar/calendar-state.service.d.ts +15 -0
- package/lib/components/calendar/calendar.component.d.ts +32 -0
- package/lib/components/calendar/components/calendar-add-buttons/calendar-add-buttons.component.d.ts +13 -0
- package/lib/components/calendar/components/calendar-day/calendar-day-base.component.d.ts +10 -0
- package/lib/components/calendar/components/calendar-day/calendar-day-card.component.d.ts +17 -0
- package/lib/components/calendar/components/calendar-day/calendar-day-tab.component.d.ts +19 -0
- package/lib/components/calendar/components/calendar-day/calendar-day-title.component.d.ts +10 -0
- package/lib/components/calendar/components/calendar-day/calendar-day.component.d.ts +30 -0
- package/lib/components/calendar/components/calendar-filter/calendar-filter.component.d.ts +39 -0
- package/lib/components/calendar/components/calendar-filter/calendar-filter.d.ts +10 -0
- package/lib/components/calendar/components/calendar-filter/contacts-filter.component.d.ts +20 -0
- package/lib/components/calendar/components/calendar-week/calendar-week-card.component.d.ts +15 -0
- package/lib/components/calendar/components/calendar-week/calendar-week-tab.component.d.ts +9 -0
- package/lib/components/calendar/components/calendar-week/calendar-week-title.component.d.ts +7 -0
- package/lib/components/calendar/components/calendar-week/calendar-week.component.d.ts +20 -0
- package/lib/components/calendar/components/calendar-weekday/calendar-weekday.component.d.ts +23 -0
- package/lib/components/calendar/components/day-slot-item/day-slot-item.component.d.ts +19 -0
- package/lib/components/calendar/components/day-slot-item/slot-context-menu.component.d.ts +40 -0
- package/lib/components/calendar/components/recurrings-tab/recurrings-tab.component.d.ts +15 -0
- package/lib/components/calendar/components/singles-tab/single-happenings-list.component.d.ts +22 -0
- package/lib/components/calendar/components/singles-tab/singles-tab.component.d.ts +29 -0
- package/lib/components/calendar/components/timing-badge/timing-badge.component.d.ts +17 -0
- package/lib/components/calendar/weekday.d.ts +7 -0
- package/lib/components/calendar-core.d.ts +10 -0
- package/lib/components/calendar-filter.service.d.ts +8 -0
- package/lib/components/calendar-slots.d.ts +5 -0
- package/lib/components/happening-base.component.d.ts +46 -0
- package/lib/components/happening-card/happening-card.component.d.ts +11 -0
- package/lib/components/happening-component-base-params.d.ts +16 -0
- package/lib/components/happening-form/happening-form.component.d.ts +52 -0
- package/lib/components/happening-form/happening-price-form/happening-price-modal.component.d.ts +29 -0
- package/lib/components/happening-form/happening-prices/happening-prices.component.d.ts +16 -0
- package/lib/components/happening-participants/happening-participants.component.d.ts +24 -0
- package/lib/components/happening-slot-form/happening-slot-form.component.d.ts +76 -0
- package/lib/components/happening-slot-form/happening-slot-modal.component.d.ts +26 -0
- package/lib/components/happening-slot-form/happening-slot-modal.service.d.ts +18 -0
- package/lib/components/happening-slot-participants/happening-slot-participants.component.d.ts +19 -0
- package/lib/components/happening-slots/happening-slots.component.d.ts +28 -0
- package/lib/components/index.d.ts +5 -0
- package/lib/components/start-end-dates-range-form/start-end-dates-range-form.component.d.ts +16 -0
- package/lib/components/start-end-datetime-form/start-end-datetime-form.component.d.ts +53 -0
- package/lib/components/start-end-datetime-form/time-selector.component.d.ts +15 -0
- package/lib/components/swipeable-base.component.d.ts +25 -0
- package/lib/components/swipeable-ui.d.ts +24 -0
- package/lib/components/week.d.ts +4 -0
- package/lib/components/weekday-functions.d.ts +3 -0
- package/lib/components/weekdays/weekdays-form-base.d.ts +31 -0
- package/lib/index.d.ts +2 -0
- package/lib/modals/happening-title-modal/happening-title-modal.component.d.ts +24 -0
- package/lib/services/calendar-data-provider.d.ts +33 -0
- package/lib/services/calendar-day.d.ts +45 -0
- package/lib/services/calendar-day.service.d.ts +18 -0
- package/lib/services/calendar-nav.service.d.ts +14 -0
- package/lib/services/calendar-space.d.ts +23 -0
- package/lib/services/calendar-types.d.ts +10 -0
- package/lib/services/calendarium-services.module.d.ts +6 -0
- package/lib/services/calendarium-space.service.d.ts +8 -0
- package/lib/services/happening.service.d.ts +99 -0
- package/lib/services/index.d.ts +5 -0
- package/package.json +26 -0
- package/sneat-extensions-schedulus-shared.d.ts +5 -0
- package/tsconfig.lib.prod.tsbuildinfo +1 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, input, Input, Output, inject, } from '@angular/core';
|
|
2
|
+
import { FormsModule } from '@angular/forms';
|
|
3
|
+
import { IonSegment, IonSegmentButton } from '@ionic/angular/standalone';
|
|
4
|
+
import { WithSpaceInput } from '@sneat/space-services';
|
|
5
|
+
import { HappeningService } from '../../../../services/happening.service';
|
|
6
|
+
import { SingleHappeningsListComponent } from './single-happenings-list.component';
|
|
7
|
+
import { ClassName } from '@sneat/ui';
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
import * as i1 from "@angular/forms";
|
|
10
|
+
export class SinglesTabComponent extends WithSpaceInput {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.happeningService = inject(HappeningService);
|
|
14
|
+
this.changeDetectorRef = inject(ChangeDetectorRef);
|
|
15
|
+
this.tab = 'upcoming';
|
|
16
|
+
this.slotClicked = new EventEmitter();
|
|
17
|
+
this.$contactusSpace = input.required(...(ngDevMode ? [{ debugName: "$contactusSpace" }] : []));
|
|
18
|
+
}
|
|
19
|
+
ngOnChanges(changes) {
|
|
20
|
+
// console.log('SinglesTabComponent.ngOnChanges()', changes);
|
|
21
|
+
const spaceChange = changes['$space'];
|
|
22
|
+
if (spaceChange) {
|
|
23
|
+
if (this.$spaceID() !== spaceChange.previousValue?.id) {
|
|
24
|
+
switch (this.tab) {
|
|
25
|
+
case 'upcoming':
|
|
26
|
+
this.watchUpcomingSingles();
|
|
27
|
+
break;
|
|
28
|
+
case 'past':
|
|
29
|
+
this.watchPastSingles();
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
onTabChanged(event) {
|
|
36
|
+
event.stopPropagation();
|
|
37
|
+
switch (this.tab) {
|
|
38
|
+
case 'upcoming':
|
|
39
|
+
if (!this.upcomingSinglesSubscription) {
|
|
40
|
+
this.watchUpcomingSingles();
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
case 'past':
|
|
44
|
+
if (!this.pastSinglesSubscription) {
|
|
45
|
+
this.watchPastSingles();
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
48
|
+
case 'recent':
|
|
49
|
+
if (!this.recentSinglesSubscription) {
|
|
50
|
+
this.watchRecentSingles();
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
watchUpcomingSingles() {
|
|
56
|
+
const space = this.$space();
|
|
57
|
+
if (!space) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.upcomingSinglesSubscription = this.watchSingles(this.happeningService.watchUpcomingSingles(space), this.upcomingSinglesSubscription, (singles) => (this.upcomingSingles = singles));
|
|
61
|
+
}
|
|
62
|
+
watchPastSingles() {
|
|
63
|
+
const space = this.$space();
|
|
64
|
+
if (!space) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.pastSinglesSubscription = this.watchSingles(this.happeningService.watchPastSingles(space), this.pastSinglesSubscription, (singles) => (this.pastSingles = singles));
|
|
68
|
+
}
|
|
69
|
+
watchRecentSingles() {
|
|
70
|
+
const space = this.$space();
|
|
71
|
+
if (!space) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.recentSinglesSubscription = this.watchSingles(this.happeningService.watchRecentlyCreatedSingles(space), this.recentSinglesSubscription, (singles) => (this.recentSingles = singles));
|
|
75
|
+
}
|
|
76
|
+
watchSingles(singles$, sub, processSingles) {
|
|
77
|
+
sub?.unsubscribe();
|
|
78
|
+
const space = this.$space();
|
|
79
|
+
if (!space) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
return singles$.pipe(this.takeUntilDestroyed()).subscribe({
|
|
83
|
+
next: (singles) => {
|
|
84
|
+
processSingles(singles);
|
|
85
|
+
this.changeDetectorRef.detectChanges();
|
|
86
|
+
},
|
|
87
|
+
error: this.errorLogger.logErrorHandler('Failed to load past happenings'),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: SinglesTabComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
91
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: SinglesTabComponent, isStandalone: true, selector: "sneat-singles-tab", inputs: { onDateSelected: { classPropertyName: "onDateSelected", publicName: "onDateSelected", isSignal: false, isRequired: false, transformFunction: null }, $contactusSpace: { classPropertyName: "$contactusSpace", publicName: "$contactusSpace", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { slotClicked: "slotClicked" }, providers: [{ provide: ClassName, useValue: 'SinglesTabComponent' }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"ion-padding-horizontal\">\n <ion-segment\n [(ngModel)]=\"tab\"\n color=\"dark\"\n (ionChange)=\"onTabChanged($event)\"\n >\n <ion-segment-button value=\"upcoming\">Upcoming</ion-segment-button>\n <ion-segment-button value=\"past\">Past</ion-segment-button>\n <ion-segment-button value=\"recent\">Recently created</ion-segment-button>\n </ion-segment>\n</div>\n\n@switch (tab) {\n @case (\"upcoming\") {\n <sneat-single-happenings-list\n [$space]=\"$space()\"\n [happenings]=\"upcomingSingles\"\n [$contactusSpace]=\"$contactusSpace()\"\n />\n }\n @case (\"past\") {\n <sneat-single-happenings-list\n [$space]=\"$space()\"\n [happenings]=\"pastSingles\"\n [$contactusSpace]=\"$contactusSpace()\"\n />\n }\n @case (\"recent\") {\n <sneat-single-happenings-list\n [$space]=\"$space()\"\n [happenings]=\"recentSingles\"\n [$contactusSpace]=\"$contactusSpace()\"\n />\n }\n}\n", dependencies: [{ kind: "component", type: SingleHappeningsListComponent, selector: "sneat-single-happenings-list", inputs: ["happenings", "$contactusSpace"] }, { kind: "component", type: IonSegment, selector: "ion-segment", inputs: ["color", "disabled", "mode", "scrollable", "selectOnFocus", "swipeGesture", "value"] }, { kind: "component", type: IonSegmentButton, selector: "ion-segment-button", inputs: ["contentId", "disabled", "layout", "mode", "type", "value"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
92
|
+
}
|
|
93
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: SinglesTabComponent, decorators: [{
|
|
94
|
+
type: Component,
|
|
95
|
+
args: [{ imports: [
|
|
96
|
+
SingleHappeningsListComponent,
|
|
97
|
+
IonSegment,
|
|
98
|
+
IonSegmentButton,
|
|
99
|
+
FormsModule,
|
|
100
|
+
], providers: [{ provide: ClassName, useValue: 'SinglesTabComponent' }], changeDetection: ChangeDetectionStrategy.OnPush, selector: 'sneat-singles-tab', template: "<div class=\"ion-padding-horizontal\">\n <ion-segment\n [(ngModel)]=\"tab\"\n color=\"dark\"\n (ionChange)=\"onTabChanged($event)\"\n >\n <ion-segment-button value=\"upcoming\">Upcoming</ion-segment-button>\n <ion-segment-button value=\"past\">Past</ion-segment-button>\n <ion-segment-button value=\"recent\">Recently created</ion-segment-button>\n </ion-segment>\n</div>\n\n@switch (tab) {\n @case (\"upcoming\") {\n <sneat-single-happenings-list\n [$space]=\"$space()\"\n [happenings]=\"upcomingSingles\"\n [$contactusSpace]=\"$contactusSpace()\"\n />\n }\n @case (\"past\") {\n <sneat-single-happenings-list\n [$space]=\"$space()\"\n [happenings]=\"pastSingles\"\n [$contactusSpace]=\"$contactusSpace()\"\n />\n }\n @case (\"recent\") {\n <sneat-single-happenings-list\n [$space]=\"$space()\"\n [happenings]=\"recentSingles\"\n [$contactusSpace]=\"$contactusSpace()\"\n />\n }\n}\n" }]
|
|
101
|
+
}], ctorParameters: () => [], propDecorators: { slotClicked: [{
|
|
102
|
+
type: Output
|
|
103
|
+
}], onDateSelected: [{
|
|
104
|
+
type: Input
|
|
105
|
+
}], $contactusSpace: [{ type: i0.Input, args: [{ isSignal: true, alias: "$contactusSpace", required: true }] }] } });
|
|
106
|
+
//# sourceMappingURL=singles-tab.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singles-tab.component.js","sourceRoot":"","sources":["../../../../../../../../../../../libs/extensions/schedulus/shared/src/lib/components/calendar/components/singles-tab/singles-tab.component.ts","../../../../../../../../../../../libs/extensions/schedulus/shared/src/lib/components/calendar/components/singles-tab/singles-tab.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,iBAAiB,E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AAE,CAAC,mBACnD,uBAAuB,CAAC,MAAM,YACrC,mBAAmB;;sBAqB5B,MAAM;;sBAEN,KAAK","sourcesContent":["import {\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n EventEmitter,\n input,\n Input,\n OnChanges,\n OnDestroy,\n Output,\n SimpleChanges,\n inject,\n} from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { IonSegment, IonSegmentButton } from '@ionic/angular/standalone';\nimport { IContactusSpaceDboAndID } from '@sneat/contactus-core';\nimport { ISlotUIEvent } from '@sneat/mod-schedulus-core';\nimport { IHappeningContext } from '@sneat/mod-schedulus-core';\nimport { WithSpaceInput } from '@sneat/space-services';\nimport { HappeningService } from '../../../../services/happening.service';\nimport { Observable, Subscription } from 'rxjs';\nimport { SingleHappeningsListComponent } from './single-happenings-list.component';\nimport { ClassName } from '@sneat/ui';\n\n@Component({\n imports: [\n SingleHappeningsListComponent,\n IonSegment,\n IonSegmentButton,\n FormsModule,\n ],\n providers: [{ provide: ClassName, useValue: 'SinglesTabComponent' }],\n changeDetection: ChangeDetectionStrategy.OnPush,\n selector: 'sneat-singles-tab',\n templateUrl: 'singles-tab.component.html',\n})\nexport class SinglesTabComponent\n extends WithSpaceInput\n implements OnChanges, OnDestroy\n{\n private readonly happeningService = inject(HappeningService);\n private readonly changeDetectorRef = inject(ChangeDetectorRef);\n\n private upcomingSinglesSubscription?: Subscription;\n protected upcomingSingles?: IHappeningContext[];\n\n private pastSinglesSubscription?: Subscription;\n protected pastSingles?: IHappeningContext[];\n\n private recentSinglesSubscription?: Subscription;\n protected recentSingles?: IHappeningContext[];\n\n public tab: 'upcoming' | 'past' | 'recent' = 'upcoming';\n\n @Output() readonly slotClicked = new EventEmitter<ISlotUIEvent>();\n\n @Input() onDateSelected?: (date: Date) => void;\n\n public readonly $contactusSpace = input.required<\n IContactusSpaceDboAndID | undefined\n >();\n\n public constructor() {\n super();\n }\n\n public ngOnChanges(changes: SimpleChanges): void {\n // console.log('SinglesTabComponent.ngOnChanges()', changes);\n const spaceChange = changes['$space'];\n if (spaceChange) {\n if (this.$spaceID() !== spaceChange.previousValue?.id) {\n switch (this.tab) {\n case 'upcoming':\n this.watchUpcomingSingles();\n break;\n case 'past':\n this.watchPastSingles();\n break;\n }\n }\n }\n }\n\n protected onTabChanged(event: Event): void {\n event.stopPropagation();\n switch (this.tab) {\n case 'upcoming':\n if (!this.upcomingSinglesSubscription) {\n this.watchUpcomingSingles();\n }\n break;\n case 'past':\n if (!this.pastSinglesSubscription) {\n this.watchPastSingles();\n }\n break;\n case 'recent':\n if (!this.recentSinglesSubscription) {\n this.watchRecentSingles();\n }\n break;\n }\n }\n\n private watchUpcomingSingles(): void {\n const space = this.$space();\n if (!space) {\n return;\n }\n this.upcomingSinglesSubscription = this.watchSingles(\n this.happeningService.watchUpcomingSingles(space),\n this.upcomingSinglesSubscription,\n (singles) => (this.upcomingSingles = singles),\n );\n }\n\n private watchPastSingles(): void {\n const space = this.$space();\n if (!space) {\n return;\n }\n this.pastSinglesSubscription = this.watchSingles(\n this.happeningService.watchPastSingles(space),\n this.pastSinglesSubscription,\n (singles) => (this.pastSingles = singles),\n );\n }\n\n private watchRecentSingles(): void {\n const space = this.$space();\n if (!space) {\n return;\n }\n this.recentSinglesSubscription = this.watchSingles(\n this.happeningService.watchRecentlyCreatedSingles(space),\n this.recentSinglesSubscription,\n (singles) => (this.recentSingles = singles),\n );\n }\n\n private watchSingles(\n singles$: Observable<IHappeningContext[]>,\n sub: Subscription | undefined,\n processSingles: (singles: IHappeningContext[]) => void,\n ): Subscription | undefined {\n sub?.unsubscribe();\n const space = this.$space();\n if (!space) {\n return;\n }\n return singles$.pipe(this.takeUntilDestroyed()).subscribe({\n next: (singles) => {\n processSingles(singles);\n this.changeDetectorRef.detectChanges();\n },\n error: this.errorLogger.logErrorHandler('Failed to load past happenings'),\n });\n }\n}\n","<div class=\"ion-padding-horizontal\">\n <ion-segment\n [(ngModel)]=\"tab\"\n color=\"dark\"\n (ionChange)=\"onTabChanged($event)\"\n >\n <ion-segment-button value=\"upcoming\">Upcoming</ion-segment-button>\n <ion-segment-button value=\"past\">Past</ion-segment-button>\n <ion-segment-button value=\"recent\">Recently created</ion-segment-button>\n </ion-segment>\n</div>\n\n@switch (tab) {\n @case (\"upcoming\") {\n <sneat-single-happenings-list\n [$space]=\"$space()\"\n [happenings]=\"upcomingSingles\"\n [$contactusSpace]=\"$contactusSpace()\"\n />\n }\n @case (\"past\") {\n <sneat-single-happenings-list\n [$space]=\"$space()\"\n [happenings]=\"pastSingles\"\n [$contactusSpace]=\"$contactusSpace()\"\n />\n }\n @case (\"recent\") {\n <sneat-single-happenings-list\n [$space]=\"$space()\"\n [happenings]=\"recentSingles\"\n [$contactusSpace]=\"$contactusSpace()\"\n />\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, input, } from '@angular/core';
|
|
2
|
+
import { IonText } from '@ionic/angular/standalone';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export class TimingBadgeComponent {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.$isCanceled = input.required(...(ngDevMode ? [{ debugName: "$isCanceled" }] : []));
|
|
7
|
+
this.$timing = input.required(...(ngDevMode ? [{ debugName: "$timing" }] : []));
|
|
8
|
+
this.$adjustment = input.required(...(ngDevMode ? [{ debugName: "$adjustment" }] : []));
|
|
9
|
+
this.$startTime = computed(() => this.$timing().start?.time, ...(ngDevMode ? [{ debugName: "$startTime" }] : []));
|
|
10
|
+
this.$endTime = computed(() => this.$timing().end?.time, ...(ngDevMode ? [{ debugName: "$endTime" }] : []));
|
|
11
|
+
this.$hasEnd = computed(() => !!this.$timing().end, ...(ngDevMode ? [{ debugName: "$hasEnd" }] : []));
|
|
12
|
+
this.$hasEndTime = computed(() => !!this.$endTime(), ...(ngDevMode ? [{ debugName: "$hasEndTime" }] : []));
|
|
13
|
+
this.$adjustedStartTime = computed(() => this.$adjustment()?.adjustment?.start?.time, ...(ngDevMode ? [{ debugName: "$adjustedStartTime" }] : []));
|
|
14
|
+
this.$adjustedEndTime = computed(() => this.$adjustment()?.adjustment?.end?.time, ...(ngDevMode ? [{ debugName: "$adjustedEndTime" }] : []));
|
|
15
|
+
this.$hasAdjustedEnd = computed(() => !!this.$adjustment()?.adjustment?.end, ...(ngDevMode ? [{ debugName: "$hasAdjustedEnd" }] : []));
|
|
16
|
+
this.$hasAdjustedEndTime = computed(() => !!this.$adjustedEndTime(), ...(ngDevMode ? [{ debugName: "$hasAdjustedEndTime" }] : []));
|
|
17
|
+
}
|
|
18
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: TimingBadgeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
19
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.0", type: TimingBadgeComponent, isStandalone: true, selector: "sneat-timing-badge", inputs: { $isCanceled: { classPropertyName: "$isCanceled", publicName: "$isCanceled", isSignal: true, isRequired: true, transformFunction: null }, $timing: { classPropertyName: "$timing", publicName: "$timing", isSignal: true, isRequired: true, transformFunction: null }, $adjustment: { classPropertyName: "$adjustment", publicName: "$adjustment", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "From\n@if ($adjustedStartTime() && $adjustedStartTime() !== $startTime()) {\n <ion-text color=\"danger\" title=\"Original: {{ $startTime() }}-{{ $endTime() }}\"\n >{{ $adjustedStartTime() }}\n </ion-text>\n} @else {\n {{ $startTime() }}\n}\n\n@if ($hasAdjustedEnd() || $hasEnd()) {\n <div style=\"font-size: small; color: #777; text-align: right\">\n <small>ends</small>\n @if ($hasAdjustedEndTime() && $adjustedEndTime() !== $endTime()) {\n <ion-text\n [color]=\"\n $adjustedStartTime() && $adjustedStartTime() !== $startTime()\n ? 'warning'\n : 'danger'\n \"\n title=\"Original: {{ $startTime() }}-{{ $endTime() }}\"\n >{{ $adjustedEndTime() }}\n </ion-text>\n } @else {\n {{ $endTime() }}\n }\n </div>\n}\n", dependencies: [{ kind: "component", type: IonText, selector: "ion-text", inputs: ["color", "mode"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
20
|
+
}
|
|
21
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: TimingBadgeComponent, decorators: [{
|
|
22
|
+
type: Component,
|
|
23
|
+
args: [{ selector: 'sneat-timing-badge', changeDetection: ChangeDetectionStrategy.OnPush, imports: [IonText], template: "From\n@if ($adjustedStartTime() && $adjustedStartTime() !== $startTime()) {\n <ion-text color=\"danger\" title=\"Original: {{ $startTime() }}-{{ $endTime() }}\"\n >{{ $adjustedStartTime() }}\n </ion-text>\n} @else {\n {{ $startTime() }}\n}\n\n@if ($hasAdjustedEnd() || $hasEnd()) {\n <div style=\"font-size: small; color: #777; text-align: right\">\n <small>ends</small>\n @if ($hasAdjustedEndTime() && $adjustedEndTime() !== $endTime()) {\n <ion-text\n [color]=\"\n $adjustedStartTime() && $adjustedStartTime() !== $startTime()\n ? 'warning'\n : 'danger'\n \"\n title=\"Original: {{ $startTime() }}-{{ $endTime() }}\"\n >{{ $adjustedEndTime() }}\n </ion-text>\n } @else {\n {{ $endTime() }}\n }\n </div>\n}\n" }]
|
|
24
|
+
}], propDecorators: { $isCanceled: [{ type: i0.Input, args: [{ isSignal: true, alias: "$isCanceled", required: true }] }], $timing: [{ type: i0.Input, args: [{ isSignal: true, alias: "$timing", required: true }] }], $adjustment: [{ type: i0.Input, args: [{ isSignal: true, alias: "$adjustment", required: true }] }] } });
|
|
25
|
+
//# sourceMappingURL=timing-badge.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timing-badge.component.js","sourceRoot":"","sources":["../../../../../../../../../../../libs/extensions/schedulus/shared/src/lib/components/calendar/components/timing-badge/timing-badge.component.ts","../../../../../../../../../../../libs/extensions/sched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GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,EAAE,+DAChC,CAAC;KACH;8GAtBY,oBAAoB;kGAApB,oBAAoB,yeCfjC,qyBA2BA,4CDdY,OAAO;;2FAEN,oBAAoB;kBANhC,SAAS;+BACE,oBAAoB,mBAEb,uBAAuB,CAAC,MAAM,WACtC,CAAC,OAAO,CAAC","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n computed,\n input,\n} from '@angular/core';\nimport { IonText } from '@ionic/angular/standalone';\nimport { ISlotAdjustment, ITiming } from '@sneat/mod-schedulus-core';\n\n@Component({\n selector: 'sneat-timing-badge',\n templateUrl: 'timing-badge.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [IonText],\n})\nexport class TimingBadgeComponent {\n public readonly $isCanceled = input.required<boolean>();\n public readonly $timing = input.required<ITiming>();\n public readonly $adjustment = input.required<ISlotAdjustment | undefined>();\n\n protected readonly $startTime = computed(() => this.$timing().start?.time);\n protected readonly $endTime = computed(() => this.$timing().end?.time);\n protected readonly $hasEnd = computed(() => !!this.$timing().end);\n protected readonly $hasEndTime = computed(() => !!this.$endTime());\n\n protected readonly $adjustedStartTime = computed(\n () => this.$adjustment()?.adjustment?.start?.time,\n );\n protected readonly $adjustedEndTime = computed(\n () => this.$adjustment()?.adjustment?.end?.time,\n );\n protected readonly $hasAdjustedEnd = computed(\n () => !!this.$adjustment()?.adjustment?.end,\n );\n protected readonly $hasAdjustedEndTime = computed(\n () => !!this.$adjustedEndTime(),\n );\n}\n","From\n@if ($adjustedStartTime() && $adjustedStartTime() !== $startTime()) {\n <ion-text color=\"danger\" title=\"Original: {{ $startTime() }}-{{ $endTime() }}\"\n >{{ $adjustedStartTime() }}\n </ion-text>\n} @else {\n {{ $startTime() }}\n}\n\n@if ($hasAdjustedEnd() || $hasEnd()) {\n <div style=\"font-size: small; color: #777; text-align: right\">\n <small>ends</small>\n @if ($hasAdjustedEndTime() && $adjustedEndTime() !== $endTime()) {\n <ion-text\n [color]=\"\n $adjustedStartTime() && $adjustedStartTime() !== $startTime()\n ? 'warning'\n : 'danger'\n \"\n title=\"Original: {{ $startTime() }}-{{ $endTime() }}\"\n >{{ $adjustedEndTime() }}\n </ion-text>\n } @else {\n {{ $endTime() }}\n }\n </div>\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weekday.js","sourceRoot":"","sources":["../../../../../../../../../libs/extensions/schedulus/shared/src/lib/components/calendar/weekday.ts"],"names":[],"mappings":"","sourcesContent":["import { WeekdayCode2 } from '@sneat/mod-schedulus-core';\nimport { CalendarDay } from '../../services/calendar-day';\n\nexport interface Weekday {\n // This is used to\n readonly id: WeekdayCode2;\n readonly longTitle: string;\n readonly day?: CalendarDay;\n}\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { VirtualSliderDirectPushedNext, VirtualSliderDirectPushedPrev, VirtualSliderReversePushedNext, VirtualSliderReversePushedPrev, } from '@sneat/components';
|
|
2
|
+
import { wd2, wdCodeToWeekdayLongName, } from '@sneat/mod-schedulus-core';
|
|
3
|
+
import { addDays } from './calendar/calendar-state.service';
|
|
4
|
+
export function isToday(date) {
|
|
5
|
+
return areSameDates(date, new Date());
|
|
6
|
+
}
|
|
7
|
+
export function isTomorrow(date) {
|
|
8
|
+
if (!date) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const tomorrow = addDays(new Date(), 1);
|
|
12
|
+
return areSameDates(date, tomorrow);
|
|
13
|
+
}
|
|
14
|
+
export function areSameDates(d1, d2) {
|
|
15
|
+
return (d1.getDate() === d2.getDate() &&
|
|
16
|
+
d1.getMonth() === d2.getMonth() &&
|
|
17
|
+
d1.getFullYear() === d2.getFullYear());
|
|
18
|
+
}
|
|
19
|
+
export function getWdDate(wd, activeWd, activeDate) {
|
|
20
|
+
if (wd === activeWd) {
|
|
21
|
+
return activeDate;
|
|
22
|
+
}
|
|
23
|
+
const wdIndex = wd2.indexOf(wd);
|
|
24
|
+
const dayIndex = wd2.indexOf(activeWd);
|
|
25
|
+
return new Date(activeDate.getFullYear(), activeDate.getMonth(), activeDate.getDate() + wdIndex - dayIndex);
|
|
26
|
+
}
|
|
27
|
+
export const createWeekdays = () => wd2.map((id) => ({
|
|
28
|
+
id,
|
|
29
|
+
day: undefined,
|
|
30
|
+
longTitle: wdCodeToWeekdayLongName(id),
|
|
31
|
+
}));
|
|
32
|
+
export function animationState(activeParity, direction) {
|
|
33
|
+
let result;
|
|
34
|
+
switch (activeParity) {
|
|
35
|
+
case 'odd':
|
|
36
|
+
switch (direction) {
|
|
37
|
+
case 'forward':
|
|
38
|
+
result = VirtualSliderReversePushedNext;
|
|
39
|
+
break;
|
|
40
|
+
case 'back':
|
|
41
|
+
result = VirtualSliderDirectPushedPrev;
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
throw new Error(`Invalid direction: ${direction}`);
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
case 'even':
|
|
48
|
+
switch (direction) {
|
|
49
|
+
case 'forward':
|
|
50
|
+
result = VirtualSliderDirectPushedNext;
|
|
51
|
+
break;
|
|
52
|
+
case 'back':
|
|
53
|
+
result = VirtualSliderReversePushedPrev;
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
throw new Error(`Invalid direction: ${direction}`);
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
throw new Error(`Unknown parity: ${activeParity}`);
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=calendar-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-core.js","sourceRoot":"","sources":["../../../../../../../../libs/extensions/schedulus/shared/src/lib/components/calendar-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,8BAA8B,GAC/B,MAAM,mBAA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AAG,GAAuB,EAAE,CACrD,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACf,EAAE;IACF,GAAG,EAAE,SAAS;IACd,SAAS,EAAE,uBAAuB,CAAC,EAAE,CAAC;CACvC,CAAC,CAAC,CAAC;AAEN,MAAM,UAAU,cAAc,CAC5B,YAAoB,EACpB,SAA6B;IAE7B,IAAI,MAAoC,CAAC;IACzC,QAAQ,YAAY,EAAE,CAAC;QACrB,KAAK,KAAK;YACR,QAAQ,SAAS,EAAE,CAAC;gBAClB,KAAK,SAAS;oBACZ,MAAM,GAAG,8BAA8B,CAAC;oBACxC,MAAM;gBACR,KAAK,MAAM;oBACT,MAAM,GAAG,6BAA6B,CAAC;oBACvC,MAAM;gBACR;oBACE,MAAM,IAAI,KAAK,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC;YACvD,CAAC;YACD,MAAM;QACR,KAAK,MAAM;YACT,QAAQ,SAAS,EAAE,CAAC;gBAClB,KAAK,SAAS;oBACZ,MAAM,GAAG,6BAA6B,CAAC;oBACvC,MAAM;gBACR,KAAK,MAAM;oBACT,MAAM,GAAG,8BAA8B,CAAC;oBACxC,MAAM;gBACR;oBACE,MAAM,IAAI,KAAK,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC;YACvD,CAAC;YACD,MAAM;QACR;YACE,MAAM,IAAI,KAAK,CAAC,mBAAmB,YAAY,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import {\n VirtualSliderAnimationStates,\n VirtualSliderDirectPushedNext,\n VirtualSliderDirectPushedPrev,\n VirtualSliderReversePushedNext,\n VirtualSliderReversePushedPrev,\n} from '@sneat/components';\nimport {\n wd2,\n wdCodeToWeekdayLongName,\n WeekdayCode2,\n} from '@sneat/mod-schedulus-core';\nimport { addDays } from './calendar/calendar-state.service';\nimport { Weekday } from './calendar/weekday';\nimport { Parity } from './swipeable-ui';\n\nexport function isToday(date: Date): boolean {\n return areSameDates(date, new Date());\n}\n\nexport function isTomorrow(date?: Date): boolean {\n if (!date) {\n return false;\n }\n const tomorrow = addDays(new Date(), 1);\n return areSameDates(date, tomorrow);\n}\n\nexport function areSameDates(d1: Date, d2: Date): boolean {\n return (\n d1.getDate() === d2.getDate() &&\n d1.getMonth() === d2.getMonth() &&\n d1.getFullYear() === d2.getFullYear()\n );\n}\n\nexport function getWdDate(\n wd: WeekdayCode2,\n activeWd: WeekdayCode2,\n activeDate: Date,\n): Date {\n if (wd === activeWd) {\n return activeDate;\n }\n const wdIndex = wd2.indexOf(wd);\n const dayIndex = wd2.indexOf(activeWd);\n return new Date(\n activeDate.getFullYear(),\n activeDate.getMonth(),\n activeDate.getDate() + wdIndex - dayIndex,\n );\n}\n\nexport const createWeekdays = (): readonly Weekday[] =>\n wd2.map((id) => ({\n id,\n day: undefined,\n longTitle: wdCodeToWeekdayLongName(id),\n }));\n\nexport function animationState(\n activeParity: Parity,\n direction: 'forward' | 'back',\n): VirtualSliderAnimationStates {\n let result: VirtualSliderAnimationStates;\n switch (activeParity) {\n case 'odd':\n switch (direction) {\n case 'forward':\n result = VirtualSliderReversePushedNext;\n break;\n case 'back':\n result = VirtualSliderDirectPushedPrev;\n break;\n default:\n throw new Error(`Invalid direction: ${direction}`);\n }\n break;\n case 'even':\n switch (direction) {\n case 'forward':\n result = VirtualSliderDirectPushedNext;\n break;\n case 'back':\n result = VirtualSliderReversePushedPrev;\n break;\n default:\n throw new Error(`Invalid direction: ${direction}`);\n }\n break;\n default:\n throw new Error(`Unknown parity: ${activeParity}`);\n }\n return result;\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BehaviorSubject, distinctUntilChanged } from 'rxjs';
|
|
2
|
+
export const emptyCalendarFilter = {
|
|
3
|
+
text: '',
|
|
4
|
+
showRecurrings: true,
|
|
5
|
+
showSingles: true,
|
|
6
|
+
contactIDs: [],
|
|
7
|
+
weekdays: [],
|
|
8
|
+
repeats: [],
|
|
9
|
+
};
|
|
10
|
+
export class CalendarFilterService {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.filter$ = new BehaviorSubject(emptyCalendarFilter);
|
|
13
|
+
this.filter = this.filter$
|
|
14
|
+
.asObservable()
|
|
15
|
+
.pipe(distinctUntilChanged());
|
|
16
|
+
}
|
|
17
|
+
next(filter) {
|
|
18
|
+
if (this.filter$.value == filter) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this.filter$.next(filter);
|
|
22
|
+
}
|
|
23
|
+
resetScheduleFilter(event) {
|
|
24
|
+
event.stopPropagation();
|
|
25
|
+
this.filter$.next(emptyCalendarFilter);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=calendar-filter.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-filter.service.js","sourceRoot":"","sources":["../../../../../../../../libs/extensions/schedulus/shared/src/lib/components/calendar-filter.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAG7D,MAAM,CAAC,MAAM,mBAAmB,GAAoB;IAClD,IAAI,EAAE,EAAE;IACR,cAAc,EAAE,IAAI;IACpB,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,EAAE;IACd,QAAQ,EAAE,EAAE;IACZ,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,MAAM,OAAO,qBAAqB;IAAlC;QACmB,YAAO,GAAG,IAAI,eAAe,CAC5C,mBAAmB,CACpB,CAAC;QACc,WAAM,GAAG,IAAI,CAAC,OAAO;aAClC,YAAY,EAAE;aACd,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAalC,CAAC;IAXC,IAAI,CAAC,MAAuB;QAC1B,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,MAAM,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,mBAAmB,CAAC,KAAY;QAC9B,KAAK,CAAC,eAAe,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["import { BehaviorSubject, distinctUntilChanged } from 'rxjs';\nimport { ICalendarFilter } from './calendar/components/calendar-filter/calendar-filter';\n\nexport const emptyCalendarFilter: ICalendarFilter = {\n text: '',\n showRecurrings: true,\n showSingles: true,\n contactIDs: [],\n weekdays: [],\n repeats: [],\n};\n\nexport class CalendarFilterService {\n private readonly filter$ = new BehaviorSubject<ICalendarFilter>(\n emptyCalendarFilter,\n );\n public readonly filter = this.filter$\n .asObservable()\n .pipe(distinctUntilChanged());\n\n next(filter: ICalendarFilter): void {\n if (this.filter$.value == filter) {\n return;\n }\n this.filter$.next(filter);\n }\n\n resetScheduleFilter(event: Event): void {\n event.stopPropagation();\n this.filter$.next(emptyCalendarFilter);\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getRelatedItemIDs } from '@sneat/dto';
|
|
2
|
+
export function hasContact(spaceID, contactIDs, related) {
|
|
3
|
+
if (!contactIDs.length) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
const relatedContactIDs = getRelatedItemIDs(related, 'contactus', 'contacts', spaceID);
|
|
7
|
+
return ((!relatedContactIDs?.length && contactIDs.includes('')) ||
|
|
8
|
+
relatedContactIDs?.some((id) => contactIDs.includes(id)));
|
|
9
|
+
}
|
|
10
|
+
// noinspection JSMethodCanBeStatic
|
|
11
|
+
// export function hasWeekday(slots: IHappeningSlot[] | undefined, weekdays?: WeekdayCode2[]): boolean {
|
|
12
|
+
// return !weekdays || !!slots?.some(slot => slot.weekdays?.some(wd => weekdays.includes(wd)));
|
|
13
|
+
// }
|
|
14
|
+
export function isSlotVisible(slot, filter) {
|
|
15
|
+
if (!hasContact(slot.happening.space.id, filter.contactIDs, slot.happening?.dbo?.related || slot.happening?.brief?.related)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
// if (!hasWeekday(happening?.brief?.slots || happening?.dto?.slots, weekdays)) {
|
|
19
|
+
// return false;
|
|
20
|
+
// }
|
|
21
|
+
const happeningBrief = slot.happening?.brief || slot.happening?.dbo;
|
|
22
|
+
if (filter.repeats?.length &&
|
|
23
|
+
!Object.values(happeningBrief?.slots || {}).some((slot) => filter.repeats.includes(slot.repeats))) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return (((!!slot.happening && filter.showRecurrings) ||
|
|
27
|
+
(!!slot.happening && filter.showSingles)) &&
|
|
28
|
+
(!filter || slot.title.toLowerCase().includes(filter.text)));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=calendar-slots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-slots.js","sourceRoot":"","sources":["../../../../../../../../libs/extensions/schedulus/shared/src/lib/components/calendar-slots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAmB,MAAM,YAAY,CAAC;AAIhE,MAAM,UAAU,UAAU,CACxB,OAAe,EACf,UAA6B,EAC7B,OAAyB;IAEzB,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,iBAAiB,GAAG,iBAAiB,CACzC,OAAO,EACP,WAAW,EACX,UAAU,EACV,OAAO,CACR,CAAC;IACF,OAAO,CACL,CAAC,CAAC,iBAAiB,EAAE,MAAM,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACvD,iBAAiB,EAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CACzD,CAAC;AACJ,CAAC;AAED,mCAAmC;AAEnC,wGAAwG;AACxG,gGAAgG;AAChG,IAAI;AAEJ,MAAM,UAAU,aAAa,CAC3B,IAAoB,EACpB,MAAuB;IAEvB,IACE,CAAC,UAAU,CACT,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EACvB,MAAM,CAAC,UAAU,EACjB,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAC/D,EACD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,iFAAiF;IACjF,iBAAiB;IACjB,IAAI;IACJ,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,IAAI,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC;IACpE,IACE,MAAM,CAAC,OAAO,EAAE,MAAM;QACtB,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CACxD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CACtC,EACD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CACL,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,cAAc,CAAC;QAC1C,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;QAC3C,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAC5D,CAAC;AACJ,CAAC","sourcesContent":["import { getRelatedItemIDs, IRelatedModules } from '@sneat/dto';\nimport { ISlotUIContext } from '@sneat/mod-schedulus-core';\nimport { ICalendarFilter } from './calendar/components/calendar-filter/calendar-filter';\n\nexport function hasContact(\n spaceID: string,\n contactIDs: readonly string[],\n related?: IRelatedModules,\n): boolean {\n if (!contactIDs.length) {\n return true;\n }\n const relatedContactIDs = getRelatedItemIDs(\n related,\n 'contactus',\n 'contacts',\n spaceID,\n );\n return (\n (!relatedContactIDs?.length && contactIDs.includes('')) ||\n relatedContactIDs?.some((id) => contactIDs.includes(id))\n );\n}\n\n// noinspection JSMethodCanBeStatic\n\n// export function hasWeekday(slots: IHappeningSlot[] | undefined, weekdays?: WeekdayCode2[]): boolean {\n// \treturn !weekdays || !!slots?.some(slot => slot.weekdays?.some(wd => weekdays.includes(wd)));\n// }\n\nexport function isSlotVisible(\n slot: ISlotUIContext,\n filter: ICalendarFilter,\n): boolean {\n if (\n !hasContact(\n slot.happening.space.id,\n filter.contactIDs,\n slot.happening?.dbo?.related || slot.happening?.brief?.related,\n )\n ) {\n return false;\n }\n // if (!hasWeekday(happening?.brief?.slots || happening?.dto?.slots, weekdays)) {\n // \treturn false;\n // }\n const happeningBrief = slot.happening?.brief || slot.happening?.dbo;\n if (\n filter.repeats?.length &&\n !Object.values(happeningBrief?.slots || {}).some((slot) =>\n filter.repeats.includes(slot.repeats),\n )\n ) {\n return false;\n }\n\n return (\n ((!!slot.happening && filter.showRecurrings) ||\n (!!slot.happening && filter.showSingles)) &&\n (!filter || slot.title.toLowerCase().includes(filter.text))\n );\n}\n"]}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { ChangeDetectorRef, Directive, EventEmitter, Injectable, input, Output, signal, inject, } from '@angular/core';
|
|
2
|
+
import { ModalController } from '@ionic/angular/standalone';
|
|
3
|
+
import { addSpace, } from '@sneat/contactus-core';
|
|
4
|
+
import { ContactsSelectorService } from '@sneat/contactus-shared';
|
|
5
|
+
import { isoStringsToDate } from '@sneat/core';
|
|
6
|
+
import { getRelatedItemIDs } from '@sneat/dto';
|
|
7
|
+
import { getWd2 } from '@sneat/mod-schedulus-core';
|
|
8
|
+
import { ErrorLogger } from '@sneat/core';
|
|
9
|
+
import { WithSpaceInput } from '@sneat/space-services';
|
|
10
|
+
import { zipMapBriefsWithIDs } from '@sneat/space-models';
|
|
11
|
+
import { SpaceNavService } from '@sneat/space-services';
|
|
12
|
+
import { NEVER } from 'rxjs';
|
|
13
|
+
import { HappeningService, } from '../services/happening.service';
|
|
14
|
+
import * as i0 from "@angular/core";
|
|
15
|
+
export class HappeningBaseComponentParams {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.errorLogger = inject(ErrorLogger);
|
|
18
|
+
this.happeningService = inject(HappeningService);
|
|
19
|
+
this.spaceNavService = inject(SpaceNavService);
|
|
20
|
+
this.contactsSelectorService = inject(ContactsSelectorService);
|
|
21
|
+
this.modalController = inject(ModalController);
|
|
22
|
+
}
|
|
23
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: HappeningBaseComponentParams, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
24
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: HappeningBaseComponentParams }); }
|
|
25
|
+
}
|
|
26
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: HappeningBaseComponentParams, decorators: [{
|
|
27
|
+
type: Injectable
|
|
28
|
+
}] });
|
|
29
|
+
/* The meatadata should be passed to component declaration as:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
@Component({
|
|
33
|
+
selector: 'some-component',
|
|
34
|
+
|
|
35
|
+
// Next 2 rows allow to inherit metadata
|
|
36
|
+
providers: [...HappeningBaseComponent.providers],
|
|
37
|
+
...BaseComponent.metadata
|
|
38
|
+
})
|
|
39
|
+
class SomeComponent extends BaseComponent
|
|
40
|
+
```
|
|
41
|
+
*/
|
|
42
|
+
export class HappeningBaseComponent extends WithSpaceInput {
|
|
43
|
+
static { this.providers = [HappeningBaseComponentParams]; }
|
|
44
|
+
static { this.metadata = {
|
|
45
|
+
inputs: ['space', 'happening'],
|
|
46
|
+
outputs: ['deleted'],
|
|
47
|
+
}; }
|
|
48
|
+
get date() {
|
|
49
|
+
const happeningDbo = this.$happening().dbo;
|
|
50
|
+
if (!happeningDbo?.dates?.length) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return isoStringsToDate(happeningDbo.dates[0]);
|
|
54
|
+
}
|
|
55
|
+
get wd() {
|
|
56
|
+
const date = this.date;
|
|
57
|
+
return date && getWd2(date);
|
|
58
|
+
}
|
|
59
|
+
get happeningService() {
|
|
60
|
+
return this.happeningBaseComponentParams.happeningService;
|
|
61
|
+
}
|
|
62
|
+
get contactsSelectorService() {
|
|
63
|
+
return this.happeningBaseComponentParams.contactsSelectorService;
|
|
64
|
+
}
|
|
65
|
+
constructor() {
|
|
66
|
+
super();
|
|
67
|
+
this.$happening = input.required(...(ngDevMode ? [{ debugName: "$happening" }] : []));
|
|
68
|
+
this.$contactusSpace = input.required(...(ngDevMode ? [{ debugName: "$contactusSpace" }] : []));
|
|
69
|
+
this.deleted = new EventEmitter();
|
|
70
|
+
this.deleting = false;
|
|
71
|
+
this.happeningBaseComponentParams = inject(HappeningBaseComponentParams);
|
|
72
|
+
this.changeDetectorRef = inject(ChangeDetectorRef);
|
|
73
|
+
this.onContactAdded = (contact) => {
|
|
74
|
+
const [space, happening] = this.spaceAndHappening();
|
|
75
|
+
if (!space || !happening) {
|
|
76
|
+
return NEVER;
|
|
77
|
+
}
|
|
78
|
+
const request = {
|
|
79
|
+
spaceID: space.id,
|
|
80
|
+
happeningID: happening.id,
|
|
81
|
+
contact: { id: contact.id },
|
|
82
|
+
};
|
|
83
|
+
return this.happeningService.addParticipant(request);
|
|
84
|
+
};
|
|
85
|
+
this.onMemberRemoved = (member) => {
|
|
86
|
+
const [space, happening] = this.spaceAndHappening();
|
|
87
|
+
if (!space || !happening) {
|
|
88
|
+
return NEVER;
|
|
89
|
+
}
|
|
90
|
+
const request = {
|
|
91
|
+
spaceID: space.id,
|
|
92
|
+
happeningID: happening.id,
|
|
93
|
+
contact: { id: member.id },
|
|
94
|
+
};
|
|
95
|
+
return this.happeningService.removeParticipant(request);
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
goHappening(event) {
|
|
99
|
+
event.stopPropagation();
|
|
100
|
+
const [space, happening] = this.spaceAndHappening();
|
|
101
|
+
if (!space || !happening) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this.spaceNavService
|
|
105
|
+
.navigateForwardToSpacePage(space, `happening/${happening.id}`, {
|
|
106
|
+
state: { happening },
|
|
107
|
+
})
|
|
108
|
+
.catch(this.errorLogger.logErrorHandler('failed to navigate to happening page'));
|
|
109
|
+
// this.navigateForward('regular-activity', { id: activity.id }, { happeningDto: activity }, { excludeCommuneId: true });
|
|
110
|
+
}
|
|
111
|
+
delete(event) {
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
const [space, happening] = this.spaceAndHappening();
|
|
114
|
+
if (!space || !happening) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (!happening) {
|
|
118
|
+
this.errorLogger.logError(new Error('Single happening card has no happening context at moment of delete attempt'));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (!confirm(`
|
|
122
|
+
DELETING: ${happening?.brief?.title}
|
|
123
|
+
|
|
124
|
+
Are you sure you want to delete this happening?
|
|
125
|
+
|
|
126
|
+
This operation can NOT be undone.`)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
this.deleting = true;
|
|
130
|
+
const happeningWithSpace = happening?.space
|
|
131
|
+
? happening
|
|
132
|
+
: {
|
|
133
|
+
...happening,
|
|
134
|
+
space: space || { id: '' },
|
|
135
|
+
};
|
|
136
|
+
this.happeningService
|
|
137
|
+
.deleteHappening(happeningWithSpace)
|
|
138
|
+
.pipe(this.takeUntilDestroyed())
|
|
139
|
+
.subscribe({
|
|
140
|
+
next: () => this.deleted.emit(),
|
|
141
|
+
error: (e) => {
|
|
142
|
+
this.errorLogger.logError(e, 'Failed to delete happening');
|
|
143
|
+
this.deleting = false;
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
selectMembers(event) {
|
|
148
|
+
event.stopPropagation();
|
|
149
|
+
const [space, happening] = this.spaceAndHappening();
|
|
150
|
+
if (!space || !happening) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const spaceID = space?.id;
|
|
154
|
+
if (!spaceID) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const spaceContacts = zipMapBriefsWithIDs(this.$contactusSpace()?.dbo?.contacts)?.map(addSpace(space));
|
|
158
|
+
this.contactsSelectorService
|
|
159
|
+
.selectMultipleContacts({
|
|
160
|
+
selectedItems: spaceContacts?.filter((m) => getRelatedItemIDs(happening?.brief?.related, 'contactus', 'contacts', space.id)?.includes(m.id)) || [],
|
|
161
|
+
items: signal(spaceContacts), // TODO: provide proper observable
|
|
162
|
+
onAdded: this.onContactAdded,
|
|
163
|
+
onRemoved: this.onMemberRemoved,
|
|
164
|
+
})
|
|
165
|
+
.catch((err) => {
|
|
166
|
+
this.errorLogger.logError(err, 'Failed to select members');
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
spaceAndHappening() {
|
|
170
|
+
const happening = this.$happening();
|
|
171
|
+
if (!happening) {
|
|
172
|
+
console.error(this.className + ': $happening is not set');
|
|
173
|
+
}
|
|
174
|
+
const space = this.$space();
|
|
175
|
+
if (!space) {
|
|
176
|
+
console.error(this.className + ': $space is not set');
|
|
177
|
+
}
|
|
178
|
+
return [space, happening];
|
|
179
|
+
}
|
|
180
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: HappeningBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
181
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.0", type: HappeningBaseComponent, isStandalone: true, inputs: { $happening: { classPropertyName: "$happening", publicName: "$happening", isSignal: true, isRequired: true, transformFunction: null }, $contactusSpace: { classPropertyName: "$contactusSpace", publicName: "$contactusSpace", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { deleted: "deleted" }, usesInheritance: true, ngImport: i0 }); }
|
|
182
|
+
}
|
|
183
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: HappeningBaseComponent, decorators: [{
|
|
184
|
+
type: Directive
|
|
185
|
+
}], ctorParameters: () => [], propDecorators: { $happening: [{ type: i0.Input, args: [{ isSignal: true, alias: "$happening", required: true }] }], $contactusSpace: [{ type: i0.Input, args: [{ isSignal: true, alias: "$contactusSpace", required: true }] }], deleted: [{
|
|
186
|
+
type: Output
|
|
187
|
+
}] } });
|
|
188
|
+
//# sourceMappingURL=happening-base.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"happening-base.component.js","sourceRoot":"","sources":["../../../../../../../../libs/extensions/schedulus/shared/src/lib/components/happening-base.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,QAAQ,GAIT,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAiB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;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EAAE,MAAM,CAAC,aAAa,CAAC,EAAE,kCAAkC;YAChE,OAAO,EAAE,IAAI,CAAC,cAAc;YAC5B,SAAS,EAAE,IAAI,CAAC,eAAe;SAChC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,0BAA0B,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACP,CAAC;IAiBS,iBAAiB;QACzB,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACpC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,yBAAyB,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,qBAAqB,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC5B,CAAC;8GA5KmB,sBAAsB;kGAAtB,sBAAsB;;2FAAtB,sBAAsB;kBAD3C,SAAS;;sBAeP,MAAM","sourcesContent":["import {\n ChangeDetectorRef,\n Directive,\n EventEmitter,\n Injectable,\n input,\n Output,\n signal,\n inject,\n} from '@angular/core';\nimport { ModalController } from '@ionic/angular/standalone';\nimport {\n addSpace,\n IContactusSpaceDboAndID,\n IContactWithBrief,\n IContactWithBriefAndSpace,\n} from '@sneat/contactus-core';\nimport { ContactsSelectorService } from '@sneat/contactus-shared';\nimport { isoStringsToDate } from '@sneat/core';\nimport { getRelatedItemIDs } from '@sneat/dto';\nimport { IHappeningContext, WeekdayCode2 } from '@sneat/mod-schedulus-core';\nimport { getWd2 } from '@sneat/mod-schedulus-core';\nimport { ErrorLogger, IErrorLogger } from '@sneat/core';\nimport { WithSpaceInput } from '@sneat/space-services';\nimport { ISpaceContext, zipMapBriefsWithIDs } from '@sneat/space-models';\nimport { SpaceNavService } from '@sneat/space-services';\nimport { NEVER, Observable } from 'rxjs';\nimport {\n HappeningService,\n IHappeningContactRequest,\n} from '../services/happening.service';\n\n@Injectable()\nexport class HappeningBaseComponentParams {\n readonly errorLogger = inject<IErrorLogger>(ErrorLogger);\n readonly happeningService = inject(HappeningService);\n readonly spaceNavService = inject(SpaceNavService);\n readonly contactsSelectorService = inject(ContactsSelectorService);\n readonly modalController = inject(ModalController);\n}\n\n/* The meatadata should be passed to component declaration as:\n\n\t```\n\t@Component({\n\t\tselector: 'some-component',\n\n\t\t// Next 2 rows allow to inherit metadata\n\t\tproviders: [...HappeningBaseComponent.providers],\n\t\t...BaseComponent.metadata\n\t})\n\tclass SomeComponent extends BaseComponent\n\t```\n */\n@Directive()\nexport abstract class HappeningBaseComponent extends WithSpaceInput {\n static providers = [HappeningBaseComponentParams];\n\n static metadata = {\n inputs: ['space', 'happening'],\n outputs: ['deleted'],\n };\n\n public readonly $happening = input.required<IHappeningContext>();\n\n public readonly $contactusSpace = input.required<\n IContactusSpaceDboAndID | undefined\n >();\n\n @Output() readonly deleted = new EventEmitter<string>();\n\n get date(): Date | undefined {\n const happeningDbo = this.$happening().dbo;\n if (!happeningDbo?.dates?.length) {\n return undefined;\n }\n return isoStringsToDate(happeningDbo.dates[0]);\n }\n\n get wd(): WeekdayCode2 | undefined {\n const date = this.date;\n return date && getWd2(date);\n }\n\n public deleting = false;\n\n get happeningService() {\n return this.happeningBaseComponentParams.happeningService;\n }\n\n get contactsSelectorService() {\n return this.happeningBaseComponentParams.contactsSelectorService;\n }\n\n private readonly happeningBaseComponentParams = inject(\n HappeningBaseComponentParams,\n );\n\n protected readonly changeDetectorRef = inject(ChangeDetectorRef);\n\n protected constructor() {\n super();\n }\n\n protected goHappening(event: Event): void {\n event.stopPropagation();\n const [space, happening] = this.spaceAndHappening();\n if (!space || !happening) {\n return;\n }\n this.spaceNavService\n .navigateForwardToSpacePage(space, `happening/${happening.id}`, {\n state: { happening },\n })\n .catch(\n this.errorLogger.logErrorHandler(\n 'failed to navigate to happening page',\n ),\n );\n // this.navigateForward('regular-activity', { id: activity.id }, { happeningDto: activity }, { excludeCommuneId: true });\n }\n\n protected delete(event: Event): void {\n event.stopPropagation();\n const [space, happening] = this.spaceAndHappening();\n if (!space || !happening) {\n return;\n }\n if (!happening) {\n this.errorLogger.logError(\n new Error(\n 'Single happening card has no happening context at moment of delete attempt',\n ),\n );\n return;\n }\n if (\n !confirm(`\nDELETING: ${happening?.brief?.title}\n\nAre you sure you want to delete this happening?\n\nThis operation can NOT be undone.`)\n ) {\n return;\n }\n this.deleting = true;\n\n const happeningWithSpace: IHappeningContext = happening?.space\n ? happening\n : {\n ...happening,\n space: space || { id: '' },\n };\n\n this.happeningService\n .deleteHappening(happeningWithSpace)\n .pipe(this.takeUntilDestroyed())\n .subscribe({\n next: () => this.deleted.emit(),\n error: (e) => {\n this.errorLogger.logError(e, 'Failed to delete happening');\n this.deleting = false;\n },\n });\n }\n\n protected selectMembers(event: Event): void {\n event.stopPropagation();\n const [space, happening] = this.spaceAndHappening();\n if (!space || !happening) {\n return;\n }\n const spaceID = space?.id;\n if (!spaceID) {\n return;\n }\n const spaceContacts: IContactWithBriefAndSpace[] | undefined =\n zipMapBriefsWithIDs(this.$contactusSpace()?.dbo?.contacts)?.map(\n addSpace(space),\n );\n\n this.contactsSelectorService\n .selectMultipleContacts({\n selectedItems:\n spaceContacts?.filter((m) =>\n getRelatedItemIDs(\n happening?.brief?.related,\n 'contactus',\n 'contacts',\n space.id,\n )?.includes(m.id),\n ) || [],\n items: signal(spaceContacts), // TODO: provide proper observable\n onAdded: this.onContactAdded,\n onRemoved: this.onMemberRemoved,\n })\n .catch((err) => {\n this.errorLogger.logError(err, 'Failed to select members');\n });\n }\n\n private readonly onContactAdded = (\n contact: IContactWithBrief,\n ): Observable<void> => {\n const [space, happening] = this.spaceAndHappening();\n if (!space || !happening) {\n return NEVER;\n }\n const request: IHappeningContactRequest = {\n spaceID: space.id,\n happeningID: happening.id,\n contact: { id: contact.id },\n };\n return this.happeningService.addParticipant(request);\n };\n\n protected spaceAndHappening(): [ISpaceContext, IHappeningContext] {\n const happening = this.$happening();\n if (!happening) {\n console.error(this.className + ': $happening is not set');\n }\n const space = this.$space();\n if (!space) {\n console.error(this.className + ': $space is not set');\n }\n return [space, happening];\n }\n\n private readonly onMemberRemoved = (\n member: IContactWithBrief,\n ): Observable<void> => {\n const [space, happening] = this.spaceAndHappening();\n if (!space || !happening) {\n return NEVER;\n }\n const request: IHappeningContactRequest = {\n spaceID: space.id,\n happeningID: happening.id,\n contact: { id: member.id },\n };\n return this.happeningService.removeParticipant(request);\n };\n}\n"]}
|