@things-factory/calendar 10.1.296 → 10.1.298

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.
@@ -129,12 +129,20 @@ let CalendarListPage = class CalendarListPage extends localize(i18next)(PageView
129
129
  header: i18next.t('field.calendar-kind'),
130
130
  record: { editable: true,
131
131
  hint: i18next.t('text.calendar-kind-hint'),
132
- options: ['GENERAL', 'DAYS_OFF', 'PUBLIC_HOLIDAYS'].map(value => ({ display: i18next.t(`text.calendar-kind-${value.toLowerCase().replace(/_/g, '-')}`), value }))
132
+ options: ['GENERAL', 'DAYS_OFF', 'PUBLIC_HOLIDAYS', 'RECORD'].map(value => ({ display: i18next.t(`text.calendar-kind-${value.toLowerCase().replace(/_/g, '-')}`), value }))
133
133
  },
134
134
  filter: true,
135
135
  sortable: true,
136
136
  width: 110
137
137
  },
138
+ /* What the import from Teams or Outlook leaves out - taken off on the calendar's events. */
139
+ {
140
+ type: 'string',
141
+ name: 'importExcludes',
142
+ header: i18next.t('field.import-excludes'),
143
+ record: { editable: false, renderer: (value) => (value ?? []).join(', ') },
144
+ width: 200
145
+ },
138
146
  { type: 'checkbox',
139
147
  name: 'active',
140
148
  label: true,
@@ -184,6 +192,7 @@ let CalendarListPage = class CalendarListPage extends localize(i18next)(PageView
184
192
  description
185
193
  kind
186
194
  active
195
+ importExcludes
187
196
  updater { id
188
197
  name
189
198
  }
@@ -1,10 +1,14 @@
1
1
  import '@operato/data-grist';
2
+ import '@things-factory/ai-assistant/dist-client/index.js';
2
3
  import { PageView } from '@operato/shell';
3
4
  import { FetchOption } from '@operato/data-grist';
4
5
  declare const EventListPage_base: (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
5
6
  /**
6
7
  * The events of the domain, one-off and occurrences of series alike. Read only: an event's time and status change by
7
8
  * postponing, cancelling or holding it, and an application (Office's meeting sessions) does that in its own screens.
9
+ *
10
+ * An event brought in from Teams or Outlook can be left out of the import by its name - every occurrence of a recurring
11
+ * meeting - from the selection bar; the calendar's left-out names show over the list, each taken off with one click.
8
12
  */
9
13
  export declare class EventListPage extends EventListPage_base {
10
14
  static styles: import("lit").CSSResult[];
@@ -27,11 +31,16 @@ export declare class EventListPage extends EventListPage_base {
27
31
  help: string;
28
32
  };
29
33
  render(): import("lit-html").TemplateResult<1>;
34
+ private _fetchCalendars;
30
35
  pageInitialized(lifecycle: any): Promise<void>;
31
36
  pageUpdated(changes: any, lifecycle: any): Promise<void>;
32
37
  fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
33
38
  total: any;
34
39
  records: any;
35
40
  }>;
41
+ /** Leaves the names of the picked events brought in from another calendar out of their calendar's import. */
42
+ private _excludeFromImport;
43
+ /** Brings a left-out name in again - the next reading adds its events. */
44
+ private _includeInImport;
36
45
  }
37
46
  export {};
@@ -1,5 +1,6 @@
1
1
  import { __decorate, __metadata } from "tslib";
2
2
  import '@operato/data-grist';
3
+ import '@things-factory/ai-assistant/dist-client/index.js';
3
4
  import { CommonGristStyles, CommonHeaderStyles, ScrollbarStyles, WorkSurfacePageStyles } from '@operato/styles';
4
5
  import { PageView } from '@operato/shell';
5
6
  import { css, html } from 'lit';
@@ -7,11 +8,16 @@ import { customElement, property, query, state } from 'lit/decorators.js';
7
8
  import { DataGrist } from '@operato/data-grist';
8
9
  import { client } from '@operato/graphql';
9
10
  import { i18next, localize } from '@operato/i18n';
11
+ import { notify } from '@operato/layout';
12
+ import { OxPrompt } from '@operato/popup';
10
13
  import { isMobileDevice } from '@operato/utils';
11
14
  import gql from 'graphql-tag';
12
15
  /**
13
16
  * The events of the domain, one-off and occurrences of series alike. Read only: an event's time and status change by
14
17
  * postponing, cancelling or holding it, and an application (Office's meeting sessions) does that in its own screens.
18
+ *
19
+ * An event brought in from Teams or Outlook can be left out of the import by its name - every occurrence of a recurring
20
+ * meeting - from the selection bar; the calendar's left-out names show over the list, each taken off with one click.
15
21
  */
16
22
  let EventListPage = class EventListPage extends localize(i18next)(PageView) {
17
23
  constructor() {
@@ -31,6 +37,33 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
31
37
  ox-filters-form {
32
38
  flex: 1;
33
39
  }
40
+
41
+ .excludes {
42
+ display: flex;
43
+ flex-wrap: wrap;
44
+ align-items: center;
45
+ gap: var(--spacing-small, 4px);
46
+ padding: var(--spacing-small, 4px) var(--spacing-medium, 8px);
47
+ font-size: var(--fontsize-small, 0.8rem);
48
+ color: var(--md-sys-color-on-surface-variant);
49
+ }
50
+
51
+ .excludes button {
52
+ display: inline-flex;
53
+ align-items: center;
54
+ gap: 2px;
55
+ border: 1px solid var(--md-sys-color-outline-variant);
56
+ border-radius: 999px;
57
+ background: transparent;
58
+ color: var(--md-sys-color-on-surface);
59
+ font: inherit;
60
+ padding: 0 4px 0 8px;
61
+ cursor: pointer;
62
+ }
63
+
64
+ .excludes md-icon {
65
+ --md-icon-size: 14px;
66
+ }
34
67
  `
35
68
  ]; }
36
69
  get context() {
@@ -56,7 +89,23 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
56
89
  }
57
90
  render() {
58
91
  const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
92
+ const calendar = this.calendars.find(one => one.id === this.calendarId);
93
+ const excludes = calendar?.importExcludes ?? [];
59
94
  return html `
95
+ <ox-assistant-selection-bar
96
+ .gridOf=${() => this.grist}
97
+ name=${i18next.t('title.event list')}
98
+ .assistant=${false}
99
+ .actions=${[{ id: 'exclude-from-import', title: i18next.t('button.exclude-from-import'), icon: 'event_busy', action: () => this._excludeFromImport() }]}
100
+ ></ox-assistant-selection-bar>
101
+ ${excludes.length
102
+ ? html `<div class="excludes">
103
+ <span>${i18next.t('field.import-excludes')}</span>
104
+ ${excludes.map(name => html `<button title=${i18next.t('button.include-in-import')} @click=${() => this._includeInImport(calendar.id, name)}>
105
+ ${name}<md-icon>close</md-icon>
106
+ </button>`)}
107
+ </div>`
108
+ : ''}
60
109
  <ox-grist class="page-fill" .mode=${mode} .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
61
110
  <div slot="headroom" class="header">
62
111
  <div class="filters">
@@ -66,7 +115,7 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
66
115
  </ox-grist>
67
116
  `;
68
117
  }
69
- async pageInitialized(lifecycle) {
118
+ async _fetchCalendars() {
70
119
  const response = await client.query({
71
120
  query: gql `
72
121
  query {
@@ -74,12 +123,16 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
74
123
  items {
75
124
  id
76
125
  name
126
+ importExcludes
77
127
  }
78
128
  }
79
129
  }
80
130
  `
81
131
  });
82
132
  this.calendars = response.data?.calendars?.items || [];
133
+ }
134
+ async pageInitialized(lifecycle) {
135
+ await this._fetchCalendars();
83
136
  this.calendarId = lifecycle?.params?.calendar || '';
84
137
  this.updateContext();
85
138
  this.gristConfig = {
@@ -89,6 +142,7 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
89
142
  },
90
143
  columns: [
91
144
  { type: 'gutter', gutterName: 'sequence' },
145
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
92
146
  { type: 'string', name: 'name', header: i18next.t('field.name'), filter: 'search', sortable: true, width: 200 },
93
147
  /* Which calendar an event is of - a holiday counts as a day off only on a calendar of days off or public holidays. */
94
148
  {
@@ -128,7 +182,7 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
128
182
  }
129
183
  ],
130
184
  rows: {
131
- selectable: false
185
+ selectable: { multiple: true }
132
186
  },
133
187
  sorters: [{ name: 'startAt' }]
134
188
  };
@@ -169,6 +223,7 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
169
223
  name
170
224
  }
171
225
  sourceMailboxes
226
+ source
172
227
  }
173
228
  total
174
229
  }
@@ -185,6 +240,64 @@ let EventListPage = class EventListPage extends localize(i18next)(PageView) {
185
240
  records: response.data.responses.items || []
186
241
  };
187
242
  }
243
+ /** Leaves the names of the picked events brought in from another calendar out of their calendar's import. */
244
+ async _excludeFromImport() {
245
+ const picked = new Map();
246
+ for (const one of this.grist.selected ?? []) {
247
+ if (!one.source || !one.calendarId)
248
+ continue;
249
+ const key = `${one.calendarId}:${String(one.name).trim().toLowerCase()}`;
250
+ if (!picked.has(key))
251
+ picked.set(key, { calendarId: one.calendarId, name: String(one.name).trim() });
252
+ }
253
+ if (!picked.size) {
254
+ notify({ level: 'info', message: i18next.t('text.select-imported-events') });
255
+ return;
256
+ }
257
+ const names = [...new Set([...picked.values()].map(one => one.name))];
258
+ const sure = await OxPrompt.open({
259
+ title: i18next.t('button.exclude-from-import'),
260
+ text: i18next.t('text.sure-to-exclude-from-import', { names: names.join(', ') }),
261
+ confirmButton: { text: i18next.t('button.confirm') },
262
+ cancelButton: { text: i18next.t('button.cancel') }
263
+ });
264
+ if (!sure)
265
+ return;
266
+ for (const one of picked.values()) {
267
+ const response = await client.mutate({
268
+ mutation: gql `
269
+ mutation ($calendarId: String!, $name: String!) {
270
+ excludeEventFromImport(calendarId: $calendarId, name: $name) {
271
+ id
272
+ }
273
+ }
274
+ `,
275
+ variables: one
276
+ });
277
+ if (response.errors)
278
+ return;
279
+ }
280
+ await this._fetchCalendars();
281
+ this.grist.fetch();
282
+ notify({ message: i18next.t('text.excluded-from-import', { names: names.join(', ') }) });
283
+ }
284
+ /** Brings a left-out name in again - the next reading adds its events. */
285
+ async _includeInImport(calendarId, name) {
286
+ const response = await client.mutate({
287
+ mutation: gql `
288
+ mutation ($calendarId: String!, $name: String!) {
289
+ includeEventInImport(calendarId: $calendarId, name: $name) {
290
+ id
291
+ }
292
+ }
293
+ `,
294
+ variables: { calendarId, name }
295
+ });
296
+ if (response.errors)
297
+ return;
298
+ await this._fetchCalendars();
299
+ notify({ message: i18next.t('text.included-in-import', { name }) });
300
+ }
188
301
  };
189
302
  __decorate([
190
303
  property({ type: Object }),
@@ -5,4 +5,6 @@ export declare class CalendarMutation {
5
5
  updateCalendar(id: string, patch: CalendarPatch, context: ResolverContext): Promise<Calendar>;
6
6
  updateMultipleCalendar(patches: CalendarPatch[], context: ResolverContext): Promise<Calendar[]>;
7
7
  deleteCalendars(ids: string[], context: ResolverContext): Promise<boolean>;
8
+ excludeEventFromImport(calendarId: string, name: string, context: ResolverContext): Promise<Calendar>;
9
+ includeEventInImport(calendarId: string, name: string, context: ResolverContext): Promise<Calendar>;
8
10
  }
@@ -7,6 +7,7 @@ const shell_1 = require("@things-factory/shell");
7
7
  const calendar_1 = require("./calendar");
8
8
  const calendar_service_1 = require("./calendar-service");
9
9
  const calendar_type_1 = require("./calendar-type");
10
+ const event_import_1 = require("../event/event-import");
10
11
  let CalendarMutation = class CalendarMutation {
11
12
  createCalendar(calendar, context) {
12
13
  const { domain, user, tx } = context.state;
@@ -32,6 +33,14 @@ let CalendarMutation = class CalendarMutation {
32
33
  const { domain, user, tx } = context.state;
33
34
  return (0, calendar_service_1.deleteCalendars)(tx, domain, user, ids);
34
35
  }
36
+ excludeEventFromImport(calendarId, name, context) {
37
+ const { domain, user, tx } = context.state;
38
+ return (0, event_import_1.excludeFromImport)(tx, domain, user, calendarId, name);
39
+ }
40
+ includeEventInImport(calendarId, name, context) {
41
+ const { domain, user, tx } = context.state;
42
+ return (0, event_import_1.includeInImport)(tx, domain, user, calendarId, name);
43
+ }
35
44
  };
36
45
  exports.CalendarMutation = CalendarMutation;
37
46
  tslib_1.__decorate([
@@ -75,6 +84,28 @@ tslib_1.__decorate([
75
84
  tslib_1.__metadata("design:paramtypes", [Array, Object]),
76
85
  tslib_1.__metadata("design:returntype", Promise)
77
86
  ], CalendarMutation.prototype, "deleteCalendars", null);
87
+ tslib_1.__decorate([
88
+ (0, type_graphql_1.Directive)('@transaction'),
89
+ (0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "mutation", domainOwnerGranted: true)'),
90
+ (0, type_graphql_1.Mutation)(returns => calendar_1.Calendar, { description: 'To leave events of a name out of what is brought in onto a calendar; those already brought in on it are deleted' }),
91
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('calendarId', { description: 'Id of the calendar' })),
92
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('name', { description: 'Name of the events, matched trimmed and without case' })),
93
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
94
+ tslib_1.__metadata("design:type", Function),
95
+ tslib_1.__metadata("design:paramtypes", [String, String, Object]),
96
+ tslib_1.__metadata("design:returntype", Promise)
97
+ ], CalendarMutation.prototype, "excludeEventFromImport", null);
98
+ tslib_1.__decorate([
99
+ (0, type_graphql_1.Directive)('@transaction'),
100
+ (0, type_graphql_1.Directive)('@privilege(category: "calendar", privilege: "mutation", domainOwnerGranted: true)'),
101
+ (0, type_graphql_1.Mutation)(returns => calendar_1.Calendar, { description: 'To bring events of a name in again onto a calendar, from the next reading' }),
102
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('calendarId', { description: 'Id of the calendar' })),
103
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('name', { description: 'Name of the events left out' })),
104
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
105
+ tslib_1.__metadata("design:type", Function),
106
+ tslib_1.__metadata("design:paramtypes", [String, String, Object]),
107
+ tslib_1.__metadata("design:returntype", Promise)
108
+ ], CalendarMutation.prototype, "includeEventInImport", null);
78
109
  exports.CalendarMutation = CalendarMutation = tslib_1.__decorate([
79
110
  (0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals),
80
111
  (0, type_graphql_1.Resolver)(calendar_1.Calendar)
@@ -60,7 +60,7 @@ async function deleteCalendars(tx, domain, user, ids) {
60
60
  /** The public holidays are one calendar of a domain, the one the import fills. */
61
61
  async function checkCalendarKind(tx, domain, kind, id) {
62
62
  if (!Object.values(calendar_1.CalendarKind).includes(kind))
63
- throw new shell_1.Refusal('calendar-kind-invalid', { kind: String(kind) }, 'Choose general, days off or public holidays');
63
+ throw new shell_1.Refusal('calendar-kind-invalid', { kind: String(kind) }, 'Choose general, days off, public holidays or work records');
64
64
  if (kind === calendar_1.CalendarKind.PUBLIC_HOLIDAYS) {
65
65
  const other = await tx.getRepository(calendar_1.Calendar).findOne({ where: { domain: { id: domain.id }, kind, ...(id ? { id: (0, typeorm_1.Not)(id) } : {}) } });
66
66
  if (other)
@@ -4,7 +4,8 @@ import { User } from '@things-factory/auth-base';
4
4
  export declare enum CalendarKind {
5
5
  GENERAL = "GENERAL",
6
6
  DAYS_OFF = "DAYS_OFF",
7
- PUBLIC_HOLIDAYS = "PUBLIC_HOLIDAYS"
7
+ PUBLIC_HOLIDAYS = "PUBLIC_HOLIDAYS",
8
+ RECORD = "RECORD"
8
9
  }
9
10
  /**
10
11
  * A named group of events in a domain — "management meetings", "plant holidays". Events and series may belong to
@@ -32,6 +33,11 @@ export declare class Calendar {
32
33
  reason: string | null;
33
34
  }[];
34
35
  } | null;
36
+ /**
37
+ * Names of events not brought in from another calendar onto this one - a recurring meeting of the other calendar that
38
+ * is not this domain's business. Matched trimmed and without case, so every occurrence is covered.
39
+ */
40
+ importExcludes?: string[] | null;
35
41
  createdAt?: Date;
36
42
  updatedAt?: Date;
37
43
  deletedAt?: Date;
@@ -12,6 +12,7 @@ var CalendarKind;
12
12
  CalendarKind["GENERAL"] = "GENERAL";
13
13
  CalendarKind["DAYS_OFF"] = "DAYS_OFF";
14
14
  CalendarKind["PUBLIC_HOLIDAYS"] = "PUBLIC_HOLIDAYS";
15
+ CalendarKind["RECORD"] = "RECORD";
15
16
  })(CalendarKind || (exports.CalendarKind = CalendarKind = {}));
16
17
  (0, type_graphql_1.registerEnumType)(CalendarKind, {
17
18
  name: 'CalendarKind',
@@ -19,7 +20,8 @@ var CalendarKind;
19
20
  valuesConfig: {
20
21
  GENERAL: { description: 'Meetings and happenings; the working days do not change' },
21
22
  DAYS_OFF: { description: "The company's own days off; a day one of its events covers is not a working day" },
22
- PUBLIC_HOLIDAYS: { description: 'The public holidays, one per domain, filled by an import; not working days' }
23
+ PUBLIC_HOLIDAYS: { description: 'The public holidays, one per domain, filled by an import; not working days' },
24
+ RECORD: { description: 'Records of work done elsewhere, such as a work mail; not meetings, and the working days do not change' }
23
25
  }
24
26
  });
25
27
  /**
@@ -68,6 +70,11 @@ tslib_1.__decorate([
68
70
  (0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true, description: 'The last reading brought in: { at, source, read, mailboxes, failed: [{ mailbox, reason }] }' }),
69
71
  tslib_1.__metadata("design:type", Object)
70
72
  ], Calendar.prototype, "lastImport", void 0);
73
+ tslib_1.__decorate([
74
+ (0, typeorm_1.Column)('simple-json', { nullable: true }),
75
+ (0, type_graphql_1.Field)(type => [String], { nullable: true, description: 'Names of events left out when events are brought in from another calendar onto this one' }),
76
+ tslib_1.__metadata("design:type", Array)
77
+ ], Calendar.prototype, "importExcludes", void 0);
71
78
  tslib_1.__decorate([
72
79
  (0, typeorm_1.CreateDateColumn)(),
73
80
  (0, type_graphql_1.Field)({ nullable: true, description: 'Creation timestamp' }),
@@ -1,6 +1,7 @@
1
1
  import { EntityManager } from 'typeorm';
2
2
  import { User } from '@things-factory/auth-base';
3
3
  import { Domain } from '@things-factory/shell';
4
+ import { Calendar } from '../calendar/calendar';
4
5
  export interface ImportedAttendee {
5
6
  email: string;
6
7
  name?: string | null;
@@ -26,6 +27,8 @@ export interface ImportedEvent {
26
27
  /** Every calendar it was read from - mergedReadings gathers them. */
27
28
  mailboxes?: string[];
28
29
  }
30
+ /** How an event's name is compared with the names a calendar leaves out: trimmed, without case. */
31
+ export declare function importNameKey(name: string | null | undefined): string;
29
32
  /**
30
33
  * One event read from several people's calendars is one event: the first reading, with every measured attendance. It
31
34
  * is cancelled when any calendar says so - an attendee's copy of a meeting its organizer cancelled can stay standing.
@@ -64,3 +67,10 @@ export declare function importEvents(tx: EntityManager, domain: Domain, user: Us
64
67
  left: number;
65
68
  cancelled: number;
66
69
  }>;
70
+ /**
71
+ * Leaves the events named `name` out of what is brought in onto the calendar `calendarId`. Those already brought in on it
72
+ * are deleted (soft) - the rest of the calendar, and events made here, stay.
73
+ */
74
+ export declare function excludeFromImport(tx: EntityManager, domain: Domain, user: User, calendarId: string, name: string): Promise<Calendar>;
75
+ /** Brings the events named `name` in again onto the calendar: the next reading adds them. */
76
+ export declare function includeInImport(tx: EntityManager, domain: Domain, user: User, calendarId: string, name: string): Promise<Calendar>;
@@ -1,18 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.importNameKey = importNameKey;
3
4
  exports.mergedReadings = mergedReadings;
4
5
  exports.peopleOf = peopleOf;
5
6
  exports.importEvents = importEvents;
7
+ exports.excludeFromImport = excludeFromImport;
8
+ exports.includeInImport = includeInImport;
6
9
  const typeorm_1 = require("typeorm");
7
10
  const auth_base_1 = require("@things-factory/auth-base");
8
11
  const shell_1 = require("@things-factory/shell");
9
12
  const attendee_1 = require("../attendee/attendee");
10
13
  const attendee_service_1 = require("../attendee/attendee-service");
11
14
  const calendar_1 = require("../calendar/calendar");
15
+ const calendar_service_1 = require("../calendar/calendar-service");
12
16
  const event_1 = require("./event");
13
17
  const event_rules_1 = require("./event-rules");
14
18
  const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
15
19
  const NO_TITLE = '(no title)';
20
+ /** How an event's name is compared with the names a calendar leaves out: trimmed, without case. */
21
+ function importNameKey(name) {
22
+ return String(name ?? '').trim().toLowerCase();
23
+ }
16
24
  /**
17
25
  * One event read from several people's calendars is one event: the first reading, with every measured attendance. It
18
26
  * is cancelled when any calendar says so - an attendee's copy of a meeting its organizer cancelled can stay standing.
@@ -81,7 +89,11 @@ async function importEvents(tx, domain, user, input) {
81
89
  if (!source)
82
90
  throw new shell_1.Refusal('event-import-source-required', {}, 'Name the calendar the events come from');
83
91
  const calendar = await calendarNamed(tx, domain, user, calendarName);
84
- const events = mergedReadings(input.events ?? []);
92
+ const read = mergedReadings(input.events ?? []);
93
+ /* An event of a name the calendar leaves out is not brought in - nor taken as removed by cancelRemoved. */
94
+ const excluded = new Set((calendar.importExcludes ?? []).map(importNameKey).filter(Boolean));
95
+ const skipped = read.filter(one => excluded.has(importNameKey(one.subject)));
96
+ const events = read.filter(one => !excluded.has(importNameKey(one.subject)));
85
97
  /* The domain's users among the addresses, read once. */
86
98
  const addresses = [...new Set(events.flatMap(one => peopleOf(one).map(person => person.email)))];
87
99
  const found = addresses.length ? await tx.getRepository(auth_base_1.User).find({ where: { email: (0, typeorm_1.In)(addresses) } }) : [];
@@ -147,7 +159,7 @@ async function importEvents(tx, domain, user, input) {
147
159
  await tx.getRepository(attendee_1.Attendee).update({ id: row.id }, { ...change, updater: user });
148
160
  }
149
161
  }
150
- const cancelled = input.reading ? await cancelRemoved(tx, domain, user, source, input.reading, new Set(events.map(one => one.id))) : 0;
162
+ const cancelled = input.reading ? await cancelRemoved(tx, domain, user, source, input.reading, new Set(read.map(one => one.id))) : 0;
151
163
  if (input.reading) {
152
164
  const lastImport = {
153
165
  at: new Date().toISOString(),
@@ -158,7 +170,7 @@ async function importEvents(tx, domain, user, input) {
158
170
  };
159
171
  await tx.getRepository(calendar_1.Calendar).update({ id: calendar.id }, { lastImport, updater: user });
160
172
  }
161
- return { created, updated, left, cancelled };
173
+ return { created, updated, left: left + skipped.length, cancelled };
162
174
  }
163
175
  /** The events of `source` in the reading's window, held by a mailbox it read, that it did not find - removed there. */
164
176
  async function cancelRemoved(tx, domain, user, source, reading, found) {
@@ -183,4 +195,33 @@ async function cancelRemoved(tx, domain, user, source, reading, found) {
183
195
  }
184
196
  return cancelled;
185
197
  }
198
+ /**
199
+ * Leaves the events named `name` out of what is brought in onto the calendar `calendarId`. Those already brought in on it
200
+ * are deleted (soft) - the rest of the calendar, and events made here, stay.
201
+ */
202
+ async function excludeFromImport(tx, domain, user, calendarId, name) {
203
+ const calendar = await (0, calendar_service_1.calendarInDomain)(tx, domain, calendarId);
204
+ const key = importNameKey(name);
205
+ if (!key)
206
+ throw new shell_1.Refusal('event-import-exclude-name-required', {}, 'Name the event to leave out');
207
+ const names = calendar.importExcludes ?? [];
208
+ if (!names.some(one => importNameKey(one) === key)) {
209
+ await tx.getRepository(calendar_1.Calendar).update({ id: calendar.id }, { importExcludes: [...names, String(name).trim()], updater: user });
210
+ }
211
+ const brought = await tx.getRepository(event_1.Event).find({ where: { domain: { id: domain.id }, calendar: { id: calendar.id }, source: (0, typeorm_1.Not)((0, typeorm_1.IsNull)()) } });
212
+ const gone = brought.filter(one => importNameKey(one.name) === key).map(one => one.id);
213
+ if (gone.length) {
214
+ await tx.getRepository(event_1.Event).update({ id: (0, typeorm_1.In)(gone) }, { updater: user });
215
+ await tx.getRepository(event_1.Event).softDelete({ id: (0, typeorm_1.In)(gone) });
216
+ }
217
+ return (0, calendar_service_1.calendarInDomain)(tx, domain, calendar.id);
218
+ }
219
+ /** Brings the events named `name` in again onto the calendar: the next reading adds them. */
220
+ async function includeInImport(tx, domain, user, calendarId, name) {
221
+ const calendar = await (0, calendar_service_1.calendarInDomain)(tx, domain, calendarId);
222
+ const key = importNameKey(name);
223
+ const names = (calendar.importExcludes ?? []).filter(one => importNameKey(one) !== key);
224
+ await tx.getRepository(calendar_1.Calendar).update({ id: calendar.id }, { importExcludes: names.length ? names : null, updater: user });
225
+ return (0, calendar_service_1.calendarInDomain)(tx, domain, calendar.id);
226
+ }
186
227
  //# sourceMappingURL=event-import.js.map
@@ -10,11 +10,11 @@ export * from './attendee/attendee-type';
10
10
  export * from './calendar/calendar-service';
11
11
  export * from './calendar/working-days';
12
12
  export * from './event/event-service';
13
- export { importEvents, mergedReadings, peopleOf } from './event/event-import';
13
+ export { excludeFromImport, importEvents, importNameKey, includeInImport, mergedReadings, peopleOf } from './event/event-import';
14
14
  export * from './event-series/event-series-service';
15
15
  export * from './event-series/recurrence';
16
16
  export { attendeesOf } from './attendee/attendee-service';
17
- export declare const entities: (typeof import("./calendar/calendar").Calendar | typeof import("./event-series/event-series").EventSeries | typeof import("./event/event").Event | typeof import("./attendee/attendee").Attendee)[];
17
+ export declare const entities: (typeof import("./calendar/calendar").Calendar | typeof import("./event/event").Event | typeof import("./event-series/event-series").EventSeries | typeof import("./attendee/attendee").Attendee)[];
18
18
  export declare const subscribers: any[];
19
19
  export declare const schema: {
20
20
  resolverClasses: (typeof import("./calendar/calendar-query").CalendarQuery | typeof import("./calendar/calendar-mutation").CalendarMutation | typeof import("./calendar/working-days-resolver").WorkingDaysResolver | typeof import("./event/event-query").EventQuery | typeof import("./event/event-mutation").EventMutation | typeof import("./event-series/event-series-query").EventSeriesQuery | typeof import("./event-series/event-series-mutation").EventSeriesMutation | typeof import("./attendee/attendee-query").AttendeeQuery)[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.schema = exports.subscribers = exports.entities = exports.attendeesOf = exports.peopleOf = exports.mergedReadings = exports.importEvents = void 0;
3
+ exports.schema = exports.subscribers = exports.entities = exports.attendeesOf = exports.peopleOf = exports.mergedReadings = exports.includeInImport = exports.importNameKey = exports.importEvents = exports.excludeFromImport = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  /* EXPORT ENTITY TYPES */
6
6
  tslib_1.__exportStar(require("./calendar/calendar"), exports);
@@ -18,7 +18,10 @@ tslib_1.__exportStar(require("./calendar/calendar-service"), exports);
18
18
  tslib_1.__exportStar(require("./calendar/working-days"), exports);
19
19
  tslib_1.__exportStar(require("./event/event-service"), exports);
20
20
  var event_import_1 = require("./event/event-import");
21
+ Object.defineProperty(exports, "excludeFromImport", { enumerable: true, get: function () { return event_import_1.excludeFromImport; } });
21
22
  Object.defineProperty(exports, "importEvents", { enumerable: true, get: function () { return event_import_1.importEvents; } });
23
+ Object.defineProperty(exports, "importNameKey", { enumerable: true, get: function () { return event_import_1.importNameKey; } });
24
+ Object.defineProperty(exports, "includeInImport", { enumerable: true, get: function () { return event_import_1.includeInImport; } });
22
25
  Object.defineProperty(exports, "mergedReadings", { enumerable: true, get: function () { return event_import_1.mergedReadings; } });
23
26
  Object.defineProperty(exports, "peopleOf", { enumerable: true, get: function () { return event_import_1.peopleOf; } });
24
27
  tslib_1.__exportStar(require("./event-series/event-series-service"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/calendar",
3
- "version": "10.1.296",
3
+ "version": "10.1.298",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "files": [
@@ -50,11 +50,11 @@
50
50
  "@operato/graphql": "^10.29.69",
51
51
  "@operato/popup": "^10.0.0",
52
52
  "@operato/shell": "^10.29.69",
53
- "@things-factory/ai-assistant": "^10.1.296",
54
- "@things-factory/auth-base": "^10.1.296",
55
- "@things-factory/notification": "^10.1.296",
56
- "@things-factory/shell": "^10.1.296",
53
+ "@things-factory/ai-assistant": "^10.1.298",
54
+ "@things-factory/auth-base": "^10.1.298",
55
+ "@things-factory/notification": "^10.1.298",
56
+ "@things-factory/shell": "^10.1.298",
57
57
  "cron-parser": "^4.3.0"
58
58
  },
59
- "gitHead": "0cd4b6207e4dfc557157f86630d82aed423b1dde"
59
+ "gitHead": "5b5dce33c891a02896ef3a9cb3974abefc3f53d6"
60
60
  }
@@ -53,8 +53,8 @@
53
53
  "text.calendar-kind-general": "General",
54
54
  "text.calendar-kind-days-off": "Days off",
55
55
  "text.calendar-kind-public-holidays": "Public holidays",
56
- "text.calendar-kind-hint": "Days in a days-off or public holiday calendar are not working days.",
57
- "error.calendar-kind-invalid": "Choose general, days off or public holidays",
56
+ "text.calendar-kind-hint": "Days in a days-off or public holiday calendar are not working days. A work records calendar holds work done elsewhere, such as work mail, and is not read into the weekly report's meetings or system records.",
57
+ "error.calendar-kind-invalid": "Choose general, days off, public holidays or work records",
58
58
  "error.calendar-public-holidays-taken": "A domain has one public holiday calendar; '{name}' is already it",
59
59
  "error.working-days-day-invalid": "{field}: '{value}' must be a date as YYYY-MM-DD",
60
60
  "error.working-days-range-reversed": "The end ({to}) must be on or after the start ({from})",
@@ -63,5 +63,14 @@
63
63
  "error.public-holidays-day-outside-year": "{day} is not in {year}",
64
64
  "error.public-holidays-name-required": "{day} needs the holiday's name",
65
65
  "work.calendar.keeping": "Working days and holidays",
66
- "field.event-source-mailboxes": "Read from"
66
+ "field.event-source-mailboxes": "Read from",
67
+ "text.calendar-kind-record": "Work records",
68
+ "button.exclude-from-import": "Exclude from import",
69
+ "button.include-in-import": "Import again",
70
+ "field.import-excludes": "Excluded from import",
71
+ "text.select-imported-events": "Select events imported from Teams or Outlook",
72
+ "text.sure-to-exclude-from-import": "Events named '{names}' will no longer be imported from Teams or Outlook. Events of that name already imported to this calendar will be deleted.",
73
+ "text.excluded-from-import": "'{names}' is excluded from import",
74
+ "text.included-in-import": "'{name}' will be imported again from the next import",
75
+ "error.event-import-exclude-name-required": "Enter the name of the event to exclude"
67
76
  }
@@ -53,8 +53,8 @@
53
53
  "text.calendar-kind-general": "General",
54
54
  "text.calendar-kind-days-off": "Días libres",
55
55
  "text.calendar-kind-public-holidays": "Festivos nacionales",
56
- "text.calendar-kind-hint": "Los días de un calendario de días libres o festivos no son laborables.",
57
- "error.calendar-kind-invalid": "Elija general, días libres o festivos nacionales",
56
+ "text.calendar-kind-hint": "Los días de un calendario de días libres o festivos no son laborables. Un calendario de registros de trabajo guarda trabajo hecho en otro lugar, como el correo de trabajo, y no entra en las reuniones ni los registros del informe semanal.",
57
+ "error.calendar-kind-invalid": "Elija general, días libres, festivos nacionales o registros de trabajo",
58
58
  "error.calendar-public-holidays-taken": "Un dominio tiene un solo calendario de festivos; ya es '{name}'",
59
59
  "error.working-days-day-invalid": "{field}: '{value}' debe ser una fecha AAAA-MM-DD",
60
60
  "error.working-days-range-reversed": "El fin ({to}) debe ser igual o posterior al inicio ({from})",
@@ -63,5 +63,14 @@
63
63
  "error.public-holidays-day-outside-year": "{day} no está en {year}",
64
64
  "error.public-holidays-name-required": "{day} necesita el nombre del festivo",
65
65
  "work.calendar.keeping": "Días laborables y festivos",
66
- "field.event-source-mailboxes": "Leído de"
66
+ "field.event-source-mailboxes": "Leído de",
67
+ "text.calendar-kind-record": "Registros de trabajo",
68
+ "button.exclude-from-import": "Excluir de la importación",
69
+ "button.include-in-import": "Importar de nuevo",
70
+ "field.import-excludes": "Excluidos de la importación",
71
+ "text.select-imported-events": "Seleccione eventos importados de Teams u Outlook",
72
+ "text.sure-to-exclude-from-import": "Los eventos llamados '{names}' ya no se importarán de Teams u Outlook. Los eventos con ese nombre ya importados en este calendario se eliminarán.",
73
+ "text.excluded-from-import": "'{names}' se ha excluido de la importación",
74
+ "text.included-in-import": "'{name}' se importará de nuevo a partir de la próxima importación",
75
+ "error.event-import-exclude-name-required": "Introduzca el nombre del evento que desea excluir"
67
76
  }
@@ -53,8 +53,8 @@
53
53
  "text.calendar-kind-general": "一般",
54
54
  "text.calendar-kind-days-off": "休業日",
55
55
  "text.calendar-kind-public-holidays": "国の祝日",
56
- "text.calendar-kind-hint": "休業日・国の祝日カレンダーの日は勤務日から除かれます。",
57
- "error.calendar-kind-invalid": "カレンダーの種類を一般・休業日・国の祝日から選んでください",
56
+ "text.calendar-kind-hint": "休業日・国の祝日カレンダーの日は勤務日から除かれます。業務記録カレンダーは他の場所で行った仕事(業務メールなど)を記録し、週報の会議・システム記録には入りません。",
57
+ "error.calendar-kind-invalid": "カレンダーの種類を一般・休業日・国の祝日・業務記録から選んでください",
58
58
  "error.calendar-public-holidays-taken": "国の祝日カレンダーは事業所に一つです。すでに「{name}」があります",
59
59
  "error.working-days-day-invalid": "{field}: '{value}'はYYYY-MM-DD形式の日付でなければなりません",
60
60
  "error.working-days-range-reversed": "終了日({to})は開始日({from})以降でなければなりません",
@@ -63,5 +63,14 @@
63
63
  "error.public-holidays-day-outside-year": "{day}は{year}年の日ではありません",
64
64
  "error.public-holidays-name-required": "{day}の祝日名がありません",
65
65
  "work.calendar.keeping": "勤務日・休日の管理",
66
- "field.event-source-mailboxes": "読み取ったメールボックス"
66
+ "field.event-source-mailboxes": "読み取ったメールボックス",
67
+ "text.calendar-kind-record": "業務記録",
68
+ "button.exclude-from-import": "連携から除外",
69
+ "button.include-in-import": "再取り込み",
70
+ "field.import-excludes": "連携除外",
71
+ "text.select-imported-events": "Teams・Outlook から取り込んだ予定を選択してください",
72
+ "text.sure-to-exclude-from-import": "「{names}」の予定を Teams・Outlook から取り込まなくなります。このカレンダーに取り込み済みの同名の予定は削除されます。",
73
+ "text.excluded-from-import": "「{names}」を連携から除外しました",
74
+ "text.included-in-import": "「{name}」は次回の連携から再び取り込みます",
75
+ "error.event-import-exclude-name-required": "除外する予定の名前を入力してください"
67
76
  }
@@ -53,8 +53,8 @@
53
53
  "text.calendar-kind-general": "일반",
54
54
  "text.calendar-kind-days-off": "휴무일",
55
55
  "text.calendar-kind-public-holidays": "국가 공휴일",
56
- "text.calendar-kind-hint": "휴무일·국가 공휴일 캘린더의 날은 근무일에서 빠집니다.",
57
- "error.calendar-kind-invalid": "캘린더 종류를 일반·휴무일·국가 공휴일 중에서 고르세요",
56
+ "text.calendar-kind-hint": "휴무일·국가 공휴일 캘린더의 날은 근무일에서 빠집니다. 업무 기록 캘린더는 다른 곳에서 한 일(업무 메일 등)을 담으며, 주간보고의 회의·시스템 기록에 들어가지 않습니다.",
57
+ "error.calendar-kind-invalid": "캘린더 종류를 일반·휴무일·국가 공휴일·업무 기록 중에서 고르세요",
58
58
  "error.calendar-public-holidays-taken": "국가 공휴일 캘린더는 사업장에 하나입니다. 이미 「{name}」이 있습니다",
59
59
  "error.working-days-day-invalid": "{field}: '{value}'은(는) YYYY-MM-DD 형식의 날짜여야 합니다",
60
60
  "error.working-days-range-reversed": "끝 날짜({to})는 시작 날짜({from}) 이후여야 합니다",
@@ -63,5 +63,14 @@
63
63
  "error.public-holidays-day-outside-year": "{day}은(는) {year}년의 날이 아닙니다",
64
64
  "error.public-holidays-name-required": "{day}의 공휴일 이름이 없습니다",
65
65
  "work.calendar.keeping": "근무일 · 휴일 관리",
66
- "field.event-source-mailboxes": "읽은 메일함"
66
+ "field.event-source-mailboxes": "읽은 메일함",
67
+ "text.calendar-kind-record": "업무 기록",
68
+ "button.exclude-from-import": "연동에서 제외",
69
+ "button.include-in-import": "다시 가져오기",
70
+ "field.import-excludes": "연동 제외",
71
+ "text.select-imported-events": "Teams·Outlook 에서 가져온 일정을 선택하세요",
72
+ "text.sure-to-exclude-from-import": "「{names}」 일정을 Teams·Outlook 에서 더 가져오지 않습니다. 이 캘린더에 이미 가져온 같은 이름의 일정은 삭제합니다.",
73
+ "text.excluded-from-import": "「{names}」 일정을 연동에서 제외했습니다",
74
+ "text.included-in-import": "「{name}」 일정은 다음 연동부터 다시 가져옵니다",
75
+ "error.event-import-exclude-name-required": "제외할 일정 이름을 입력하세요"
67
76
  }
@@ -53,8 +53,8 @@
53
53
  "text.calendar-kind-general": "Umum",
54
54
  "text.calendar-kind-days-off": "Hari cuti",
55
55
  "text.calendar-kind-public-holidays": "Cuti umum",
56
- "text.calendar-kind-hint": "Hari dalam kalendar hari cuti atau cuti umum bukan hari bekerja.",
57
- "error.calendar-kind-invalid": "Pilih umum, hari cuti atau cuti umum",
56
+ "text.calendar-kind-hint": "Hari dalam kalendar hari cuti atau cuti umum bukan hari bekerja. Kalendar rekod kerja menyimpan kerja yang dibuat di tempat lain, seperti mel kerja, dan tidak dimasukkan ke dalam mesyuarat atau rekod sistem laporan mingguan.",
57
+ "error.calendar-kind-invalid": "Pilih umum, hari cuti, cuti umum atau rekod kerja",
58
58
  "error.calendar-public-holidays-taken": "Domain mempunyai satu kalendar cuti umum; '{name}' sudah ada",
59
59
  "error.working-days-day-invalid": "{field}: '{value}' mesti tarikh YYYY-MM-DD",
60
60
  "error.working-days-range-reversed": "Akhir ({to}) mesti pada atau selepas mula ({from})",
@@ -63,5 +63,14 @@
63
63
  "error.public-holidays-day-outside-year": "{day} bukan dalam {year}",
64
64
  "error.public-holidays-name-required": "{day} memerlukan nama cuti",
65
65
  "work.calendar.keeping": "Hari bekerja dan cuti umum",
66
- "field.event-source-mailboxes": "Dibaca daripada"
66
+ "field.event-source-mailboxes": "Dibaca daripada",
67
+ "text.calendar-kind-record": "Rekod kerja",
68
+ "button.exclude-from-import": "Kecualikan daripada import",
69
+ "button.include-in-import": "Import semula",
70
+ "field.import-excludes": "Dikecualikan daripada import",
71
+ "text.select-imported-events": "Pilih acara yang diimport daripada Teams atau Outlook",
72
+ "text.sure-to-exclude-from-import": "Acara bernama '{names}' tidak akan diimport lagi daripada Teams atau Outlook. Acara dengan nama itu yang sudah diimport ke kalendar ini akan dipadam.",
73
+ "text.excluded-from-import": "'{names}' dikecualikan daripada import",
74
+ "text.included-in-import": "'{name}' akan diimport semula mulai import seterusnya",
75
+ "error.event-import-exclude-name-required": "Masukkan nama acara yang hendak dikecualikan"
67
76
  }
@@ -53,8 +53,8 @@
53
53
  "text.calendar-kind-general": "一般",
54
54
  "text.calendar-kind-days-off": "休息日",
55
55
  "text.calendar-kind-public-holidays": "法定节假日",
56
- "text.calendar-kind-hint": "休息日和法定节假日日历中的日子不计为工作日。",
57
- "error.calendar-kind-invalid": "请选择一般、休息日或法定节假日",
56
+ "text.calendar-kind-hint": "休息日和法定节假日日历中的日子不计为工作日。工作记录日历保存在其他地方完成的工作(如工作邮件),不计入周报的会议和系统记录。",
57
+ "error.calendar-kind-invalid": "请选择一般、休息日、法定节假日或工作记录",
58
58
  "error.calendar-public-holidays-taken": "每个域只有一个法定节假日日历;已有「{name}」",
59
59
  "error.working-days-day-invalid": "{field}:'{value}'必须是YYYY-MM-DD格式的日期",
60
60
  "error.working-days-range-reversed": "结束日期({to})必须不早于开始日期({from})",
@@ -63,5 +63,14 @@
63
63
  "error.public-holidays-day-outside-year": "{day}不在{year}年",
64
64
  "error.public-holidays-name-required": "{day}缺少节假日名称",
65
65
  "work.calendar.keeping": "工作日与假日管理",
66
- "field.event-source-mailboxes": "读取的邮箱"
66
+ "field.event-source-mailboxes": "读取的邮箱",
67
+ "text.calendar-kind-record": "工作记录",
68
+ "button.exclude-from-import": "从同步中排除",
69
+ "button.include-in-import": "重新导入",
70
+ "field.import-excludes": "同步排除",
71
+ "text.select-imported-events": "请选择从 Teams 或 Outlook 导入的日程",
72
+ "text.sure-to-exclude-from-import": "将不再从 Teams 或 Outlook 导入名为「{names}」的日程。此日历中已导入的同名日程将被删除。",
73
+ "text.excluded-from-import": "已将「{names}」从同步中排除",
74
+ "text.included-in-import": "「{name}」将从下次同步起重新导入",
75
+ "error.event-import-exclude-name-required": "请输入要排除的日程名称"
67
76
  }