@things-factory/calendar 10.1.234 → 10.1.236
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/pages/calendar/calendar-days-off-page.d.ts +43 -0
- package/dist-client/pages/calendar/calendar-days-off-page.js +161 -0
- package/dist-client/pages/calendar/calendar-days-off-page.js.map +1 -0
- package/dist-client/pages/calendar/calendar-list-page.js +33 -5
- package/dist-client/pages/calendar/calendar-list-page.js.map +1 -1
- package/dist-client/pages/event/event-list-page.d.ts +4 -0
- package/dist-client/pages/event/event-list-page.js +60 -5
- package/dist-client/pages/event/event-list-page.js.map +1 -1
- package/dist-client/pages/sure-to-delete.d.ts +1 -0
- package/dist-client/pages/sure-to-delete.js +10 -0
- package/dist-client/pages/sure-to-delete.js.map +1 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +3 -0
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/calendar/calendar-service.js +14 -1
- package/dist-server/service/calendar/calendar-service.js.map +1 -1
- package/dist-server/service/calendar/calendar-type.d.ts +24 -1
- package/dist-server/service/calendar/calendar-type.js +85 -1
- package/dist-server/service/calendar/calendar-type.js.map +1 -1
- package/dist-server/service/calendar/calendar.d.ts +7 -0
- package/dist-server/service/calendar/calendar.js +22 -1
- package/dist-server/service/calendar/calendar.js.map +1 -1
- package/dist-server/service/calendar/index.d.ts +2 -1
- package/dist-server/service/calendar/index.js +2 -1
- package/dist-server/service/calendar/index.js.map +1 -1
- package/dist-server/service/calendar/working-days-resolver.d.ts +8 -0
- package/dist-server/service/calendar/working-days-resolver.js +92 -0
- package/dist-server/service/calendar/working-days-resolver.js.map +1 -0
- package/dist-server/service/calendar/working-days.d.ts +49 -0
- package/dist-server/service/calendar/working-days.js +185 -0
- package/dist-server/service/calendar/working-days.js.map +1 -0
- package/dist-server/service/event/event-query.js +1 -1
- package/dist-server/service/event/event-query.js.map +1 -1
- package/dist-server/service/event-series/recurrence.d.ts +2 -0
- package/dist-server/service/event-series/recurrence.js +1 -0
- package/dist-server/service/event-series/recurrence.js.map +1 -1
- package/dist-server/service/index.d.ts +3 -2
- package/dist-server/service/index.js +1 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/things-factory.config.js +4 -0
- package/translations/en.json +23 -1
- package/translations/es.json +23 -1
- package/translations/ja.json +23 -1
- package/translations/ko.json +23 -1
- package/translations/ms.json +23 -1
- package/translations/zh.json +23 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import '@operato/data-grist';
|
|
2
|
+
import { PageView } from '@operato/shell';
|
|
3
|
+
declare const CalendarDaysOffPage_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
|
|
4
|
+
/**
|
|
5
|
+
* A days-off calendar's days (ADR-0179): the company's days off written as rows from one day to another - 창립기념일,
|
|
6
|
+
* 하계 휴무. Each counts at once: leave skips it, the calendars paint it. Opened from the calendar's row; the public
|
|
7
|
+
* holiday calendar is the import's and is read on the event list instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare class CalendarDaysOffPage extends CalendarDaysOffPage_base {
|
|
10
|
+
static styles: import("lit").CSSResult[];
|
|
11
|
+
gristConfig: any;
|
|
12
|
+
private calendarId;
|
|
13
|
+
private calendarName;
|
|
14
|
+
private grist;
|
|
15
|
+
get context(): {
|
|
16
|
+
title: string;
|
|
17
|
+
help: string;
|
|
18
|
+
menu: string;
|
|
19
|
+
actions: {
|
|
20
|
+
icon: string;
|
|
21
|
+
emphasis: {
|
|
22
|
+
raised: boolean;
|
|
23
|
+
outlined: boolean;
|
|
24
|
+
dense: boolean;
|
|
25
|
+
danger: boolean;
|
|
26
|
+
};
|
|
27
|
+
title: string;
|
|
28
|
+
action: () => Promise<void>;
|
|
29
|
+
}[];
|
|
30
|
+
};
|
|
31
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
32
|
+
pageInitialized(lifecycle: any): Promise<void>;
|
|
33
|
+
pageUpdated(changes: any, lifecycle: any): Promise<void>;
|
|
34
|
+
private open;
|
|
35
|
+
fetchHandler(): Promise<{
|
|
36
|
+
total: any;
|
|
37
|
+
records: any;
|
|
38
|
+
}>;
|
|
39
|
+
private write;
|
|
40
|
+
private save;
|
|
41
|
+
private delete;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@operato/data-grist';
|
|
3
|
+
import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles';
|
|
4
|
+
import { PageView } from '@operato/shell';
|
|
5
|
+
import { html } from 'lit';
|
|
6
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
7
|
+
import { DataGrist } from '@operato/data-grist';
|
|
8
|
+
import { client } from '@operato/graphql';
|
|
9
|
+
import { i18next, localize } from '@operato/i18n';
|
|
10
|
+
import { notify } from '@operato/layout';
|
|
11
|
+
import gql from 'graphql-tag';
|
|
12
|
+
import { sureToDelete } from '../sure-to-delete';
|
|
13
|
+
/** The longest day off one row holds - the server's DAYS_OFF_MAX_SPAN, said next to the field. */
|
|
14
|
+
const DAYS_OFF_MAX_SPAN = 31;
|
|
15
|
+
/**
|
|
16
|
+
* A days-off calendar's days (ADR-0179): the company's days off written as rows from one day to another - 창립기념일,
|
|
17
|
+
* 하계 휴무. Each counts at once: leave skips it, the calendars paint it. Opened from the calendar's row; the public
|
|
18
|
+
* holiday calendar is the import's and is read on the event list instead.
|
|
19
|
+
*/
|
|
20
|
+
let CalendarDaysOffPage = class CalendarDaysOffPage extends localize(i18next)(PageView) {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.calendarId = '';
|
|
24
|
+
this.calendarName = '';
|
|
25
|
+
}
|
|
26
|
+
static { this.styles = [WorkSurfacePageStyles, ScrollbarStyles, CommonGristStyles]; }
|
|
27
|
+
get context() {
|
|
28
|
+
return {
|
|
29
|
+
title: this.calendarName ? `${i18next.t('title.calendar-days-off')} · ${this.calendarName}` : i18next.t('title.calendar-days-off'),
|
|
30
|
+
help: 'calendar/calendar',
|
|
31
|
+
/* The days of a calendar - the menu marks the calendars. */
|
|
32
|
+
menu: 'calendar-list',
|
|
33
|
+
actions: [
|
|
34
|
+
{ title: i18next.t('button.save'), action: this.save.bind(this), ...CommonButtonStyles.save },
|
|
35
|
+
{ title: i18next.t('button.delete'), action: this.delete.bind(this), ...CommonButtonStyles.delete }
|
|
36
|
+
]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
return html `<ox-grist class="page-fill" mode="GRID" .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}></ox-grist>`;
|
|
41
|
+
}
|
|
42
|
+
async pageInitialized(lifecycle) {
|
|
43
|
+
this.gristConfig = {
|
|
44
|
+
columns: [
|
|
45
|
+
{ type: 'gutter', gutterName: 'sequence' },
|
|
46
|
+
{ type: 'gutter', gutterName: 'row-selector', multiple: true },
|
|
47
|
+
{ type: 'string', name: 'name', header: i18next.t('field.name'), record: { editable: true, mandatory: true }, width: 200 },
|
|
48
|
+
{ type: 'date', name: 'from', header: i18next.t('field.days-off-from'), record: { editable: true, mandatory: true }, width: 130 },
|
|
49
|
+
{
|
|
50
|
+
type: 'date',
|
|
51
|
+
name: 'to',
|
|
52
|
+
header: i18next.t('field.days-off-to'),
|
|
53
|
+
record: { editable: true, hint: i18next.t('text.days-off-to-hint', { max: DAYS_OFF_MAX_SPAN }) },
|
|
54
|
+
width: 130
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
rows: { selectable: { multiple: true } },
|
|
58
|
+
pagination: { infinite: true }
|
|
59
|
+
};
|
|
60
|
+
await this.open(lifecycle?.params?.calendar || '');
|
|
61
|
+
}
|
|
62
|
+
async pageUpdated(changes, lifecycle) {
|
|
63
|
+
if (!this.active || !changes.params)
|
|
64
|
+
return;
|
|
65
|
+
const calendarId = lifecycle?.params?.calendar || '';
|
|
66
|
+
if (calendarId !== this.calendarId)
|
|
67
|
+
await this.open(calendarId);
|
|
68
|
+
}
|
|
69
|
+
async open(calendarId) {
|
|
70
|
+
this.calendarId = calendarId;
|
|
71
|
+
this.calendarName = '';
|
|
72
|
+
if (calendarId) {
|
|
73
|
+
const response = await client.query({
|
|
74
|
+
query: gql `
|
|
75
|
+
query ($id: String!) {
|
|
76
|
+
calendar(id: $id) {
|
|
77
|
+
name
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`,
|
|
81
|
+
variables: { id: calendarId }
|
|
82
|
+
});
|
|
83
|
+
this.calendarName = response.data?.calendar?.name ?? '';
|
|
84
|
+
}
|
|
85
|
+
this.updateContext();
|
|
86
|
+
this.grist?.fetch();
|
|
87
|
+
}
|
|
88
|
+
async fetchHandler() {
|
|
89
|
+
if (!this.calendarId)
|
|
90
|
+
return { total: 0, records: [] };
|
|
91
|
+
const response = await client.query({
|
|
92
|
+
query: gql `
|
|
93
|
+
query ($calendarId: String!) {
|
|
94
|
+
calendarDaysOff(calendarId: $calendarId) {
|
|
95
|
+
id
|
|
96
|
+
name
|
|
97
|
+
from
|
|
98
|
+
to
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
`,
|
|
102
|
+
variables: { calendarId: this.calendarId },
|
|
103
|
+
fetchPolicy: 'no-cache'
|
|
104
|
+
});
|
|
105
|
+
const records = response.data?.calendarDaysOff ?? [];
|
|
106
|
+
return { total: records.length, records };
|
|
107
|
+
}
|
|
108
|
+
async write(patches) {
|
|
109
|
+
const response = await client.mutate({
|
|
110
|
+
mutation: gql `
|
|
111
|
+
mutation ($calendarId: String!, $patches: [DayOffSpanPatch!]!) {
|
|
112
|
+
updateCalendarDaysOff(calendarId: $calendarId, patches: $patches)
|
|
113
|
+
}
|
|
114
|
+
`,
|
|
115
|
+
variables: { calendarId: this.calendarId, patches }
|
|
116
|
+
});
|
|
117
|
+
if (!response.errors) {
|
|
118
|
+
this.grist.fetch();
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
async save() {
|
|
124
|
+
const patches = (this.grist.dirtyRecords || []).map((row) => {
|
|
125
|
+
const patch = { cuFlag: row.__dirty__, ...(row.id ? { id: row.id } : {}) };
|
|
126
|
+
for (const key in row.__dirtyfields__)
|
|
127
|
+
patch[key] = row.__dirtyfields__[key].after || undefined;
|
|
128
|
+
return patch;
|
|
129
|
+
});
|
|
130
|
+
if (patches.length && (await this.write(patches)))
|
|
131
|
+
notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.save') }) });
|
|
132
|
+
}
|
|
133
|
+
async delete() {
|
|
134
|
+
const ids = this.grist.selected.map((row) => row.id).filter(Boolean);
|
|
135
|
+
if (!ids.length || !(await sureToDelete()))
|
|
136
|
+
return;
|
|
137
|
+
if (await this.write(ids.map((id) => ({ id, cuFlag: '-' }))))
|
|
138
|
+
notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') }) });
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
__decorate([
|
|
142
|
+
property({ type: Object }),
|
|
143
|
+
__metadata("design:type", Object)
|
|
144
|
+
], CalendarDaysOffPage.prototype, "gristConfig", void 0);
|
|
145
|
+
__decorate([
|
|
146
|
+
state(),
|
|
147
|
+
__metadata("design:type", Object)
|
|
148
|
+
], CalendarDaysOffPage.prototype, "calendarId", void 0);
|
|
149
|
+
__decorate([
|
|
150
|
+
state(),
|
|
151
|
+
__metadata("design:type", Object)
|
|
152
|
+
], CalendarDaysOffPage.prototype, "calendarName", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
query('ox-grist'),
|
|
155
|
+
__metadata("design:type", DataGrist)
|
|
156
|
+
], CalendarDaysOffPage.prototype, "grist", void 0);
|
|
157
|
+
CalendarDaysOffPage = __decorate([
|
|
158
|
+
customElement('calendar-days-off-page')
|
|
159
|
+
], CalendarDaysOffPage);
|
|
160
|
+
export { CalendarDaysOffPage };
|
|
161
|
+
//# sourceMappingURL=calendar-days-off-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-days-off-page.js","sourceRoot":"","sources":["../../../client/pages/calendar/calendar-days-off-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAC/G,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAExC,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,kGAAkG;AAClG,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAE5B;;;;GAIG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,QAAQ,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC;IAA7D;;QAKY,eAAU,GAAG,EAAE,CAAA;QACf,iBAAY,GAAG,EAAE,CAAA;IAsHpC,CAAC;aA3HQ,WAAM,GAAG,CAAC,qBAAqB,EAAE,eAAe,EAAE,iBAAiB,CAAC,AAA9D,CAA8D;IAS3E,IAAI,OAAO;QACT,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,YAAY,CAA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AC,CAAC,CAAC,0BAA0B,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IACnK,CAAC;;AAxH2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wDAAiB;AAE3B;IAAhB,KAAK,EAAE;;uDAAwB;AACf;IAAhB,KAAK,EAAE;;yDAA0B;AAEP;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;kDAAA;AARjC,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CA4H/B","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonButtonStyles, CommonGristStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { PageView } from '@operato/shell'\nimport { html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { DataGrist } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\n\nimport gql from 'graphql-tag'\n\nimport { sureToDelete } from '../sure-to-delete'\n\n/** The longest day off one row holds - the server's DAYS_OFF_MAX_SPAN, said next to the field. */\nconst DAYS_OFF_MAX_SPAN = 31\n\n/**\n * A days-off calendar's days (ADR-0179): the company's days off written as rows from one day to another - 창립기념일,\n * 하계 휴무. Each counts at once: leave skips it, the calendars paint it. Opened from the calendar's row; the public\n * holiday calendar is the import's and is read on the event list instead.\n */\n@customElement('calendar-days-off-page')\nexport class CalendarDaysOffPage extends localize(i18next)(PageView) {\n static styles = [WorkSurfacePageStyles, ScrollbarStyles, CommonGristStyles]\n\n @property({ type: Object }) gristConfig: any\n\n @state() private calendarId = ''\n @state() private calendarName = ''\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: this.calendarName ? `${i18next.t('title.calendar-days-off')} · ${this.calendarName}` : i18next.t('title.calendar-days-off'),\n help: 'calendar/calendar',\n /* The days of a calendar - the menu marks the calendars. */\n menu: 'calendar-list',\n actions: [\n { title: i18next.t('button.save'), action: this.save.bind(this), ...CommonButtonStyles.save },\n { title: i18next.t('button.delete'), action: this.delete.bind(this), ...CommonButtonStyles.delete }\n ]\n }\n }\n\n render() {\n return html`<ox-grist class=\"page-fill\" mode=\"GRID\" .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}></ox-grist>`\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n { type: 'string', name: 'name', header: i18next.t('field.name'), record: { editable: true, mandatory: true }, width: 200 },\n { type: 'date', name: 'from', header: i18next.t('field.days-off-from'), record: { editable: true, mandatory: true }, width: 130 },\n {\n type: 'date',\n name: 'to',\n header: i18next.t('field.days-off-to'),\n record: { editable: true, hint: i18next.t('text.days-off-to-hint', { max: DAYS_OFF_MAX_SPAN }) },\n width: 130\n }\n ],\n rows: { selectable: { multiple: true } },\n pagination: { infinite: true }\n }\n await this.open(lifecycle?.params?.calendar || '')\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !changes.params) return\n const calendarId = lifecycle?.params?.calendar || ''\n if (calendarId !== this.calendarId) await this.open(calendarId)\n }\n\n private async open(calendarId: string) {\n this.calendarId = calendarId\n this.calendarName = ''\n if (calendarId) {\n const response = await client.query({\n query: gql`\n query ($id: String!) {\n calendar(id: $id) {\n name\n }\n }\n `,\n variables: { id: calendarId }\n })\n this.calendarName = response.data?.calendar?.name ?? ''\n }\n this.updateContext()\n this.grist?.fetch()\n }\n\n async fetchHandler() {\n if (!this.calendarId) return { total: 0, records: [] }\n const response = await client.query({\n query: gql`\n query ($calendarId: String!) {\n calendarDaysOff(calendarId: $calendarId) {\n id\n name\n from\n to\n }\n }\n `,\n variables: { calendarId: this.calendarId },\n fetchPolicy: 'no-cache'\n })\n const records = response.data?.calendarDaysOff ?? []\n return { total: records.length, records }\n }\n\n private async write(patches: any[]) {\n const response = await client.mutate({\n mutation: gql`\n mutation ($calendarId: String!, $patches: [DayOffSpanPatch!]!) {\n updateCalendarDaysOff(calendarId: $calendarId, patches: $patches)\n }\n `,\n variables: { calendarId: this.calendarId, patches }\n })\n if (!response.errors) {\n this.grist.fetch()\n return true\n }\n return false\n }\n\n private async save() {\n const patches = (this.grist.dirtyRecords || []).map((row: any) => {\n const patch: any = { cuFlag: row.__dirty__, ...(row.id ? { id: row.id } : {}) }\n for (const key in row.__dirtyfields__) patch[key] = row.__dirtyfields__[key].after || undefined\n return patch\n })\n if (patches.length && (await this.write(patches))) notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.save') }) })\n }\n\n private async delete() {\n const ids = this.grist.selected.map((row: any) => row.id).filter(Boolean)\n if (!ids.length || !(await sureToDelete())) return\n if (await this.write(ids.map((id: string) => ({ id, cuFlag: '-' })))) notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') }) })\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import '@operato/data-grist';
|
|
3
3
|
import { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles';
|
|
4
|
-
import { PageView } from '@operato/shell';
|
|
4
|
+
import { navigate, PageView } from '@operato/shell';
|
|
5
5
|
import { css, html } from 'lit';
|
|
6
6
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
7
7
|
import { DataGrist } from '@operato/data-grist';
|
|
@@ -10,6 +10,7 @@ import { i18next, localize } from '@operato/i18n';
|
|
|
10
10
|
import { notify } from '@operato/layout';
|
|
11
11
|
import { isMobileDevice } from '@operato/utils';
|
|
12
12
|
import gql from 'graphql-tag';
|
|
13
|
+
import { sureToDelete } from '../sure-to-delete';
|
|
13
14
|
let CalendarListPage = class CalendarListPage extends localize(i18next)(PageView) {
|
|
14
15
|
constructor() {
|
|
15
16
|
super(...arguments);
|
|
@@ -82,6 +83,22 @@ let CalendarListPage = class CalendarListPage extends localize(i18next)(PageView
|
|
|
82
83
|
columns: [
|
|
83
84
|
{ type: 'gutter', gutterName: 'sequence' },
|
|
84
85
|
{ type: 'gutter', gutterName: 'row-selector', multiple: true },
|
|
86
|
+
/*
|
|
87
|
+
* A calendar's days are its events - opened from its row, so which days a calendar holds is one click away. A
|
|
88
|
+
* days-off calendar's days are written there as days off; the others are read on the event list.
|
|
89
|
+
*/
|
|
90
|
+
{
|
|
91
|
+
type: 'gutter',
|
|
92
|
+
gutterName: 'button',
|
|
93
|
+
icon: 'event_note',
|
|
94
|
+
title: i18next.t('button.calendar-events'),
|
|
95
|
+
handlers: {
|
|
96
|
+
click: (_columns, _data, _column, record) => {
|
|
97
|
+
if (record?.id)
|
|
98
|
+
navigate(record.kind === 'DAYS_OFF' ? `calendar-days-off?calendar=${record.id}` : `event-list?calendar=${record.id}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
85
102
|
{ type: 'string',
|
|
86
103
|
name: 'name',
|
|
87
104
|
header: i18next.t('field.name'),
|
|
@@ -99,6 +116,17 @@ let CalendarListPage = class CalendarListPage extends localize(i18next)(PageView
|
|
|
99
116
|
filter: 'search',
|
|
100
117
|
width: 200
|
|
101
118
|
},
|
|
119
|
+
{ type: 'select',
|
|
120
|
+
name: 'kind',
|
|
121
|
+
header: i18next.t('field.calendar-kind'),
|
|
122
|
+
record: { editable: true,
|
|
123
|
+
hint: i18next.t('text.calendar-kind-hint'),
|
|
124
|
+
options: ['GENERAL', 'DAYS_OFF', 'PUBLIC_HOLIDAYS'].map(value => ({ display: i18next.t(`text.calendar-kind-${value.toLowerCase().replace(/_/g, '-')}`), value }))
|
|
125
|
+
},
|
|
126
|
+
filter: true,
|
|
127
|
+
sortable: true,
|
|
128
|
+
width: 110
|
|
129
|
+
},
|
|
102
130
|
{ type: 'checkbox',
|
|
103
131
|
name: 'active',
|
|
104
132
|
label: true,
|
|
@@ -132,8 +160,7 @@ let CalendarListPage = class CalendarListPage extends localize(i18next)(PageView
|
|
|
132
160
|
sorters: [
|
|
133
161
|
{ name: 'name'
|
|
134
162
|
}
|
|
135
|
-
]
|
|
136
|
-
};
|
|
163
|
+
] };
|
|
137
164
|
}
|
|
138
165
|
async pageUpdated(changes, lifecycle) {
|
|
139
166
|
if (this.active) { // do something here when this page just became as active
|
|
@@ -144,6 +171,7 @@ let CalendarListPage = class CalendarListPage extends localize(i18next)(PageView
|
|
|
144
171
|
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { responses: calendars(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id
|
|
145
172
|
name
|
|
146
173
|
description
|
|
174
|
+
kind
|
|
147
175
|
active
|
|
148
176
|
updater { id
|
|
149
177
|
name
|
|
@@ -164,7 +192,7 @@ let CalendarListPage = class CalendarListPage extends localize(i18next)(PageView
|
|
|
164
192
|
};
|
|
165
193
|
}
|
|
166
194
|
async _deleteCalendar() {
|
|
167
|
-
if (
|
|
195
|
+
if (await sureToDelete()) {
|
|
168
196
|
const ids = this.grist.selected.map(record => record.id);
|
|
169
197
|
if (ids && ids.length > 0) {
|
|
170
198
|
const response = await client.mutate({ mutation: gql `
|
|
@@ -209,7 +237,7 @@ let CalendarListPage = class CalendarListPage extends localize(i18next)(PageView
|
|
|
209
237
|
}
|
|
210
238
|
async exportHandler() {
|
|
211
239
|
const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records;
|
|
212
|
-
const targetFieldSet = new Set(['id', 'name', 'description', 'active']);
|
|
240
|
+
const targetFieldSet = new Set(['id', 'name', 'description', 'kind', 'active']);
|
|
213
241
|
return exportTargets.map(calendar => {
|
|
214
242
|
let tempObj = {};
|
|
215
243
|
for (const field of targetFieldSet) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar-list-page.js","sourceRoot":"","sources":["../../../client/pages/calendar/calendar-list-page.ts"],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AE,CAAC;;8CAAoE;AAEpE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;+CAAA;AApBjC,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CA+M5B","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { PageView } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { isMobileDevice } from '@operato/utils'\n\nimport gql from 'graphql-tag'\n\n@customElement('calendar-list-page')\nexport class CalendarListPage extends localize(i18next)(PageView) { static styles = [\n /* The work surface frame for a list screen (ADR-0060 decision 8). */\n WorkSurfacePageStyles,\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n :host {\n --grid-record-emphasized-background-color: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-filters-form { flex: 1;\n }\n `\n ]\n\n @property({ type: Object }) gristConfig: any\n @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() { return { title: i18next.t('title.calendar list'),\n search: { handler: (search: string) => { this.grist.searchText = search\n },\n value: this.grist?.searchText || '',\n autofocus: true\n },\n filter: { handler: () => { this.grist.toggleHeadroom()\n }\n },\n help: 'calendar/calendar',\n actions: [\n { title: i18next.t('button.save'),\n action: this._updateCalendar.bind(this),\n ...CommonButtonStyles.save\n },\n { title: i18next.t('button.delete'),\n action: this._deleteCalendar.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: { name: i18next.t('title.calendar list'),\n data: this.exportHandler.bind(this)\n }\n }\n }\n\n render() { const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist class=\"page-fill\" .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form without-search autofocus></ox-filters-form>\n\n <div id=\"modes\">\n <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>\n <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>\n <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>\n </div>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) { this.gristConfig = { list: { fields: ['name', 'description'],\n details: ['active', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n { type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: { editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n { type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: { editable: true\n },\n filter: 'search',\n width: 200\n },\n { type: 'checkbox',\n name: 'active',\n label: true,\n header: i18next.t('field.active'),\n record: { editable: true\n },\n filter: true,\n sortable: true,\n width: 60\n },\n { type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: { editable: false\n },\n sortable: true,\n width: 120\n },\n { type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: { editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: { selectable: { multiple: true\n }\n },\n sorters: [\n { name: 'name'\n }\n ]\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) { if (this.active) { // do something here when this page just became as active\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) { const response = await client.query({ query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { responses: calendars(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id\n name\n description\n active\n updater { id\n name\n }\n updatedAt\n }\n total\n }\n }\n `,\n variables: { filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n return { total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n\n async _deleteCalendar() { if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) { const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) { const response = await client.mutate({ mutation: gql`\n mutation ($ids: [String!]!) { deleteCalendars(ids: $ids)\n }\n `,\n variables: { ids\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n async _updateCalendar() { let patches = this.grist.dirtyRecords\n if (patches && patches.length) { patches = patches.map(patch => { let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) { patchField[key] = dirtyFields[key].after\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({ mutation: gql`\n mutation ($patches: [CalendarPatch!]!) { updateMultipleCalendar(patches: $patches) { name\n }\n }\n `,\n variables: { patches\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n }\n }\n }\n\n async exportHandler() { const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set(['id', 'name', 'description', 'active'])\n\n return exportTargets.map(calendar => { let tempObj = {}\n for (const field of targetFieldSet) { tempObj[field] = calendar[field]\n }\n\n return tempObj\n })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"calendar-list-page.js","sourceRoot":"","sources":["../../../client/pages/calendar/calendar-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAE,qBAAqB,EAAE,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AAO;iBACpC;aACA,CAAC,CAAA;YAEG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBAAS,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;YACvD,CAAC;QACD,CAAC;IACD,CAAC;IAEA,KAAK,CAAC,aAAa;QAAS,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAA;QAC/H,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;QAE/E,OAAO,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAAS,IAAI,OAAO,GAAG,EAAE,CAAA;YAC3D,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE,CAAC;gBAAS,OAAO,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;YACnF,CAAC;YAEI,OAAO,OAAO,CAAA;QACnB,CAAC,CAAC,CAAA;IACF,CAAC;;AAxN4B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qDAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CAAoE;AAEpE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;+CAAA;AApBjC,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CA0O5B","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonButtonStyles, CommonHeaderStyles, CommonGristStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { navigate, PageView } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\nimport { isMobileDevice } from '@operato/utils'\n\nimport gql from 'graphql-tag'\n\nimport { sureToDelete } from '../sure-to-delete'\n\n@customElement('calendar-list-page')\nexport class CalendarListPage extends localize(i18next)(PageView) { static styles = [\n /* The work surface frame for a list screen (ADR-0060 decision 8). */\n WorkSurfacePageStyles,\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n :host {\n --grid-record-emphasized-background-color: #8b0000;\n --grid-record-emphasized-color: #ff6b6b;\n }\n\n ox-filters-form { flex: 1;\n }\n `\n ]\n\n @property({ type: Object }) gristConfig: any\n @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() { return { title: i18next.t('title.calendar list'),\n search: { handler: (search: string) => { this.grist.searchText = search\n },\n value: this.grist?.searchText || '',\n autofocus: true\n },\n filter: { handler: () => { this.grist.toggleHeadroom()\n }\n },\n help: 'calendar/calendar',\n actions: [\n { title: i18next.t('button.save'),\n action: this._updateCalendar.bind(this),\n ...CommonButtonStyles.save\n },\n { title: i18next.t('button.delete'),\n action: this._deleteCalendar.bind(this),\n ...CommonButtonStyles.delete\n }\n ],\n exportable: { name: i18next.t('title.calendar list'),\n data: this.exportHandler.bind(this)\n }\n }\n }\n\n render() { const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist class=\"page-fill\" .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form without-search autofocus></ox-filters-form>\n\n <div id=\"modes\">\n <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</md-icon>\n <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>format_list_bulleted</md-icon>\n <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>\n </div>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) { this.gristConfig = { list: { fields: ['name', 'description'],\n details: ['active', 'updatedAt']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n /*\n * A calendar's days are its events - opened from its row, so which days a calendar holds is one click away. A\n * days-off calendar's days are written there as days off; the others are read on the event list.\n */\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'event_note',\n title: i18next.t('button.calendar-events'),\n handlers: {\n click: (_columns: any, _data: any, _column: any, record: any) => {\n if (record?.id) navigate(record.kind === 'DAYS_OFF' ? `calendar-days-off?calendar=${record.id}` : `event-list?calendar=${record.id}`)\n }\n }\n },\n { type: 'string',\n name: 'name',\n header: i18next.t('field.name'),\n record: { editable: true\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n { type: 'string',\n name: 'description',\n header: i18next.t('field.description'),\n record: { editable: true\n },\n filter: 'search',\n width: 200\n },\n { type: 'select',\n name: 'kind',\n header: i18next.t('field.calendar-kind'),\n record: { editable: true,\n hint: i18next.t('text.calendar-kind-hint'),\n options: ['GENERAL', 'DAYS_OFF', 'PUBLIC_HOLIDAYS'].map(value => ({ display: i18next.t(`text.calendar-kind-${value.toLowerCase().replace(/_/g, '-')}`), value }))\n },\n filter: true,\n sortable: true,\n width: 110\n },\n { type: 'checkbox',\n name: 'active',\n label: true,\n header: i18next.t('field.active'),\n record: { editable: true\n },\n filter: true,\n sortable: true,\n width: 60\n },\n { type: 'resource-object',\n name: 'updater',\n header: i18next.t('field.updater'),\n record: { editable: false\n },\n sortable: true,\n width: 120\n },\n { type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: { editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: { selectable: { multiple: true\n }\n },\n sorters: [\n { name: 'name'\n }\n ]\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) { if (this.active) { // do something here when this page just became as active\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) { const response = await client.query({ query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) { responses: calendars(filters: $filters, pagination: $pagination, sortings: $sortings) { items { id\n name\n description\n kind\n active\n updater { id\n name\n }\n updatedAt\n }\n total\n }\n }\n `,\n variables: { filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n return { total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n\n async _deleteCalendar() { if (await sureToDelete()) { const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) { const response = await client.mutate({ mutation: gql`\n mutation ($ids: [String!]!) { deleteCalendars(ids: $ids)\n }\n `,\n variables: { ids\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n notify({ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n async _updateCalendar() { let patches = this.grist.dirtyRecords\n if (patches && patches.length) { patches = patches.map(patch => { let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) { patchField[key] = dirtyFields[key].after\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({ mutation: gql`\n mutation ($patches: [CalendarPatch!]!) { updateMultipleCalendar(patches: $patches) { name\n }\n }\n `,\n variables: { patches\n }\n })\n\n if (!response.errors) { this.grist.fetch()\n }\n }\n }\n\n async exportHandler() { const exportTargets = this.grist.selected.length ? this.grist.selected : this.grist.dirtyData.records\n const targetFieldSet = new Set(['id', 'name', 'description', 'kind', 'active'])\n\n return exportTargets.map(calendar => { let tempObj = {}\n for (const field of targetFieldSet) { tempObj[field] = calendar[field]\n }\n\n return tempObj\n })\n }\n}\n"]}
|
|
@@ -11,7 +11,10 @@ export declare class EventListPage extends EventListPage_base {
|
|
|
11
11
|
gristConfig: any;
|
|
12
12
|
mode: 'CARD' | 'GRID' | 'LIST';
|
|
13
13
|
private grist;
|
|
14
|
+
private calendarId;
|
|
15
|
+
private calendars;
|
|
14
16
|
get context(): {
|
|
17
|
+
menu?: string | undefined;
|
|
15
18
|
title: string;
|
|
16
19
|
search: {
|
|
17
20
|
handler: (search: string) => void;
|
|
@@ -25,6 +28,7 @@ export declare class EventListPage extends EventListPage_base {
|
|
|
25
28
|
};
|
|
26
29
|
render(): import("lit-html").TemplateResult<1>;
|
|
27
30
|
pageInitialized(lifecycle: any): Promise<void>;
|
|
31
|
+
pageUpdated(changes: any, lifecycle: any): Promise<void>;
|
|
28
32
|
fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
|
|
29
33
|
total: any;
|
|
30
34
|
records: any;
|
|
@@ -3,7 +3,7 @@ import '@operato/data-grist';
|
|
|
3
3
|
import { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles';
|
|
4
4
|
import { PageView } from '@operato/shell';
|
|
5
5
|
import { css, html } from 'lit';
|
|
6
|
-
import { customElement, property, query } from 'lit/decorators.js';
|
|
6
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
7
7
|
import { DataGrist } from '@operato/data-grist';
|
|
8
8
|
import { client } from '@operato/graphql';
|
|
9
9
|
import { i18next, localize } from '@operato/i18n';
|
|
@@ -17,6 +17,9 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
|
|
|
17
17
|
constructor() {
|
|
18
18
|
super(...arguments);
|
|
19
19
|
this.mode = isMobileDevice() ? 'CARD' : 'GRID';
|
|
20
|
+
/* The calendar whose events are shown, when opened from a calendar's row (`event-list?calendar=<id>`). */
|
|
21
|
+
this.calendarId = '';
|
|
22
|
+
this.calendars = [];
|
|
20
23
|
}
|
|
21
24
|
static { this.styles = [
|
|
22
25
|
/* The work surface frame for a list screen (ADR-0060 decision 8). */
|
|
@@ -31,8 +34,9 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
|
|
|
31
34
|
`
|
|
32
35
|
]; }
|
|
33
36
|
get context() {
|
|
37
|
+
const calendar = this.calendars.find(one => one.id === this.calendarId);
|
|
34
38
|
return {
|
|
35
|
-
title: i18next.t('title.event list'),
|
|
39
|
+
title: calendar ? `${i18next.t('title.event list')} · ${calendar.name}` : i18next.t('title.event list'),
|
|
36
40
|
search: {
|
|
37
41
|
handler: (search) => {
|
|
38
42
|
this.grist.searchText = search;
|
|
@@ -45,7 +49,9 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
|
|
|
45
49
|
this.grist.toggleHeadroom();
|
|
46
50
|
}
|
|
47
51
|
},
|
|
48
|
-
help: 'calendar/event'
|
|
52
|
+
help: 'calendar/event',
|
|
53
|
+
/* Opened from a calendar's row, the menu marks the calendars - the page is that calendar's detail. */
|
|
54
|
+
...(calendar ? { menu: 'calendar-list' } : {})
|
|
49
55
|
};
|
|
50
56
|
}
|
|
51
57
|
render() {
|
|
@@ -61,6 +67,21 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
|
|
|
61
67
|
`;
|
|
62
68
|
}
|
|
63
69
|
async pageInitialized(lifecycle) {
|
|
70
|
+
const response = await client.query({
|
|
71
|
+
query: gql `
|
|
72
|
+
query {
|
|
73
|
+
calendars(sortings: [{ name: "name" }]) {
|
|
74
|
+
items {
|
|
75
|
+
id
|
|
76
|
+
name
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`
|
|
81
|
+
});
|
|
82
|
+
this.calendars = response.data?.calendars?.items || [];
|
|
83
|
+
this.calendarId = lifecycle?.params?.calendar || '';
|
|
84
|
+
this.updateContext();
|
|
64
85
|
this.gristConfig = {
|
|
65
86
|
list: {
|
|
66
87
|
fields: ['name', 'startAt'],
|
|
@@ -69,7 +90,16 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
|
|
|
69
90
|
columns: [
|
|
70
91
|
{ type: 'gutter', gutterName: 'sequence' },
|
|
71
92
|
{ type: 'string', name: 'name', header: i18next.t('field.name'), filter: 'search', sortable: true, width: 200 },
|
|
72
|
-
|
|
93
|
+
/* Which calendar an event is of - a holiday counts as a day off only on a calendar of days off or public holidays. */
|
|
94
|
+
{
|
|
95
|
+
type: 'select',
|
|
96
|
+
name: 'calendarId',
|
|
97
|
+
header: i18next.t('field.calendar'),
|
|
98
|
+
record: { options: [{ display: '', value: '' }, ...this.calendars.map(one => ({ display: one.name, value: one.id }))] },
|
|
99
|
+
filter: true,
|
|
100
|
+
width: 140
|
|
101
|
+
},
|
|
102
|
+
{ type: 'datetime', name: 'startAt', header: i18next.t('field.start_at'), sortable: true, width: 180 },
|
|
73
103
|
{ type: 'datetime', name: 'endAt', header: i18next.t('field.end_at'), sortable: true, width: 180 },
|
|
74
104
|
{
|
|
75
105
|
type: 'select',
|
|
@@ -95,7 +125,21 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
|
|
|
95
125
|
sorters: [{ name: 'startAt' }]
|
|
96
126
|
};
|
|
97
127
|
}
|
|
128
|
+
async pageUpdated(changes, lifecycle) {
|
|
129
|
+
if (!this.active || !changes.params)
|
|
130
|
+
return;
|
|
131
|
+
const calendarId = lifecycle?.params?.calendar || '';
|
|
132
|
+
if (calendarId === this.calendarId)
|
|
133
|
+
return;
|
|
134
|
+
this.calendarId = calendarId;
|
|
135
|
+
this.updateContext();
|
|
136
|
+
this.grist?.fetch();
|
|
137
|
+
}
|
|
98
138
|
async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
|
|
139
|
+
/* The calendar the page was opened for, unless the filter form names one. */
|
|
140
|
+
if (this.calendarId && !filters.some(one => one.name === 'calendarId')) {
|
|
141
|
+
filters = [...filters, { name: 'calendarId', operator: 'eq', value: this.calendarId }];
|
|
142
|
+
}
|
|
99
143
|
const response = await client.query({
|
|
100
144
|
query: gql `
|
|
101
145
|
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
@@ -107,6 +151,7 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
|
|
|
107
151
|
endAt
|
|
108
152
|
status
|
|
109
153
|
location
|
|
154
|
+
calendarId
|
|
110
155
|
series {
|
|
111
156
|
id
|
|
112
157
|
name
|
|
@@ -142,8 +187,18 @@ __decorate([
|
|
|
142
187
|
], EventListPage.prototype, "mode", void 0);
|
|
143
188
|
__decorate([
|
|
144
189
|
query('ox-grist'),
|
|
145
|
-
__metadata("design:type", DataGrist
|
|
190
|
+
__metadata("design:type", DataGrist
|
|
191
|
+
/* The calendar whose events are shown, when opened from a calendar's row (`event-list?calendar=<id>`). */
|
|
192
|
+
)
|
|
146
193
|
], EventListPage.prototype, "grist", void 0);
|
|
194
|
+
__decorate([
|
|
195
|
+
state(),
|
|
196
|
+
__metadata("design:type", Object)
|
|
197
|
+
], EventListPage.prototype, "calendarId", void 0);
|
|
198
|
+
__decorate([
|
|
199
|
+
state(),
|
|
200
|
+
__metadata("design:type", Array)
|
|
201
|
+
], EventListPage.prototype, "calendars", void 0);
|
|
147
202
|
EventListPage = __decorate([
|
|
148
203
|
customElement('event-list-page')
|
|
149
204
|
], EventListPage);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-list-page.js","sourceRoot":"","sources":["../../../client/pages/event/event-list-page.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAC/G,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAA;AAC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,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE;SAC7C,CAAA;IACH,CAAC;;AA9G2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2CAAoE;AAEpE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;4CAAA;AAjBjC,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CA6HzB","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { PageView } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { isMobileDevice } from '@operato/utils'\n\nimport gql from 'graphql-tag'\n\n/**\n * The events of the domain, one-off and occurrences of series alike. Read only: an event's time and status change by\n * postponing, cancelling or holding it, and an application (Office's meeting sessions) does that in its own screens.\n */\n@customElement('event-list-page')\nexport class EventListPage extends localize(i18next)(PageView) {\n static styles = [\n /* The work surface frame for a list screen (ADR-0060 decision 8). */\n WorkSurfacePageStyles,\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n ox-filters-form {\n flex: 1;\n }\n `\n ]\n\n @property({ type: Object }) gristConfig: any\n @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n\n @query('ox-grist') private grist!: DataGrist\n\n get context() {\n return {\n title: i18next.t('title.event list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || '',\n autofocus: true\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'calendar/event'\n }\n }\n\n render() {\n const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist class=\"page-fill\" .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form without-search autofocus></ox-filters-form>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) {\n this.gristConfig = {\n list: {\n fields: ['name', 'startAt'],\n details: ['status', 'location']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'string', name: 'name', header: i18next.t('field.name'), filter: 'search', sortable: true, width: 200 },\n { type: 'datetime', name: 'startAt', header: i18next.t('field.start_at'), filter: true, sortable: true, width: 180 },\n { type: 'datetime', name: 'endAt', header: i18next.t('field.end_at'), sortable: true, width: 180 },\n {\n type: 'select',\n name: 'status',\n header: i18next.t('field.status'),\n record: {\n options: ['', 'SCHEDULED', 'POSTPONED', 'CANCELLED', 'HELD'].map(value => ({\n display: value ? i18next.t(`label.event-status.${value}`) : '',\n value\n }))\n },\n filter: true,\n sortable: true,\n width: 100\n },\n { type: 'string', name: 'location', header: i18next.t('field.location'), filter: 'search', width: 160 },\n { type: 'resource-object', name: 'series', header: i18next.t('field.event-series'), width: 160 },\n { type: 'resource-object', name: 'organizer', header: i18next.t('field.organizer'), width: 120 }\n ],\n rows: {\n selectable: false\n },\n sorters: [{ name: 'startAt' }]\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n responses: events(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n startAt\n endAt\n status\n location\n series {\n id\n name\n }\n organizer {\n id\n name\n }\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n return {\n total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n}\n"]}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B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;2CAAoE;AAEpE;IAA1B,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;IAE5C,0GAA0G;;4CAF9D;AAG3B;IAAhB,KAAK,EAAE;;iDAAwB;AACf;IAAhB,KAAK,EAAE;;gDAAuD;AArBpD,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CA4KzB","sourcesContent":["import '@operato/data-grist'\n\nimport { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles'\nimport { PageView } from '@operato/shell'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { DataGrist, FetchOption } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { isMobileDevice } from '@operato/utils'\n\nimport gql from 'graphql-tag'\n\n/**\n * The events of the domain, one-off and occurrences of series alike. Read only: an event's time and status change by\n * postponing, cancelling or holding it, and an application (Office's meeting sessions) does that in its own screens.\n */\n@customElement('event-list-page')\nexport class EventListPage extends localize(i18next)(PageView) {\n static styles = [\n /* The work surface frame for a list screen (ADR-0060 decision 8). */\n WorkSurfacePageStyles,\n ScrollbarStyles,\n CommonGristStyles,\n CommonHeaderStyles,\n css`\n ox-filters-form {\n flex: 1;\n }\n `\n ]\n\n @property({ type: Object }) gristConfig: any\n @property({ type: String }) mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n\n @query('ox-grist') private grist!: DataGrist\n\n /* The calendar whose events are shown, when opened from a calendar's row (`event-list?calendar=<id>`). */\n @state() private calendarId = ''\n @state() private calendars: { id: string; name: string }[] = []\n\n get context() {\n const calendar = this.calendars.find(one => one.id === this.calendarId)\n return {\n title: calendar ? `${i18next.t('title.event list')} · ${calendar.name}` : i18next.t('title.event list'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || '',\n autofocus: true\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n help: 'calendar/event',\n /* Opened from a calendar's row, the menu marks the calendars - the page is that calendar's detail. */\n ...(calendar ? { menu: 'calendar-list' } : {})\n }\n }\n\n render() {\n const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist class=\"page-fill\" .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>\n <div slot=\"headroom\" class=\"header\">\n <div class=\"filters\">\n <ox-filters-form without-search autofocus></ox-filters-form>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle: any) {\n const response = await client.query({\n query: gql`\n query {\n calendars(sortings: [{ name: \"name\" }]) {\n items {\n id\n name\n }\n }\n }\n `\n })\n this.calendars = response.data?.calendars?.items || []\n this.calendarId = lifecycle?.params?.calendar || ''\n this.updateContext()\n\n this.gristConfig = {\n list: {\n fields: ['name', 'startAt'],\n details: ['status', 'location']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'string', name: 'name', header: i18next.t('field.name'), filter: 'search', sortable: true, width: 200 },\n /* Which calendar an event is of - a holiday counts as a day off only on a calendar of days off or public holidays. */\n {\n type: 'select',\n name: 'calendarId',\n header: i18next.t('field.calendar'),\n record: { options: [{ display: '', value: '' }, ...this.calendars.map(one => ({ display: one.name, value: one.id }))] },\n filter: true,\n width: 140\n },\n { type: 'datetime', name: 'startAt', header: i18next.t('field.start_at'), sortable: true, width: 180 },\n { type: 'datetime', name: 'endAt', header: i18next.t('field.end_at'), sortable: true, width: 180 },\n {\n type: 'select',\n name: 'status',\n header: i18next.t('field.status'),\n record: {\n options: ['', 'SCHEDULED', 'POSTPONED', 'CANCELLED', 'HELD'].map(value => ({\n display: value ? i18next.t(`label.event-status.${value}`) : '',\n value\n }))\n },\n filter: true,\n sortable: true,\n width: 100\n },\n { type: 'string', name: 'location', header: i18next.t('field.location'), filter: 'search', width: 160 },\n { type: 'resource-object', name: 'series', header: i18next.t('field.event-series'), width: 160 },\n { type: 'resource-object', name: 'organizer', header: i18next.t('field.organizer'), width: 120 }\n ],\n rows: {\n selectable: false\n },\n sorters: [{ name: 'startAt' }]\n }\n }\n\n async pageUpdated(changes: any, lifecycle: any) {\n if (!this.active || !changes.params) return\n const calendarId = lifecycle?.params?.calendar || ''\n if (calendarId === this.calendarId) return\n this.calendarId = calendarId\n this.updateContext()\n this.grist?.fetch()\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n /* The calendar the page was opened for, unless the filter form names one. */\n if (this.calendarId && !filters.some(one => one.name === 'calendarId')) {\n filters = [...filters, { name: 'calendarId', operator: 'eq', value: this.calendarId }]\n }\n\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n responses: events(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n startAt\n endAt\n status\n location\n calendarId\n series {\n id\n name\n }\n organizer {\n id\n name\n }\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n return {\n total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sureToDelete: () => Promise<boolean>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { i18next } from '@operato/i18n';
|
|
2
|
+
import { OxPrompt } from '@operato/popup';
|
|
3
|
+
/* The framework's confirmation - a browser's own confirm() can be suppressed, and then nothing is deleted with no word. */
|
|
4
|
+
export const sureToDelete = () => OxPrompt.open({
|
|
5
|
+
title: i18next.t('text.are_you_sure'),
|
|
6
|
+
text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
|
|
7
|
+
confirmButton: { text: i18next.t('button.confirm') },
|
|
8
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=sure-to-delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sure-to-delete.js","sourceRoot":"","sources":["../../client/pages/sure-to-delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,2HAA2H;AAC3H,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAC/B,QAAQ,CAAC,IAAI,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC;IACrC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC;IAClE,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAE;IACpD,YAAY,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE;CACnD,CAAC,CAAA","sourcesContent":["import { i18next } from '@operato/i18n'\nimport { OxPrompt } from '@operato/popup'\n\n/* The framework's confirmation - a browser's own confirm() can be suppressed, and then nothing is deleted with no word. */\nexport const sureToDelete = () =>\n OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n"]}
|
package/dist-client/route.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function route(page: string): "calendar" | "calendar-
|
|
1
|
+
export default function route(page: string): "calendar-list" | "calendar" | "calendar-days-off" | "event-list" | undefined;
|
package/dist-client/route.js
CHANGED
|
@@ -6,6 +6,9 @@ export default function route(page) {
|
|
|
6
6
|
case 'calendar-list':
|
|
7
7
|
import('./pages/calendar/calendar-list-page');
|
|
8
8
|
return page;
|
|
9
|
+
case 'calendar-days-off':
|
|
10
|
+
import('./pages/calendar/calendar-days-off-page');
|
|
11
|
+
return page;
|
|
9
12
|
case 'event-list':
|
|
10
13
|
import('./pages/event/event-list-page');
|
|
11
14
|
return page;
|