@cratis/scene.blueprint.bookings 0.0.0-stage → 4.71.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 (133) hide show
  1. package/README.md +66 -2
  2. package/blueprint.ts +16 -0
  3. package/blueprintCatalog.json +123 -0
  4. package/bookingsApplication.ts +28 -0
  5. package/bookingsParts.ts +58 -0
  6. package/bookingsQueries.ts +60 -0
  7. package/bookingsScreenSet.ts +22 -0
  8. package/dist/cjs/blueprint.js +19 -0
  9. package/dist/cjs/blueprint.js.map +1 -0
  10. package/dist/cjs/bookingsApplication.js +49 -0
  11. package/dist/cjs/bookingsApplication.js.map +1 -0
  12. package/dist/cjs/bookingsParts.js +151 -0
  13. package/dist/cjs/bookingsParts.js.map +1 -0
  14. package/dist/cjs/bookingsQueries.js +68 -0
  15. package/dist/cjs/bookingsQueries.js.map +1 -0
  16. package/dist/cjs/bookingsScreenSet.js +47 -0
  17. package/dist/cjs/bookingsScreenSet.js.map +1 -0
  18. package/dist/cjs/index.js +69 -0
  19. package/dist/cjs/index.js.map +1 -0
  20. package/dist/cjs/manifest.js +90 -0
  21. package/dist/cjs/manifest.js.map +1 -0
  22. package/dist/cjs/navigation.js +117 -0
  23. package/dist/cjs/navigation.js.map +1 -0
  24. package/dist/cjs/package.json +3 -0
  25. package/dist/cjs/packageName.js +8 -0
  26. package/dist/cjs/packageName.js.map +1 -0
  27. package/dist/cjs/screens/index.js +22 -0
  28. package/dist/cjs/screens/index.js.map +1 -0
  29. package/dist/cjs/templateProvenance.js +24 -0
  30. package/dist/cjs/templateProvenance.js.map +1 -0
  31. package/dist/cjs/templates/calendarTemplate.js +109 -0
  32. package/dist/cjs/templates/calendarTemplate.js.map +1 -0
  33. package/dist/cjs/templates/formTemplates.js +50 -0
  34. package/dist/cjs/templates/formTemplates.js.map +1 -0
  35. package/dist/cjs/templates/index.js +27 -0
  36. package/dist/cjs/templates/index.js.map +1 -0
  37. package/dist/cjs/templates/listTemplates.js +167 -0
  38. package/dist/cjs/templates/listTemplates.js.map +1 -0
  39. package/dist/cjs/templates/recordTemplates.js +129 -0
  40. package/dist/cjs/templates/recordTemplates.js.map +1 -0
  41. package/dist/cjs/templates/wizardTemplate.js +73 -0
  42. package/dist/cjs/templates/wizardTemplate.js.map +1 -0
  43. package/dist/esm/blueprint.d.ts +3 -0
  44. package/dist/esm/blueprint.d.ts.map +1 -0
  45. package/dist/esm/blueprint.js +17 -0
  46. package/dist/esm/blueprint.js.map +1 -0
  47. package/dist/esm/bookingsApplication.d.ts +10 -0
  48. package/dist/esm/bookingsApplication.d.ts.map +1 -0
  49. package/dist/esm/bookingsApplication.js +44 -0
  50. package/dist/esm/bookingsApplication.js.map +1 -0
  51. package/dist/esm/bookingsParts.d.ts +16 -0
  52. package/dist/esm/bookingsParts.d.ts.map +1 -0
  53. package/dist/esm/bookingsParts.js +133 -0
  54. package/dist/esm/bookingsParts.js.map +1 -0
  55. package/dist/esm/bookingsQueries.d.ts +41 -0
  56. package/dist/esm/bookingsQueries.d.ts.map +1 -0
  57. package/dist/esm/bookingsQueries.js +60 -0
  58. package/dist/esm/bookingsQueries.js.map +1 -0
  59. package/dist/esm/bookingsScreenSet.d.ts +7 -0
  60. package/dist/esm/bookingsScreenSet.d.ts.map +1 -0
  61. package/dist/esm/bookingsScreenSet.js +45 -0
  62. package/dist/esm/bookingsScreenSet.js.map +1 -0
  63. package/dist/esm/index.d.ts +12 -0
  64. package/dist/esm/index.d.ts.map +1 -0
  65. package/dist/esm/index.js +18 -0
  66. package/dist/esm/index.js.map +1 -0
  67. package/dist/esm/manifest.d.ts +3 -0
  68. package/dist/esm/manifest.d.ts.map +1 -0
  69. package/dist/esm/manifest.js +88 -0
  70. package/dist/esm/manifest.js.map +1 -0
  71. package/dist/esm/navigation.d.ts +5 -0
  72. package/dist/esm/navigation.d.ts.map +1 -0
  73. package/dist/esm/navigation.js +113 -0
  74. package/dist/esm/navigation.js.map +1 -0
  75. package/dist/esm/package.json +3 -0
  76. package/dist/esm/packageName.d.ts +2 -0
  77. package/dist/esm/packageName.d.ts.map +1 -0
  78. package/dist/esm/packageName.js +6 -0
  79. package/dist/esm/packageName.js.map +1 -0
  80. package/dist/esm/screens/index.d.ts +3 -0
  81. package/dist/esm/screens/index.d.ts.map +1 -0
  82. package/dist/esm/screens/index.js +20 -0
  83. package/dist/esm/screens/index.js.map +1 -0
  84. package/dist/esm/templateProvenance.d.ts +3 -0
  85. package/dist/esm/templateProvenance.d.ts.map +1 -0
  86. package/dist/esm/templateProvenance.js +22 -0
  87. package/dist/esm/templateProvenance.js.map +1 -0
  88. package/dist/esm/templates/calendarTemplate.d.ts +3 -0
  89. package/dist/esm/templates/calendarTemplate.d.ts.map +1 -0
  90. package/dist/esm/templates/calendarTemplate.js +107 -0
  91. package/dist/esm/templates/calendarTemplate.js.map +1 -0
  92. package/dist/esm/templates/formTemplates.d.ts +3 -0
  93. package/dist/esm/templates/formTemplates.d.ts.map +1 -0
  94. package/dist/esm/templates/formTemplates.js +48 -0
  95. package/dist/esm/templates/formTemplates.js.map +1 -0
  96. package/dist/esm/templates/index.d.ts +8 -0
  97. package/dist/esm/templates/index.d.ts.map +1 -0
  98. package/dist/esm/templates/index.js +18 -0
  99. package/dist/esm/templates/index.js.map +1 -0
  100. package/dist/esm/templates/listTemplates.d.ts +4 -0
  101. package/dist/esm/templates/listTemplates.d.ts.map +1 -0
  102. package/dist/esm/templates/listTemplates.js +164 -0
  103. package/dist/esm/templates/listTemplates.js.map +1 -0
  104. package/dist/esm/templates/recordTemplates.d.ts +3 -0
  105. package/dist/esm/templates/recordTemplates.d.ts.map +1 -0
  106. package/dist/esm/templates/recordTemplates.js +127 -0
  107. package/dist/esm/templates/recordTemplates.js.map +1 -0
  108. package/dist/esm/templates/wizardTemplate.d.ts +3 -0
  109. package/dist/esm/templates/wizardTemplate.d.ts.map +1 -0
  110. package/dist/esm/templates/wizardTemplate.js +71 -0
  111. package/dist/esm/templates/wizardTemplate.js.map +1 -0
  112. package/dist/esm/tsconfig.tsbuildinfo +1 -0
  113. package/index.ts +14 -0
  114. package/manifest.ts +41 -0
  115. package/navigation.ts +54 -0
  116. package/package.json +78 -4
  117. package/packageName.ts +5 -0
  118. package/sampleData/bookings-en.json +1057 -0
  119. package/screens/index.ts +20 -0
  120. package/templateProvenance.ts +15 -0
  121. package/templates/calendarTemplate.ts +57 -0
  122. package/templates/formTemplates.ts +33 -0
  123. package/templates/index.ts +18 -0
  124. package/templates/listTemplates.ts +106 -0
  125. package/templates/recordTemplates.ts +78 -0
  126. package/templates/wizardTemplate.ts +29 -0
  127. package/thumbnails/BookingPage.svg +17 -0
  128. package/thumbnails/BookingsCalendar.svg +34 -0
  129. package/thumbnails/BookingsList.svg +29 -0
  130. package/thumbnails/BookingsQuickCreateBooking.svg +12 -0
  131. package/thumbnails/NewBookingWizard.svg +15 -0
  132. package/thumbnails/ResourcesList.svg +29 -0
  133. package/thumbnails/bookings.svg +14 -0
