odant-work 1.0.72 → 1.0.74
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/#system/package-manifest.json +29 -27
- package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/explorer.js +1 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/calendar.js +1004 -1011
- package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/class.js +7 -90
- package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/email.js +913 -705
- package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/methods/refresh/$method/class.js +30 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/class.js +1 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/staff.js +78 -5
- package/$server/$folder/$class/ai/skills/email-mailbox.md +10 -7
- package/$server/$folder/$class/ai/skills/meeting-minutes.md +1 -1
- package/$server/$folder/$file/$eml/triggers/on_save/$trigger/class.js +17 -1
- package/$server/$folder/lib/calendar-form/calendar-form.js +482 -296
- package/$server/$folder/lib/icon/icon.js +50 -0
- package/$server/$folder/lib/tree/tree.js +9 -7
- package/USERS/$users/class.js +4 -3
- package/oda/components/icon/icon.js +6 -1
- package/package.json +1 -1
- package/sources/host/email-utils.js +25 -1
- package/sources/modules/agent/index.js +3 -1
- package/sources/modules/agent/node-rules.js +51 -0
- package/sources/modules/agent/scheduler.js +7 -0
- package/sources/modules/agent/tools/calendar-mail.js +273 -0
- package/sources/server/access/gateway.js +3 -0
- package/sources/server/class/feed.js +46 -0
- package/sources/server/class/mail-calendar.js +867 -0
- package/sources/server/class/security.js +44 -0
- package/sources/server/folder.js +1 -1
|
@@ -1,296 +1,482 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
}
|
|
3
|
-
|
|
4
|
-
const pad = n => String(n).padStart(2, '0');
|
|
5
|
-
|
|
6
|
-
function allDayBounds(start, end) {
|
|
7
|
-
const s = new Date(start);
|
|
8
|
-
const t = new Date(end);
|
|
9
|
-
s.setHours(0, 0, 0, 0);
|
|
10
|
-
t.setHours(0, 0, 0, 0);
|
|
11
|
-
if (t <= s)
|
|
12
|
-
t.setDate(s.getDate() + 1);
|
|
13
|
-
return {
|
|
14
|
-
start: s.toISOTimezoneString(),
|
|
15
|
-
end: t.toISOTimezoneString()
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function applyAllDayTimes(ev) {
|
|
20
|
-
const s = new Date(ev.start);
|
|
21
|
-
if (ev.allDay) {
|
|
22
|
-
const bounds = allDayBounds(ev.start, ev.end);
|
|
23
|
-
ev.start = bounds.start;
|
|
24
|
-
ev.end = bounds.end;
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (s.getHours() === 0 && s.getMinutes() === 0) {
|
|
28
|
-
s.setHours(9, 0, 0, 0);
|
|
29
|
-
ev.start = s.toISOTimezoneString();
|
|
30
|
-
ev.end = new Date(s.getTime() +
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
font-size:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
border:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
1
|
+
export default {
|
|
2
|
+
}
|
|
3
|
+
|
|
4
|
+
const pad = n => String(n).padStart(2, '0');
|
|
5
|
+
|
|
6
|
+
function allDayBounds(start, end) {
|
|
7
|
+
const s = new Date(start);
|
|
8
|
+
const t = new Date(end);
|
|
9
|
+
s.setHours(0, 0, 0, 0);
|
|
10
|
+
t.setHours(0, 0, 0, 0);
|
|
11
|
+
if (t <= s)
|
|
12
|
+
t.setDate(s.getDate() + 1);
|
|
13
|
+
return {
|
|
14
|
+
start: s.toISOTimezoneString(),
|
|
15
|
+
end: t.toISOTimezoneString()
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function applyAllDayTimes(ev) {
|
|
20
|
+
const s = new Date(ev.start);
|
|
21
|
+
if (ev.allDay) {
|
|
22
|
+
const bounds = allDayBounds(ev.start, ev.end);
|
|
23
|
+
ev.start = bounds.start;
|
|
24
|
+
ev.end = bounds.end;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (s.getHours() === 0 && s.getMinutes() === 0) {
|
|
28
|
+
s.setHours(9, 0, 0, 0);
|
|
29
|
+
ev.start = s.toISOTimezoneString();
|
|
30
|
+
ev.end = new Date(s.getTime() + 60 * 60 * 1000).toISOTimezoneString();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const CATEGORIES = [
|
|
35
|
+
{ id: 'meeting', label: 'Встреча', color: '#2563eb' },
|
|
36
|
+
{ id: 'important', label: 'Важное', color: '#dc2626' },
|
|
37
|
+
{ id: 'personal', label: 'Личное', color: '#7c3aed' },
|
|
38
|
+
{ id: 'client', label: 'Клиент', color: '#059669' },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
ODA({
|
|
42
|
+
is: 'calendar-form',
|
|
43
|
+
imports: 'oda//checkbox, oda//icon, oda//button',
|
|
44
|
+
template: /* html */`
|
|
45
|
+
<style>
|
|
46
|
+
:host {
|
|
47
|
+
@apply --vertical;
|
|
48
|
+
padding: 10px 14px;
|
|
49
|
+
gap: 10px;
|
|
50
|
+
min-width: 420px;
|
|
51
|
+
max-width: 560px;
|
|
52
|
+
max-height: 75vh;
|
|
53
|
+
overflow-y: auto;
|
|
54
|
+
font-size: 13px;
|
|
55
|
+
color: var(--content-color);
|
|
56
|
+
}
|
|
57
|
+
fieldset {
|
|
58
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
59
|
+
border-radius: 8px;
|
|
60
|
+
padding: 3px 10px 6px;
|
|
61
|
+
margin: 0;
|
|
62
|
+
min-width: 0;
|
|
63
|
+
background: var(--content-background);
|
|
64
|
+
}
|
|
65
|
+
legend {
|
|
66
|
+
font-size: 11.5px;
|
|
67
|
+
padding: 0 4px;
|
|
68
|
+
color: var(--muted-color);
|
|
69
|
+
}
|
|
70
|
+
input, textarea, select {
|
|
71
|
+
border: none;
|
|
72
|
+
outline: none;
|
|
73
|
+
background-color: transparent;
|
|
74
|
+
color: inherit;
|
|
75
|
+
font-family: inherit;
|
|
76
|
+
font-size: 13px;
|
|
77
|
+
width: 100%;
|
|
78
|
+
padding: 3px 0;
|
|
79
|
+
box-sizing: border-box;
|
|
80
|
+
}
|
|
81
|
+
textarea {
|
|
82
|
+
resize: vertical;
|
|
83
|
+
min-height: 64px;
|
|
84
|
+
}
|
|
85
|
+
.row {
|
|
86
|
+
@apply --horizontal;
|
|
87
|
+
gap: 10px;
|
|
88
|
+
align-items: stretch;
|
|
89
|
+
}
|
|
90
|
+
.row > fieldset {
|
|
91
|
+
@apply --flex;
|
|
92
|
+
}
|
|
93
|
+
.box {
|
|
94
|
+
@apply --vertical;
|
|
95
|
+
gap: 10px;
|
|
96
|
+
}
|
|
97
|
+
.all-day-toggle {
|
|
98
|
+
@apply --horizontal;
|
|
99
|
+
align-items: center;
|
|
100
|
+
gap: 6px;
|
|
101
|
+
cursor: pointer;
|
|
102
|
+
font-size: 13px;
|
|
103
|
+
}
|
|
104
|
+
.cats {
|
|
105
|
+
@apply --horizontal;
|
|
106
|
+
gap: 6px;
|
|
107
|
+
flex-wrap: wrap;
|
|
108
|
+
padding-top: 2px;
|
|
109
|
+
}
|
|
110
|
+
.cat-chip {
|
|
111
|
+
@apply --horizontal;
|
|
112
|
+
align-items: center;
|
|
113
|
+
gap: 5px;
|
|
114
|
+
padding: 4px 10px;
|
|
115
|
+
border-radius: 999px;
|
|
116
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
117
|
+
cursor: pointer;
|
|
118
|
+
font-size: 12px;
|
|
119
|
+
background: var(--subtle-background, #f8fafc);
|
|
120
|
+
user-select: none;
|
|
121
|
+
}
|
|
122
|
+
.cat-chip.active {
|
|
123
|
+
border-color: var(--accent-color, #2563eb);
|
|
124
|
+
background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background, #fff));
|
|
125
|
+
font-weight: 600;
|
|
126
|
+
}
|
|
127
|
+
.cat-dot {
|
|
128
|
+
width: 8px;
|
|
129
|
+
height: 8px;
|
|
130
|
+
border-radius: 50%;
|
|
131
|
+
}
|
|
132
|
+
.att-list {
|
|
133
|
+
display: flex;
|
|
134
|
+
flex-wrap: wrap;
|
|
135
|
+
gap: 5px;
|
|
136
|
+
max-height: 112px;
|
|
137
|
+
overflow-y: auto;
|
|
138
|
+
padding: 4px 0 2px;
|
|
139
|
+
}
|
|
140
|
+
.att-chip {
|
|
141
|
+
@apply --horizontal;
|
|
142
|
+
align-items: center;
|
|
143
|
+
gap: 4px;
|
|
144
|
+
padding: 3px 8px;
|
|
145
|
+
border-radius: 999px;
|
|
146
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
147
|
+
font-size: 12px;
|
|
148
|
+
cursor: pointer;
|
|
149
|
+
background: var(--subtle-background, #f8fafc);
|
|
150
|
+
}
|
|
151
|
+
.att-chip.selected {
|
|
152
|
+
border-color: var(--accent-color, #2563eb);
|
|
153
|
+
background: color-mix(in srgb, var(--accent-color, #2563eb) 14%, var(--content-background, #fff));
|
|
154
|
+
color: var(--accent-color, #2563eb);
|
|
155
|
+
font-weight: 600;
|
|
156
|
+
}
|
|
157
|
+
.att-search {
|
|
158
|
+
border-bottom: 1px solid var(--subtle-border, #e2e8f0) !important;
|
|
159
|
+
margin-bottom: 4px;
|
|
160
|
+
font-size: 12.5px;
|
|
161
|
+
}
|
|
162
|
+
.cancel-row {
|
|
163
|
+
@apply --horizontal;
|
|
164
|
+
align-items: center;
|
|
165
|
+
gap: 6px;
|
|
166
|
+
padding: 6px 8px;
|
|
167
|
+
border-radius: 8px;
|
|
168
|
+
border: 1px solid color-mix(in srgb, #dc2626 30%, transparent);
|
|
169
|
+
background: color-mix(in srgb, #dc2626 6%, transparent);
|
|
170
|
+
color: #b91c1c;
|
|
171
|
+
cursor: pointer;
|
|
172
|
+
}
|
|
173
|
+
</style>
|
|
174
|
+
<div ~for="events" class="box">
|
|
175
|
+
<fieldset>
|
|
176
|
+
<legend>Название</legend>
|
|
177
|
+
<input id="summary" placeholder="Например: Планёрка отдела" :value="$for.item.summary || ''" autofocus @input="(e) => on_input(e, $for.index)">
|
|
178
|
+
</fieldset>
|
|
179
|
+
|
|
180
|
+
<div class="row" style="align-items: center; justify-content: space-between;">
|
|
181
|
+
<label class="all-day-toggle">
|
|
182
|
+
<oda-checkbox :value="$for.item.allDay" @value-changed="(e) => on_all_day(e, $for.index)"></oda-checkbox>
|
|
183
|
+
<span>Весь день</span>
|
|
184
|
+
</label>
|
|
185
|
+
<div class="cats">
|
|
186
|
+
<span ~for="categories" class="cat-chip"
|
|
187
|
+
~class="{ active: ($for.$for.item.category || 'meeting') === $for.item.id }"
|
|
188
|
+
@tap="setCategory($for.$for.index, $for.item.id)">
|
|
189
|
+
<span class="cat-dot" :style="'background:' + $for.item.color"></span>
|
|
190
|
+
<span>{{$for.item.label}}</span>
|
|
191
|
+
</span>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
<div class="row">
|
|
196
|
+
<fieldset>
|
|
197
|
+
<legend>Начало</legend>
|
|
198
|
+
<input id="start" :type="$for.item.allDay ? 'date' : 'datetime-local'" :value="$for.item.allDay ? toDateInput($for.item.start) : toDatetimeLocalInput($for.item.start)" @input="(e) => on_input(e, $for.index)">
|
|
199
|
+
</fieldset>
|
|
200
|
+
<fieldset>
|
|
201
|
+
<legend>Окончание</legend>
|
|
202
|
+
<input id="end" :type="$for.item.allDay ? 'date' : 'datetime-local'" :value="$for.item.allDay ? toDateInput($for.item.end, true) : toDatetimeLocalInput($for.item.end)" @input="(e) => on_input(e, $for.index)">
|
|
203
|
+
</fieldset>
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
<div class="row">
|
|
207
|
+
<fieldset>
|
|
208
|
+
<legend>Повтор</legend>
|
|
209
|
+
<select id="recurrence" :value="$for.item.recurrence || 'none'" @change="(e) => on_input(e, $for.index)">
|
|
210
|
+
<option value="none">Не повторяется</option>
|
|
211
|
+
<option value="daily">Каждый день</option>
|
|
212
|
+
<option value="weekly">Каждую неделю</option>
|
|
213
|
+
<option value="monthly">Каждый месяц</option>
|
|
214
|
+
<option value="yearly">Каждый год</option>
|
|
215
|
+
</select>
|
|
216
|
+
</fieldset>
|
|
217
|
+
<fieldset>
|
|
218
|
+
<legend>Напоминание</legend>
|
|
219
|
+
<select id="reminderMin" :value="String($for.item.reminderMin || 0)" @change="(e) => on_input(e, $for.index)">
|
|
220
|
+
<option value="0">Без напоминания</option>
|
|
221
|
+
<option value="15">За 15 минут</option>
|
|
222
|
+
<option value="60">За 1 час</option>
|
|
223
|
+
<option value="1440">За 1 день</option>
|
|
224
|
+
</select>
|
|
225
|
+
</fieldset>
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
<fieldset>
|
|
229
|
+
<legend>Место или ссылка на созвон</legend>
|
|
230
|
+
<input id="location" placeholder="Переговорная / ссылка на встречу" :value="$for.item.location || ''" @input="(e) => on_input(e, $for.index)">
|
|
231
|
+
</fieldset>
|
|
232
|
+
|
|
233
|
+
<fieldset ~if="contacts.length">
|
|
234
|
+
<legend>Участники из команды ({{($for.item.attendees || []).length}})</legend>
|
|
235
|
+
<input class="att-search" type="search" placeholder="Фильтр коллег…" :value="attFilter" @input="attFilter = $event.target.value">
|
|
236
|
+
<div class="att-list">
|
|
237
|
+
<span ~for="filteredContacts" class="att-chip"
|
|
238
|
+
~class="{ selected: ($for.$for.item.attendees || []).includes($for.item.id) }"
|
|
239
|
+
@tap="toggleAttendee($for.$for.index, $for.item.id)">
|
|
240
|
+
<span>{{$for.item.label || $for.item.id}}</span>
|
|
241
|
+
</span>
|
|
242
|
+
</div>
|
|
243
|
+
</fieldset>
|
|
244
|
+
|
|
245
|
+
<fieldset>
|
|
246
|
+
<legend>Внешние email участников (через запятую)</legend>
|
|
247
|
+
<input id="externalEmails" placeholder="partner@company.ru" :value="($for.item.externalEmails || []).join(', ')" @input="(e) => on_external(e, $for.index)">
|
|
248
|
+
</fieldset>
|
|
249
|
+
|
|
250
|
+
<fieldset>
|
|
251
|
+
<legend>Описание и повестка</legend>
|
|
252
|
+
<textarea id="description" placeholder="Вопросы для обсуждения, ссылки, заметки…" :value="$for.item.description || ''" @input="(e) => on_input(e, $for.index)"></textarea>
|
|
253
|
+
</fieldset>
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
<label ~if="canCancel" class="cancel-row">
|
|
257
|
+
<oda-checkbox ::value="cancelled"></oda-checkbox>
|
|
258
|
+
<span>Отменить эту встречу (удалится из сетки календаря)</span>
|
|
259
|
+
</label>
|
|
260
|
+
`,
|
|
261
|
+
categories: CATEGORIES,
|
|
262
|
+
contacts: [],
|
|
263
|
+
attFilter: '',
|
|
264
|
+
get filteredContacts() {
|
|
265
|
+
const q = String(this.attFilter || '').trim().toLowerCase();
|
|
266
|
+
if (!q)
|
|
267
|
+
return this.contacts;
|
|
268
|
+
return this.contacts.filter(c => String(c.label || c.id || '').toLowerCase().includes(q));
|
|
269
|
+
},
|
|
270
|
+
async attached() {
|
|
271
|
+
if (!this.contacts?.length && typeof globalThis.WORK?.visible_contacts === 'function') {
|
|
272
|
+
try {
|
|
273
|
+
const list = await globalThis.WORK.visible_contacts();
|
|
274
|
+
if (Array.isArray(list))
|
|
275
|
+
this.contacts = list.filter(c => c && c.id && !c.external);
|
|
276
|
+
}
|
|
277
|
+
catch { /* ignore */ }
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
toDatetimeLocalInput(date) {
|
|
281
|
+
const d = date instanceof Date ? date : new Date(date);
|
|
282
|
+
if (isNaN(d))
|
|
283
|
+
return '';
|
|
284
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
|
|
285
|
+
+ `T${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
286
|
+
},
|
|
287
|
+
toDateInput(date, inclusiveEnd = false) {
|
|
288
|
+
const d = date instanceof Date ? new Date(date.getTime()) : new Date(date);
|
|
289
|
+
if (isNaN(d))
|
|
290
|
+
return '';
|
|
291
|
+
if (inclusiveEnd && d.getHours() === 0 && d.getMinutes() === 0)
|
|
292
|
+
d.setDate(d.getDate() - 1);
|
|
293
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
|
294
|
+
},
|
|
295
|
+
eventToPersist(ev) {
|
|
296
|
+
let start = ev.start || (ev.startStr ? new Date(ev.startStr).toISOTimezoneString() : '');
|
|
297
|
+
let end = ev.end || (ev.endStr ? new Date(ev.endStr).toISOTimezoneString() : '');
|
|
298
|
+
const allDay = !!ev.allDay;
|
|
299
|
+
if (allDay && start && end) {
|
|
300
|
+
const bounds = allDayBounds(start, end);
|
|
301
|
+
start = bounds.start;
|
|
302
|
+
end = bounds.end;
|
|
303
|
+
}
|
|
304
|
+
const result = {
|
|
305
|
+
summary: ev.summary ?? '',
|
|
306
|
+
location: ev.location ?? '',
|
|
307
|
+
description: ev.description ?? '',
|
|
308
|
+
start,
|
|
309
|
+
end,
|
|
310
|
+
allDay,
|
|
311
|
+
attendees: Array.isArray(ev.attendees) ? ev.attendees : [],
|
|
312
|
+
externalEmails: Array.isArray(ev.externalEmails) ? ev.externalEmails : [],
|
|
313
|
+
recurrence: ev.recurrence || 'none',
|
|
314
|
+
reminderMin: Number(ev.reminderMin) || 0,
|
|
315
|
+
category: ev.category || 'meeting',
|
|
316
|
+
};
|
|
317
|
+
for (const key of ['uid', 'status', 'time', 'organizer', 'sourceNodePath'])
|
|
318
|
+
if (ev[key] != null)
|
|
319
|
+
result[key] = ev[key];
|
|
320
|
+
return result;
|
|
321
|
+
},
|
|
322
|
+
setCategory(i, catId) {
|
|
323
|
+
if (!this.events?.[i])
|
|
324
|
+
return;
|
|
325
|
+
this.events[i].category = catId;
|
|
326
|
+
this.events = [...this.events];
|
|
327
|
+
this.commitEvents();
|
|
328
|
+
},
|
|
329
|
+
toggleAttendee(i, uid) {
|
|
330
|
+
if (!this.events?.[i] || !uid)
|
|
331
|
+
return;
|
|
332
|
+
const cur = Array.isArray(this.events[i].attendees) ? [...this.events[i].attendees] : [];
|
|
333
|
+
const idx = cur.indexOf(uid);
|
|
334
|
+
if (idx >= 0) cur.splice(idx, 1);
|
|
335
|
+
else cur.push(uid);
|
|
336
|
+
this.events[i].attendees = cur;
|
|
337
|
+
this.events = [...this.events];
|
|
338
|
+
this.commitEvents();
|
|
339
|
+
},
|
|
340
|
+
on_external(e, i) {
|
|
341
|
+
e.stopPropagation();
|
|
342
|
+
const arr = String(e.target.value || '').split(/[,;]/).map(s => s.trim()).filter(Boolean);
|
|
343
|
+
this.events[i].externalEmails = arr;
|
|
344
|
+
this.commitEvents();
|
|
345
|
+
},
|
|
346
|
+
on_input(e, i) {
|
|
347
|
+
e.stopPropagation();
|
|
348
|
+
const id = e.target.id;
|
|
349
|
+
if (id === 'start' || id === 'end') {
|
|
350
|
+
if (this.events[i].allDay) {
|
|
351
|
+
const d = new Date(`${e.target.value}T00:00:00`);
|
|
352
|
+
if (id === 'end')
|
|
353
|
+
d.setDate(d.getDate() + 1);
|
|
354
|
+
this.events[i][id] = d.toISOTimezoneString();
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
this.events[i][id] = new Date(e.target.value).toISOTimezoneString();
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
else if (id === 'reminderMin') {
|
|
361
|
+
this.events[i].reminderMin = Number(e.target.value) || 0;
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
this.events[i][id] = e.target.value;
|
|
365
|
+
}
|
|
366
|
+
this.commitEvents();
|
|
367
|
+
},
|
|
368
|
+
on_all_day(e, i) {
|
|
369
|
+
e.stopPropagation();
|
|
370
|
+
const ev = this.events[i];
|
|
371
|
+
const checked = !!e.detail.value;
|
|
372
|
+
if (!!ev.allDay === checked)
|
|
373
|
+
return;
|
|
374
|
+
ev.allDay = checked;
|
|
375
|
+
applyAllDayTimes(ev);
|
|
376
|
+
this.events = [...this.events];
|
|
377
|
+
this.commitEvents();
|
|
378
|
+
},
|
|
379
|
+
commitEvents() {
|
|
380
|
+
const body = JSON.stringify(
|
|
381
|
+
this.events.length === 1
|
|
382
|
+
? this.eventToPersist(this.events[0])
|
|
383
|
+
: this.events.map(ev => this.eventToPersist(ev))
|
|
384
|
+
);
|
|
385
|
+
if (this.$item && (!this.$item.body || (this.$item.body !== body))) {
|
|
386
|
+
this.$item.body = body;
|
|
387
|
+
this.$item.isChanged = true;
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
events: undefined,
|
|
391
|
+
canCancel: false,
|
|
392
|
+
cancelled: false,
|
|
393
|
+
set $item(n) {
|
|
394
|
+
if (n) {
|
|
395
|
+
this.async(async () => {
|
|
396
|
+
let content = await n.load();
|
|
397
|
+
if (typeof content === 'string')
|
|
398
|
+
content = JSON.parse(content);
|
|
399
|
+
this.cancelled = content?.status === 'cancelled';
|
|
400
|
+
this.events = [content];
|
|
401
|
+
})
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
hydrateEvent(raw) {
|
|
405
|
+
const ev = {
|
|
406
|
+
summary: raw.summary ?? '',
|
|
407
|
+
location: raw.location ?? '',
|
|
408
|
+
description: raw.description ?? '',
|
|
409
|
+
allDay: !!raw.allDay,
|
|
410
|
+
attendees: Array.isArray(raw.attendees) ? raw.attendees : [],
|
|
411
|
+
externalEmails: Array.isArray(raw.externalEmails) ? raw.externalEmails : [],
|
|
412
|
+
recurrence: raw.recurrence || 'none',
|
|
413
|
+
reminderMin: Number(raw.reminderMin) || 0,
|
|
414
|
+
category: raw.category || 'meeting',
|
|
415
|
+
start: '',
|
|
416
|
+
end: ''
|
|
417
|
+
};
|
|
418
|
+
if (raw.start)
|
|
419
|
+
ev.start = /[Zz]|[+-]\d{2}:\d{2}$/.test(raw.start) ? raw.start : new Date(raw.start).toISOTimezoneString();
|
|
420
|
+
else if (raw.startStr)
|
|
421
|
+
ev.start = new Date(raw.startStr).toISOTimezoneString();
|
|
422
|
+
if (raw.end)
|
|
423
|
+
ev.end = /[Zz]|[+-]\d{2}:\d{2}$/.test(raw.end) ? raw.end : new Date(raw.end).toISOTimezoneString();
|
|
424
|
+
else if (raw.endStr)
|
|
425
|
+
ev.end = new Date(raw.endStr).toISOTimezoneString();
|
|
426
|
+
return ev;
|
|
427
|
+
},
|
|
428
|
+
parseICSDate(dateStr) {
|
|
429
|
+
if (!dateStr)
|
|
430
|
+
return '';
|
|
431
|
+
dateStr = dateStr.replace(/\\/g, '');
|
|
432
|
+
if (dateStr.includes('-') && dateStr.includes('T'))
|
|
433
|
+
return new Date(dateStr).toISOTimezoneString();
|
|
434
|
+
const utc = /Z$/i.test(dateStr);
|
|
435
|
+
const compact = dateStr.replace(/Z$/i, '');
|
|
436
|
+
if (!/^\d{8}(T\d{6})?$/.test(compact))
|
|
437
|
+
return new Date(dateStr);
|
|
438
|
+
const year = parseInt(compact.substring(0, 4), 10);
|
|
439
|
+
const month = parseInt(compact.substring(4, 6), 10) - 1;
|
|
440
|
+
const day = parseInt(compact.substring(6, 8), 10);
|
|
441
|
+
const hasTime = compact.length > 8;
|
|
442
|
+
const hours = hasTime ? parseInt(compact.substring(9, 11), 10) : 0;
|
|
443
|
+
const minutes = hasTime ? parseInt(compact.substring(11, 13), 10) : 0;
|
|
444
|
+
const seconds = hasTime ? parseInt(compact.substring(13, 15), 10) : 0;
|
|
445
|
+
const d = utc
|
|
446
|
+
? new Date(Date.UTC(year, month, day, hours, minutes, seconds))
|
|
447
|
+
: new Date(year, month, day, hours, minutes, seconds);
|
|
448
|
+
return d.toISOTimezoneString();
|
|
449
|
+
},
|
|
450
|
+
parseICSSimple(icsText) {
|
|
451
|
+
const events = [];
|
|
452
|
+
const lines = icsText.split(/\r\n|\n|\r/);
|
|
453
|
+
let currentEvent = null;
|
|
454
|
+
for (const line of lines) {
|
|
455
|
+
if (line.startsWith('BEGIN:VEVENT')) {
|
|
456
|
+
currentEvent = {};
|
|
457
|
+
} else if (line.startsWith('END:VEVENT')) {
|
|
458
|
+
if (currentEvent)
|
|
459
|
+
events.push(this.hydrateEvent(currentEvent));
|
|
460
|
+
currentEvent = null;
|
|
461
|
+
} else if (currentEvent) {
|
|
462
|
+
const colonIdx = line.indexOf(':');
|
|
463
|
+
if (colonIdx === -1)
|
|
464
|
+
continue;
|
|
465
|
+
const key = line.slice(0, colonIdx).split(';')[0].trim();
|
|
466
|
+
const value = line.slice(colonIdx + 1).trim();
|
|
467
|
+
if (key === 'SUMMARY') currentEvent.summary = value;
|
|
468
|
+
else if (key === 'LOCATION') currentEvent.location = value;
|
|
469
|
+
else if (key === 'DESCRIPTION') currentEvent.description = value.replace(/\\n/g, '\n');
|
|
470
|
+
else if (key === 'DTSTART') {
|
|
471
|
+
currentEvent.start = this.parseICSDate(value);
|
|
472
|
+
if (/^\d{8}$/.test(value.replace(/\\/g, '')))
|
|
473
|
+
currentEvent.allDay = true;
|
|
474
|
+
}
|
|
475
|
+
else if (key === 'DTEND') {
|
|
476
|
+
currentEvent.end = this.parseICSDate(value);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return events;
|
|
481
|
+
}
|
|
482
|
+
});
|