@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.
Files changed (194) hide show
  1. package/esm2022/index.js +2 -0
  2. package/esm2022/index.js.map +1 -0
  3. package/esm2022/lib/components/calendar/calendar-base.component.js +83 -0
  4. package/esm2022/lib/components/calendar/calendar-base.component.js.map +1 -0
  5. package/esm2022/lib/components/calendar/calendar-brief.component.js +57 -0
  6. package/esm2022/lib/components/calendar/calendar-brief.component.js.map +1 -0
  7. package/esm2022/lib/components/calendar/calendar-component-types.js +2 -0
  8. package/esm2022/lib/components/calendar/calendar-component-types.js.map +1 -0
  9. package/esm2022/lib/components/calendar/calendar-state.service.js +90 -0
  10. package/esm2022/lib/components/calendar/calendar-state.service.js.map +1 -0
  11. package/esm2022/lib/components/calendar/calendar.component.js +284 -0
  12. package/esm2022/lib/components/calendar/calendar.component.js.map +1 -0
  13. package/esm2022/lib/components/calendar/components/calendar-add-buttons/calendar-add-buttons.component.js +45 -0
  14. package/esm2022/lib/components/calendar/components/calendar-add-buttons/calendar-add-buttons.component.js.map +1 -0
  15. package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-base.component.js +26 -0
  16. package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-base.component.js.map +1 -0
  17. package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-card.component.js +67 -0
  18. package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-card.component.js.map +1 -0
  19. package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-tab.component.js +74 -0
  20. package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-tab.component.js.map +1 -0
  21. package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-title.component.js +27 -0
  22. package/esm2022/lib/components/calendar/components/calendar-day/calendar-day-title.component.js.map +1 -0
  23. package/esm2022/lib/components/calendar/components/calendar-day/calendar-day.component.js +129 -0
  24. package/esm2022/lib/components/calendar/components/calendar-day/calendar-day.component.js.map +1 -0
  25. package/esm2022/lib/components/calendar/components/calendar-filter/calendar-filter.component.js +162 -0
  26. package/esm2022/lib/components/calendar/components/calendar-filter/calendar-filter.component.js.map +1 -0
  27. package/esm2022/lib/components/calendar/components/calendar-filter/calendar-filter.js +17 -0
  28. package/esm2022/lib/components/calendar/components/calendar-filter/calendar-filter.js.map +1 -0
  29. package/esm2022/lib/components/calendar/components/calendar-filter/contacts-filter.component.js +95 -0
  30. package/esm2022/lib/components/calendar/components/calendar-filter/contacts-filter.component.js.map +1 -0
  31. package/esm2022/lib/components/calendar/components/calendar-week/calendar-week-card.component.js +50 -0
  32. package/esm2022/lib/components/calendar/components/calendar-week/calendar-week-card.component.js.map +1 -0
  33. package/esm2022/lib/components/calendar/components/calendar-week/calendar-week-tab.component.js +18 -0
  34. package/esm2022/lib/components/calendar/components/calendar-week/calendar-week-tab.component.js.map +1 -0
  35. package/esm2022/lib/components/calendar/components/calendar-week/calendar-week-title.component.js +15 -0
  36. package/esm2022/lib/components/calendar/components/calendar-week/calendar-week-title.component.js.map +1 -0
  37. package/esm2022/lib/components/calendar/components/calendar-week/calendar-week.component.js +78 -0
  38. package/esm2022/lib/components/calendar/components/calendar-week/calendar-week.component.js.map +1 -0
  39. package/esm2022/lib/components/calendar/components/calendar-weekday/calendar-weekday.component.js +66 -0
  40. package/esm2022/lib/components/calendar/components/calendar-weekday/calendar-weekday.component.js.map +1 -0
  41. package/esm2022/lib/components/calendar/components/day-slot-item/day-slot-item.component.js +93 -0
  42. package/esm2022/lib/components/calendar/components/day-slot-item/day-slot-item.component.js.map +1 -0
  43. package/esm2022/lib/components/calendar/components/day-slot-item/slot-context-menu.component.js +324 -0
  44. package/esm2022/lib/components/calendar/components/day-slot-item/slot-context-menu.component.js.map +1 -0
  45. package/esm2022/lib/components/calendar/components/recurrings-tab/recurrings-tab.component.js +36 -0
  46. package/esm2022/lib/components/calendar/components/recurrings-tab/recurrings-tab.component.js.map +1 -0
  47. package/esm2022/lib/components/calendar/components/singles-tab/single-happenings-list.component.js +65 -0
  48. package/esm2022/lib/components/calendar/components/singles-tab/single-happenings-list.component.js.map +1 -0
  49. package/esm2022/lib/components/calendar/components/singles-tab/singles-tab.component.js +106 -0
  50. package/esm2022/lib/components/calendar/components/singles-tab/singles-tab.component.js.map +1 -0
  51. package/esm2022/lib/components/calendar/components/timing-badge/timing-badge.component.js +25 -0
  52. package/esm2022/lib/components/calendar/components/timing-badge/timing-badge.component.js.map +1 -0
  53. package/esm2022/lib/components/calendar/weekday.js +2 -0
  54. package/esm2022/lib/components/calendar/weekday.js.map +1 -0
  55. package/esm2022/lib/components/calendar-core.js +64 -0
  56. package/esm2022/lib/components/calendar-core.js.map +1 -0
  57. package/esm2022/lib/components/calendar-filter.service.js +28 -0
  58. package/esm2022/lib/components/calendar-filter.service.js.map +1 -0
  59. package/esm2022/lib/components/calendar-slots.js +30 -0
  60. package/esm2022/lib/components/calendar-slots.js.map +1 -0
  61. package/esm2022/lib/components/happening-base.component.js +188 -0
  62. package/esm2022/lib/components/happening-base.component.js.map +1 -0
  63. package/esm2022/lib/components/happening-card/happening-card.component.js +69 -0
  64. package/esm2022/lib/components/happening-card/happening-card.component.js.map +1 -0
  65. package/esm2022/lib/components/happening-component-base-params.js +37 -0
  66. package/esm2022/lib/components/happening-component-base-params.js.map +1 -0
  67. package/esm2022/lib/components/happening-form/happening-form.component.js +348 -0
  68. package/esm2022/lib/components/happening-form/happening-form.component.js.map +1 -0
  69. package/esm2022/lib/components/happening-form/happening-price-form/happening-price-modal.component.js +161 -0
  70. package/esm2022/lib/components/happening-form/happening-price-form/happening-price-modal.component.js.map +1 -0
  71. package/esm2022/lib/components/happening-form/happening-prices/happening-prices.component.js +142 -0
  72. package/esm2022/lib/components/happening-form/happening-prices/happening-prices.component.js.map +1 -0
  73. package/esm2022/lib/components/happening-participants/happening-participants.component.js +195 -0
  74. package/esm2022/lib/components/happening-participants/happening-participants.component.js.map +1 -0
  75. package/esm2022/lib/components/happening-slot-form/happening-slot-form.component.js +505 -0
  76. package/esm2022/lib/components/happening-slot-form/happening-slot-form.component.js.map +1 -0
  77. package/esm2022/lib/components/happening-slot-form/happening-slot-modal.component.js +140 -0
  78. package/esm2022/lib/components/happening-slot-form/happening-slot-modal.component.js.map +1 -0
  79. package/esm2022/lib/components/happening-slot-form/happening-slot-modal.service.js +47 -0
  80. package/esm2022/lib/components/happening-slot-form/happening-slot-modal.service.js.map +1 -0
  81. package/esm2022/lib/components/happening-slot-participants/happening-slot-participants.component.js +74 -0
  82. package/esm2022/lib/components/happening-slot-participants/happening-slot-participants.component.js.map +1 -0
  83. package/esm2022/lib/components/happening-slots/happening-slots.component.js +130 -0
  84. package/esm2022/lib/components/happening-slots/happening-slots.component.js.map +1 -0
  85. package/esm2022/lib/components/index.js +20 -0
  86. package/esm2022/lib/components/index.js.map +1 -0
  87. package/esm2022/lib/components/start-end-dates-range-form/start-end-dates-range-form.component.js +68 -0
  88. package/esm2022/lib/components/start-end-dates-range-form/start-end-dates-range-form.component.js.map +1 -0
  89. package/esm2022/lib/components/start-end-datetime-form/start-end-datetime-form.component.js +377 -0
  90. package/esm2022/lib/components/start-end-datetime-form/start-end-datetime-form.component.js.map +1 -0
  91. package/esm2022/lib/components/start-end-datetime-form/time-selector.component.js +92 -0
  92. package/esm2022/lib/components/start-end-datetime-form/time-selector.component.js.map +1 -0
  93. package/esm2022/lib/components/swipeable-base.component.js +112 -0
  94. package/esm2022/lib/components/swipeable-base.component.js.map +1 -0
  95. package/esm2022/lib/components/swipeable-ui.js +64 -0
  96. package/esm2022/lib/components/swipeable-ui.js.map +1 -0
  97. package/esm2022/lib/components/week.js +2 -0
  98. package/esm2022/lib/components/week.js.map +1 -0
  99. package/esm2022/lib/components/weekday-functions.js +13 -0
  100. package/esm2022/lib/components/weekday-functions.js.map +1 -0
  101. package/esm2022/lib/components/weekdays/weekdays-form-base.js +72 -0
  102. package/esm2022/lib/components/weekdays/weekdays-form-base.js.map +1 -0
  103. package/esm2022/lib/index.js +3 -0
  104. package/esm2022/lib/index.js.map +1 -0
  105. package/esm2022/lib/modals/happening-title-modal/happening-title-modal.component.js +87 -0
  106. package/esm2022/lib/modals/happening-title-modal/happening-title-modal.component.js.map +1 -0
  107. package/esm2022/lib/services/calendar-data-provider.js +271 -0
  108. package/esm2022/lib/services/calendar-data-provider.js.map +1 -0
  109. package/esm2022/lib/services/calendar-day.js +179 -0
  110. package/esm2022/lib/services/calendar-day.js.map +1 -0
  111. package/esm2022/lib/services/calendar-day.service.js +37 -0
  112. package/esm2022/lib/services/calendar-day.service.js.map +1 -0
  113. package/esm2022/lib/services/calendar-nav.service.js +36 -0
  114. package/esm2022/lib/services/calendar-nav.service.js.map +1 -0
  115. package/esm2022/lib/services/calendar-space.js +152 -0
  116. package/esm2022/lib/services/calendar-space.js.map +1 -0
  117. package/esm2022/lib/services/calendar-types.js +52 -0
  118. package/esm2022/lib/services/calendar-types.js.map +1 -0
  119. package/esm2022/lib/services/calendarium-services.module.js +16 -0
  120. package/esm2022/lib/services/calendarium-services.module.js.map +1 -0
  121. package/esm2022/lib/services/calendarium-space.service.js +16 -0
  122. package/esm2022/lib/services/calendarium-space.service.js.map +1 -0
  123. package/esm2022/lib/services/happening.service.js +225 -0
  124. package/esm2022/lib/services/happening.service.js.map +1 -0
  125. package/esm2022/lib/services/index.js +6 -0
  126. package/esm2022/lib/services/index.js.map +1 -0
  127. package/esm2022/sneat-extensions-schedulus-shared.js +5 -0
  128. package/esm2022/sneat-extensions-schedulus-shared.js.map +1 -0
  129. package/index.d.ts +1 -0
  130. package/lib/components/calendar/calendar-base.component.d.ts +23 -0
  131. package/lib/components/calendar/calendar-brief.component.d.ts +11 -0
  132. package/lib/components/calendar/calendar-component-types.d.ts +1 -0
  133. package/lib/components/calendar/calendar-state.service.d.ts +15 -0
  134. package/lib/components/calendar/calendar.component.d.ts +32 -0
  135. package/lib/components/calendar/components/calendar-add-buttons/calendar-add-buttons.component.d.ts +13 -0
  136. package/lib/components/calendar/components/calendar-day/calendar-day-base.component.d.ts +10 -0
  137. package/lib/components/calendar/components/calendar-day/calendar-day-card.component.d.ts +17 -0
  138. package/lib/components/calendar/components/calendar-day/calendar-day-tab.component.d.ts +19 -0
  139. package/lib/components/calendar/components/calendar-day/calendar-day-title.component.d.ts +10 -0
  140. package/lib/components/calendar/components/calendar-day/calendar-day.component.d.ts +30 -0
  141. package/lib/components/calendar/components/calendar-filter/calendar-filter.component.d.ts +39 -0
  142. package/lib/components/calendar/components/calendar-filter/calendar-filter.d.ts +10 -0
  143. package/lib/components/calendar/components/calendar-filter/contacts-filter.component.d.ts +20 -0
  144. package/lib/components/calendar/components/calendar-week/calendar-week-card.component.d.ts +15 -0
  145. package/lib/components/calendar/components/calendar-week/calendar-week-tab.component.d.ts +9 -0
  146. package/lib/components/calendar/components/calendar-week/calendar-week-title.component.d.ts +7 -0
  147. package/lib/components/calendar/components/calendar-week/calendar-week.component.d.ts +20 -0
  148. package/lib/components/calendar/components/calendar-weekday/calendar-weekday.component.d.ts +23 -0
  149. package/lib/components/calendar/components/day-slot-item/day-slot-item.component.d.ts +19 -0
  150. package/lib/components/calendar/components/day-slot-item/slot-context-menu.component.d.ts +40 -0
  151. package/lib/components/calendar/components/recurrings-tab/recurrings-tab.component.d.ts +15 -0
  152. package/lib/components/calendar/components/singles-tab/single-happenings-list.component.d.ts +22 -0
  153. package/lib/components/calendar/components/singles-tab/singles-tab.component.d.ts +29 -0
  154. package/lib/components/calendar/components/timing-badge/timing-badge.component.d.ts +17 -0
  155. package/lib/components/calendar/weekday.d.ts +7 -0
  156. package/lib/components/calendar-core.d.ts +10 -0
  157. package/lib/components/calendar-filter.service.d.ts +8 -0
  158. package/lib/components/calendar-slots.d.ts +5 -0
  159. package/lib/components/happening-base.component.d.ts +46 -0
  160. package/lib/components/happening-card/happening-card.component.d.ts +11 -0
  161. package/lib/components/happening-component-base-params.d.ts +16 -0
  162. package/lib/components/happening-form/happening-form.component.d.ts +52 -0
  163. package/lib/components/happening-form/happening-price-form/happening-price-modal.component.d.ts +29 -0
  164. package/lib/components/happening-form/happening-prices/happening-prices.component.d.ts +16 -0
  165. package/lib/components/happening-participants/happening-participants.component.d.ts +24 -0
  166. package/lib/components/happening-slot-form/happening-slot-form.component.d.ts +76 -0
  167. package/lib/components/happening-slot-form/happening-slot-modal.component.d.ts +26 -0
  168. package/lib/components/happening-slot-form/happening-slot-modal.service.d.ts +18 -0
  169. package/lib/components/happening-slot-participants/happening-slot-participants.component.d.ts +19 -0
  170. package/lib/components/happening-slots/happening-slots.component.d.ts +28 -0
  171. package/lib/components/index.d.ts +5 -0
  172. package/lib/components/start-end-dates-range-form/start-end-dates-range-form.component.d.ts +16 -0
  173. package/lib/components/start-end-datetime-form/start-end-datetime-form.component.d.ts +53 -0
  174. package/lib/components/start-end-datetime-form/time-selector.component.d.ts +15 -0
  175. package/lib/components/swipeable-base.component.d.ts +25 -0
  176. package/lib/components/swipeable-ui.d.ts +24 -0
  177. package/lib/components/week.d.ts +4 -0
  178. package/lib/components/weekday-functions.d.ts +3 -0
  179. package/lib/components/weekdays/weekdays-form-base.d.ts +31 -0
  180. package/lib/index.d.ts +2 -0
  181. package/lib/modals/happening-title-modal/happening-title-modal.component.d.ts +24 -0
  182. package/lib/services/calendar-data-provider.d.ts +33 -0
  183. package/lib/services/calendar-day.d.ts +45 -0
  184. package/lib/services/calendar-day.service.d.ts +18 -0
  185. package/lib/services/calendar-nav.service.d.ts +14 -0
  186. package/lib/services/calendar-space.d.ts +23 -0
  187. package/lib/services/calendar-types.d.ts +10 -0
  188. package/lib/services/calendarium-services.module.d.ts +6 -0
  189. package/lib/services/calendarium-space.service.d.ts +8 -0
  190. package/lib/services/happening.service.d.ts +99 -0
  191. package/lib/services/index.d.ts +5 -0
  192. package/package.json +26 -0
  193. package/sneat-extensions-schedulus-shared.d.ts +5 -0
  194. package/tsconfig.lib.prod.tsbuildinfo +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-day.js","sourceRoot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sneat/core';\nimport { IErrorLogger } from '@sneat/core';\nimport { ISpaceContext } from '@sneat/space-models';\nimport {\n BehaviorSubject,\n Observable,\n shareReplay,\n Subject,\n Subscription,\n takeUntil,\n} from 'rxjs';\nimport {\n getWd2,\n ISlotUIContext,\n RecurringSlots,\n sortSlotItems,\n ICalendarDayDbo,\n WeekdayCode2,\n wdCodeToWeekdayLongName,\n IHappeningContext,\n ITiming,\n} from '@sneat/mod-schedulus-core';\nimport { HappeningService } from './happening.service';\nimport { CalendarDayService } from './calendar-day.service';\nimport { runInInjectionContext, Injector, EffectRef } from '@angular/core';\n\nexport interface ICalendarDayInput {\n readonly spaceID: string; // Should we use observable on ISpaceContext as we might want to use space settings?\n readonly $recurringSlots: Signal<RecurringSlots | undefined>;\n\n // Probably can be made obsolete - to be replaced with `$recurringSlots`,\n // though it's not clear if it's possible.\n readonly recurringSlots$: Observable<RecurringSlots>;\n}\n\nexport class CalendarDay {\n private readonly destroyed$ = new Subject<void>();\n\n // private recurringSlots?: RecurringSlots;\n\n private $recurringSlots = computed(() => {\n const inputs = this.$inputs();\n const recurringSlots = inputs\n .map((input) => input.$recurringSlots())\n .filter((v) => !!v);\n const result = recurringSlots.length ? recurringSlots[0] : undefined; // TODO: add support for multiple inputs\n return result;\n });\n\n private singles?: ISlotUIContext[];\n\n private _spaces: readonly ISpaceContext[] = [];\n\n public get spaces(): readonly ISpaceContext[] {\n return this._spaces;\n }\n\n public readonly dateID: string;\n public readonly wd: WeekdayCode2;\n public readonly wdLongTitle: string;\n\n private readonly _isLoading = signal(true);\n\n public readonly $isLoading = this._isLoading.asReadonly();\n\n // private readonly $slots = signal<ISlotUIContext[] | undefined>(undefined);\n\n private readonly _slots = new BehaviorSubject<ISlotUIContext[] | undefined>(\n undefined,\n );\n\n public readonly slots$ = this._slots.asObservable().pipe(\n shareReplay(1),\n takeUntil(this.destroyed$),\n // tap((slots) => console.log(`SpaceDay[${this.dateID}].slots$ =>`, slots)),\n // map((slots) => slots?.sort(sortSlotItems)),\n );\n\n private calendarDayDbo?: ICalendarDayDbo | null;\n\n public get slots(): ISlotUIContext[] | undefined {\n return this._slots.value;\n }\n\n private readonly subscriptions: Subscription[] = [];\n\n private effectRef?: EffectRef;\n\n constructor(\n public readonly date: Date,\n injector: Injector,\n private readonly $inputs: Signal<readonly ICalendarDayInput[]>,\n private readonly errorLogger: IErrorLogger,\n // TODO: document why we need both HappeningService & CalendarDayService\n private readonly happeningService: HappeningService,\n private readonly calendarDayService: CalendarDayService,\n ) {\n if (!date) {\n throw new Error('missing required parameter: date');\n }\n this.dateID = dateToIso(date);\n if (this.dateID === '1970-01-01') {\n throw new Error('an attempt to set an empty date 1970-01-01');\n }\n this.wd = getWd2(date);\n this.wdLongTitle = wdCodeToWeekdayLongName(this.wd);\n\n runInInjectionContext(injector, () => {\n this.effectRef = effect(() => {\n const inputs = $inputs();\n inputs.forEach((input) => {\n this.subscriptions.forEach((s) => s.unsubscribe());\n this.subscriptions.length = 0;\n this.processSpaceID(input.spaceID);\n this.subscribeForRecurrings(input.recurringSlots$);\n });\n });\n });\n }\n\n public destroy(): void {\n this.effectRef?.destroy();\n this.destroyed$.next();\n this.destroyed$.complete();\n }\n\n private readonly processSpaceID = (spaceID: string | undefined) => {\n this.singles = undefined;\n if (spaceID) {\n this.subscribeForSingles(spaceID);\n this.subscribeForCalendarDay(spaceID);\n }\n };\n\n private readonly subscribeForCalendarDay = (spaceID: string): void => {\n this.subscriptions.push(\n this.calendarDayService\n .watchSpaceDay({ id: spaceID }, this.dateID)\n .pipe(takeUntil(this.destroyed$))\n .subscribe({\n next: (calendarDay) => {\n const changed = this.calendarDayDbo != calendarDay.dbo;\n if (changed) {\n this.calendarDayDbo = calendarDay.dbo;\n this.joinRecurringsWithSinglesAndEmit();\n }\n },\n error: this.errorLogger.logErrorHandler(\n 'Failed to load calendarDay record',\n { show: false, feedback: false },\n ),\n }),\n );\n };\n\n private readonly subscribeForSingles = (spaceID: string): void => {\n if (!this.dateID) {\n console.error('Tried to subscribe for single happenings without dateID');\n return;\n }\n try {\n this.subscriptions.push(\n this.happeningService\n .watchSinglesOnSpecificDay({ id: spaceID }, this.dateID)\n .pipe(takeUntil(this.destroyed$))\n .subscribe({\n next: this.processSingles,\n error: this.errorLogger.logErrorHandler(\n `Failed to get single happenings for a given day: spaceID=${spaceID}, date=${this.dateID}`,\n ),\n }),\n );\n } catch (e) {\n this.errorLogger.logError(\n e,\n 'Failed to subscribe for team day single happenings',\n );\n }\n };\n\n private readonly processSingles = (\n singleHappenings: IHappeningContext[],\n ): void => {\n try {\n this.singles = [];\n\n singleHappenings.forEach((happening) => {\n const slotIDs: readonly string[] = Object.keys(\n happening.dbo?.slots || {},\n );\n const slot = slotIDs?.length && happening.dbo?.slots?.[slotIDs[0]];\n if (!slot) {\n return;\n }\n const timing: ITiming = {\n start: slot.start,\n end: slot.end,\n durationMinutes: slot.durationMinutes,\n };\n const slotItem: ISlotUIContext = {\n slot: { ...slot, id: slotIDs[0] },\n title: happening.brief?.title || happening?.dbo?.title || 'NO TITLE',\n timing,\n repeats: 'once',\n happening,\n };\n this.singles?.push(slotItem);\n });\n // console.log('SpaceDay[${this.isoID}].processSingles()`, changes, this.singles);\n this.joinRecurringsWithSinglesAndEmit();\n } catch (e) {\n this.errorLogger.logError(e, 'failed to process single happenings');\n }\n };\n\n private subscribeForRecurrings(\n recurrings$: Observable<RecurringSlots>,\n ): void {\n this.subscriptions.push(\n recurrings$.pipe(takeUntil(this.destroyed$)).subscribe({\n next: this.processRecurrings,\n }),\n );\n }\n\n private readonly processRecurrings = (): void => {\n // this.recurringSlots = slots;\n this.joinRecurringsWithSinglesAndEmit();\n };\n\n private joinRecurringsWithSinglesAndEmit(): void {\n let slots: ISlotUIContext[] = [];\n\n const recurringSlots = this.$recurringSlots();\n const weekdaySlots = recurringSlots?.byWeekday[this.wd]?.map((wdSlot) => {\n // console.log(\n // \t'joinRecurringsWithSinglesAndEmit, wdSlot',\n // \tthis.wd,\n // \twdSlot,\n // \tthis.scheduleDayDto,\n // );\n if (this.calendarDayDbo) {\n const adjustment =\n this.calendarDayDbo?.happeningAdjustments?.[wdSlot.happening.id]\n ?.slots?.[wdSlot.slot.id];\n if (adjustment) {\n return Object.assign(wdSlot, { adjustment });\n }\n }\n return wdSlot;\n });\n\n if (weekdaySlots?.length) {\n slots.push(...weekdaySlots);\n }\n if (this.singles) {\n slots.push(...this.singles);\n }\n\n // console.log(\n // \t'SpaceDay[id=${this.isoID}, wd=${this.wd}].joinRecurringsWithSinglesAndEmit()`,\n // \t`${weekdaySlots?.length || 0} recurrings:`, weekdaySlots,\n // \t`${this.singles?.length || 0} singles:`, weekdaySlots,\n // \t`=> ${slots.length} slots:`, slots);\n\n slots = slots.toSorted(sortSlotItems);\n this._slots.next(slots);\n // this.$slots.set(slots);\n\n this._isLoading.set(false);\n }\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import { Injectable, NgModule, inject, Injector } from '@angular/core';