@@ -0,0 +1,20 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Screen } from '@cratis/scene.model';
5
+ import { LayoutName } from '@cratis/scene.blueprint.default';
6
+ import { bookingsScreenDefinitions } from '../bookingsScreenSet';
7
+
8
+ /**
9
+ * The ready-to-use screens: real `Screen` instances, one for each entry of the manifest's `blueprint.screenSet`, each filling the screen template it names in
10
+ * the foundation's application shell. A new application that adopts the blueprint gets these, wired into its navigation (`bookingsNavigation`).
11
+ */
12
+ export const bookingsScreens: Screen[] = bookingsScreenDefinitions.map(definition => ({
13
+ name: definition.name,
14
+ layout: LayoutName.AppShell,
15
+ screenTemplate: definition.template,
16
+ slotContent: {},
17
+ forms: [],
18
+ contributions: [],
19
+ path: definition.name.split('.'),
20
+ }));
@@ -0,0 +1,15 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { TemplateMetadata } from '@cratis/scene.model';
5
+
6
+ /** The compatibility, attribution and license metadata every template this blueprint ships carries. */
7
+ export const bookingsTemplateProvenance: Pick<TemplateMetadata, 'compatibility' | 'attribution' | 'license' | 'licenseUrl'> = {
8
+ compatibility: {
9
+ scene: '^4.13.0',
10
+ packages: [{ name: 'Cratis.Blueprint.Default', versionRange: '^1.0.0' }],
11
+ },
12
+ attribution: { author: 'Cratis', url: 'https://github.com/Cratis/Scene/tree/main/Source/JavaScript/blueprint.bookings' },
13
+ license: 'MIT',
14
+ licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',
15
+ };
@@ -0,0 +1,57 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { ScreenTemplate, TemplateScope, WidthSizeClass } from '@cratis/scene.model';
5
+ import { column, grid, slotLeaf } from '@cratis/scene.blueprint.default';
6
+ import { BookingsQuery, fromQuery, localeOfData } from '../bookingsQueries';
7
+ import { actionButton, component, goesTo, bookingsMetadata, opensDialog, withBehaviors } from '../bookingsParts';
8
+
9
+ interface Action { id: string; label: string; emphasis: 'primary' | 'secondary' | 'quiet' | 'danger'; dialog?: string; screen?: string }
10
+
11
+ interface CalendarOptions {
12
+ name: string;
13
+ displayName: string;
14
+ description: string;
15
+ title: string;
16
+ subtitle: string;
17
+ label: string;
18
+ listLabel: string;
19
+ events: string;
20
+ columns: string;
21
+ titleField: string;
22
+ actions: Action[];
23
+ }
24
+
25
+ /**
26
+ * One calendar: the foundation's `calendarGrid` on a month, a week or as an agenda. The status is told in words as well as by color, the day and view are kept in the
27
+ * address so a link shares the calendar as it is, and the list beside it names everything in the period.
28
+ */
29
+ function calendarOf(options: CalendarOptions): ScreenTemplate {
30
+ const id = options.name;
31
+ return {
32
+ name: options.name,
33
+ fitsSlot: 'content',
34
+ slots: [{ name: 'header' }, { name: 'calendar' }, { name: 'due' }],
35
+ arrangement: {
36
+ root: column([slotLeaf('header'), grid([slotLeaf('calendar', { span: 2 }), slotLeaf('due')], 3, 16)], 16),
37
+ overrides: [{ width: WidthSizeClass.Compact, root: column([slotLeaf('header'), slotLeaf('calendar'), slotLeaf('due')], 16) }],
38
+ },
39
+ content: {
40
+ header: [component(`${id}-header`, 'pageHeader', { title: options.title, subtitle: options.subtitle }, {
41
+ actions: options.actions.map(action => withBehaviors(actionButton(`${id}-${action.id}`, action.label, action.emphasis), action.dialog ? opensDialog(action.dialog) : goesTo(action.screen!))),
42
+ })],
43
+ calendar: [component(`${id}-grid`, 'calendarGrid', { label: options.label, events: fromQuery(options.events), date: fromQuery(BookingsQuery.Settings, '0.today'), urlKey: 'day', ...localeOfData })],
44
+ due: [component(`${id}-list`, 'dataList', { label: options.listLabel, rows: fromQuery(options.events), columns: fromQuery(options.columns), titleField: options.titleField, pageSize: 6, ...localeOfData })],
45
+ },
46
+ displayName: options.displayName,
47
+ description: options.description,
48
+ metadata: bookingsMetadata(options.name, 'Calendar', [TemplateScope.Module, TemplateScope.Feature]),
49
+ };
50
+ }
51
+
52
+ /** The bookings calendar: each booking on its day on a month, a week or an agenda; the status is told in words as well as by color, and the list beside it names every booking in the period. */
53
+ export const bookingsCalendarTemplate = calendarOf({
54
+ name: 'BookingsCalendar', displayName: 'Bookings calendar', description: 'Every booking on the day it falls, on a month, a week or as an agenda, with the status told in words.', title: 'Calendar', subtitle: 'Who has what, and when', label: 'Bookings', listLabel: 'Bookings in this period',
55
+ events: BookingsQuery.BookingEvents, columns: BookingsQuery.BookingEventColumns, titleField: 'title',
56
+ actions: [{ id: 'book', label: 'Book a resource', emphasis: 'primary', screen: 'bookings.new' }],
57
+ });
@@ -0,0 +1,33 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { DialogTemplate, TemplateScope } from '@cratis/scene.model';
5
+ import { quickCreateDialogTemplate } from '@cratis/scene.blueprint.default';
6
+ import { BookingsQuery, fromQuery, localeOfData } from '../bookingsQueries';
7
+ import { closesDialog, component, bookingsMetadata, withBehaviors } from '../bookingsParts';
8
+
9
+ /**
10
+ * One quick-create dialog: the foundation `QuickCreateDialog` - a short form opened from a page to make one record without leaving it - with the fields
11
+ * that thing needs to get started.
12
+ */
13
+ function quickCreateOf(name: string, title: string, sections: string, noun: string, submit: string): DialogTemplate {
14
+ return {
15
+ name,
16
+ slots: quickCreateDialogTemplate.slots,
17
+ content: {
18
+ header: [component(`${name}-frame`, 'dialogFrame', { title, subtitle: 'Only what is needed to get started' })],
19
+ body: [withBehaviors(component(`${name}-form`, 'formScreenBody', {
20
+ mode: 'create', saveAndNew: false, strings: { formSave: submit }, sections: fromQuery(sections), errors: fromQuery(BookingsQuery.FormErrors, '0'), ...localeOfData,
21
+ }), closesDialog())],
22
+ actions: [],
23
+ },
24
+ displayName: `Bookings quick create ${noun}`,
25
+ description: `A short form that creates one ${noun} without leaving the page.`,
26
+ metadata: bookingsMetadata(name, 'Dialog', [TemplateScope.Slice]),
27
+ };
28
+ }
29
+
30
+ /** The quick dialogs of the blueprint. */
31
+ export const bookingsDialogs: DialogTemplate[] = [
32
+ quickCreateOf('BookingsQuickCreateBooking', 'Quick booking', 'BookingQuickSections', 'booking', 'Book'),
33
+ ];
@@ -0,0 +1,18 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { bookingsCalendarTemplate } from './calendarTemplate';
5
+ import { bookingsListTemplate, resourcesListTemplate } from './listTemplates';
6
+ import { bookingPageTemplate } from './recordTemplates';
7
+ import { newBookingWizardTemplate } from './wizardTemplate';
8
+
9
+ export * from './calendarTemplate';
10
+ export * from './listTemplates';
11
+ export * from './recordTemplates';
12
+ export * from './wizardTemplate';
13
+ export * from './formTemplates';
14
+
15
+ /** Every screen template this blueprint provides, in the order the manifest lists them. */
16
+ export const bookingsScreenTemplates = [bookingsCalendarTemplate, bookingsListTemplate, bookingPageTemplate, resourcesListTemplate, newBookingWizardTemplate];
17
+
18
+ export { bookingsDialogs as bookingsDialogTemplates } from './formTemplates';
@@ -0,0 +1,106 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { InteractionActionKind, InteractionTriggerKind, NotificationLevel, NotifyAction, ScreenTemplate, TemplateScope } from '@cratis/scene.model';
5
+ import { listScreenTemplate } from '@cratis/scene.blueprint.default';
6
+ import { BookingsEntityKind, fromQuery, bookingsQueriesOf, localeOfData } from '../bookingsQueries';
7
+ import { actionButton, component, goesTo, bookingsMetadata, opensDialog, opensDialogOnSelect, opensRecordOnSelect, withBehaviors } from '../bookingsParts';
8
+
9
+ const listScopes = [TemplateScope.Module, TemplateScope.Feature];
10
+
11
+ /** The Export button: it tells the user the export has started, which is what the shell does for a long-running action it does not wait on. */
12
+ const exportAction = (id: string) => withBehaviors(actionButton(id, 'Export', 'secondary'), [{
13
+ bindings: [{
14
+ trigger: { kind: InteractionTriggerKind.Click },
15
+ actions: [{ kind: InteractionActionKind.Notify, level: NotificationLevel.Info, message: { text: 'The export has started.' } } as unknown as NotifyAction],
16
+ }],
17
+ }]);
18
+
19
+ interface ListOptions {
20
+ name: string;
21
+ entity: BookingsEntityKind;
22
+ displayName: string;
23
+ description: string;
24
+ title: string;
25
+ subtitle: string;
26
+ searchLabel: string;
27
+ urlKey: string;
28
+ /** The primary action of the header: a quick-create dialog to open, or a screen to go to. */
29
+ primary: { label: string; dialog?: string; screen?: string };
30
+ rowActions: string[];
31
+ bulkActions: string[];
32
+ titleField: string;
33
+ /** The screen a chosen row opens; the list then selects one row at a time. Absent, rows are selected many at a time for the bulk bar. */
34
+ recordScreen?: string;
35
+ /** The side sheet a chosen row opens instead of a record page; the list then selects one row at a time. */
36
+ recordDialog?: string;
37
+ /** Group the rows (`variant: grouped`) by this field. */
38
+ grouped?: { groupBy: string };
39
+ /** Rows are not selectable at all: a record of what happened, which nobody edits. */
40
+ readOnly?: boolean;
41
+ /** Show the records as cards, each with the picture its `imageField` names. */
42
+ cards?: { imageField?: string };
43
+ /** Tint a row by the tone in this field (always beside a status column that says the same in words). */
44
+ toneField?: string;
45
+ }
46
+
47
+ /**
48
+ * One list: the foundation `ListScreen` with its header, toolbar, filters, list and bulk bar filled for an entity. The slots, arrangement and
49
+ * every behavior - sort, search, paging and selection in the address, the table collapsing to cards on a phone - are the foundation's.
50
+ */
51
+ function listTemplateOf(options: ListOptions): ScreenTemplate {
52
+ const queries = bookingsQueriesOf(options.entity);
53
+ const id = options.name;
54
+ const listId = `${id}-records`;
55
+ const primary = withBehaviors(actionButton(`${id}-primary`, options.primary.label, 'primary'), options.primary.dialog ? opensDialog(options.primary.dialog) : goesTo(options.primary.screen!));
56
+ const list = component(listId, 'dataList', {
57
+ label: options.title, rows: fromQuery(queries.rows), columns: fromQuery(queries.columns), titleField: options.titleField, pageSize: options.cards ? 12 : 10, urlKey: options.urlKey, ...localeOfData,
58
+ rowActions: options.rowActions,
59
+ ...(options.readOnly ? {} : { selectionMode: options.recordScreen || options.recordDialog ? 'single' : 'multiple' }),
60
+ ...(options.cards ? { variant: 'cards', ...(options.cards.imageField ? { imageField: options.cards.imageField } : {}) } : {}),
61
+ ...(options.grouped ? { variant: 'grouped', groupBy: options.grouped.groupBy } : {}),
62
+ ...(options.toneField ? { toneField: options.toneField } : {}),
63
+ });
64
+
65
+ return {
66
+ name: options.name,
67
+ fitsSlot: 'content',
68
+ slots: listScreenTemplate.slots,
69
+ arrangement: listScreenTemplate.arrangement,
70
+ content: {
71
+ header: [component(`${id}-header`, 'pageHeader', { title: options.title, subtitle: options.subtitle }, { actions: [exportAction(`${id}-export`), primary] })],
72
+ toolbar: [
73
+ component(`${id}-search`, 'globalSearch', { placeholder: options.searchLabel, label: options.searchLabel, urlKey: `${options.urlKey}q` }),
74
+ component(`${id}-views`, 'savedViewsMenu', { views: fromQuery(queries.views), savePermission: 'enabled', managePermission: 'enabled' }),
75
+ component(`${id}-columns`, 'columnChooser', { columns: fromQuery(queries.columnChoices) }),
76
+ ],
77
+ filters: [component(`${id}-filter`, 'filterBuilder', { fields: fromQuery(queries.filterFields), ...localeOfData })],
78
+ list: [options.recordScreen ? withBehaviors(list, opensRecordOnSelect(listId, options.recordScreen)) : options.recordDialog ? withBehaviors(list, opensDialogOnSelect(options.recordDialog)) : list],
79
+ bulkBar: options.recordScreen || options.recordDialog || options.readOnly ? [] : [component(`${id}-bulk`, 'bulkBar', { selection: fromQuery(queries.selection), actions: options.bulkActions })],
80
+ footer: [],
81
+ },
82
+ displayName: options.displayName,
83
+ description: options.description,
84
+ metadata: bookingsMetadata(options.name, 'List', listScopes),
85
+ };
86
+ }
87
+
88
+
89
+ /** The bookings: every booking with its resource, who booked it, when and its status. Choosing a booking opens it. */
90
+ export const bookingsListTemplate = listTemplateOf({
91
+ name: 'BookingsList',
92
+ entity: BookingsEntityKind.Booking, displayName: 'Bookings list', description: 'Every booking with its resource, who booked it, date and time and status, filtered by resource, status, person and date.', title: 'Bookings', subtitle: 'Everything that has been booked', searchLabel: 'Search bookings', urlKey: 'bookings',
93
+ primary: { label: 'Quick booking', dialog: 'BookingsQuickCreateBooking' },
94
+ rowActions: ['Open', 'Cancel booking'], bulkActions: [],
95
+ titleField: 'reference', recordScreen: 'bookings.record'
96
+ });
97
+
98
+ /** The resources: the rooms, equipment and vehicles that can be booked, as cards with their type, capacity, location and whether each is free. */
99
+ export const resourcesListTemplate = listTemplateOf({
100
+ name: 'ResourcesList',
101
+ entity: BookingsEntityKind.Resource, displayName: 'Resources list', description: 'The rooms, equipment and vehicles that can be booked, with their capacity, location and whether each is free.', title: 'Resources', subtitle: 'What can be booked', searchLabel: 'Search resources', urlKey: 'resources',
102
+ primary: { label: 'Book a resource', screen: 'bookings.new' },
103
+ rowActions: ['Book'], bulkActions: [],
104
+ titleField: 'name',
105
+ readOnly: true, cards: {}
106
+ });
@@ -0,0 +1,78 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { ScreenTemplate, TemplateScope } from '@cratis/scene.model';
5
+ import { recordPageTemplate } from '@cratis/scene.blueprint.default';
6
+ import { BookingsEntityKind, currencyOfData, fromQuery, localeOfData, bookingsQueriesOf } from '../bookingsQueries';
7
+ import { actionButton, component, goesTo, bookingsMetadata, opensDialog, withBehaviors } from '../bookingsParts';
8
+
9
+ interface Fact { id: string; label: string; field: string; format?: 'currency' | 'percent' }
10
+ interface Extra { key: string; label: string; titleField: string; pageSize?: number }
11
+ interface Action { id: string; label: string; emphasis: 'primary' | 'secondary' | 'quiet' | 'danger'; dialog?: string; screen?: string }
12
+
13
+ interface RecordOptions {
14
+ name: string;
15
+ entity: BookingsEntityKind;
16
+ displayName: string;
17
+ description: string;
18
+ titleField: string;
19
+ backScreen: string;
20
+ backLabel: string;
21
+ facts: Fact[];
22
+ extras: Extra[];
23
+ actions: Action[];
24
+ }
25
+
26
+ /**
27
+ * One record page: the foundation `RecordPage` with the record's own title, its status and key facts at the top, its fields and the lists that belong to it in the
28
+ * main region, and the activity beside it. What it shows is the record the list handed it the id of.
29
+ */
30
+ function recordPageOf(options: RecordOptions): ScreenTemplate {
31
+ const queries = bookingsQueriesOf(options.entity);
32
+ const id = options.name;
33
+ return {
34
+ name: options.name,
35
+ fitsSlot: 'content',
36
+ slots: recordPageTemplate.slots,
37
+ arrangement: recordPageTemplate.arrangement,
38
+ content: {
39
+ header: [component(`${id}-header`, 'pageHeader', { title: fromQuery(queries.record, `0.${options.titleField}`), subtitle: fromQuery(queries.record, '0.summary') }, {
40
+ actions: [
41
+ withBehaviors(actionButton(`${id}-back`, options.backLabel, 'secondary'), goesTo(options.backScreen)),
42
+ ...options.actions.map(action => withBehaviors(actionButton(`${id}-${action.id}`, action.label, action.emphasis), action.dialog ? opensDialog(action.dialog) : goesTo(action.screen!))),
43
+ ],
44
+ })],
45
+ summary: [
46
+ component(`${id}-status`, 'statusChip', { status: fromQuery(queries.summary, '0.status'), tone: fromQuery(queries.summary, '0.tone') }),
47
+ ...options.facts.map(fact => component(`${id}-${fact.id}`, 'statCard', {
48
+ label: fact.label, value: fromQuery(queries.summary, `0.${fact.field}`), ...(fact.format ? { format: fact.format } : {}), ...currencyOfData,
49
+ })),
50
+ ],
51
+ tabs: [component(`${id}-tabs`, 'tabSet', { tabs: fromQuery(queries.tabs), urlKey: 'tab', label: `${options.displayName} sections` })],
52
+ main: [
53
+ component(`${id}-form`, 'formScreenBody', { mode: 'readOnly', sections: fromQuery(queries.sections), values: fromQuery(queries.record, '0'), ...currencyOfData }),
54
+ ...options.extras.map(extra => component(`${id}-${extra.key.toLowerCase()}`, 'dataList', {
55
+ label: extra.label, rows: fromQuery(`${options.entity}${extra.key}`), columns: fromQuery(`${options.entity}${extra.key}Columns`), titleField: extra.titleField, pageSize: extra.pageSize ?? 8, ...currencyOfData,
56
+ })),
57
+ ],
58
+ related: [],
59
+ activity: [component(`${id}-activity`, 'activityFeed', { label: 'Activity', entries: fromQuery(queries.activity), ...localeOfData })],
60
+ aside: [],
61
+ },
62
+ displayName: options.displayName,
63
+ description: options.description,
64
+ metadata: bookingsMetadata(options.name, 'Detail', [TemplateScope.Feature, TemplateScope.Subfeature]),
65
+ };
66
+ }
67
+
68
+ /** The booking page: the booking reference as its title, its status, date, hours and people at the top, its details, attendees and extras in the main region, and the activity beside it. */
69
+ export const bookingPageTemplate = recordPageOf({
70
+ name: 'BookingPage', entity: BookingsEntityKind.Booking, displayName: 'Booking page', description: 'One booking: status, date, hours and people, its details, attendees and extras, and its activity.', titleField: 'reference', backScreen: 'bookings.list', backLabel: 'Back to bookings',
71
+ facts: [
72
+ { id: 'date', label: 'Date', field: 'date' },
73
+ { id: 'hours', label: 'Hours', field: 'hours' },
74
+ { id: 'people', label: 'People', field: 'people' },
75
+ ],
76
+ extras: [{ key: 'Attendees', label: 'Attendees', titleField: 'name' }, { key: 'Extras', label: 'Extras', titleField: 'item' }],
77
+ actions: [],
78
+ });
@@ -0,0 +1,29 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { ScreenTemplate, TemplateScope } from '@cratis/scene.model';
5
+ import { wizardScreenTemplate } from '@cratis/scene.blueprint.default';
6
+ import { BookingsQuery, currencyOfData, fromQuery, localeOfData } from '../bookingsQueries';
7
+ import { bookingsMetadata, component } from '../bookingsParts';
8
+
9
+ /** The new-booking wizard: what you need, when you need it, a few details, then a review. The step the person has reached survives a refresh and an invalid step blocks Next and says why. */
10
+ export const newBookingWizardTemplate: ScreenTemplate = {
11
+ name: 'NewBookingWizard',
12
+ fitsSlot: 'content',
13
+ slots: wizardScreenTemplate.slots,
14
+ arrangement: wizardScreenTemplate.arrangement,
15
+ content: {
16
+ header: [component('NewBookingWizard-header', 'pageHeader', { title: 'New booking', subtitle: 'Four short steps' })],
17
+ progress: [component('NewBookingWizard-progress', 'wizardProgress', { steps: fromQuery(BookingsQuery.BookingWizardSteps), urlKey: 'step' }, {
18
+ resource: [component('NewBookingWizard-resource', 'formScreenBody', { mode: 'create', sections: fromQuery(BookingsQuery.BookingResourceSections), errors: fromQuery(BookingsQuery.FormErrors, '0'), ...localeOfData })],
19
+ when: [component('NewBookingWizard-when', 'formScreenBody', { mode: 'create', sections: fromQuery(BookingsQuery.BookingWhenSections), errors: fromQuery(BookingsQuery.FormErrors, '0'), ...localeOfData })],
20
+ details: [component('NewBookingWizard-details', 'formScreenBody', { mode: 'create', sections: fromQuery(BookingsQuery.BookingDetailSections), errors: fromQuery(BookingsQuery.FormErrors, '0'), ...localeOfData })],
21
+ review: [component('NewBookingWizard-review', 'formScreenBody', { mode: 'readOnly', sections: fromQuery(BookingsQuery.BookingReviewSections), values: fromQuery(BookingsQuery.BookingReviewValues, '0'), ...currencyOfData })],
22
+ })],
23
+ step: [],
24
+ actions: [],
25
+ },
26
+ displayName: 'New booking wizard',
27
+ description: 'Resource, time, details, then review and book; the step survives a refresh and an invalid step blocks Next and says why.',
28
+ metadata: bookingsMetadata('NewBookingWizard', 'Wizard', [TemplateScope.Feature, TemplateScope.Subfeature]),
29
+ };
@@ -0,0 +1,17 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="320" height="200" viewBox="0 0 320 200" role="img" aria-label="BookingPage">
2
+ <rect x="0" y="0" width="320" height="200" rx="4" fill="#f4f5f7"/>
3
+ <rect x="12" y="12" width="296" height="20" rx="4" fill="#db2777"/>
4
+ <rect x="12" y="40" width="64" height="148" rx="4" fill="#d5d9df"/>
5
+ <rect x="84" y="40" width="70" height="30" rx="4" fill="#ffffff" stroke="#d5d9df"/>
6
+ <rect x="160" y="40" width="70" height="30" rx="4" fill="#ffffff" stroke="#d5d9df"/>
7
+ <rect x="236" y="40" width="70" height="30" rx="4" fill="#ffffff" stroke="#d5d9df"/>
8
+ <rect x="84" y="78" width="150" height="110" rx="4" fill="#ffffff" stroke="#d5d9df"/>
9
+ <rect x="242" y="78" width="66" height="110" rx="4" fill="#ffffff" stroke="#d5d9df"/>
10
+ <rect x="94" y="90" width="130" height="6" rx="3" fill="#9aa3b2"/>
11
+ <rect x="94" y="107" width="130" height="6" rx="3" fill="#9aa3b2"/>
12
+ <rect x="94" y="124" width="130" height="6" rx="3" fill="#9aa3b2"/>
13
+ <rect x="94" y="141" width="130" height="6" rx="3" fill="#9aa3b2"/>
14
+ <rect x="250" y="90" width="50" height="6" rx="3" fill="#db2777"/>
15
+ <rect x="250" y="107" width="50" height="6" rx="3" fill="#db2777"/>
16
+ <rect x="250" y="124" width="50" height="6" rx="3" fill="#db2777"/>
17
+ </svg>
@@ -0,0 +1,34 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="320" height="200" viewBox="0 0 320 200" role="img" aria-label="BookingsCalendar">
2
+ <rect x="0" y="0" width="320" height="200" rx="4" fill="#f4f5f7"/>
3
+ <rect x="12" y="12" width="296" height="20" rx="4" fill="#db2777"/>
4
+ <rect x="12" y="40" width="64" height="148" rx="4" fill="#d5d9df"/>
5
+ <rect x="84" y="40" width="224" height="148" rx="4" fill="#ffffff" stroke="#d5d9df"/>
6
+ <rect x="90" y="70" width="26" height="24" rx="4" fill="#db2777"/>
7
+ <rect x="120" y="70" width="26" height="24" rx="4" fill="#eef0f3"/>
8
+ <rect x="150" y="70" width="26" height="24" rx="4" fill="#eef0f3"/>
9
+ <rect x="180" y="70" width="26" height="24" rx="4" fill="#eef0f3"/>
10
+ <rect x="210" y="70" width="26" height="24" rx="4" fill="#eef0f3"/>
11
+ <rect x="240" y="70" width="26" height="24" rx="4" fill="#db2777"/>
12
+ <rect x="270" y="70" width="26" height="24" rx="4" fill="#eef0f3"/>
13
+ <rect x="90" y="98" width="26" height="24" rx="4" fill="#eef0f3"/>
14
+ <rect x="120" y="98" width="26" height="24" rx="4" fill="#eef0f3"/>
15
+ <rect x="150" y="98" width="26" height="24" rx="4" fill="#eef0f3"/>
16
+ <rect x="180" y="98" width="26" height="24" rx="4" fill="#eef0f3"/>
17
+ <rect x="210" y="98" width="26" height="24" rx="4" fill="#db2777"/>
18
+ <rect x="240" y="98" width="26" height="24" rx="4" fill="#eef0f3"/>
19
+ <rect x="270" y="98" width="26" height="24" rx="4" fill="#eef0f3"/>
20
+ <rect x="90" y="126" width="26" height="24" rx="4" fill="#eef0f3"/>
21
+ <rect x="120" y="126" width="26" height="24" rx="4" fill="#eef0f3"/>
22
+ <rect x="150" y="126" width="26" height="24" rx="4" fill="#eef0f3"/>
23
+ <rect x="180" y="126" width="26" height="24" rx="4" fill="#db2777"/>
24
+ <rect x="210" y="126" width="26" height="24" rx="4" fill="#eef0f3"/>
25
+ <rect x="240" y="126" width="26" height="24" rx="4" fill="#eef0f3"/>
26
+ <rect x="270" y="126" width="26" height="24" rx="4" fill="#eef0f3"/>
27
+ <rect x="90" y="154" width="26" height="24" rx="4" fill="#eef0f3"/>
28
+ <rect x="120" y="154" width="26" height="24" rx="4" fill="#eef0f3"/>
29
+ <rect x="150" y="154" width="26" height="24" rx="4" fill="#db2777"/>
30
+ <rect x="180" y="154" width="26" height="24" rx="4" fill="#eef0f3"/>
31
+ <rect x="210" y="154" width="26" height="24" rx="4" fill="#eef0f3"/>
32
+ <rect x="240" y="154" width="26" height="24" rx="4" fill="#eef0f3"/>
33
+ <rect x="270" y="154" width="26" height="24" rx="4" fill="#eef0f3"/>
34
+ </svg>
@@ -0,0 +1,29 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="320" height="200" viewBox="0 0 320 200" role="img" aria-label="BookingsList">
2
+ <rect x="0" y="0" width="320" height="200" rx="4" fill="#f4f5f7"/>
3
+ <rect x="12" y="12" width="296" height="20" rx="4" fill="#db2777"/>
4
+ <rect x="12" y="40" width="64" height="148" rx="4" fill="#d5d9df"/>
5
+ <rect x="84" y="40" width="68" height="70" rx="4" fill="#ffffff" stroke="#d5d9df"/>
6
+ <rect x="88" y="44" width="60" height="30" rx="4" fill="#d5d9df"/>
7
+ <rect x="90" y="82" width="40" height="5" rx="3" fill="#db2777"/>
8
+ <rect x="90" y="94" width="52" height="5" rx="3" fill="#9aa3b2"/>
9
+ <rect x="160" y="40" width="68" height="70" rx="4" fill="#ffffff" stroke="#d5d9df"/>
10
+ <rect x="164" y="44" width="60" height="30" rx="4" fill="#d5d9df"/>
11
+ <rect x="166" y="82" width="40" height="5" rx="3" fill="#db2777"/>
12
+ <rect x="166" y="94" width="52" height="5" rx="3" fill="#9aa3b2"/>
13
+ <rect x="236" y="40" width="68" height="70" rx="4" fill="#ffffff" stroke="#d5d9df"/>
14
+ <rect x="240" y="44" width="60" height="30" rx="4" fill="#d5d9df"/>
15
+ <rect x="242" y="82" width="40" height="5" rx="3" fill="#db2777"/>
16
+ <rect x="242" y="94" width="52" height="5" rx="3" fill="#9aa3b2"/>
17
+ <rect x="84" y="116" width="68" height="70" rx="4" fill="#ffffff" stroke="#d5d9df"/>
18
+ <rect x="88" y="120" width="60" height="30" rx="4" fill="#d5d9df"/>
19
+ <rect x="90" y="158" width="40" height="5" rx="3" fill="#db2777"/>
20
+ <rect x="90" y="170" width="52" height="5" rx="3" fill="#9aa3b2"/>
21
+ <rect x="160" y="116" width="68" height="70" rx="4" fill="#ffffff" stroke="#d5d9df"/>
22
+ <rect x="164" y="120" width="60" height="30" rx="4" fill="#d5d9df"/>
23
+ <rect x="166" y="158" width="40" height="5" rx="3" fill="#db2777"/>
24
+ <rect x="166" y="170" width="52" height="5" rx="3" fill="#9aa3b2"/>
25
+ <rect x="236" y="116" width="68" height="70" rx="4" fill="#ffffff" stroke="#d5d9df"/>
26
+ <rect x="240" y="120" width="60" height="30" rx="4" fill="#d5d9df"/>
27
+ <rect x="242" y="158" width="40" height="5" rx="3" fill="#db2777"/>
28
+ <rect x="242" y="170" width="52" height="5" rx="3" fill="#9aa3b2"/>
29
+ </svg>
@@ -0,0 +1,12 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="320" height="200" viewBox="0 0 320 200" role="img" aria-label="BookingsQuickCreateBooking">
2
+ <rect x="0" y="0" width="320" height="200" rx="4" fill="#f4f5f7"/>
3
+ <rect x="12" y="12" width="296" height="20" rx="4" fill="#db2777"/>
4
+ <rect x="12" y="40" width="64" height="148" rx="4" fill="#d5d9df"/>
5
+ <rect x="84" y="40" width="224" height="148" rx="4" fill="#e4e7ec"/>
6
+ <rect x="120" y="56" width="152" height="120" rx="4" fill="#ffffff" stroke="#d5d9df"/>
7
+ <rect x="130" y="66" width="70" height="7" rx="3" fill="#db2777"/>
8
+ <rect x="130" y="86" width="132" height="14" rx="4" fill="#eef0f3"/>
9
+ <rect x="130" y="108" width="132" height="14" rx="4" fill="#eef0f3"/>
10
+ <rect x="130" y="130" width="132" height="14" rx="4" fill="#eef0f3"/>
11
+ <rect x="206" y="152" width="56" height="16" rx="4" fill="#db2777"/>
12
+ </svg>
@@ -0,0 +1,15 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="320" height="200" viewBox="0 0 320 200" role="img" aria-label="NewBookingWizard">
2
+ <rect x="0" y="0" width="320" height="200" rx="4" fill="#f4f5f7"/>
3
+ <rect x="12" y="12" width="296" height="20" rx="4" fill="#db2777"/>
4
+ <rect x="12" y="40" width="64" height="148" rx="4" fill="#d5d9df"/>
5
+ <rect x="84" y="40" width="224" height="24" rx="4" fill="#ffffff" stroke="#d5d9df"/>
6
+ <circle cx="100" cy="52" r="6" fill="#db2777"/>
7
+ <circle cx="160" cy="52" r="6" fill="#db2777"/>
8
+ <circle cx="220" cy="52" r="6" fill="#d5d9df"/>
9
+ <circle cx="280" cy="52" r="6" fill="#d5d9df"/>
10
+ <rect x="84" y="72" width="224" height="90" rx="4" fill="#ffffff" stroke="#d5d9df"/>
11
+ <rect x="96" y="84" width="120" height="8" rx="3" fill="#9aa3b2"/>
12
+ <rect x="96" y="102" width="190" height="14" rx="4" fill="#eef0f3"/>
13
+ <rect x="96" y="126" width="190" height="14" rx="4" fill="#eef0f3"/>
14
+ <rect x="236" y="168" width="72" height="18" rx="4" fill="#db2777"/>
15
+ </svg>
@@ -0,0 +1,29 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="320" height="200" viewBox="0 0 320 200" role="img" aria-label="ResourcesList">
2
+ <rect x="0" y="0" width="320" height="200" rx="4" fill="#f4f5f7"/>
3
+ <rect x="12" y="12" width="296" height="20" rx="4" fill="#db2777"/>
4
+ <rect x="12" y="40" width="64" height="148" rx="4" fill="#d5d9df"/>
5
+ <rect x="84" y="40" width="68" height="70" rx="4" fill="#ffffff" stroke="#d5d9df"/>
6
+ <rect x="88" y="44" width="60" height="30" rx="4" fill="#d5d9df"/>
7
+ <rect x="90" y="82" width="40" height="5" rx="3" fill="#db2777"/>
8
+ <rect x="90" y="94" width="52" height="5" rx="3" fill="#9aa3b2"/>
9
+ <rect x="160" y="40" width="68" height="70" rx="4" fill="#ffffff" stroke="#d5d9df"/>
10
+ <rect x="164" y="44" width="60" height="30" rx="4" fill="#d5d9df"/>
11
+ <rect x="166" y="82" width="40" height="5" rx="3" fill="#db2777"/>
12
+ <rect x="166" y="94" width="52" height="5" rx="3" fill="#9aa3b2"/>
13
+ <rect x="236" y="40" width="68" height="70" rx="4" fill="#ffffff" stroke="#d5d9df"/>
14
+ <rect x="240" y="44" width="60" height="30" rx="4" fill="#d5d9df"/>
15
+ <rect x="242" y="82" width="40" height="5" rx="3" fill="#db2777"/>
16
+ <rect x="242" y="94" width="52" height="5" rx="3" fill="#9aa3b2"/>
17
+ <rect x="84" y="116" width="68" height="70" rx="4" fill="#ffffff" stroke="#d5d9df"/>
18
+ <rect x="88" y="120" width="60" height="30" rx="4" fill="#d5d9df"/>
19
+ <rect x="90" y="158" width="40" height="5" rx="3" fill="#db2777"/>
20
+ <rect x="90" y="170" width="52" height="5" rx="3" fill="#9aa3b2"/>
21
+ <rect x="160" y="116" width="68" height="70" rx="4" fill="#ffffff" stroke="#d5d9df"/>
22
+ <rect x="164" y="120" width="60" height="30" rx="4" fill="#d5d9df"/>
23
+ <rect x="166" y="158" width="40" height="5" rx="3" fill="#db2777"/>
24
+ <rect x="166" y="170" width="52" height="5" rx="3" fill="#9aa3b2"/>
25
+ <rect x="236" y="116" width="68" height="70" rx="4" fill="#ffffff" stroke="#d5d9df"/>
26
+ <rect x="240" y="120" width="60" height="30" rx="4" fill="#d5d9df"/>
27
+ <rect x="242" y="158" width="40" height="5" rx="3" fill="#db2777"/>
28
+ <rect x="242" y="170" width="52" height="5" rx="3" fill="#9aa3b2"/>
29
+ </svg>
@@ -0,0 +1,14 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="320" height="200" viewBox="0 0 320 200" role="img" aria-label="Bookings blueprint">
2
+ <rect x="0" y="0" width="320" height="200" rx="4" fill="#f4f5f7"/>
3
+ <rect x="12" y="12" width="296" height="20" rx="4" fill="#db2777"/>
4
+ <rect x="12" y="40" width="64" height="148" rx="4" fill="#d5d9df"/>
5
+ <rect x="84" y="40" width="70" height="30" rx="4" fill="#ffffff" stroke="#d5d9df"/>
6
+ <rect x="160" y="40" width="70" height="30" rx="4" fill="#ffffff" stroke="#d5d9df"/>
7
+ <rect x="236" y="40" width="70" height="30" rx="4" fill="#ffffff" stroke="#d5d9df"/>
8
+ <rect x="84" y="78" width="224" height="110" rx="4" fill="#ffffff" stroke="#d5d9df"/>
9
+ <rect x="94" y="90" width="200" height="6" rx="3" fill="#9aa3b2"/>
10
+ <rect x="94" y="107" width="164" height="6" rx="3" fill="#9aa3b2"/>
11
+ <rect x="94" y="124" width="200" height="6" rx="3" fill="#9aa3b2"/>
12
+ <rect x="94" y="141" width="164" height="6" rx="3" fill="#9aa3b2"/>
13
+ <rect x="94" y="158" width="200" height="6" rx="3" fill="#9aa3b2"/>
14
+ </svg>