odant-work 1.0.65 → 1.0.67
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 +56 -59
- package/{PROJECTS → $server/$folder/$class}/$domain/handlers/methods/restore/$handler/class.js +40 -24
- package/$server/$folder/$class/$structure/$server/handlers/methods/distro/$handler/class.js +0 -2
- package/$server/$folder/$class/$structure/handlers/methods/archive/$handler/class.js +27 -0
- package/$server/$folder/$class/$structure/handlers/pages/data/$handler/class.js +9 -0
- package/$server/$folder/$class/$structure/handlers/pages/data/$handler/data.js +310 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/class.js +1 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +160 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +2 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/class.js +1 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/class.js +10 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/system.js +233 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/system/$handler/tabs/agent.js +289 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/{search/$handler → system/$handler/tabs}/search.js +4 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/{staff/$handler → system/$handler/tabs}/staff.js +122 -14
- package/$server/$folder/$class/handlers/pages/form/editor/$handler/class.js +3 -0
- package/$server/$folder/$class/handlers/pages/form/folder/$handler/class.js +10 -6
- package/$server/$folder/handlers/pages/form/$handler/form.js +27 -2
- package/$server/$folder/lib/dot/dot-math.js +1 -1
- package/$server/$folder/lib/dot/dot.js +19 -5
- package/$server/$folder/lib/explorer/explorer.js +29 -15
- package/$server/$folder/lib/node/node.js +49 -4
- package/$server/$folder/lib/security/users/users.js +68 -3
- package/$server/$folder/lib/tools/tools.js +3 -3
- package/$server/$folder/lib/tree/tree.js +29 -13
- package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/gantt.js" +293 -1
- package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/scheduler.js" +234 -1
- package/ORGANIZATIONS/$domain/class.js +1 -0
- package/PROJECTS/$domain/class.js +1 -0
- package/package.json +1 -1
- package/sources/client/handler.js +27 -11
- package/sources/client.js +36 -0
- package/sources/data/api.js +25 -5
- package/sources/data/db.js +39 -0
- package/sources/data/scope.js +2 -1
- package/sources/host/websocket.js +22 -0
- package/sources/modules/agent/index.js +11 -1
- package/sources/modules/agent/node-rules.js +171 -0
- package/sources/modules/agent/resources.js +1 -0
- package/sources/modules/agent/scheduler.js +75 -17
- package/sources/modules/agent/triggers.js +486 -198
- package/sources/modules/agent/twin-bus.js +163 -0
- package/sources/server/access/gateway.js +3 -0
- package/sources/server/access/links.js +8 -4
- package/sources/server/access/policy.js +7 -2
- package/sources/server/access/workplaces.js +14 -5
- package/sources/server/chat-threads.js +640 -0
- package/sources/server/class/archive.js +4 -3
- package/sources/server/class/feed.js +59 -0
- package/sources/server/class/security.js +18 -3
- package/sources/server/handler.js +1 -2
- package/$server/$folder/$class/$structure/$base/handlers/methods/archive/$handler/class.js +0 -23
- package/$server/$folder/$class/$structure/$project/handlers/methods/archive/$handler/class.js +0 -23
- package/$server/$folder/$class/$structure/$server/handlers/pages/form/license/$handler/class.js +0 -9
- package/$server/$folder/$class/$structure/handlers/pages/form/database/$handler/class.js +0 -9
- package/$server/$folder/$class/$structure/handlers/pages/form/gantt/$handler/class.js +0 -27
- package/$server/$folder/$class/$structure/handlers/pages/form/gantt/$handler/gantt.js +0 -293
- package/$server/$folder/$class/$structure/handlers/pages/form/messengers/$handler/class.js +0 -5
- package/$server/$folder/$class/$structure/handlers/pages/form/scheduler/$handler/class.js +0 -27
- package/$server/$folder/$class/$structure/handlers/pages/form/scheduler/$handler/scheduler.js +0 -234
- package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/class.js +0 -5
- package/$server/$folder/$class/$structure/handlers/pages/form/staff/$handler/class.js +0 -5
- package/ORGANIZATIONS/$domain/handlers/methods/restore/$handler/class.js +0 -173
- /package/$server/$folder/$class/$structure/handlers/pages/form/{database/$handler → system/$handler/tabs}/database.js +0 -0
- /package/$server/$folder/$class/$structure/{$server/handlers/pages/form/license/$handler → handlers/pages/form/system/$handler/tabs}/license.js +0 -0
- /package/$server/$folder/$class/$structure/handlers/pages/form/{messengers/$handler → system/$handler/tabs}/messengers.js +0 -0
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import * as fs from 'node:fs';
|
|
5
5
|
import { FS } from '../index.js';
|
|
6
6
|
import * as LOGS from '../logs.js';
|
|
7
|
+
import * as CHAT from '../chat-threads.js';
|
|
7
8
|
import * as POLICY from '../access/policy.js';
|
|
8
9
|
import { DEV_MODE } from '../../host/config.js';
|
|
9
10
|
|
|
@@ -167,6 +168,64 @@ export const classFeedMethods = {
|
|
|
167
168
|
return LOGS.deleteLogEntry(this, params);
|
|
168
169
|
},
|
|
169
170
|
|
|
171
|
+
/** Открыть/создать беседу мессенджера (twin на $structure, dm на $user, group). */
|
|
172
|
+
async chat_thread_open(params = {}) {
|
|
173
|
+
return CHAT.openThread(this, params);
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
/** Список бесед (mine — свои, audit — взаимодействия пользователей с Агентом для BOSS). */
|
|
177
|
+
async chat_threads_list(params = {}) {
|
|
178
|
+
return CHAT.listThreads(this, params);
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
/** Сообщения беседы с проверкой прав (участник или BOSS для twin-аудита). */
|
|
182
|
+
async chat_messages_list(params = {}) {
|
|
183
|
+
return CHAT.listMessages(this, params);
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
/** Отправить сообщение в беседу + рассылка по WebSocket. */
|
|
187
|
+
async chat_send(params = {}) {
|
|
188
|
+
return CHAT.sendMessage(this, params);
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
/** Отметить беседу прочитанной. */
|
|
192
|
+
async chat_mark_read(params = {}) {
|
|
193
|
+
return CHAT.markRead(this, params);
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
/** Сводка непрочитанного. */
|
|
197
|
+
async chat_unread_summary(params = {}) {
|
|
198
|
+
return CHAT.unreadSummary(this, params);
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
/** Подтвердить/отклонить карточку действия (kind = 'approval') в беседе. */
|
|
202
|
+
async chat_action(params = {}) {
|
|
203
|
+
return CHAT.resolveApproval(this, params);
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
/** Вычисляемый список видимых контактов («Люди»). */
|
|
207
|
+
async visible_contacts(params = {}) {
|
|
208
|
+
return CHAT.visibleContacts(this, params);
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
/** Список проактивных правил и расписаний узла (только BOSS). */
|
|
212
|
+
async agent_rules_list(params = {}) {
|
|
213
|
+
const { listNodeRules } = await import('../../modules/agent/node-rules.js');
|
|
214
|
+
return listNodeRules(this, params);
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
/** Сохранить/удалить правило проактивности узла (только BOSS). */
|
|
218
|
+
async agent_rule_save(params = {}) {
|
|
219
|
+
const { saveNodeRule } = await import('../../modules/agent/node-rules.js');
|
|
220
|
+
return saveNodeRule(this, params);
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
/** Сохранить/переключить/удалить расписание узла (только BOSS). */
|
|
224
|
+
async agent_schedule_save(params = {}) {
|
|
225
|
+
const { saveNodeSchedule } = await import('../../modules/agent/node-rules.js');
|
|
226
|
+
return saveNodeSchedule(this, params);
|
|
227
|
+
},
|
|
228
|
+
|
|
170
229
|
/** @deprecated используй append_log_includes({ entryPath, includePaths }) */
|
|
171
230
|
async appendLogIncludes(entryPath, includePaths = [], params = {}) {
|
|
172
231
|
if (entryPath && typeof entryPath === 'object' && entryPath.entryPath) {
|
|
@@ -136,6 +136,13 @@ export const classSecurityMethods = {
|
|
|
136
136
|
|| WORKPLACES.hasPlaceAssignments(this.DATA?.['#security']);
|
|
137
137
|
},
|
|
138
138
|
|
|
139
|
+
/** Назначен ли uid на внешнюю клиентскую роль (#security.CLIENT или место с external: true). */
|
|
140
|
+
async _isClientMember(uid) {
|
|
141
|
+
if (!(await this._isStructure()))
|
|
142
|
+
return false;
|
|
143
|
+
return WORKPLACES.isClientMember(this.DATA?.['#security'], uid);
|
|
144
|
+
},
|
|
145
|
+
|
|
139
146
|
/** Получить список ролей текущего пользователя в классе. */
|
|
140
147
|
async roles(params = {}) {
|
|
141
148
|
const uid = this.constructor.resolveUid(params);
|
|
@@ -144,6 +151,8 @@ export const classSecurityMethods = {
|
|
|
144
151
|
if (!uid) {
|
|
145
152
|
if (WORKPLACES.matchesUserList(this._roleIds('USER', declared), null) || await this._isPlaceMember(null))
|
|
146
153
|
return ['USER'];
|
|
154
|
+
if (WORKPLACES.matchesUserList(this._roleIds('CLIENT', declared), null) || await this._isClientMember(null))
|
|
155
|
+
return ['CLIENT'];
|
|
147
156
|
return [];
|
|
148
157
|
}
|
|
149
158
|
const roles = [];
|
|
@@ -167,6 +176,8 @@ export const classSecurityMethods = {
|
|
|
167
176
|
}
|
|
168
177
|
if (!roles.includes('USER') && await this._isPlaceMember(uid))
|
|
169
178
|
roles.push('USER');
|
|
179
|
+
if (!roles.includes('CLIENT') && await this._isClientMember(uid))
|
|
180
|
+
roles.push('CLIENT');
|
|
170
181
|
const principal = params.session?.principal;
|
|
171
182
|
if (principal?.kind === 'node') {
|
|
172
183
|
const claimed = principal.roles?.length ? new Set(principal.roles) : null;
|
|
@@ -188,7 +199,8 @@ export const classSecurityMethods = {
|
|
|
188
199
|
return false;
|
|
189
200
|
await this.init;
|
|
190
201
|
return WORKPLACES.matchesUserList(this._roleIds(role), uid)
|
|
191
|
-
|| (role === this.constructor.ROLES.USER && await this._isPlaceMember(uid))
|
|
202
|
+
|| (role === this.constructor.ROLES.USER && await this._isPlaceMember(uid))
|
|
203
|
+
|| (role === 'CLIENT' && await this._isClientMember(uid));
|
|
192
204
|
},
|
|
193
205
|
|
|
194
206
|
/** Единое файловое хранилище точки — метапапка класса без деления на подпапки ролей. */
|
|
@@ -242,8 +254,10 @@ export const classSecurityMethods = {
|
|
|
242
254
|
}
|
|
243
255
|
}
|
|
244
256
|
else {
|
|
245
|
-
|
|
246
|
-
|
|
257
|
+
if (roles.includes('USER')) {
|
|
258
|
+
for (const l of common)
|
|
259
|
+
add(l.id, l.access, [null]);
|
|
260
|
+
}
|
|
247
261
|
for (const [id, e] of WORKPLACES.placeLinksFor(sec, uid, { bossAll: false }))
|
|
248
262
|
add(id, e.access, e.via);
|
|
249
263
|
}
|
|
@@ -423,6 +437,7 @@ export const classSecurityMethods = {
|
|
|
423
437
|
links.push({ id: l.id, access: l.access, ...(await describe(l.id) || {}) });
|
|
424
438
|
out.push({
|
|
425
439
|
id: node.id, label: node.label, icon: node.icon,
|
|
440
|
+
...(node.external ? { external: true } : {}),
|
|
426
441
|
users: [...node.USERS], links,
|
|
427
442
|
tree: await this._linkTrie(toEff(node.LINKS, [key])),
|
|
428
443
|
mine: mine.has(key),
|
|
@@ -102,9 +102,8 @@ export class $handler extends $class {
|
|
|
102
102
|
data.service = true;
|
|
103
103
|
data.isService = true;
|
|
104
104
|
}
|
|
105
|
-
if (this.DATA?.isButton
|
|
105
|
+
if (this.DATA?.isButton) {
|
|
106
106
|
data.isButton = true;
|
|
107
|
-
data.button = true;
|
|
108
107
|
}
|
|
109
108
|
if (this.DATA?.allowList)
|
|
110
109
|
data.allowList = true;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Архивация организации ($base): упаковывает все классы, подразделения,
|
|
3
|
-
* файлы и изолированную БД work.db в единый ZIP-архив и скачивает его.
|
|
4
|
-
*/
|
|
5
|
-
export default {
|
|
6
|
-
icon: 'icons:archive',
|
|
7
|
-
label: 'Архивация',
|
|
8
|
-
roles: ['BOSS'],
|
|
9
|
-
order: 10,
|
|
10
|
-
async execute() {
|
|
11
|
-
const ctx = await (this.$context || this.$item?.$context);
|
|
12
|
-
const target = ctx?.type === '$base' ? ctx : (this.$context || this.$item);
|
|
13
|
-
const shortPath = target?.short || target?.path;
|
|
14
|
-
if (!shortPath)
|
|
15
|
-
return;
|
|
16
|
-
const link = document.createElement('a');
|
|
17
|
-
link.href = encodeURI(shortPath) + '?export_archive';
|
|
18
|
-
link.download = `${target.id || 'organization'}.zip`;
|
|
19
|
-
document.body.appendChild(link);
|
|
20
|
-
link.click();
|
|
21
|
-
link.remove();
|
|
22
|
-
},
|
|
23
|
-
}
|
package/$server/$folder/$class/$structure/$project/handlers/methods/archive/$handler/class.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Архивация проекта ($project): упаковывает все рабочие места, модули,
|
|
3
|
-
* файлы и изолированную БД work.db в единый ZIP-архив и скачивает его.
|
|
4
|
-
*/
|
|
5
|
-
export default {
|
|
6
|
-
icon: 'icons:archive',
|
|
7
|
-
label: 'Архивация',
|
|
8
|
-
roles: ['BOSS'],
|
|
9
|
-
order: 10,
|
|
10
|
-
async execute() {
|
|
11
|
-
const ctx = await (this.$context || this.$item?.$context);
|
|
12
|
-
const target = ctx?.type === '$project' ? ctx : (this.$context || this.$item);
|
|
13
|
-
const shortPath = target?.short || target?.path;
|
|
14
|
-
if (!shortPath)
|
|
15
|
-
return;
|
|
16
|
-
const link = document.createElement('a');
|
|
17
|
-
link.href = encodeURI(shortPath) + '?export_archive';
|
|
18
|
-
link.download = `${target.id || 'project'}.zip`;
|
|
19
|
-
document.body.appendChild(link);
|
|
20
|
-
link.click();
|
|
21
|
-
link.remove();
|
|
22
|
-
},
|
|
23
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
label: 'Диаграмма Ганта',
|
|
3
|
-
icon: 'carbon:chart-gantt',
|
|
4
|
-
order: 29,
|
|
5
|
-
allowSave: false,
|
|
6
|
-
roles: ['BOSS', 'USER'],
|
|
7
|
-
async allowUse($context) {
|
|
8
|
-
const t = $context?.type;
|
|
9
|
-
if (t === '$catalog')
|
|
10
|
-
return String($context?.path || '').includes('/Process/Задачи и этапы');
|
|
11
|
-
if (t === '$server' || t === '$user')
|
|
12
|
-
return true;
|
|
13
|
-
if (t === '$base' || t === '$project' || t === '$structure') {
|
|
14
|
-
const m = /^(\/(?:ORGANIZATIONS|PROJECTS)\/[^/]+)/.exec(String($context?.path || ''));
|
|
15
|
-
if (m) {
|
|
16
|
-
try {
|
|
17
|
-
const mod = await globalThis.WORK?.get_item(`${m[1]}/MODULES/Process`);
|
|
18
|
-
return Boolean(mod && !(await mod.isModuleBlocked?.()));
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
},
|
|
27
|
-
}
|
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Единое представление «Диаграмма Ганта» (form/gantt): временная шкала задач и этапов,
|
|
3
|
-
* отображение длительности, прогресса выполнения, зависимостей (depends_on) и сдвига сроков.
|
|
4
|
-
*/
|
|
5
|
-
function parseIsoDay(s) {
|
|
6
|
-
if (!s)
|
|
7
|
-
return null;
|
|
8
|
-
const t = Date.parse(String(s).slice(0, 10) + 'T00:00:00Z');
|
|
9
|
-
return Number.isFinite(t) ? t : null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function fmtIsoDay(ms) {
|
|
13
|
-
return new Date(ms).toISOString().slice(0, 10);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const DAY_MS = 86400_000;
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
imports: 'oda//button, oda//icon',
|
|
20
|
-
template: /* html */`
|
|
21
|
-
<style>
|
|
22
|
-
:host {
|
|
23
|
-
@apply --vertical;
|
|
24
|
-
@apply --flex;
|
|
25
|
-
overflow: hidden;
|
|
26
|
-
background: var(--content-background);
|
|
27
|
-
color: var(--content-color);
|
|
28
|
-
font-size: 12.5px;
|
|
29
|
-
}
|
|
30
|
-
.toolbar {
|
|
31
|
-
@apply --horizontal;
|
|
32
|
-
align-items: center;
|
|
33
|
-
gap: 8px;
|
|
34
|
-
padding: 8px 12px;
|
|
35
|
-
border-bottom: 1px solid var(--subtle-border);
|
|
36
|
-
background: var(--subtle-background);
|
|
37
|
-
flex-wrap: wrap;
|
|
38
|
-
}
|
|
39
|
-
.gantt-wrap {
|
|
40
|
-
@apply --flex;
|
|
41
|
-
overflow: auto;
|
|
42
|
-
position: relative;
|
|
43
|
-
}
|
|
44
|
-
.gantt-grid {
|
|
45
|
-
display: flex;
|
|
46
|
-
flex-direction: column;
|
|
47
|
-
min-width: max-content;
|
|
48
|
-
}
|
|
49
|
-
.gantt-head, .gantt-row {
|
|
50
|
-
display: flex;
|
|
51
|
-
align-items: center;
|
|
52
|
-
border-bottom: 1px solid var(--subtle-border);
|
|
53
|
-
}
|
|
54
|
-
.gantt-head {
|
|
55
|
-
position: sticky;
|
|
56
|
-
top: 0;
|
|
57
|
-
z-index: 3;
|
|
58
|
-
background: var(--subtle-background);
|
|
59
|
-
font-weight: 700;
|
|
60
|
-
}
|
|
61
|
-
.left-col {
|
|
62
|
-
width: 280px;
|
|
63
|
-
flex-shrink: 0;
|
|
64
|
-
padding: 6px 10px;
|
|
65
|
-
border-right: 1px solid var(--subtle-border);
|
|
66
|
-
position: sticky;
|
|
67
|
-
left: 0;
|
|
68
|
-
background: var(--content-background);
|
|
69
|
-
z-index: 2;
|
|
70
|
-
display: flex;
|
|
71
|
-
justify-content: space-between;
|
|
72
|
-
align-items: center;
|
|
73
|
-
gap: 6px;
|
|
74
|
-
}
|
|
75
|
-
.gantt-head .left-col {
|
|
76
|
-
background: var(--subtle-background);
|
|
77
|
-
z-index: 4;
|
|
78
|
-
}
|
|
79
|
-
.timeline {
|
|
80
|
-
position: relative;
|
|
81
|
-
display: flex;
|
|
82
|
-
height: 32px;
|
|
83
|
-
}
|
|
84
|
-
.day-cell {
|
|
85
|
-
width: {{dayWidth}}px;
|
|
86
|
-
flex-shrink: 0;
|
|
87
|
-
border-right: 1px dashed rgba(148,163,184,0.28);
|
|
88
|
-
text-align: center;
|
|
89
|
-
line-height: 32px;
|
|
90
|
-
font-size: 11px;
|
|
91
|
-
color: var(--muted-color);
|
|
92
|
-
}
|
|
93
|
-
.day-cell.weekend {
|
|
94
|
-
background: rgba(148,163,184,0.08);
|
|
95
|
-
}
|
|
96
|
-
.bar {
|
|
97
|
-
position: absolute;
|
|
98
|
-
top: 5px;
|
|
99
|
-
height: 22px;
|
|
100
|
-
border-radius: 6px;
|
|
101
|
-
background: rgba(29, 99, 220, 0.25);
|
|
102
|
-
border: 1px solid #1d63dc;
|
|
103
|
-
overflow: hidden;
|
|
104
|
-
cursor: pointer;
|
|
105
|
-
display: flex;
|
|
106
|
-
align-items: center;
|
|
107
|
-
}
|
|
108
|
-
.bar.done {
|
|
109
|
-
background: rgba(16, 185, 129, 0.28);
|
|
110
|
-
border-color: #10b981;
|
|
111
|
-
}
|
|
112
|
-
.bar-fill {
|
|
113
|
-
height: 100%;
|
|
114
|
-
background: rgba(29, 99, 220, 0.72);
|
|
115
|
-
}
|
|
116
|
-
.bar.done .bar-fill {
|
|
117
|
-
background: rgba(16, 185, 129, 0.8);
|
|
118
|
-
}
|
|
119
|
-
.bar-lbl {
|
|
120
|
-
position: relative;
|
|
121
|
-
z-index: 1;
|
|
122
|
-
padding: 0 6px;
|
|
123
|
-
font-size: 11px;
|
|
124
|
-
font-weight: 600;
|
|
125
|
-
white-space: nowrap;
|
|
126
|
-
color: var(--content-color);
|
|
127
|
-
}
|
|
128
|
-
.shift-btns {
|
|
129
|
-
display: flex;
|
|
130
|
-
gap: 2px;
|
|
131
|
-
}
|
|
132
|
-
.shift-btn {
|
|
133
|
-
border: 1px solid var(--subtle-border);
|
|
134
|
-
background: var(--subtle-background);
|
|
135
|
-
color: var(--content-color);
|
|
136
|
-
border-radius: 4px;
|
|
137
|
-
cursor: pointer;
|
|
138
|
-
font-size: 11px;
|
|
139
|
-
padding: 1px 5px;
|
|
140
|
-
}
|
|
141
|
-
</style>
|
|
142
|
-
|
|
143
|
-
<div class="toolbar">
|
|
144
|
-
<b>Диаграмма Ганта ({{bars.length}})</b>
|
|
145
|
-
<oda-button icon="icons:zoom-in" @tap="dayWidth = Math.min(48, dayWidth + 6)">Крупнее</oda-button>
|
|
146
|
-
<oda-button icon="icons:zoom-out" @tap="dayWidth = Math.max(18, dayWidth - 6)">Мельче</oda-button>
|
|
147
|
-
<oda-button icon="icons:refresh" @tap="reload()">Обновить</oda-button>
|
|
148
|
-
<span style="margin-left:auto;color:var(--muted-color);">Период: {{minDayStr}} — {{maxDayStr}}</span>
|
|
149
|
-
</div>
|
|
150
|
-
|
|
151
|
-
<div class="gantt-wrap">
|
|
152
|
-
<div class="gantt-grid">
|
|
153
|
-
<div class="gantt-head">
|
|
154
|
-
<div class="left-col">Задача / Этап</div>
|
|
155
|
-
<div class="timeline">
|
|
156
|
-
<div ~for="days" class="day-cell" ~class="{weekend: $for.item.weekend}">{{$for.item.label}}</div>
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
|
|
160
|
-
<div ~if="!bars.length" style="padding:20px;color:var(--muted-color);">
|
|
161
|
-
Нет задач с датами. Создайте этапы в «Планировщике» или запустите BPMN-процесс.
|
|
162
|
-
</div>
|
|
163
|
-
|
|
164
|
-
<div class="gantt-row" ~for="bars">
|
|
165
|
-
<div class="left-col">
|
|
166
|
-
<span style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;" @tap="openTask($for.item)">{{$for.item.title}}</span>
|
|
167
|
-
<div class="shift-btns">
|
|
168
|
-
<button class="shift-btn" title="Сдвинуть на −1 день" @tap="shiftBar($for.item, -1)">◀</button>
|
|
169
|
-
<button class="shift-btn" title="Сдвинуть на +1 день" @tap="shiftBar($for.item, 1)">▶</button>
|
|
170
|
-
</div>
|
|
171
|
-
</div>
|
|
172
|
-
<div class="timeline" :style="'width:' + (days.length * dayWidth) + 'px;'">
|
|
173
|
-
<div ~for="days" class="day-cell" ~class="{weekend: $for.$for.item.weekend}"></div>
|
|
174
|
-
<div class="bar" ~class="{done: $for.item.status === 'Выполнено'}"
|
|
175
|
-
:style="'left:' + $for.item.leftPx + 'px;width:' + $for.item.widthPx + 'px;'"
|
|
176
|
-
:title="$for.item.startStr + ' → ' + $for.item.dueStr + ' (' + $for.item.progress + '%)'"
|
|
177
|
-
@tap="openTask($for.item)">
|
|
178
|
-
<div class="bar-fill" :style="'width:' + $for.item.progress + '%'"></div>
|
|
179
|
-
<span class="bar-lbl">{{$for.item.progress}}%</span>
|
|
180
|
-
</div>
|
|
181
|
-
</div>
|
|
182
|
-
</div>
|
|
183
|
-
</div>
|
|
184
|
-
</div>
|
|
185
|
-
`,
|
|
186
|
-
items: [],
|
|
187
|
-
tasksTarget: null,
|
|
188
|
-
dayWidth: 28,
|
|
189
|
-
attached() {
|
|
190
|
-
this.reload();
|
|
191
|
-
},
|
|
192
|
-
async _resolveTarget() {
|
|
193
|
-
const p = String(this.$item?.short || this.$item?.path || '');
|
|
194
|
-
if (p.includes('/Process/Задачи и этапы') && this.$item?.fetch)
|
|
195
|
-
return this.$item;
|
|
196
|
-
const m = /^(\/(?:ORGANIZATIONS|PROJECTS)\/[^/]+)/.exec(p);
|
|
197
|
-
if (m) {
|
|
198
|
-
const candidate = await WORK.get_item(`${m[1]}/MODULES/Process/Задачи и этапы`).catch(() => null);
|
|
199
|
-
if (candidate?.fetch)
|
|
200
|
-
return candidate;
|
|
201
|
-
}
|
|
202
|
-
const rootCandidate = await WORK.get_item('/MODULES/Process/Задачи и этапы').catch(() => null);
|
|
203
|
-
return rootCandidate?.fetch ? rootCandidate : null;
|
|
204
|
-
},
|
|
205
|
-
get range() {
|
|
206
|
-
const todayMs = parseIsoDay(new Date().toISOString().slice(0, 10));
|
|
207
|
-
let minMs = todayMs - 2 * DAY_MS;
|
|
208
|
-
let maxMs = todayMs + 14 * DAY_MS;
|
|
209
|
-
for (const it of this.items || []) {
|
|
210
|
-
const s = parseIsoDay(it.start_at);
|
|
211
|
-
const e = parseIsoDay(it.due_at);
|
|
212
|
-
if (s && s < minMs)
|
|
213
|
-
minMs = s - DAY_MS;
|
|
214
|
-
if (e && e > maxMs)
|
|
215
|
-
maxMs = e + 2 * DAY_MS;
|
|
216
|
-
}
|
|
217
|
-
return { minMs, maxMs };
|
|
218
|
-
},
|
|
219
|
-
get minDayStr() {
|
|
220
|
-
return fmtIsoDay(this.range.minMs);
|
|
221
|
-
},
|
|
222
|
-
get maxDayStr() {
|
|
223
|
-
return fmtIsoDay(this.range.maxMs);
|
|
224
|
-
},
|
|
225
|
-
get days() {
|
|
226
|
-
const { minMs, maxMs } = this.range;
|
|
227
|
-
const out = [];
|
|
228
|
-
for (let t = minMs; t <= maxMs && out.length < 180; t += DAY_MS) {
|
|
229
|
-
const d = new Date(t);
|
|
230
|
-
const dow = d.getUTCDay();
|
|
231
|
-
out.push({
|
|
232
|
-
ms: t,
|
|
233
|
-
label: `${String(d.getUTCDate()).padStart(2, '0')}.${String(d.getUTCMonth() + 1).padStart(2, '0')}`,
|
|
234
|
-
weekend: dow === 0 || dow === 6,
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
return out;
|
|
238
|
-
},
|
|
239
|
-
get bars() {
|
|
240
|
-
const { minMs } = this.range;
|
|
241
|
-
return (this.items || []).map(it => {
|
|
242
|
-
const s = parseIsoDay(it.start_at) || parseIsoDay(it.due_at) || minMs;
|
|
243
|
-
const e = Math.max(s, parseIsoDay(it.due_at) || s);
|
|
244
|
-
const leftDays = Math.max(0, Math.round((s - minMs) / DAY_MS));
|
|
245
|
-
const spanDays = Math.max(1, Math.round((e - s) / DAY_MS) + 1);
|
|
246
|
-
return {
|
|
247
|
-
...it,
|
|
248
|
-
startMs: s,
|
|
249
|
-
dueMs: e,
|
|
250
|
-
startStr: fmtIsoDay(s),
|
|
251
|
-
dueStr: fmtIsoDay(e),
|
|
252
|
-
leftPx: leftDays * this.dayWidth + 2,
|
|
253
|
-
widthPx: Math.max(18, spanDays * this.dayWidth - 4),
|
|
254
|
-
};
|
|
255
|
-
});
|
|
256
|
-
},
|
|
257
|
-
async reload() {
|
|
258
|
-
const target = await this._resolveTarget();
|
|
259
|
-
this.tasksTarget = target;
|
|
260
|
-
if (!target?.fetch) {
|
|
261
|
-
this.items = [];
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
const res = await target.fetch('db_query', { limit: 300 }).catch(() => null);
|
|
265
|
-
this.items = (res?.items || []).map(o => ({
|
|
266
|
-
id: o.id,
|
|
267
|
-
version: o.version,
|
|
268
|
-
title: o.title || o.id,
|
|
269
|
-
start_at: o.body?.start_at || new Date().toISOString().slice(0, 10),
|
|
270
|
-
due_at: o.body?.due_at || o.body?.start_at || new Date().toISOString().slice(0, 10),
|
|
271
|
-
progress: Number(o.body?.progress) || 0,
|
|
272
|
-
status: o.body?.status || 'К выполнению',
|
|
273
|
-
body: o.body || {},
|
|
274
|
-
}));
|
|
275
|
-
},
|
|
276
|
-
async shiftBar(bar, deltaDays) {
|
|
277
|
-
if (!bar?.id || !this.tasksTarget?.fetch)
|
|
278
|
-
return;
|
|
279
|
-
const nextStart = fmtIsoDay(bar.startMs + deltaDays * DAY_MS);
|
|
280
|
-
const nextDue = fmtIsoDay(bar.dueMs + deltaDays * DAY_MS);
|
|
281
|
-
await this.tasksTarget.fetch('db_update', {}, {
|
|
282
|
-
id: bar.id,
|
|
283
|
-
version: bar.version,
|
|
284
|
-
body: { ...bar.body, start_at: nextStart, due_at: nextDue },
|
|
285
|
-
});
|
|
286
|
-
await this.reload();
|
|
287
|
-
},
|
|
288
|
-
openTask(bar) {
|
|
289
|
-
if (!bar?.id || !this.tasksTarget)
|
|
290
|
-
return;
|
|
291
|
-
window.execute?.(this.tasksTarget, { view: 'object', id: bar.id });
|
|
292
|
-
},
|
|
293
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
label: 'Планировщик',
|
|
3
|
-
icon: 'carbon:calendar-heat-map',
|
|
4
|
-
order: 28,
|
|
5
|
-
allowSave: false,
|
|
6
|
-
roles: ['BOSS', 'USER'],
|
|
7
|
-
async allowUse($context) {
|
|
8
|
-
const t = $context?.type;
|
|
9
|
-
if (t === '$catalog')
|
|
10
|
-
return String($context?.path || '').includes('/Process/Задачи и этапы');
|
|
11
|
-
if (t === '$server' || t === '$user')
|
|
12
|
-
return true;
|
|
13
|
-
if (t === '$base' || t === '$project' || t === '$structure') {
|
|
14
|
-
const m = /^(\/(?:ORGANIZATIONS|PROJECTS)\/[^/]+)/.exec(String($context?.path || ''));
|
|
15
|
-
if (m) {
|
|
16
|
-
try {
|
|
17
|
-
const mod = await globalThis.WORK?.get_item(`${m[1]}/MODULES/Process`);
|
|
18
|
-
return Boolean(mod && !(await mod.isModuleBlocked?.()));
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
},
|
|
27
|
-
}
|