2
+ import { Firestore as AngularFirestore } from '@angular/fire/firestore';
3
+ import { SneatApiService } from '@sneat/api';
4
+ import { ErrorLogger } from '@sneat/core';
5
+ import { ModuleSpaceItemService } from '@sneat/space-services';
6
+ import { tap } from 'rxjs';
7
+ import * as i0 from "@angular/core";
8
+ export class CalendarDayService {
9
+ constructor() {
10
+ this.errorLogger = inject(ErrorLogger);
11
+ this.afs = inject(AngularFirestore);
12
+ const afs = this.afs;
13
+ const sneatApiService = inject(SneatApiService);
14
+ const injector = inject(Injector);
15
+ this.spaceItemService = new ModuleSpaceItemService(injector, 'calendarium', 'days', afs, sneatApiService);
16
+ }
17
+ watchSpaceDay(space, dateID) {
18
+ return this.spaceItemService
19
+ .watchSpaceItemByIdWithSpaceRef(space, dateID)
20
+ .pipe(tap((scheduleDay) => console.log('ScheduleDayService.watchTeamDay() => scheduleDay', scheduleDay, scheduleDay.dbo)));
21
+ }
22
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendarDayService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
23
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendarDayService }); }
24
+ }
25
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendarDayService, decorators: [{
26
+ type: Injectable
27
+ }], ctorParameters: () => [] });
28
+ export class CalendarDayServiceModule {
29
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendarDayServiceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
30
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.0", ngImport: i0, type: CalendarDayServiceModule }); }
31
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendarDayServiceModule, providers: [CalendarDayService] }); }
32
+ } // TODO: Should we simply pass to `provide: []`?
33
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendarDayServiceModule, decorators: [{
34
+ type: NgModule,
35
+ args: [{ providers: [CalendarDayService] }]
36
+ }] });
37
+ //# sourceMappingURL=calendar-day.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-day.service.js","sourceRoot":"","sources":["../../../../../../../../libs/extensions/schedulus/shared/src/lib/services/calendar-day.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;;AAG3B,MAAM,OAAO,kBAAkB;IAS7B;QARiB,gBAAW,GAAG,MAAM,CAAe,WAAW,CAAC,CAAC;QACxD,QAAG,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAQtC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACrB,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClC,IAAI,CAAC,gBAAgB,GAAG,IAAI,sBAAsB,CAChD,QAAQ,EACR,aAAa,EACb,MAAM,EACN,GAAG,EACH,eAAe,CAChB,CAAC;IACJ,CAAC;IAEM,aAAa,CAAC,KAAoB,EAAE,MAAc;QACvD,OAAO,IAAI,CAAC,gBAAgB;aACzB,8BAA8B,CAAC,KAAK,EAAE,MAAM,CAAC;aAC7C,IAAI,CACH,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAClB,OAAO,CAAC,GAAG,CACT,kDAAkD,EAClD,WAAW,EACX,WAAW,CAAC,GAAG,CAChB,CACF,CACF,CAAC;IACN,CAAC;8GAlCU,kBAAkB;kHAAlB,kBAAkB;;2FAAlB,kBAAkB;kBAD9B,UAAU;;AAuCX,MAAM,OAAO,wBAAwB;8GAAxB,wBAAwB;+GAAxB,wBAAwB;+GAAxB,wBAAwB,aADd,CAAC,kBAAkB,CAAC;EACF,gDAAgD;2FAA5E,wBAAwB;kBADpC,QAAQ;mBAAC,EAAE,SAAS,EAAE,CAAC,kBAAkB,CAAC,EAAE","sourcesContent":["import { Injectable, NgModule, inject, Injector } from '@angular/core';\nimport { Firestore as AngularFirestore } from '@angular/fire/firestore';\nimport { SneatApiService } from '@sneat/api';\nimport { ICalendarDayBrief, ICalendarDayDbo } from '@sneat/mod-schedulus-core';\nimport { ErrorLogger, IErrorLogger } from '@sneat/core';\nimport { ISpaceContext } from '@sneat/space-models';\nimport { ModuleSpaceItemService } from '@sneat/space-services';\nimport { tap } from 'rxjs';\n\n@Injectable()\nexport class CalendarDayService {\n private readonly errorLogger = inject<IErrorLogger>(ErrorLogger);\n readonly afs = inject(AngularFirestore);\n\n private readonly spaceItemService: ModuleSpaceItemService<\n ICalendarDayBrief,\n ICalendarDayDbo\n >;\n\n constructor() {\n const afs = this.afs;\n const sneatApiService = inject(SneatApiService);\n const injector = inject(Injector);\n this.spaceItemService = new ModuleSpaceItemService(\n injector,\n 'calendarium',\n 'days',\n afs,\n sneatApiService,\n );\n }\n\n public watchSpaceDay(space: ISpaceContext, dateID: string) {\n return this.spaceItemService\n .watchSpaceItemByIdWithSpaceRef(space, dateID)\n .pipe(\n tap((scheduleDay) =>\n console.log(\n 'ScheduleDayService.watchTeamDay() => scheduleDay',\n scheduleDay,\n scheduleDay.dbo,\n ),\n ),\n );\n }\n}\n\n@NgModule({ providers: [CalendarDayService] })\nexport class CalendarDayServiceModule {} // TODO: Should we simply pass to `provide: []`?\n"]}
@@ -0,0 +1,36 @@
1
+ import { inject, Injectable, NgModule } from '@angular/core';
2
+ import { ErrorLogger } from '@sneat/core';
3
+ import { SpaceNavService } from '@sneat/space-services';
4
+ import * as i0 from "@angular/core";
5
+ export class CalendarNavService {
6
+ constructor() {
7
+ this.errorLogger = inject(ErrorLogger);
8
+ this.spaceNavService = inject(SpaceNavService);
9
+ }
10
+ navigateToHappeningPage(args) {
11
+ const happening = args.slot.happening;
12
+ const page = `happening/${happening.id}`;
13
+ this.spaceNavService
14
+ .navigateForwardToSpacePage(happening.space, page, {
15
+ state: { happening },
16
+ })
17
+ .catch(this.errorLogger.logErrorHandler('failed to navigate to recurring happening page'));
18
+ }
19
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendarNavService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
20
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendarNavService }); }
21
+ }
22
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendarNavService, decorators: [{
23
+ type: Injectable
24
+ }] });
25
+ export class CalendarNavServicesModule {
26
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendarNavServicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
27
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.0", ngImport: i0, type: CalendarNavServicesModule }); }
28
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendarNavServicesModule, providers: [CalendarNavService] }); }
29
+ }
30
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendarNavServicesModule, decorators: [{
31
+ type: NgModule,
32
+ args: [{
33
+ providers: [CalendarNavService],
34
+ }]
35
+ }] });
36
+ //# sourceMappingURL=calendar-nav.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-nav.service.js","sourceRoot":"","sources":["../../../../../../../../libs/extensions/schedulus/shared/src/lib/services/calendar-nav.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;;AAGxD,MAAM,OAAO,kBAAkB;IAD/B;QAEmB,gBAAW,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QAClC,oBAAe,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;KAe5D;IAbQ,uBAAuB,CAAC,IAAkB;QAC/C,MAAM,SAAS,GAAsB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;QACzD,MAAM,IAAI,GAAG,aAAa,SAAS,CAAC,EAAE,EAAE,CAAC;QACzC,IAAI,CAAC,eAAe;aACjB,0BAA0B,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE;YACjD,KAAK,EAAE,EAAE,SAAS,EAAE;SACrB,CAAC;aACD,KAAK,CACJ,IAAI,CAAC,WAAW,CAAC,eAAe,CAC9B,gDAAgD,CACjD,CACF,CAAC;IACN,CAAC;8GAhBU,kBAAkB;kHAAlB,kBAAkB;;2FAAlB,kBAAkB;kBAD9B,UAAU;;AAuBX,MAAM,OAAO,yBAAyB;8GAAzB,yBAAyB;+GAAzB,yBAAyB;+GAAzB,yBAAyB,aAFzB,CAAC,kBAAkB,CAAC;;2FAEpB,yBAAyB;kBAHrC,QAAQ;mBAAC;oBACR,SAAS,EAAE,CAAC,kBAAkB,CAAC;iBAChC","sourcesContent":["import { inject, Injectable, NgModule } from '@angular/core';\nimport { ErrorLogger } from '@sneat/core';\nimport { ISlotUIEvent } from '@sneat/mod-schedulus-core';\nimport { IHappeningContext } from '@sneat/mod-schedulus-core';\nimport { SpaceNavService } from '@sneat/space-services';\n\n@Injectable()\nexport class CalendarNavService {\n private readonly errorLogger = inject(ErrorLogger);\n private readonly spaceNavService = inject(SpaceNavService);\n\n public navigateToHappeningPage(args: ISlotUIEvent): void {\n const happening: IHappeningContext = args.slot.happening;\n const page = `happening/${happening.id}`;\n this.spaceNavService\n .navigateForwardToSpacePage(happening.space, page, {\n state: { happening },\n })\n .catch(\n this.errorLogger.logErrorHandler(\n 'failed to navigate to recurring happening page',\n ),\n );\n }\n}\n\n@NgModule({\n providers: [CalendarNavService],\n})\nexport class CalendarNavServicesModule {}\n"]}
@@ -0,0 +1,152 @@
1
+ import { signal } from '@angular/core';
2
+ import { hasRelated } from '@sneat/dto';
3
+ import { zipMapBriefsWithIDs, } from '@sneat/space-models';
4
+ import { BehaviorSubject, filter, map, shareReplay, skip, Subject, takeUntil, } from 'rxjs';
5
+ import { tap } from 'rxjs/operators';
6
+ import { emptyRecurringsByWeekday, groupRecurringSlotsByWeekday, } from './calendar-types';
7
+ export class CalendarSpace {
8
+ destroy() {
9
+ this.destroyed.next();
10
+ this.destroyed.complete();
11
+ }
12
+ constructor(spaceID, calendariumSpaceService,
13
+ // private readonly recurringsSpaceItemService: ModuleSpaceItemService<
14
+ // IHappeningBrief,
15
+ // IHappeningDbo
16
+ // >,
17
+ contactID) {
18
+ this.spaceID = spaceID;
19
+ this.calendariumSpaceService = calendariumSpaceService;
20
+ this.contactID = contactID;
21
+ this.destroyed = new Subject();
22
+ this.$recurrings = signal(undefined, ...(ngDevMode ? [{ debugName: "$recurrings" }] : []));
23
+ this.$recurringByWd = signal(emptyRecurringsByWeekday(), ...(ngDevMode ? [{ debugName: "$recurringByWd" }] : []));
24
+ this.$calendariumSpace = signal(undefined, ...(ngDevMode ? [{ debugName: "$calendariumSpace" }] : []));
25
+ this.$recurringSlots = signal(undefined, ...(ngDevMode ? [{ debugName: "$recurringSlots" }] : []));
26
+ this.calendariumSpace$ = new BehaviorSubject(undefined);
27
+ // TODO: consider switching to a computed $recurringSlots signal
28
+ this.recurringSlots$ = this.calendariumSpace$.pipe(skip(1), // We are not interested in processing the first 'undefined' value of BehaviorSubject
29
+ filter((schedulusSpace) => !!schedulusSpace), // Not sure if we need this.
30
+ // TODO: Instead of providing all slots we can provide observables of slots for a specific day
31
+ // That would minimize number of handlers to be called on watching components
32
+ map((schedulusSpace) => groupRecurringSlotsByWeekday(schedulusSpace)), tap((recurringSlots) => {
33
+ this.$recurringSlots.set(recurringSlots);
34
+ }), shareReplay(1), takeUntil(this.destroyed));
35
+ this.calendariumSpaceService.watchSpaceModuleRecord(spaceID).subscribe({
36
+ next: (calendariumSpace) => {
37
+ const newRH = calendariumSpace.dbo?.recurringHappenings || {};
38
+ this.$recurrings.update((r) => Object.keys(newRH).length === 0 &&
39
+ Object.keys(r?.recurringHappenings || {}).length === 0
40
+ ? r || { spaceID, recurringHappenings: {} }
41
+ : {
42
+ spaceID,
43
+ recurringHappenings: calendariumSpace.dbo?.recurringHappenings || {},
44
+ });
45
+ if (calendariumSpace.dbo) {
46
+ this.setCalendariumSpace({
47
+ ...calendariumSpace,
48
+ space: { id: spaceID },
49
+ });
50
+ }
51
+ },
52
+ });
53
+ }
54
+ setCalendariumSpace(calendariumSpace) {
55
+ this.$calendariumSpace.set(calendariumSpace);
56
+ this.calendariumSpace$.next(calendariumSpace);
57
+ this.processRecurringBriefs();
58
+ }
59
+ // private watchRecurringsBySpaceID(
60
+ // spaceID: string,
61
+ // ): Observable<INavContext<IHappeningBrief, IHappeningDbo>[]> {
62
+ // console.log('SpaceDaysProvider.loadRegulars()');
63
+ // const $recurrings = this.recurringsSpaceItemService
64
+ // .watchModuleSpaceItemsWithSpaceRef({ id: spaceID })
65
+ // // const $regulars = this.regularService.watchByCommuneId(this.communeId)
66
+ // .pipe(
67
+ // takeUntil(this.destroyed),
68
+ // tap((recurrings) => {
69
+ // recurrings.forEach((recurring) => this.processRecurring(recurring));
70
+ // }),
71
+ // );
72
+ // return $recurrings;
73
+ // }
74
+ processRecurringBriefs() {
75
+ if (!this.calendariumSpace$.value?.dbo?.recurringHappenings) {
76
+ return;
77
+ }
78
+ const spaceID = this.spaceID;
79
+ zipMapBriefsWithIDs(this.calendariumSpace$.value?.dbo?.recurringHappenings).forEach((rh) => {
80
+ this.processRecurring({
81
+ id: rh.id,
82
+ brief: rh.brief,
83
+ space: { id: spaceID },
84
+ });
85
+ });
86
+ }
87
+ processRecurring(recurring) {
88
+ if (this.contactID &&
89
+ hasRelated(recurring.dbo?.related || recurring?.brief?.related, {
90
+ module: 'contactus',
91
+ collection: 'contacts',
92
+ spaceID: this.spaceID,
93
+ itemID: this.contactID,
94
+ })) {
95
+ return;
96
+ }
97
+ const recurringByWd = emptyRecurringsByWeekday();
98
+ const { brief } = recurring;
99
+ if (!brief) {
100
+ throw new Error('recurring context has no brief');
101
+ }
102
+ if (!brief.title) {
103
+ throw new Error(`!brief.title`);
104
+ }
105
+ if (brief.slots) {
106
+ Object.entries(brief.slots).forEach(([slotID, slot]) => {
107
+ slot.weekdays?.forEach((wd) => {
108
+ if (slot.repeats === 'weekly' && !wd) {
109
+ throw new Error(`slot.repeats === 'weekly' && !wd=${wd}`);
110
+ }
111
+ const slotItem = {
112
+ slot: { ...slot, id: slotID },
113
+ wd: wd,
114
+ happening: recurring,
115
+ title: brief.title,
116
+ repeats: slot.repeats,
117
+ timing: { start: slot.start, end: slot.end },
118
+ location: slot.location,
119
+ levels: brief.levels,
120
+ // participants: dto.participants,
121
+ };
122
+ const wdRecurrings = recurringByWd[wd];
123
+ if (wdRecurrings) {
124
+ wdRecurrings.push(slotItem);
125
+ }
126
+ });
127
+ });
128
+ }
129
+ this.$recurringByWd.set(recurringByWd);
130
+ }
131
+ addRecurringsToSlotsGroup(weekday) {
132
+ const recurrings = this.$recurringByWd()[weekday.wd];
133
+ if (!recurrings) {
134
+ return;
135
+ }
136
+ const wdRecurrings = weekday.slots &&
137
+ weekday.slots.filter((r) => r.happening.brief?.type === 'recurring');
138
+ if (wdRecurrings && wdRecurrings.length === recurrings.length) {
139
+ return;
140
+ }
141
+ if (recurrings.length) {
142
+ // weekday.slots = weekday.slots ? [
143
+ // ...recurrings,
144
+ // ...weekday.slots.filter(r => r.type !== 'recurring'),
145
+ // ] : [...recurrings];
146
+ }
147
+ else {
148
+ // weekday.slots = weekday.slots ? weekday.slots.filter(r => !r.recurring) : [];
149
+ }
150
+ }
151
+ }
152
+ //# sourceMappingURL=calendar-space.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-space.js","sourceRoot":"","sources":["../../../../../../../../libs/extensions/schedulus/shared/src/lib/services/calendar-space.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAUxC,OAAO,EAGL,mBAA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AAyB,CAAC,OAAoB;QACpD,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACrD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QACD,MAAM,YAAY,GAChB,OAAO,CAAC,KAAK;YACb,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC;QACvE,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM,EAAE,CAAC;YAC9D,OAAO;QACT,CAAC;QACD,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACtB,oCAAoC;YACpC,kBAAkB;YAClB,yDAAyD;YACzD,uBAAuB;QACzB,CAAC;aAAM,CAAC;YACN,gFAAgF;QAClF,CAAC;IACH,CAAC;CACF","sourcesContent":["import { signal } from '@angular/core';\nimport { hasRelated } from '@sneat/dto';\nimport { CalendariumSpaceService } from '../services/calendarium-space.service';\nimport {\n ICalendariumSpaceDbo,\n IHappeningBrief,\n IHappeningDbo,\n ICalendariumSpaceContext,\n ISlotUIContext,\n RecurringSlots,\n} from '@sneat/mod-schedulus-core';\nimport {\n ISpaceItemNavContext,\n ISpaceItemWithOptionalDbo,\n zipMapBriefsWithIDs,\n} from '@sneat/space-models';\nimport {\n BehaviorSubject,\n filter,\n map,\n Observable,\n shareReplay,\n skip,\n Subject,\n takeUntil,\n} from 'rxjs';\nimport { tap } from 'rxjs/operators';\nimport { CalendarDay } from './calendar-day';\nimport {\n emptyRecurringsByWeekday,\n groupRecurringSlotsByWeekday,\n ISpaceRecurrings,\n RecurringsByWeekday,\n} from './calendar-types';\n\nexport class CalendarSpace {\n private readonly destroyed = new Subject<void>();\n\n public destroy(): void {\n this.destroyed.next();\n this.destroyed.complete();\n }\n\n public readonly $recurrings = signal<ISpaceRecurrings | undefined>(undefined);\n\n public readonly $recurringByWd = signal<Readonly<RecurringsByWeekday>>(\n emptyRecurringsByWeekday(),\n );\n\n private readonly $calendariumSpace = signal<\n ICalendariumSpaceContext | undefined\n >(undefined);\n\n public readonly $recurringSlots = signal<RecurringSlots | undefined>(\n undefined,\n );\n\n private readonly calendariumSpace$ = new BehaviorSubject<\n ICalendariumSpaceContext | undefined\n >(undefined);\n\n // TODO: consider switching to a computed $recurringSlots signal\n public readonly recurringSlots$: Observable<RecurringSlots> =\n this.calendariumSpace$.pipe(\n skip(1), // We are not interested in processing the first 'undefined' value of BehaviorSubject\n filter((schedulusSpace) => !!schedulusSpace), // Not sure if we need this.\n // TODO: Instead of providing all slots we can provide observables of slots for a specific day\n // That would minimize number of handlers to be called on watching components\n map((schedulusSpace) => groupRecurringSlotsByWeekday(schedulusSpace)),\n tap((recurringSlots) => {\n this.$recurringSlots.set(recurringSlots);\n }),\n shareReplay(1),\n takeUntil(this.destroyed),\n );\n\n constructor(\n public readonly spaceID: string,\n private readonly calendariumSpaceService: CalendariumSpaceService,\n // private readonly recurringsSpaceItemService: ModuleSpaceItemService<\n // \tIHappeningBrief,\n // \tIHappeningDbo\n // >,\n private readonly contactID?: string,\n ) {\n this.calendariumSpaceService.watchSpaceModuleRecord(spaceID).subscribe({\n next: (calendariumSpace) => {\n const newRH = calendariumSpace.dbo?.recurringHappenings || {};\n this.$recurrings.update((r) =>\n Object.keys(newRH).length === 0 &&\n Object.keys(r?.recurringHappenings || {}).length === 0\n ? r || { spaceID, recurringHappenings: {} }\n : {\n spaceID,\n recurringHappenings:\n calendariumSpace.dbo?.recurringHappenings || {},\n },\n );\n if (calendariumSpace.dbo) {\n this.setCalendariumSpace({\n ...calendariumSpace,\n space: { id: spaceID },\n });\n }\n },\n });\n }\n\n public setCalendariumSpace(\n calendariumSpace: ISpaceItemWithOptionalDbo<ICalendariumSpaceDbo>,\n ): void {\n this.$calendariumSpace.set(calendariumSpace);\n this.calendariumSpace$.next(calendariumSpace);\n this.processRecurringBriefs();\n }\n\n // private watchRecurringsBySpaceID(\n // \tspaceID: string,\n // ): Observable<INavContext<IHappeningBrief, IHappeningDbo>[]> {\n // \tconsole.log('SpaceDaysProvider.loadRegulars()');\n // \tconst $recurrings = this.recurringsSpaceItemService\n // \t\t.watchModuleSpaceItemsWithSpaceRef({ id: spaceID })\n // \t\t// const $regulars = this.regularService.watchByCommuneId(this.communeId)\n // \t\t.pipe(\n // \t\t\ttakeUntil(this.destroyed),\n // \t\t\ttap((recurrings) => {\n // \t\t\t\trecurrings.forEach((recurring) => this.processRecurring(recurring));\n // \t\t\t}),\n // \t\t);\n // \treturn $recurrings;\n // }\n\n private processRecurringBriefs(): void {\n if (!this.calendariumSpace$.value?.dbo?.recurringHappenings) {\n return;\n }\n const spaceID = this.spaceID;\n zipMapBriefsWithIDs(\n this.calendariumSpace$.value?.dbo?.recurringHappenings,\n ).forEach((rh) => {\n this.processRecurring({\n id: rh.id,\n brief: rh.brief,\n space: { id: spaceID },\n });\n });\n }\n\n private processRecurring(\n recurring: ISpaceItemNavContext<IHappeningBrief, IHappeningDbo>,\n ): void {\n if (\n this.contactID &&\n hasRelated(recurring.dbo?.related || recurring?.brief?.related, {\n module: 'contactus',\n collection: 'contacts',\n spaceID: this.spaceID,\n itemID: this.contactID,\n })\n ) {\n return;\n }\n const recurringByWd = emptyRecurringsByWeekday();\n const { brief } = recurring;\n if (!brief) {\n throw new Error('recurring context has no brief');\n }\n if (!brief.title) {\n throw new Error(`!brief.title`);\n }\n if (brief.slots) {\n Object.entries(brief.slots).forEach(([slotID, slot]) => {\n slot.weekdays?.forEach((wd) => {\n if (slot.repeats === 'weekly' && !wd) {\n throw new Error(`slot.repeats === 'weekly' && !wd=${wd}`);\n }\n const slotItem: ISlotUIContext = {\n slot: { ...slot, id: slotID },\n wd: wd,\n happening: recurring,\n title: brief.title,\n repeats: slot.repeats,\n timing: { start: slot.start, end: slot.end },\n location: slot.location,\n levels: brief.levels,\n // participants: dto.participants,\n };\n const wdRecurrings = recurringByWd[wd];\n if (wdRecurrings) {\n wdRecurrings.push(slotItem);\n }\n });\n });\n }\n this.$recurringByWd.set(recurringByWd);\n }\n\n private addRecurringsToSlotsGroup(weekday: CalendarDay): void {\n const recurrings = this.$recurringByWd()[weekday.wd];\n if (!recurrings) {\n return;\n }\n const wdRecurrings =\n weekday.slots &&\n weekday.slots.filter((r) => r.happening.brief?.type === 'recurring');\n if (wdRecurrings && wdRecurrings.length === recurrings.length) {\n return;\n }\n if (recurrings.length) {\n // weekday.slots = weekday.slots ? [\n // \t...recurrings,\n // \t...weekday.slots.filter(r => r.type !== 'recurring'),\n // ] : [...recurrings];\n } else {\n // weekday.slots = weekday.slots ? weekday.slots.filter(r => !r.recurring) : [];\n }\n }\n}\n"]}
@@ -0,0 +1,52 @@
1
+ import { zipMapBriefsWithIDs } from '@sneat/space-models';
2
+ export const emptyRecurringsByWeekday = () => ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'].reduce((o, wd) => {
3
+ o[wd] = [];
4
+ return o;
5
+ }, {});
6
+ export const groupRecurringSlotsByWeekday = (calendariumSpace) => {
7
+ const slots = {
8
+ byWeekday: {},
9
+ };
10
+ if (!calendariumSpace?.dbo?.recurringHappenings) {
11
+ // console.log(logPrefix + ', no slots for team:', calendariumSpace);
12
+ return slots;
13
+ }
14
+ zipMapBriefsWithIDs(calendariumSpace.dbo.recurringHappenings).forEach((rh) => {
15
+ Object.entries(rh.brief.slots || {})?.forEach(([slotID, rs]) => {
16
+ const happening = {
17
+ id: rh.id,
18
+ brief: rh.brief,
19
+ space: calendariumSpace.space,
20
+ };
21
+ const slotItems = slotUIContextsFromRecurringSlot(happening, slotID, rs);
22
+ slotItems.forEach((si) => {
23
+ if (si.wd) {
24
+ let weekday = slots.byWeekday[si.wd];
25
+ if (!weekday) {
26
+ weekday = [];
27
+ slots.byWeekday[si.wd] = weekday;
28
+ }
29
+ weekday.push(si);
30
+ }
31
+ });
32
+ });
33
+ });
34
+ // console.log(logPrefix + ', slots:', slots);
35
+ return slots;
36
+ };
37
+ const slotUIContextsFromRecurringSlot = (r, slotID, rs) => {
38
+ const si = {
39
+ // date: rs.start.date,
40
+ slot: { ...rs, id: slotID },
41
+ happening: r,
42
+ title: r.brief?.title || r.id,
43
+ levels: r.brief?.levels,
44
+ repeats: rs.repeats,
45
+ timing: { start: rs.start, end: rs.end },
46
+ };
47
+ if (rs.weekdays?.length) {
48
+ return rs.weekdays.map((wd) => ({ ...si, wd }));
49
+ }
50
+ return [si];
51
+ };
52
+ //# sourceMappingURL=calendar-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar-types.js","sourceRoot":"","sources":["../../../../../../../../libs/extensions/schedulus/shared/src/lib/services/calendar-types.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAW1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAwB,EAAE,CAC/D,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAoB,CAAC,MAAM,CACnE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE;IACR,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;IACX,OAAO,CAAC,CAAC;AACX,CAAC,EACD,EAAyB,CAC1B,CAAC;AAEJ,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,gBAA2C,EAC3B,EAAE;IAClB,MAAM,KAAK,GAAmB;QAC5B,SAAS,EAAE,EAAE;KACd,CAAC;IACF,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE,mBAAmB,EAAE,CAAC;QAChD,qEAAqE;QACrE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,mBAAmB,CAAC,gBAAgB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,OAAO,CACnE,CAAC,EAAE,EAAE,EAAE;QACL,MAAM,CAAC,OAAO,CAAC,EAAE,CA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AAK,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE;KACzC,CAAC;IACF,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,CAAC,EAAE,CAAC,CAAC;AACd,CAAC,CAAC","sourcesContent":["import {\n IHappeningContext,\n IHappeningSlot,\n ICalendariumSpaceContext,\n ISlotUIContext,\n RecurringSlots,\n WeekdayCode2,\n IHappeningBrief,\n} from '@sneat/mod-schedulus-core';\nimport { zipMapBriefsWithIDs } from '@sneat/space-models';\n\nexport type ISpaceRecurrings = {\n readonly spaceID: string;\n readonly recurringHappenings: Readonly<Record<string, IHappeningBrief>>;\n};\n\nexport type RecurringsByWeekday = {\n [wd in WeekdayCode2]: ISlotUIContext[];\n};\n\nexport const emptyRecurringsByWeekday = (): RecurringsByWeekday =>\n (['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'] as WeekdayCode2[]).reduce(\n (o, wd) => {\n o[wd] = [];\n return o;\n },\n {} as RecurringsByWeekday,\n );\n\nexport const groupRecurringSlotsByWeekday = (\n calendariumSpace?: ICalendariumSpaceContext,\n): RecurringSlots => {\n const slots: RecurringSlots = {\n byWeekday: {},\n };\n if (!calendariumSpace?.dbo?.recurringHappenings) {\n // console.log(logPrefix + ', no slots for team:', calendariumSpace);\n return slots;\n }\n zipMapBriefsWithIDs(calendariumSpace.dbo.recurringHappenings).forEach(\n (rh) => {\n Object.entries(rh.brief.slots || {})?.forEach(([slotID, rs]) => {\n const happening: IHappeningContext = {\n id: rh.id,\n brief: rh.brief,\n space: calendariumSpace.space,\n };\n const slotItems = slotUIContextsFromRecurringSlot(\n happening,\n slotID,\n rs,\n );\n slotItems.forEach((si) => {\n if (si.wd) {\n let weekday = slots.byWeekday[si.wd];\n if (!weekday) {\n weekday = [];\n slots.byWeekday[si.wd] = weekday;\n }\n weekday.push(si);\n }\n });\n });\n },\n );\n // console.log(logPrefix + ', slots:', slots);\n return slots;\n};\n\nconst slotUIContextsFromRecurringSlot = (\n r: IHappeningContext,\n slotID: string,\n rs: IHappeningSlot,\n): ISlotUIContext[] => {\n const si = {\n // date: rs.start.date,\n slot: { ...rs, id: slotID },\n happening: r,\n title: r.brief?.title || r.id,\n levels: r.brief?.levels,\n repeats: rs.repeats,\n timing: { start: rs.start, end: rs.end },\n };\n if (rs.weekdays?.length) {\n return rs.weekdays.map((wd) => ({ ...si, wd }));\n }\n return [si];\n};\n"]}
@@ -0,0 +1,16 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { HappeningSlotModalService } from '../components/happening-slot-form/happening-slot-modal.service';
3
+ import { CalendariumSpaceService } from './calendarium-space.service';
4
+ import * as i0 from "@angular/core";
5
+ export class CalendariumServicesModule {
6
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendariumServicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
7
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.0", ngImport: i0, type: CalendariumServicesModule }); }
8
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendariumServicesModule, providers: [CalendariumSpaceService, HappeningSlotModalService] }); }
9
+ }
10
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendariumServicesModule, decorators: [{
11
+ type: NgModule,
12
+ args: [{
13
+ providers: [CalendariumSpaceService, HappeningSlotModalService],
14
+ }]
15
+ }] });
16
+ //# sourceMappingURL=calendarium-services.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendarium-services.module.js","sourceRoot":"","sources":["../../../../../../../../libs/extensions/schedulus/shared/src/lib/services/calendarium-services.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gEAAgE,CAAC;AAC3G,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;;AAKtE,MAAM,OAAO,yBAAyB;8GAAzB,yBAAyB;+GAAzB,yBAAyB;+GAAzB,yBAAyB,aAFzB,CAAC,uBAAuB,EAAE,yBAAyB,CAAC;;2FAEpD,yBAAyB;kBAHrC,QAAQ;mBAAC;oBACR,SAAS,EAAE,CAAC,uBAAuB,EAAE,yBAAyB,CAAC;iBAChE","sourcesContent":["import { NgModule } from '@angular/core';\nimport { HappeningSlotModalService } from '../components/happening-slot-form/happening-slot-modal.service';\nimport { CalendariumSpaceService } from './calendarium-space.service';\n\n@NgModule({\n providers: [CalendariumSpaceService, HappeningSlotModalService],\n})\nexport class CalendariumServicesModule {}\n"]}
@@ -0,0 +1,16 @@
1
+ import { Injectable, inject, Injector } from '@angular/core';
2
+ import { Firestore as AngularFirestore } from '@angular/fire/firestore';
3
+ import { SpaceModuleService } from '@sneat/space-services';
4
+ import * as i0 from "@angular/core";
5
+ export class CalendariumSpaceService extends SpaceModuleService {
6
+ constructor() {
7
+ const afs = inject(AngularFirestore);
8
+ super(inject(Injector), 'calendarium', afs);
9
+ }
10
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendariumSpaceService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
11
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendariumSpaceService }); }
12
+ }
13
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: CalendariumSpaceService, decorators: [{
14
+ type: Injectable
15
+ }], ctorParameters: () => [] });
16
+ //# sourceMappingURL=calendarium-space.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendarium-space.service.js","sourceRoot":"","sources":["../../../../../../../../libs/extensions/schedulus/shared/src/lib/services/calendarium-space.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;;AAG3D,MAAM,OAAO,uBAAwB,SAAQ,kBAAwC;IACnF;QACE,MAAM,GAAG,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACrC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,GAAG,CAAC,CAAC;IAC9C,CAAC;8GAJU,uBAAuB;kHAAvB,uBAAuB;;2FAAvB,uBAAuB;kBADnC,UAAU","sourcesContent":["import { Injectable, inject, Injector } from '@angular/core';\nimport { Firestore as AngularFirestore } from '@angular/fire/firestore';\nimport { ICalendariumSpaceDbo } from '@sneat/mod-schedulus-core';\nimport { SpaceModuleService } from '@sneat/space-services';\n\n@Injectable()\nexport class CalendariumSpaceService extends SpaceModuleService<ICalendariumSpaceDbo> {\n public constructor() {\n const afs = inject(AngularFirestore);\n super(inject(Injector), 'calendarium', afs);\n }\n}\n"]}
@@ -0,0 +1,225 @@
1
+ import { Injectable, NgModule, inject, Injector } from '@angular/core';
2
+ import { Firestore as AngularFirestore, orderBy, } from '@angular/fire/firestore';
3
+ import { SneatApiService } from '@sneat/api';
4
+ import { dateToIso } from '@sneat/core';
5
+ import { validateHappeningDto, } from '@sneat/mod-schedulus-core';
6
+ import { ErrorLogger } from '@sneat/core';
7
+ import { map, tap, throwError } from 'rxjs';
8
+ import { ModuleSpaceItemService } from '@sneat/space-services';
9
+ import * as i0 from "@angular/core";
10
+ function processHappeningContext(h, space) {
11
+ if (h.dbo) {
12
+ try {
13
+ validateHappeningDto(h.dbo);
14
+ }
15
+ catch (e) {
16
+ console.warn(`Received invalid happening DTO (id=${h.id}: ${e}`);
17
+ }
18
+ }
19
+ if (!h.space && space) {
20
+ h = { ...h, space };
21
+ }
22
+ return h;
23
+ }
24
+ export class HappeningService {
25
+ static statusFilter(statuses) {
26
+ const operator = statuses?.length === 1 ? '==' : 'in';
27
+ const value = statuses.length === 1 ? statuses[0] : statuses;
28
+ return { field: 'status', operator, value };
29
+ }
30
+ constructor() {
31
+ this.errorLogger = inject(ErrorLogger);
32
+ this.sneatApiService = inject(SneatApiService);
33
+ this.removeParticipant = (request) => {
34
+ return this.removeParticipants({
35
+ spaceID: request.spaceID,
36
+ happeningID: request.happeningID,
37
+ contacts: [request.contact],
38
+ });
39
+ };
40
+ this.removeParticipants = (request) => this.sneatApiService.post('happenings/remove_participants', request);
41
+ this.addParticipant = (request) => {
42
+ return this.addParticipants({
43
+ spaceID: request.spaceID,
44
+ happeningID: request.happeningID,
45
+ contacts: [request.contact],
46
+ });
47
+ };
48
+ this.addParticipants = (request) => this.sneatApiService.post('happenings/add_participants', request);
49
+ this.addSlot = (spaceID, happeningID, slot) => {
50
+ const request = {
51
+ spaceID,
52
+ happeningID,
53
+ slot,
54
+ };
55
+ return this.sneatApiService.post('happenings/add_slot', request);
56
+ };
57
+ this.updateSlot = (spaceID, happeningID, slot) => {
58
+ const request = {
59
+ spaceID,
60
+ happeningID,
61
+ slot,
62
+ };
63
+ return this.sneatApiService.post('happenings/update_slot', request);
64
+ };
65
+ const afs = inject(AngularFirestore);
66
+ const sneatApiService = this.sneatApiService;
67
+ this.spaceItemService = new ModuleSpaceItemService(inject(Injector), 'calendarium', 'happenings', afs, sneatApiService);
68
+ }
69
+ createHappening(request) {
70
+ const title = request.happening.title.trim();
71
+ if (title !== request.happening.title) {
72
+ request = {
73
+ ...request,
74
+ happening: {
75
+ ...request.happening,
76
+ title,
77
+ },
78
+ };
79
+ }
80
+ if (request.happening.type === 'single' &&
81
+ request.happening.slots &&
82
+ Object.values(request.happening.slots).some((slot) => slot.repeats !== 'once')) {
83
+ return throwError(() => 'Single occurrence happening cannot have recurring slots');
84
+ }
85
+ try {
86
+ validateHappeningDto(request.happening);
87
+ }
88
+ catch (e) {
89
+ return throwError(() => e);
90
+ }
91
+ return this.sneatApiService.post('happenings/create_happening', request);
92
+ }
93
+ cancelHappening(request) {
94
+ return this.sneatApiService.post('happenings/cancel_happening', request);
95
+ }
96
+ revokeHappeningCancellation(request) {
97
+ return this.sneatApiService.post('happenings/revoke_happening_cancellation', request);
98
+ }
99
+ deleteHappening(happening) {
100
+ const request = {
101
+ spaceID: happening.space?.id || '',
102
+ happeningID: happening.id,
103
+ happeningType: happening.brief?.type || happening.dbo?.type,
104
+ };
105
+ return this.sneatApiService.delete('happenings/delete_happening', undefined, request);
106
+ }
107
+ deleteSlot(request) {
108
+ return this.sneatApiService.delete('happenings/delete_slot', undefined, request);
109
+ }
110
+ updateHappeningTexts(request) {
111
+ return this.sneatApiService.post('happenings/update_happening_texts', request);
112
+ }
113
+ deleteHappeningPrices(request) {
114
+ return this.sneatApiService.post('happenings/delete_prices', request);
115
+ }
116
+ setHappeningPrices(request) {
117
+ return this.sneatApiService.post('happenings/set_prices', request);
118
+ }
119
+ adjustSlot(spaceID, happeningID, slot, date) {
120
+ slot = {
121
+ id: slot.id,
122
+ repeats: 'once',
123
+ start: { time: slot.start?.time || '', date },
124
+ end: slot.end,
125
+ durationMinutes: slot.durationMinutes,
126
+ };
127
+ const request = {
128
+ spaceID: spaceID,
129
+ happeningID,
130
+ slot,
131
+ date,
132
+ };
133
+ return this.sneatApiService.post('happenings/adjust_slot', request);
134
+ }
135
+ cancelAdjustment(spaceID, happeningID, slotID, date) {
136
+ const request = {
137
+ spaceID,
138
+ happeningID,
139
+ slotID,
140
+ date,
141
+ };
142
+ return this.sneatApiService.post('happenings/cancel_adjustment', request);
143
+ }
144
+ // watchByTeam(space: ISpaceContext): Observable<IHappeningContext[]> {
145
+ // return this.sfs.watchBySpaceID(team.id);
146
+ // }
147
+ watchHappeningByID(space, id) {
148
+ return this.spaceItemService.watchSpaceItemByIdWithSpaceRef(space, id).pipe(
149
+ // tap((happening) => console.log('watchHappeningByID() =>', happening)),
150
+ map((h) => processHappeningContext(h, space)));
151
+ }
152
+ watchUpcomingSingles(space, statuses = ['active']) {
153
+ return this.watchSingles(space, statuses, {
154
+ field: 'dateMax',
155
+ operator: '>=',
156
+ });
157
+ }
158
+ watchPastSingles(space, statuses = ['active']) {
159
+ return this.watchSingles(space, statuses, {
160
+ field: 'dateMax',
161
+ operator: '<',
162
+ }, undefined, 100);
163
+ }
164
+ watchRecentlyCreatedSingles(space, statuses = ['active']) {
165
+ return this.watchSingles(space, statuses, undefined, orderBy('createdAt', 'desc'), 10);
166
+ }
167
+ watchSingles(space, statuses, dateCondition, // Past
168
+ orderByConstraint, limit) {
169
+ const date = dateToIso(new Date());
170
+ const typeCondition = {
171
+ field: 'type',
172
+ operator: '==',
173
+ value: 'single',
174
+ };
175
+ const filter = [typeCondition, HappeningService.statusFilter(statuses)];
176
+ if (dateCondition) {
177
+ filter.push({ ...dateCondition, value: date });
178
+ }
179
+ return this.spaceItemService
180
+ .watchModuleSpaceItemsWithSpaceRef(space, {
181
+ filter,
182
+ orderBy: orderByConstraint ? [orderByConstraint] : undefined,
183
+ limit,
184
+ })
185
+ .pipe(tap((happenings) => console.log('watchSingles() =>', happenings)), map((happenings) => {
186
+ return happenings.map((h) => processHappeningContext(h, space));
187
+ }));
188
+ }
189
+ watchSinglesOnSpecificDay(space, date, status = 'active') {
190
+ if (!space.id) {
191
+ return throwError(() => 'missing required field "spaceID"');
192
+ }
193
+ if (!date) {
194
+ return throwError(() => 'missing required field "date"');
195
+ }
196
+ // const teamDate = team.id + ':' + date;
197
+ return this.spaceItemService
198
+ .watchModuleSpaceItemsWithSpaceRef(space, {
199
+ filter: [
200
+ HappeningService.statusFilter([status]),
201
+ { field: 'dates', operator: 'array-contains', value: date },
202
+ ],
203
+ })
204
+ .pipe(tap((happenings) => {
205
+ console.log('watchSinglesOnSpecificDay() =>', space.id, date, status, happenings);
206
+ }), map((happenings) => happenings.map((h) => processHappeningContext(h, space))));
207
+ }
208
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: HappeningService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
209
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: HappeningService }); }
210
+ }
211
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: HappeningService, decorators: [{
212
+ type: Injectable
213
+ }], ctorParameters: () => [] });
214
+ export class HappeningServiceModule {
215
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: HappeningServiceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
216
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.0", ngImport: i0, type: HappeningServiceModule }); }
217
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: HappeningServiceModule, providers: [HappeningService] }); }
218
+ }
219
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImport: i0, type: HappeningServiceModule, decorators: [{
220
+ type: NgModule,
221
+ args: [{
222
+ providers: [HappeningService],
223
+ }]
224
+ }] });
225
+ //# sourceMappingURL=happening.service.js.map