odant-work 1.0.90 → 1.0.92
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 +275 -246
- package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/$virtual/class.js +4 -0
- package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/class.js +4 -0
- package/$server/$folder/$class/$data/$catalog/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +4 -0
- package/$server/$folder/$class/$data/$catalog/$virtual/class.js +8 -0
- package/{MODULES/Register/CATALOGS/$catalog/$folder/$class → $server/$folder/$class/$data}/$catalog/class.js +1 -0
- package/$server/$folder/$class/$data/$operation/$folder/$class/$data/$operation/class.js +4 -0
- package/{MODULES/Register/OPERATIONS/$operation/$folder/$class → $server/$folder/$class/$data}/$operation/class.js +1 -0
- package/$server/$folder/$class/$data/$register/$account/$folder/$class/$data/$register/$account/class.js +4 -0
- package/$server/$folder/$class/$data/$register/$account/class.js +8 -0
- package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/$account/class.js +4 -0
- package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/class.js +4 -0
- package/$server/$folder/$class/$data/$register/class.js +8 -0
- package/$server/$folder/$class/$data/$struct/$folder/$class/$data/$struct/class.js +4 -0
- package/$server/$folder/$class/$data/$struct/class.js +5 -0
- package/$server/$folder/$class/$data/class.js +5 -0
- package/$server/$folder/$class/$data/handlers/pages/form/objects/$handler/class.js +2158 -0
- package/$server/$folder/$class/$data/handlers/pages/form/objects/object/$handler/class.js +1377 -0
- package/$server/$folder/$class/$domain/$folder/$class/$domain/class.js +4 -0
- package/$server/$folder/$class/$domain/handlers/methods/restore/$handler/class.js +5 -5
- package/$server/$folder/$class/$domain/readme.md +1 -1
- package/$server/$folder/$class/$handler/$method/class.js +4 -0
- package/$server/$folder/$class/$handler/$timer/class.js +4 -0
- package/$server/$folder/$class/$module/$folder/$class/$data/$catalog/class.js +4 -0
- package/$server/$folder/$class/$module/$folder/$class/$data/$operation/class.js +4 -0
- package/$server/$folder/$class/$module/$folder/$class/$data/$register/class.js +4 -0
- package/$server/$folder/$class/$module/$folder/$class/$data/$struct/class.js +4 -0
- package/$server/$folder/$class/$module/$folder/$class/$domain/class.js +4 -0
- package/$server/$folder/$class/$module/$folder/$class/$module/class.js +4 -0
- package/$server/$folder/$class/$module/class.js +418 -6
- package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/mcp.js → $module/handlers/pages/form/system/mcp/$handler/class.js} +261 -220
- package/$server/$folder/$class/$module/handlers/pages/form/system/modules/$handler/class.js +7 -0
- package/$server/$folder/$class/$structure/$folder/$class/$structure/class.js +4 -0
- package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$catalog/class.js +4 -0
- package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$operation/class.js +4 -0
- package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$register/class.js +4 -0
- package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$struct/class.js +4 -0
- package/$server/$folder/$class/$structure/$organization/$folder/$class/$domain/class.js +4 -0
- package/$server/$folder/$class/$structure/$organization/$folder/$class/$module/class.js +4 -0
- package/{ORGANIZATIONS/$domain/$folder/$class/$base → $server/$folder/$class/$structure/$organization/$folder/$class/$structure/$organization}/class.js +4 -5
- package/$server/$folder/$class/$structure/$organization/$folder/$class/$structure/class.js +4 -0
- package/{ORGANIZATIONS/$domain/$folder/$class/$base/$folder/$class/$structure/$base → $server/$folder/$class/$structure/$organization}/class.js +19 -17
- package/$server/$folder/$class/$structure/$organization/handlers/pages/form/system/requisites/$handler/class.js +3 -0
- package/$server/$folder/$class/$structure/{$base/handlers/pages/site/$handler/site.js → $organization/handlers/pages/site/$handler/class.js} +352 -365
- package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$catalog/class.js +4 -0
- package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$operation/class.js +4 -0
- package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$register/class.js +4 -0
- package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$struct/class.js +4 -0
- package/$server/$folder/$class/$structure/$project/$folder/$class/$domain/class.js +4 -0
- package/$server/$folder/$class/$structure/$project/$folder/$class/$module/class.js +4 -0
- package/$server/$folder/$class/$structure/$project/class.js +1 -0
- package/$server/$folder/$class/$structure/$project/readme.md +1 -1
- package/$server/$folder/$class/$structure/$server/$folder/$class/$domain/class.js +4 -0
- package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/database/$handler/class.js +3 -0
- package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/license.js → $structure/$server/handlers/pages/form/system/license/$handler/class.js} +104 -103
- package/$server/$folder/$class/$structure/$server/handlers/pages/site/$handler/{site.js → class.js} +45 -30
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +3 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/messengers/$handler/class.js +3 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/modules/$handler/class.js +3 -0
- package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js +18 -0
- package/$server/$folder/$class/$structure/ai/system.md +1 -1
- package/$server/$folder/$class/$structure/class.js +1 -1
- package/$server/$folder/$class/$structure/handlers/methods/archive/$handler/class.js +3 -3
- package/$server/$folder/$class/$structure/handlers/pages/data/$handler/class.js +309 -8
- package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/class.js +15 -4
- package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/class.js +1281 -7
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +2216 -6
- package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/class.js +1304 -6
- package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/methods/refresh/$method/class.js +1 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/class.js +305 -9
- package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/agent.js → $structure/handlers/pages/form/system/agent/$handler/class.js} +329 -320
- package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/database.js → $structure/handlers/pages/form/system/database/$handler/class.js} +510 -577
- package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/messengers.js → $structure/handlers/pages/form/system/messengers/$handler/class.js} +143 -144
- package/$server/$folder/$class/$structure/handlers/pages/form/system/modules/$handler/class.js +270 -0
- package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +2114 -0
- package/$server/$folder/$class/$structure/handlers/pages/site/$handler/class.js +229 -4
- package/$server/$folder/$class/$structure/handlers/pages/site/$handler/readme.md +1 -1
- package/$server/$folder/$class/$structure/readme.md +3 -3
- package/$server/$folder/$class/$users/$folder/$class/$structure/$user/class.js +4 -0
- package/$server/$folder/$class/$users/class.js +4 -0
- package/$server/$folder/$class/ai/agents/integrator-1c.md +1 -1
- package/$server/$folder/$class/ai/agents/it-admin.md +1 -1
- package/$server/$folder/$class/ai/agents/org-architect.md +4 -4
- package/$server/$folder/$class/ai/agents/readme.md +1 -1
- package/$server/$folder/$class/ai/agents/schema-validator.md +2 -2
- package/$server/$folder/$class/ai/skills/lan-inventory.md +2 -2
- package/$server/$folder/$class/ai/skills/org-structure.md +1 -1
- package/$server/$folder/$class/ai/skills/printer-setup.md +1 -1
- package/$server/$folder/$class/ai/skills/telegram-notify.md +2 -2
- package/$server/$folder/$class/ai/skills/work-scenarios.md +3 -3
- package/$server/$folder/$class/ai/system.md +14 -8
- package/$server/$folder/$class/class.js +2 -6
- package/$server/$folder/$class/handlers/pages/form/folder/$handler/class.js +3 -0
- package/$server/$folder/$class/handlers/pages/form/system/$handler/class.js +2 -4
- package/$server/$folder/$class/handlers/pages/form/system/files/$handler/class.js +7 -0
- package/$server/$folder/$class/handlers/pages/form/system/requisites/$handler/class.js +100 -0
- package/$server/$folder/$class/handlers/pages/storage/$handler/class.js +25 -6
- package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/class.js +32 -5
- package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/class.js +31 -3
- package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/class.js +11 -3
- package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/class.js +83 -3
- package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/class.js +61 -3
- package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/class.js +1699 -2
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +827 -2
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/readme.md +1 -1
- package/$server/$folder/$file/handlers/pages/form/file/$handler/class.js +33 -3
- package/$server/$folder/$file/handlers/pages/form/folder/$handler/class.js +3 -0
- package/$server/$folder/handlers/methods/create/$handler/class.js +5 -5
- package/$server/$folder/handlers/pages/form/$handler/class.js +2467 -3
- package/$server/$folder/handlers/pages/form/folder/$handler/class.js +22 -0
- package/$server/$folder/handlers/readme.md +1 -1
- package/$server/$folder/lib/chat-item/chat-item.js +5 -10
- package/$server/$folder/lib/consultant/consultant.js +7 -10
- package/$server/$folder/lib/explorer/explorer.js +1 -1
- package/$server/$folder/lib/icon/icon.js +1 -1
- package/$server/$folder/lib/menu/menu.js +3 -2
- package/$server/$folder/lib/messenger-settings/messenger-settings.js +4 -4
- package/$server/$folder/lib/node/node.js +3 -3
- package/$server/$folder/lib/prompt-bar/prompt-bar.js +2 -2
- package/$server/$folder/lib/role/role.js +1 -2
- package/$server/$folder/lib/security/admin/admin.js +3 -3
- package/$server/$folder/lib/security/security.js +4 -4
- package/$server/$folder/lib/security/users/users.js +2 -5
- package/$server/$folder/lib/site-loc/site-loc.js +3 -3
- package/$server/$folder/lib/tree/tree.js +14 -22
- package/$server/class.js +1 -0
- package/AGENTS.md +21 -13
- package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-model.js → MODELS/$ai/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js} +385 -425
- package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-provider.js → MODELS/$ai/$folder/$class/$provider/handlers/pages/form/system/ai/$handler/class.js} +157 -161
- package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-root.js → MODELS/$ai/handlers/pages/form/system/ai/$handler/class.js} +34 -33
- package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-local.js → MODELS/Local/$provider/handlers/pages/form/system/ai/$handler/class.js} +572 -622
- package/MODULES/$domain/class.js +85 -4
- package/MODULES/$domain/handlers/pages/form/system/mcp/$handler/class.js +7 -0
- package/MODULES/$domain/readme.md +7 -6
- package/{SERVICES/1C/$service → MODULES/1C/$module}/class.js +7 -1
- package/MODULES/2GIS/$module/class.js +32 -0
- package/MODULES/2GIS/$module/readme.md +57 -0
- package/{SERVICES/Bitrix24/$service → MODULES/Bitrix24/$module}/class.js +7 -2
- package/{SERVICES/CBR/$service → MODULES/CBR/$module}/class.js +5 -0
- package/{SERVICES/DaData/$service → MODULES/DaData/$module}/class.js +9 -3
- package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/class.js +648 -21
- package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/class.js +140 -6
- package/{SERVICES/Marketplaces/$service → MODULES/Marketplaces/$domain}/class.js +1 -1
- package/{SERVICES/Marketplaces/Ozon/$service → MODULES/Marketplaces/Ozon/$module}/class.js +1 -1
- package/{SERVICES/Marketplaces/Wildberries/$service → MODULES/Marketplaces/Wildberries/$module}/class.js +1 -1
- package/{SERVICES/Marketplaces/YandexMarket/$service → MODULES/Marketplaces/YandexMarket/$module}/class.js +1 -1
- package/MODULES/Process/$module/readme.md +1 -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/gantt/$handler/class.js" +305 -6
- 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/class.js" +241 -6
- package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/class.js" +515 -16
- package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual → $data/$catalog/$virtual}/class.js +3 -0
- package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/$virtual/handlers/pages/form/objects/$handler/class.js +3 -0
- package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual/handlers/pages/form/virtual/$handler/virtual.js → $data/$catalog/$virtual/handlers/pages/form/virtual/$handler/class.js} +413 -390
- package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/class.js +14 -0
- package/MODULES/Register/CATALOGS/$catalog/class.js +7 -14
- package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +9 -0
- package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/class.js +0 -7
- package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/$folder/$class/$data/$catalog/class.js +11 -0
- package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/class.js +0 -9
- package/MODULES/Register/OPERATIONS/$operation/$folder/$class/$data/$operation/class.js +16 -0
- package/MODULES/Register/OPERATIONS/$operation/class.js +0 -9
- package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/$folder/$class/$data/$operation/class.js +8 -0
- package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/class.js +4 -10
- package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/$folder/$class/$data/$operation/class.js +8 -0
- package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/class.js +0 -6
- package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/$folder/$class/$data/$operation/class.js +8 -0
- package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/class.js +4 -10
- package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/$folder/$class/$data/$operation/class.js" +10 -0
- package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/class.js" +4 -12
- package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/$folder/$class/$data/$operation/class.js" +10 -0
- package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/class.js" +4 -12
- package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/$folder/$class/$data/$operation/class.js +24 -0
- package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/class.js +0 -22
- package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/analysis/$handler/analysis.js → $data/$register/$account/handlers/pages/form/analysis/$handler/class.js} +9 -4
- package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/postings/$handler/postings.js → $data/$register/$account/handlers/pages/form/postings/$handler/class.js} +845 -753
- package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/turnovers/$handler/turnovers.js → $data/$register/$account/handlers/pages/form/turnovers/$handler/class.js} +9 -4
- package/MODULES/Register/REGISTER/$register/{$folder/$class/$register/handlers/pages/form/journal/$handler/journal.js → handlers/pages/form/journal/$handler/class.js} +382 -329
- package/MODULES/Register/REGISTER/$register/handlers/pages/form/sheet/$handler/class.js +807 -0
- package/MODULES/Register/REGISTER/10/$account/$folder/$class/$data/$register/$account/class.js +21 -0
- package/MODULES/Register/REGISTER/10/$account/class.js +0 -19
- package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/$folder/$class/$data/$register/$account/class.js +14 -0
- package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/class.js +4 -16
- package/{SERVICES/SearXNG/$service → MODULES/SearXNG/$module}/class.js +5 -0
- package/{SERVICES/Yandex/$service → MODULES/Yandex/$module}/class.js +7 -0
- package/{SERVICES/YandexDisk/$service → MODULES/YandexDisk/$module}/class.js +8 -2
- package/NODES/$node/handlers/pages/form/network/$handler/class.js +122 -5
- package/ORGANIZATIONS/$domain/$folder/$class/$structure/$organization/class.js +5 -0
- package/ORGANIZATIONS/$domain/class.js +5 -5
- package/oda/components/inputs/link/link.js +1 -1
- package/package.json +1 -1
- package/readme.md +6 -7
- package/scripts/check-architecture.mjs +541 -0
- package/scripts/cleanup-storage.mjs +1 -1
- package/scripts/demo-seed.mjs +3 -3
- package/scripts/import-bis.mjs +33 -15
- package/scripts/import-delovaya.mjs +26 -14
- package/sources/client/class.js +19 -10
- package/sources/client/folder.js +10 -22
- package/sources/client/handler.js +75 -33
- package/sources/data/api.js +9 -10
- package/sources/data/classes.js +85 -9
- package/sources/data/db.js +10 -6
- package/sources/data/print.js +15 -41
- package/sources/data/readme.md +5 -5
- package/sources/data/schema.js +206 -118
- package/sources/data/sql-inspector.js +7 -7
- package/sources/host/auth-methods.js +2 -5
- package/sources/host/auto-updater.js +1 -2
- package/sources/host/babel-merge.js +174 -129
- package/sources/host/prewarm.js +1 -1
- package/sources/host/watch.js +1 -1
- package/sources/index.html +1 -1
- package/sources/modules/agent/extensions.js +48 -38
- package/sources/modules/agent/index.js +1 -1
- package/sources/modules/agent/node-rules.js +69 -41
- package/sources/modules/agent/permissions.js +1 -1
- package/sources/modules/agent/plugins.js +11 -11
- package/sources/modules/agent/resources.js +96 -52
- package/sources/modules/agent/tools/net.js +1 -1
- package/sources/modules/agent/tools/services.js +7 -7
- package/sources/modules/agent/tools/work/access.js +10 -8
- package/sources/modules/agent/tools/work/classes.js +26 -47
- package/sources/modules/agent/tools/work/common.js +8 -10
- package/sources/modules/agent/tools/work/data.js +4 -4
- package/sources/modules/agent/triggers.js +1 -1
- package/sources/modules/agent/twin-bus.js +4 -4
- package/sources/modules/agent/voice.js +1 -1
- package/sources/modules/call/call.js +4 -4
- package/sources/modules/kladr/index.js +3 -3
- package/sources/modules/lan/register.js +7 -7
- package/sources/modules/mcp-marketplaces/ozon.js +1 -1
- package/sources/modules/mcp-marketplaces/wildberries.js +1 -1
- package/sources/modules/mcp-marketplaces/yandex-market.js +1 -1
- package/sources/modules/nodes/mount.js +2 -4
- package/sources/modules/notify/index.js +18 -18
- package/sources/modules/rag/extract.js +9 -2
- package/sources/modules/rag/indexer.js +1 -1
- package/sources/modules/rag/scope.js +7 -33
- package/sources/modules/trainer/dataset.js +2 -2
- package/sources/modules/trainer/local-engine.js +1 -1
- package/sources/page.html +2 -2
- package/sources/readme.md +1 -1
- package/sources/server/access/gateway.js +19 -19
- package/sources/server/access/invites.js +4 -5
- package/sources/server/access/links.js +10 -8
- package/sources/server/access/policy.js +65 -39
- package/sources/server/access/workplaces.js +20 -14
- package/sources/server/chat-threads.js +4 -4
- package/sources/server/class/archive.js +15 -15
- package/sources/server/class/base-template.js +13 -9
- package/sources/server/class/distro.js +3 -4
- package/sources/server/class/feed.js +3 -3
- package/sources/server/class/mail-calendar.js +9 -8
- package/sources/server/class/scaffold.js +110 -60
- package/sources/server/class/search.js +2 -2
- package/sources/server/class/security.js +76 -94
- package/sources/server/class.js +181 -64
- package/sources/server/file.js +2 -2
- package/sources/server/folder.js +376 -191
- package/sources/server/handler.js +52 -13
- package/sources/server/logs.js +7 -7
- package/sources/server/node.js +12 -43
- package/sources/server/server.js +16 -17
- package/$server/$folder/$class/$device/class.js +0 -3
- package/$server/$folder/$class/$handler/$task/class.js +0 -3
- package/$server/$folder/$class/$service/$class/$service/class.js +0 -4
- package/$server/$folder/$class/$structure/$base/class.js +0 -10
- package/$server/$folder/$class/$structure/$base/roots_1/roots.test +0 -0
- package/$server/$folder/$class/$structure/handlers/pages/data/$handler/data.js +0 -313
- package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/explorer.js +0 -16
- package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/calendar.js +0 -1226
- package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +0 -2217
- package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/email.js +0 -1188
- package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/search.js +0 -289
- package/$server/$folder/$class/$structure/handlers/pages/site/$handler/site.js +0 -240
- package/$server/$folder/$class/handlers/pages/form/object/$handler/class.js +0 -33
- package/$server/$folder/$class/handlers/pages/form/object/$handler/object.js +0 -1371
- package/$server/$folder/$class/handlers/pages/form/objects/$handler/class.js +0 -33
- package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +0 -2130
- package/$server/$folder/$class/handlers/pages/form/system/$handler/system.js +0 -384
- package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/modules.js +0 -244
- package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/staff.js +0 -2126
- package/$server/$folder/$class/handlers/pages/storage/$handler/storage.js +0 -21
- package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/editor.js +0 -27
- package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/file.js +0 -31
- package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/file.js +0 -10
- package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/file.js +0 -72
- package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/file.js +0 -63
- package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/file.js +0 -1845
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js +0 -785
- package/$server/$folder/$file/handlers/pages/form/file/$handler/file.js +0 -29
- package/$server/$folder/handlers/pages/form/$handler/form.js +0 -2122
- package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/map.js +0 -623
- package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/kladr.js +0 -134
- 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" +0 -293
- 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" +0 -234
- package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/bpmn.js" +0 -406
- package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$virtual/handlers/pages/form/virtual/$handler/class.js +0 -6
- package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/analysis/$handler/class.js +0 -9
- package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/postings/$handler/class.js +0 -9
- package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/turnovers/$handler/class.js +0 -9
- package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/journal/$handler/class.js +0 -6
- package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/sheet/$handler/class.js +0 -6
- package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/sheet/$handler/sheet.js +0 -808
- package/NODES/$node/handlers/pages/form/network/$handler/network.js +0 -110
- package/SERVICES/$service/$folder/$storage/$service/class.js +0 -8
- package/SERVICES/$service/class.js +0 -442
- package/SERVICES/readme.md +0 -36
- /package/$server/$folder/$class/$structure/{$base → $organization}/icon.png +0 -0
- /package/{SERVICES/DuckDuckGo/$service → MODULES/DuckDuckGo/$module}/class.js +0 -0
- /package/MODULES/KLADR/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
- /package/MODULES/Process/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
- /package/MODULES/Register/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
- /package/MODULES/Register/$module/$folder/$class/{$operation → $data/$operation}/class.js +0 -0
- /package/MODULES/Register/$module/$folder/$class/{$register → $data/$register}/class.js +0 -0
- /package/MODULES/Register/$module/$folder/$class/{$struct → $data/$struct}/class.js +0 -0
- /package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual/$folder/$class → $data/$catalog/$virtual/$folder/$class/$data/$catalog}/$virtual/class.js +0 -0
- /package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/{print → $folder/$class/$data/$operation/print}//320/237/320/273/320/260/321/202/321/221/320/266/320/275/320/276/320/265 /320/277/320/276/321/200/321/203/321/207/320/265/320/275/320/270/320/265.html" +0 -0
- /package/MODULES/Register/REGISTER/$register/$folder/$class/{$account → $data/$register/$account}/class.js +0 -0
- /package/MODULES/Register/REGISTER/$register/$folder/$class/{$account → $data/$register/$account}/readme.md +0 -0
- /package/MODULES/Register/REGISTER/$register/$folder/$class/{$register → $data/$register}/class.js +0 -0
- /package/MODULES/Register/STRUCTS/$struct/$folder/$class/{$struct → $data/$struct}/class.js +0 -0
- /package/{SERVICES/RuCalendar/$service → MODULES/RuCalendar/$module}/class.js +0 -0
- /package/{SERVICES/Telegram/$service → MODULES/Telegram/$module}/class.js +0 -0
- /package/{SERVICES/Weather/$service → MODULES/Weather/$module}/class.js +0 -0
- /package/PROJECTS/$domain/$folder/$class/{$project → $structure/$project}/class.js +0 -0
|
@@ -0,0 +1,2114 @@
|
|
|
1
|
+
const RWCD_RANK = Object.freeze({
|
|
2
|
+
none: 0,
|
|
3
|
+
read: 1,
|
|
4
|
+
write: 2,
|
|
5
|
+
create: 3,
|
|
6
|
+
delete: 4,
|
|
7
|
+
admin: 5
|
|
8
|
+
});
|
|
9
|
+
const RWCD_SEGMENTS = Object.freeze([{
|
|
10
|
+
key: 'none',
|
|
11
|
+
rank: 0,
|
|
12
|
+
short: '—',
|
|
13
|
+
title: 'Нет доступа'
|
|
14
|
+
}, {
|
|
15
|
+
key: 'read',
|
|
16
|
+
rank: 1,
|
|
17
|
+
short: 'R',
|
|
18
|
+
title: 'Чтение (R)'
|
|
19
|
+
}, {
|
|
20
|
+
key: 'write',
|
|
21
|
+
rank: 2,
|
|
22
|
+
short: 'W',
|
|
23
|
+
title: 'Редактирование и проведение (W)'
|
|
24
|
+
}, {
|
|
25
|
+
key: 'create',
|
|
26
|
+
rank: 3,
|
|
27
|
+
short: 'C',
|
|
28
|
+
title: 'Создание объектов и документов (C)'
|
|
29
|
+
}, {
|
|
30
|
+
key: 'delete',
|
|
31
|
+
rank: 4,
|
|
32
|
+
short: 'D',
|
|
33
|
+
title: 'Удаление и полный доступ к данным (D)'
|
|
34
|
+
}]);
|
|
35
|
+
function normalizeAccess(raw) {
|
|
36
|
+
if (raw === undefined || raw === null) return null;
|
|
37
|
+
const s = String(raw).trim().toLowerCase();
|
|
38
|
+
if (s === 'none' || s === '0' || s === '-') return 'none';
|
|
39
|
+
if (s === 'read' || s === '1' || s === 'r') return 'read';
|
|
40
|
+
if (s === 'write' || s === '2' || s === 'w') return 'write';
|
|
41
|
+
if (s === 'create' || s === '3' || s === 'c') return 'create';
|
|
42
|
+
if (s === 'delete' || s === '4' || s === 'd') return 'delete';
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function normPath(p) {
|
|
46
|
+
const s = String(p || '').trim().replace(/\\/g, '/').replace(/\/+$/, '');
|
|
47
|
+
return s || '/';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Стабильный порядок узлов дерева прав: по названию, затем по пути. */
|
|
51
|
+
const CLASS_LABEL_COLLATOR = new Intl.Collator('ru', {
|
|
52
|
+
numeric: true,
|
|
53
|
+
sensitivity: 'base'
|
|
54
|
+
});
|
|
55
|
+
function compareClassNodes(a, b) {
|
|
56
|
+
return CLASS_LABEL_COLLATOR.compare(String(a?.label || a?.id || ''), String(b?.label || b?.id || '')) || String(a?.id || '').localeCompare(String(b?.id || ''), 'ru');
|
|
57
|
+
}
|
|
58
|
+
function parseDroppedItem(e) {
|
|
59
|
+
const dt = e?.dataTransfer;
|
|
60
|
+
if (!dt) return null;
|
|
61
|
+
const rawJson = dt.getData('data') || dt.getData('application/json') || dt.getData('application/oda.work.shortcut');
|
|
62
|
+
if (rawJson) {
|
|
63
|
+
try {
|
|
64
|
+
const parsed = JSON.parse(rawJson);
|
|
65
|
+
if (parsed && typeof parsed === 'object') {
|
|
66
|
+
const p = String(parsed.path || parsed.short || '').replace(/\/+$/, '');
|
|
67
|
+
return {
|
|
68
|
+
id: parsed.id || p.split('/').pop() || '',
|
|
69
|
+
path: p,
|
|
70
|
+
type: parsed.type || '',
|
|
71
|
+
label: parsed.label || parsed.DATA?.label || parsed.id || p
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
} catch {/* ignore */}
|
|
75
|
+
}
|
|
76
|
+
const text = String(dt.getData('text/plain') || '').trim().replace(/\/+$/, '');
|
|
77
|
+
if (!text.startsWith('/')) return null;
|
|
78
|
+
return {
|
|
79
|
+
id: text.split('/').pop() || '',
|
|
80
|
+
path: text,
|
|
81
|
+
type: '',
|
|
82
|
+
label: text.split('/').pop() || text
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function isDroppedUser(info) {
|
|
86
|
+
if (!info) return false;
|
|
87
|
+
return info.type === '$user' || /^\/users\/[^/]+$/i.test(info.path || '');
|
|
88
|
+
}
|
|
89
|
+
function isDroppedRemoteSubject(info) {
|
|
90
|
+
if (!info) return false;
|
|
91
|
+
return /^\/NODES\/[^/]+(?:\/.+)?$/i.test(info.path || '');
|
|
92
|
+
}
|
|
93
|
+
function isDroppedStructure(info) {
|
|
94
|
+
if (!info) return false;
|
|
95
|
+
if (isDroppedRemoteSubject(info)) return false;
|
|
96
|
+
if (['$structure', '$organization', '$project', '$server'].includes(info.type)) return true;
|
|
97
|
+
return /^\/(?:ORGANIZATIONS|PROJECTS)\/[^/]+(?:\/[^/]+)*$/.test(info.path || '') && !String(info.path || '').includes('/MODULES/');
|
|
98
|
+
}
|
|
99
|
+
function isDroppedNetworkNode(info) {
|
|
100
|
+
if (!info) return false;
|
|
101
|
+
if (info.type === '$node' && info.id !== 'NODES') return true;
|
|
102
|
+
return /^\/NODES\/[^/]+$/i.test(info.path || '');
|
|
103
|
+
}
|
|
104
|
+
function isDroppedClass(info) {
|
|
105
|
+
if (!info) return false;
|
|
106
|
+
if (['$catalog', '$virtual', '$operation', '$register', '$account', '$struct', '$module'].includes(info.type)) return true;
|
|
107
|
+
return String(info.path || '').includes('/MODULES/');
|
|
108
|
+
}
|
|
109
|
+
function buildFallbackClassTree(links) {
|
|
110
|
+
const out = [];
|
|
111
|
+
for (const l of Array.isArray(links) ? links : []) {
|
|
112
|
+
if (!l?.id) continue;
|
|
113
|
+
const clean = String(l.id).replace(/^\/(?:ORGANIZATIONS|PROJECTS)\/[^/]+\/MODULES\//, '').replace(/^\/MODULES\//, '');
|
|
114
|
+
const label = clean.split('/').filter(Boolean).pop() || clean;
|
|
115
|
+
out.push({
|
|
116
|
+
id: label,
|
|
117
|
+
path: l.id,
|
|
118
|
+
label,
|
|
119
|
+
type: '$class',
|
|
120
|
+
icon: 'odant:class',
|
|
121
|
+
children: []
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
function accessLabelRu(access) {
|
|
127
|
+
if (access === 'read') return 'Чтение (R)';
|
|
128
|
+
if (access === 'write') return 'Редактирование (W)';
|
|
129
|
+
if (access === 'create') return 'Создание (C)';
|
|
130
|
+
if (access === 'delete') return 'Удаление (D)';
|
|
131
|
+
if (access === 'none') return 'Нет доступа (—)';
|
|
132
|
+
return String(access || '');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// ---------------------------------------------------------------------------
|
|
136
|
+
// Выпадающий выбор руководителя (BOSS) из /USERS своего сервера
|
|
137
|
+
// ---------------------------------------------------------------------------
|
|
138
|
+
if (typeof ODA === 'function' && !customElements.get('staff-boss-menu')) {
|
|
139
|
+
ODA({
|
|
140
|
+
is: 'staff-boss-menu',
|
|
141
|
+
imports: 'oda//icon',
|
|
142
|
+
template: /*html*/`
|
|
143
|
+
<style>
|
|
144
|
+
:host {
|
|
145
|
+
@apply --vertical;
|
|
146
|
+
padding: 6px;
|
|
147
|
+
width: min(340px, calc(100vw - 24px));
|
|
148
|
+
max-height: min(400px, 70dvh);
|
|
149
|
+
font-size: 13px;
|
|
150
|
+
box-sizing: border-box;
|
|
151
|
+
}
|
|
152
|
+
.search {
|
|
153
|
+
padding: 6px 9px;
|
|
154
|
+
margin-bottom: 6px;
|
|
155
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
156
|
+
border-radius: 6px;
|
|
157
|
+
font: inherit;
|
|
158
|
+
background: var(--content-background);
|
|
159
|
+
color: inherit;
|
|
160
|
+
width: 100%;
|
|
161
|
+
box-sizing: border-box;
|
|
162
|
+
}
|
|
163
|
+
.list {
|
|
164
|
+
@apply --vertical;
|
|
165
|
+
overflow-y: auto;
|
|
166
|
+
gap: 2px;
|
|
167
|
+
min-height: 0;
|
|
168
|
+
flex: 1 1 auto;
|
|
169
|
+
}
|
|
170
|
+
.it {
|
|
171
|
+
@apply --horizontal;
|
|
172
|
+
align-items: center;
|
|
173
|
+
gap: 8px;
|
|
174
|
+
padding: 6px 8px;
|
|
175
|
+
border-radius: 6px;
|
|
176
|
+
cursor: pointer;
|
|
177
|
+
min-height: 30px;
|
|
178
|
+
box-sizing: border-box;
|
|
179
|
+
}
|
|
180
|
+
.it:hover { background: var(--accent-soft, rgba(37, 99, 235, 0.1)); }
|
|
181
|
+
.it.active { font-weight: 600; background: var(--subtle-background); }
|
|
182
|
+
.it.folder { font-weight: 600; color: var(--muted-color); }
|
|
183
|
+
.exp {
|
|
184
|
+
width: 16px;
|
|
185
|
+
height: 16px;
|
|
186
|
+
display: inline-flex;
|
|
187
|
+
align-items: center;
|
|
188
|
+
justify-content: center;
|
|
189
|
+
flex-shrink: 0;
|
|
190
|
+
color: var(--muted-color);
|
|
191
|
+
}
|
|
192
|
+
.sep { height: 1px; background: var(--subtle-border); margin: 4px 0; flex-shrink: 0; }
|
|
193
|
+
.empty { padding: 12px 8px; color: var(--muted-color); font-size: 12.5px; text-align: center; }
|
|
194
|
+
</style>
|
|
195
|
+
<input class="search" type="text" placeholder="Поиск пользователя…" ::value="query">
|
|
196
|
+
<div class="list">
|
|
197
|
+
<div class="it" ~if="hasLocalBoss" @tap="pick('')">
|
|
198
|
+
<oda-icon icon="icons:undo" icon-size="16"></oda-icon>
|
|
199
|
+
<span>Наследовать сверху</span>
|
|
200
|
+
</div>
|
|
201
|
+
<div class="sep" ~if="hasLocalBoss"></div>
|
|
202
|
+
<div class="it" ~for="visibleRows"
|
|
203
|
+
~class="{ active: $for.item.isUser && $for.item.id === currentId, folder: !$for.item.isUser }"
|
|
204
|
+
:style="'padding-left:' + (8 + $for.item.depth * 18) + 'px'"
|
|
205
|
+
@tap="onRowTap($for.item)">
|
|
206
|
+
<span class="exp" ~if="$for.item.hasChildren" @tap.stop="toggleNode($for.item.key)">
|
|
207
|
+
{{$for.item.expanded ? '▾' : '▸'}}
|
|
208
|
+
</span>
|
|
209
|
+
<oda-icon :round="$for.item.isUser" :icon="$for.item.icon" :icon-color="$for.item.iconColor" icon-size="20"></oda-icon>
|
|
210
|
+
<span>{{$for.item.label}}</span>
|
|
211
|
+
</div>
|
|
212
|
+
<div class="empty" ~if="!visibleRows.length">Пользователи не найдены</div>
|
|
213
|
+
</div>
|
|
214
|
+
`,
|
|
215
|
+
users: [],
|
|
216
|
+
usersTree: [],
|
|
217
|
+
currentId: '',
|
|
218
|
+
hasLocalBoss: false,
|
|
219
|
+
query: '',
|
|
220
|
+
expandedMap: {},
|
|
221
|
+
get visibleRows() {
|
|
222
|
+
const q = String(this.query || '').trim().toLowerCase();
|
|
223
|
+
const source = Array.isArray(this.usersTree) && this.usersTree.length ? this.usersTree : (this.users || []).map(u => ({
|
|
224
|
+
...u,
|
|
225
|
+
type: '$user',
|
|
226
|
+
children: []
|
|
227
|
+
}));
|
|
228
|
+
const filterTree = nodes => {
|
|
229
|
+
const res = [];
|
|
230
|
+
for (const n of nodes || []) {
|
|
231
|
+
const kids = filterTree(n.children || []);
|
|
232
|
+
const selfMatch = !q || String(n.label || n.id || '').toLowerCase().includes(q);
|
|
233
|
+
if (selfMatch || kids.length > 0) res.push({
|
|
234
|
+
...n,
|
|
235
|
+
children: kids
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return res;
|
|
239
|
+
};
|
|
240
|
+
const out = [];
|
|
241
|
+
const walk = (nodes, depth) => {
|
|
242
|
+
for (const n of nodes) {
|
|
243
|
+
const isUser = !n.children?.length && (n.type === '$user' || !n.type);
|
|
244
|
+
const hasChildren = Array.isArray(n.children) && n.children.length > 0;
|
|
245
|
+
const key = n.path || n.id;
|
|
246
|
+
const expanded = q ? true : this.expandedMap?.[key] !== false;
|
|
247
|
+
out.push({
|
|
248
|
+
key,
|
|
249
|
+
id: n.id,
|
|
250
|
+
label: n.label || n.id,
|
|
251
|
+
icon: n.icon || (isUser ? 'icons:person' : 'odant:folder'),
|
|
252
|
+
iconColor: n.iconColor || '',
|
|
253
|
+
isUser,
|
|
254
|
+
hasChildren,
|
|
255
|
+
expanded,
|
|
256
|
+
depth
|
|
257
|
+
});
|
|
258
|
+
if (hasChildren && expanded) walk(n.children, depth + 1);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
walk(filterTree(source), 0);
|
|
262
|
+
return out;
|
|
263
|
+
},
|
|
264
|
+
toggleNode(key) {
|
|
265
|
+
const cur = this.expandedMap?.[key] !== false;
|
|
266
|
+
this.expandedMap = {
|
|
267
|
+
...this.expandedMap,
|
|
268
|
+
[key]: !cur
|
|
269
|
+
};
|
|
270
|
+
},
|
|
271
|
+
onRowTap(row) {
|
|
272
|
+
if (row.isUser) this.pick(row.id);else if (row.hasChildren) this.toggleNode(row.key);
|
|
273
|
+
},
|
|
274
|
+
pick(id) {
|
|
275
|
+
this.parentElement?.close?.(id);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ---------------------------------------------------------------------------
|
|
281
|
+
// Иерархический выбор участника роли:
|
|
282
|
+
// Пользователи (/USERS), Организации (/ORGANIZATIONS), Проекты (/PROJECTS), Сеть (/NODES + ленивое раскрытие)
|
|
283
|
+
// ---------------------------------------------------------------------------
|
|
284
|
+
if (typeof ODA === 'function' && !customElements.get('staff-member-menu')) {
|
|
285
|
+
ODA({
|
|
286
|
+
is: 'staff-member-menu',
|
|
287
|
+
imports: 'oda//icon',
|
|
288
|
+
template: /*html*/`
|
|
289
|
+
<style>
|
|
290
|
+
:host {
|
|
291
|
+
@apply --vertical;
|
|
292
|
+
padding: 6px;
|
|
293
|
+
width: min(400px, calc(100vw - 24px));
|
|
294
|
+
max-height: min(440px, 72dvh);
|
|
295
|
+
font-size: 13px;
|
|
296
|
+
box-sizing: border-box;
|
|
297
|
+
}
|
|
298
|
+
.search {
|
|
299
|
+
padding: 6px 9px;
|
|
300
|
+
margin-bottom: 6px;
|
|
301
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
302
|
+
border-radius: 6px;
|
|
303
|
+
font: inherit;
|
|
304
|
+
background: var(--content-background);
|
|
305
|
+
color: inherit;
|
|
306
|
+
width: 100%;
|
|
307
|
+
box-sizing: border-box;
|
|
308
|
+
}
|
|
309
|
+
.list {
|
|
310
|
+
@apply --vertical;
|
|
311
|
+
overflow-y: auto;
|
|
312
|
+
gap: 1px;
|
|
313
|
+
min-height: 0;
|
|
314
|
+
flex: 1 1 auto;
|
|
315
|
+
}
|
|
316
|
+
.it {
|
|
317
|
+
@apply --horizontal;
|
|
318
|
+
align-items: center;
|
|
319
|
+
gap: 6px;
|
|
320
|
+
padding: 5px 8px;
|
|
321
|
+
border-radius: 6px;
|
|
322
|
+
cursor: pointer;
|
|
323
|
+
min-height: 29px;
|
|
324
|
+
box-sizing: border-box;
|
|
325
|
+
}
|
|
326
|
+
.it:hover { background: var(--accent-soft, rgba(37, 99, 235, 0.1)); }
|
|
327
|
+
.it.root-group { font-weight: 600; background: color-mix(in srgb, var(--subtle-background) 60%, transparent); margin-top: 2px; }
|
|
328
|
+
.it.disabled { opacity: .45; cursor: default; }
|
|
329
|
+
.it.disabled:hover { background: transparent; }
|
|
330
|
+
.exp {
|
|
331
|
+
width: 18px;
|
|
332
|
+
height: 18px;
|
|
333
|
+
display: inline-flex;
|
|
334
|
+
align-items: center;
|
|
335
|
+
justify-content: center;
|
|
336
|
+
flex-shrink: 0;
|
|
337
|
+
border-radius: 4px;
|
|
338
|
+
color: var(--muted-color);
|
|
339
|
+
user-select: none;
|
|
340
|
+
}
|
|
341
|
+
.exp:hover { background: var(--subtle-background); color: var(--content-color); }
|
|
342
|
+
.lbl {
|
|
343
|
+
flex: 1;
|
|
344
|
+
min-width: 0;
|
|
345
|
+
overflow: hidden;
|
|
346
|
+
text-overflow: ellipsis;
|
|
347
|
+
white-space: nowrap;
|
|
348
|
+
}
|
|
349
|
+
.tag {
|
|
350
|
+
margin-left: auto;
|
|
351
|
+
font-size: 11px;
|
|
352
|
+
color: var(--muted-color);
|
|
353
|
+
flex-shrink: 0;
|
|
354
|
+
}
|
|
355
|
+
.hint-row {
|
|
356
|
+
padding: 4px 8px;
|
|
357
|
+
font-size: 12px;
|
|
358
|
+
color: var(--muted-color);
|
|
359
|
+
font-style: italic;
|
|
360
|
+
}
|
|
361
|
+
.empty { padding: 14px 8px; color: var(--muted-color); font-size: 12.5px; text-align: center; }
|
|
362
|
+
</style>
|
|
363
|
+
<input class="search" type="text" placeholder="Поиск пользователя, организации, проекта, сервера…" ::value="query">
|
|
364
|
+
<div class="list">
|
|
365
|
+
<div ~for="visibleRows">
|
|
366
|
+
<div ~if="$for.item.isHint" class="hint-row" :style="'padding-left:' + (10 + $for.item.depth * 18) + 'px'">
|
|
367
|
+
{{$for.item.label}}
|
|
368
|
+
</div>
|
|
369
|
+
<div ~if="!$for.item.isHint" class="it"
|
|
370
|
+
~class="{ 'root-group': $for.item.isGroupRoot, disabled: $for.item.disabled }"
|
|
371
|
+
:style="'padding-left:' + (6 + $for.item.depth * 18) + 'px'"
|
|
372
|
+
@tap="onRowTap($for.item)">
|
|
373
|
+
<span class="exp" @tap.stop="toggleNode($for.item)">
|
|
374
|
+
{{$for.item.expandable ? ($for.item.loading ? '…' : ($for.item.expanded ? '▾' : '▸')) : ''}}
|
|
375
|
+
</span>
|
|
376
|
+
<oda-icon :round="$for.item.round" :icon="$for.item.icon" :icon-color="$for.item.iconColor" icon-size="18"></oda-icon>
|
|
377
|
+
<span class="lbl" :title="$for.item.title || $for.item.label">{{$for.item.label}}</span>
|
|
378
|
+
<span class="tag" ~if="$for.item.tag">{{$for.item.tag}}</span>
|
|
379
|
+
</div>
|
|
380
|
+
</div>
|
|
381
|
+
<div class="empty" ~if="!visibleRows.length">Ничего не найдено</div>
|
|
382
|
+
</div>
|
|
383
|
+
`,
|
|
384
|
+
treeRoots: [],
|
|
385
|
+
query: '',
|
|
386
|
+
expandedMap: {
|
|
387
|
+
'root:users': true,
|
|
388
|
+
'root:orgs': true,
|
|
389
|
+
'root:projects': false,
|
|
390
|
+
'root:nodes': true
|
|
391
|
+
},
|
|
392
|
+
remoteChildrenMap: {},
|
|
393
|
+
remoteLoadingMap: {},
|
|
394
|
+
remoteEmptyMap: {},
|
|
395
|
+
remoteMetaCollector: null,
|
|
396
|
+
get visibleRows() {
|
|
397
|
+
const q = String(this.query || '').trim().toLowerCase();
|
|
398
|
+
const getKids = node => {
|
|
399
|
+
if (node.lazyPath && this.remoteChildrenMap?.[node.lazyPath]) return this.remoteChildrenMap[node.lazyPath];
|
|
400
|
+
return Array.isArray(node.children) ? node.children : [];
|
|
401
|
+
};
|
|
402
|
+
const filterNodes = nodes => {
|
|
403
|
+
const res = [];
|
|
404
|
+
for (const n of nodes || []) {
|
|
405
|
+
const kids = filterNodes(getKids(n));
|
|
406
|
+
const hay = `${n.label || ''} ${n.tag || ''} ${n.value || ''}`.toLowerCase();
|
|
407
|
+
const match = !q || hay.includes(q);
|
|
408
|
+
if (match || kids.length > 0) res.push({
|
|
409
|
+
...n,
|
|
410
|
+
_filteredKids: kids
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
return res;
|
|
414
|
+
};
|
|
415
|
+
const out = [];
|
|
416
|
+
const walk = (nodes, depth) => {
|
|
417
|
+
for (const n of nodes) {
|
|
418
|
+
const kids = n._filteredKids || [];
|
|
419
|
+
const expandable = kids.length > 0 || Boolean(n.lazyPath);
|
|
420
|
+
const loading = Boolean(n.lazyPath && this.remoteLoadingMap?.[n.lazyPath]);
|
|
421
|
+
const expanded = q ? kids.length > 0 : Boolean(this.expandedMap?.[n.key]);
|
|
422
|
+
out.push({
|
|
423
|
+
key: n.key,
|
|
424
|
+
value: n.value || '',
|
|
425
|
+
label: n.label,
|
|
426
|
+
title: n.title || n.value || n.label,
|
|
427
|
+
icon: n.icon || 'odant:folder',
|
|
428
|
+
iconColor: n.iconColor || '',
|
|
429
|
+
round: Boolean(n.round),
|
|
430
|
+
tag: n.tag || '',
|
|
431
|
+
selectable: Boolean(n.selectable && !n.disabled),
|
|
432
|
+
disabled: Boolean(n.disabled),
|
|
433
|
+
isGroupRoot: Boolean(n.isGroupRoot),
|
|
434
|
+
expandable,
|
|
435
|
+
expanded,
|
|
436
|
+
loading,
|
|
437
|
+
lazyPath: n.lazyPath || '',
|
|
438
|
+
remoteNodeLabel: n.remoteNodeLabel || '',
|
|
439
|
+
depth
|
|
440
|
+
});
|
|
441
|
+
if (expandable && expanded) {
|
|
442
|
+
if (loading) {
|
|
443
|
+
out.push({
|
|
444
|
+
isHint: true,
|
|
445
|
+
label: 'Загрузка с удалённого сервера…',
|
|
446
|
+
depth: depth + 1
|
|
447
|
+
});
|
|
448
|
+
} else if (kids.length) {
|
|
449
|
+
walk(kids, depth + 1);
|
|
450
|
+
} else if (n.lazyPath && this.remoteEmptyMap?.[n.lazyPath]) {
|
|
451
|
+
out.push({
|
|
452
|
+
isHint: true,
|
|
453
|
+
label: 'Нет открытых разделов или пользователей',
|
|
454
|
+
depth: depth + 1
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
walk(filterNodes(this.treeRoots || []), 0);
|
|
461
|
+
return out;
|
|
462
|
+
},
|
|
463
|
+
async toggleNode(row) {
|
|
464
|
+
if (!row?.expandable) return;
|
|
465
|
+
const nextExpanded = !this.expandedMap?.[row.key];
|
|
466
|
+
this.expandedMap = {
|
|
467
|
+
...this.expandedMap,
|
|
468
|
+
[row.key]: nextExpanded
|
|
469
|
+
};
|
|
470
|
+
if (nextExpanded && row.lazyPath && !this.remoteChildrenMap?.[row.lazyPath] && !this.remoteLoadingMap?.[row.lazyPath]) {
|
|
471
|
+
await this._loadRemoteChildren(row.lazyPath, row.remoteNodeLabel || row.label);
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
async _loadRemoteChildren(remotePath, remoteNodeLabel) {
|
|
475
|
+
this.remoteLoadingMap = {
|
|
476
|
+
...this.remoteLoadingMap,
|
|
477
|
+
[remotePath]: true
|
|
478
|
+
};
|
|
479
|
+
try {
|
|
480
|
+
const target = typeof WORK?.get_item === 'function' ? await WORK.get_item(remotePath).catch(() => null) : null;
|
|
481
|
+
const rawItems = target ? await Promise.resolve(target.items).catch(() => []) : [];
|
|
482
|
+
const kids = [];
|
|
483
|
+
for (const it of Array.isArray(rawItems) ? rawItems : []) {
|
|
484
|
+
if (!it || !it.id || String(it.id).startsWith('$')) continue;
|
|
485
|
+
const t = it.type || '';
|
|
486
|
+
const p = normPath(it.path || `${remotePath}/${it.id}`);
|
|
487
|
+
const idUpper = String(it.id).toUpperCase();
|
|
488
|
+
const isDomainGroup = (t === '$domain' || t === '$folder') && ['USERS', 'ORGANIZATIONS', 'PROJECTS'].includes(idUpper);
|
|
489
|
+
const isUser = t === '$user' || /\/USERS\/[^/]+$/i.test(p);
|
|
490
|
+
const isUnit = ['$organization', '$project', '$structure'].includes(t);
|
|
491
|
+
if (!isDomainGroup && !isUser && !isUnit) continue;
|
|
492
|
+
const lbl = it.DATA?.label || it.label || it.id;
|
|
493
|
+
const icon = it.DATA?.icon || it.icon || (isUser ? 'icons:person' : isDomainGroup ? idUpper === 'USERS' ? 'social:people' : idUpper === 'PROJECTS' ? 'odant:project' : 'odant:base' : 'odant:structure');
|
|
494
|
+
const child = {
|
|
495
|
+
key: `remote:${p}`,
|
|
496
|
+
value: isDomainGroup ? '' : p,
|
|
497
|
+
label: lbl,
|
|
498
|
+
title: `${lbl} (${remoteNodeLabel})`,
|
|
499
|
+
icon,
|
|
500
|
+
iconColor: it.iconColor || '',
|
|
501
|
+
round: isUser,
|
|
502
|
+
tag: isUser ? 'пользователь' : t === '$organization' ? 'организация' : t === '$project' ? 'проект' : isUnit ? 'подразделение' : '',
|
|
503
|
+
selectable: !isDomainGroup,
|
|
504
|
+
lazyPath: isUser ? '' : p,
|
|
505
|
+
remoteNodeLabel,
|
|
506
|
+
children: []
|
|
507
|
+
};
|
|
508
|
+
if (!isDomainGroup && typeof this.remoteMetaCollector === 'function') {
|
|
509
|
+
this.remoteMetaCollector(p, {
|
|
510
|
+
label: lbl,
|
|
511
|
+
icon,
|
|
512
|
+
iconColor: it.iconColor || '',
|
|
513
|
+
isUser,
|
|
514
|
+
type: t,
|
|
515
|
+
nodeLabel: remoteNodeLabel
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
kids.push(child);
|
|
519
|
+
}
|
|
520
|
+
this.remoteChildrenMap = {
|
|
521
|
+
...this.remoteChildrenMap,
|
|
522
|
+
[remotePath]: kids
|
|
523
|
+
};
|
|
524
|
+
this.remoteEmptyMap = {
|
|
525
|
+
...this.remoteEmptyMap,
|
|
526
|
+
[remotePath]: kids.length === 0
|
|
527
|
+
};
|
|
528
|
+
} catch {
|
|
529
|
+
this.remoteChildrenMap = {
|
|
530
|
+
...this.remoteChildrenMap,
|
|
531
|
+
[remotePath]: []
|
|
532
|
+
};
|
|
533
|
+
this.remoteEmptyMap = {
|
|
534
|
+
...this.remoteEmptyMap,
|
|
535
|
+
[remotePath]: true
|
|
536
|
+
};
|
|
537
|
+
} finally {
|
|
538
|
+
this.remoteLoadingMap = {
|
|
539
|
+
...this.remoteLoadingMap,
|
|
540
|
+
[remotePath]: false
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
onRowTap(row) {
|
|
545
|
+
if (row.disabled) return;
|
|
546
|
+
if (row.selectable && row.value) {
|
|
547
|
+
this.pick(row.value);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
if (row.expandable) this.toggleNode(row);
|
|
551
|
+
},
|
|
552
|
+
pick(val) {
|
|
553
|
+
this.parentElement?.close?.(val);
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// ---------------------------------------------------------------------------
|
|
559
|
+
// Рекурсивный узел роли с двумя подгруппами: «Пользователи» и «Классы» (RWCD)
|
|
560
|
+
// ---------------------------------------------------------------------------
|
|
561
|
+
if (typeof ODA === 'function' && !customElements.get('staff-role-node')) {
|
|
562
|
+
ODA({
|
|
563
|
+
is: 'staff-role-node',
|
|
564
|
+
imports: 'oda//icon',
|
|
565
|
+
template: /*html*/`
|
|
566
|
+
<style>
|
|
567
|
+
:host {
|
|
568
|
+
@apply --vertical;
|
|
569
|
+
display: flex;
|
|
570
|
+
}
|
|
571
|
+
.tree-row {
|
|
572
|
+
@apply --horizontal;
|
|
573
|
+
align-items: center;
|
|
574
|
+
gap: 6px;
|
|
575
|
+
padding: 5px 12px;
|
|
576
|
+
min-height: 32px;
|
|
577
|
+
border-bottom: 1px solid color-mix(in srgb, var(--subtle-border) 50%, transparent);
|
|
578
|
+
box-sizing: border-box;
|
|
579
|
+
}
|
|
580
|
+
.tree-row.role-row {
|
|
581
|
+
background: var(--content-background);
|
|
582
|
+
flex-wrap: wrap;
|
|
583
|
+
}
|
|
584
|
+
.tree-row.role-row:hover {
|
|
585
|
+
background: color-mix(in srgb, var(--subtle-background) 65%, transparent);
|
|
586
|
+
}
|
|
587
|
+
.tree-row.role-row.drop-hover {
|
|
588
|
+
background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background));
|
|
589
|
+
outline: 1px dashed var(--accent-color, #2563eb);
|
|
590
|
+
outline-offset: -2px;
|
|
591
|
+
}
|
|
592
|
+
.tree-row.subgroup-row {
|
|
593
|
+
min-height: 28px;
|
|
594
|
+
padding-top: 3px;
|
|
595
|
+
padding-bottom: 3px;
|
|
596
|
+
background: color-mix(in srgb, var(--subtle-background) 55%, var(--content-background));
|
|
597
|
+
font-size: 12.5px;
|
|
598
|
+
font-weight: 600;
|
|
599
|
+
color: var(--muted-color);
|
|
600
|
+
}
|
|
601
|
+
.tree-row.subgroup-row:hover {
|
|
602
|
+
background: var(--subtle-background);
|
|
603
|
+
}
|
|
604
|
+
.tree-row.member-row {
|
|
605
|
+
min-height: 29px;
|
|
606
|
+
padding-top: 3px;
|
|
607
|
+
padding-bottom: 3px;
|
|
608
|
+
background: var(--content-background);
|
|
609
|
+
font-size: 13px;
|
|
610
|
+
}
|
|
611
|
+
.tree-row.member-row:hover {
|
|
612
|
+
background: color-mix(in srgb, var(--subtle-background) 55%, transparent);
|
|
613
|
+
}
|
|
614
|
+
.tree-row.class-row {
|
|
615
|
+
min-height: 30px;
|
|
616
|
+
padding-top: 3px;
|
|
617
|
+
padding-bottom: 3px;
|
|
618
|
+
background: color-mix(in srgb, var(--subtle-background) 24%, var(--content-background));
|
|
619
|
+
flex-wrap: wrap;
|
|
620
|
+
gap: 6px;
|
|
621
|
+
}
|
|
622
|
+
.tree-row.class-row:hover {
|
|
623
|
+
background: var(--subtle-background);
|
|
624
|
+
}
|
|
625
|
+
.tree-row.empty-row {
|
|
626
|
+
min-height: 26px;
|
|
627
|
+
padding-top: 3px;
|
|
628
|
+
padding-bottom: 3px;
|
|
629
|
+
color: var(--muted-color);
|
|
630
|
+
font-size: 12px;
|
|
631
|
+
font-style: italic;
|
|
632
|
+
background: var(--content-background);
|
|
633
|
+
}
|
|
634
|
+
.expander {
|
|
635
|
+
width: 16px;
|
|
636
|
+
height: 16px;
|
|
637
|
+
display: inline-flex;
|
|
638
|
+
align-items: center;
|
|
639
|
+
justify-content: center;
|
|
640
|
+
cursor: pointer;
|
|
641
|
+
color: var(--muted-color);
|
|
642
|
+
user-select: none;
|
|
643
|
+
border-radius: 4px;
|
|
644
|
+
flex-shrink: 0;
|
|
645
|
+
}
|
|
646
|
+
.expander:hover {
|
|
647
|
+
background: var(--subtle-background);
|
|
648
|
+
color: var(--content-color);
|
|
649
|
+
}
|
|
650
|
+
.role-name {
|
|
651
|
+
font-weight: 600;
|
|
652
|
+
font-size: 13.5px;
|
|
653
|
+
}
|
|
654
|
+
.sub-title {
|
|
655
|
+
cursor: pointer;
|
|
656
|
+
user-select: none;
|
|
657
|
+
}
|
|
658
|
+
.sub-count {
|
|
659
|
+
font-weight: 500;
|
|
660
|
+
font-size: 11.5px;
|
|
661
|
+
opacity: .8;
|
|
662
|
+
}
|
|
663
|
+
.member-name {
|
|
664
|
+
cursor: pointer;
|
|
665
|
+
min-width: 0;
|
|
666
|
+
overflow: hidden;
|
|
667
|
+
text-overflow: ellipsis;
|
|
668
|
+
white-space: nowrap;
|
|
669
|
+
}
|
|
670
|
+
.member-name:hover {
|
|
671
|
+
color: var(--accent-color);
|
|
672
|
+
text-decoration: underline;
|
|
673
|
+
}
|
|
674
|
+
.member-tag {
|
|
675
|
+
font-size: 11px;
|
|
676
|
+
color: var(--muted-color);
|
|
677
|
+
margin-left: auto;
|
|
678
|
+
padding: 1px 6px;
|
|
679
|
+
border-radius: 6px;
|
|
680
|
+
background: color-mix(in srgb, var(--subtle-background) 85%, transparent);
|
|
681
|
+
flex-shrink: 0;
|
|
682
|
+
}
|
|
683
|
+
.member-tag.net {
|
|
684
|
+
color: #7c3aed;
|
|
685
|
+
background: color-mix(in srgb, #7c3aed 10%, var(--content-background));
|
|
686
|
+
}
|
|
687
|
+
.member-tag.node {
|
|
688
|
+
color: #0284c7;
|
|
689
|
+
background: color-mix(in srgb, #0284c7 10%, var(--content-background));
|
|
690
|
+
}
|
|
691
|
+
.badge {
|
|
692
|
+
font-size: 11px;
|
|
693
|
+
font-weight: 600;
|
|
694
|
+
padding: 1px 6px;
|
|
695
|
+
border-radius: 8px;
|
|
696
|
+
background: var(--accent-soft);
|
|
697
|
+
color: var(--accent-color);
|
|
698
|
+
}
|
|
699
|
+
.badge.ext {
|
|
700
|
+
background: light-dark(#fef3c7, #422006);
|
|
701
|
+
color: light-dark(#92400e, #fcd34d);
|
|
702
|
+
}
|
|
703
|
+
.icon-btn {
|
|
704
|
+
border: 1px solid transparent;
|
|
705
|
+
background: transparent;
|
|
706
|
+
color: var(--muted-color);
|
|
707
|
+
border-radius: 6px;
|
|
708
|
+
padding: 2px 7px;
|
|
709
|
+
font: inherit;
|
|
710
|
+
font-size: 12px;
|
|
711
|
+
cursor: pointer;
|
|
712
|
+
display: inline-flex;
|
|
713
|
+
align-items: center;
|
|
714
|
+
gap: 4px;
|
|
715
|
+
flex-shrink: 0;
|
|
716
|
+
}
|
|
717
|
+
.icon-btn:hover {
|
|
718
|
+
background: var(--subtle-background);
|
|
719
|
+
border-color: var(--subtle-border);
|
|
720
|
+
color: var(--content-color);
|
|
721
|
+
}
|
|
722
|
+
.icon-btn.active {
|
|
723
|
+
background: var(--accent-soft);
|
|
724
|
+
color: var(--accent-color);
|
|
725
|
+
border-color: color-mix(in srgb, var(--accent-color) 35%, transparent);
|
|
726
|
+
font-weight: 600;
|
|
727
|
+
}
|
|
728
|
+
.icon-btn.danger:hover {
|
|
729
|
+
color: var(--error-color, #dc2626);
|
|
730
|
+
}
|
|
731
|
+
.row-actions {
|
|
732
|
+
@apply --horizontal;
|
|
733
|
+
align-items: center;
|
|
734
|
+
gap: 4px;
|
|
735
|
+
margin-left: auto;
|
|
736
|
+
flex-wrap: wrap;
|
|
737
|
+
}
|
|
738
|
+
.class-title {
|
|
739
|
+
cursor: pointer;
|
|
740
|
+
flex: 1;
|
|
741
|
+
min-width: 110px;
|
|
742
|
+
overflow: hidden;
|
|
743
|
+
text-overflow: ellipsis;
|
|
744
|
+
white-space: nowrap;
|
|
745
|
+
}
|
|
746
|
+
.class-title.granted {
|
|
747
|
+
font-weight: 500;
|
|
748
|
+
}
|
|
749
|
+
.class-title.denied {
|
|
750
|
+
color: var(--muted-color);
|
|
751
|
+
text-decoration: line-through;
|
|
752
|
+
}
|
|
753
|
+
.class-title:hover {
|
|
754
|
+
color: var(--accent-color);
|
|
755
|
+
text-decoration: underline;
|
|
756
|
+
}
|
|
757
|
+
.rwcd-wrap {
|
|
758
|
+
@apply --horizontal;
|
|
759
|
+
align-items: center;
|
|
760
|
+
gap: 4px;
|
|
761
|
+
margin-left: auto;
|
|
762
|
+
flex-shrink: 0;
|
|
763
|
+
}
|
|
764
|
+
.rwcd-reset {
|
|
765
|
+
border: 1px solid transparent;
|
|
766
|
+
background: transparent;
|
|
767
|
+
color: var(--muted-color);
|
|
768
|
+
border-radius: 5px;
|
|
769
|
+
width: 22px;
|
|
770
|
+
height: 22px;
|
|
771
|
+
padding: 0;
|
|
772
|
+
font-size: 12px;
|
|
773
|
+
line-height: 1;
|
|
774
|
+
cursor: pointer;
|
|
775
|
+
display: inline-flex;
|
|
776
|
+
align-items: center;
|
|
777
|
+
justify-content: center;
|
|
778
|
+
}
|
|
779
|
+
.rwcd-reset:hover {
|
|
780
|
+
background: var(--subtle-background);
|
|
781
|
+
border-color: var(--subtle-border);
|
|
782
|
+
color: var(--accent-color);
|
|
783
|
+
}
|
|
784
|
+
.rwcd-slider {
|
|
785
|
+
display: inline-flex;
|
|
786
|
+
align-items: stretch;
|
|
787
|
+
border: 1px solid var(--subtle-border, #cbd5e1);
|
|
788
|
+
border-radius: 6px;
|
|
789
|
+
overflow: hidden;
|
|
790
|
+
background: var(--content-background);
|
|
791
|
+
height: 22px;
|
|
792
|
+
user-select: none;
|
|
793
|
+
}
|
|
794
|
+
.rwcd-slider.inherited {
|
|
795
|
+
border-style: dashed;
|
|
796
|
+
border-color: color-mix(in srgb, var(--accent-color, #4f46e5) 40%, var(--subtle-border));
|
|
797
|
+
}
|
|
798
|
+
.rwcd-seg {
|
|
799
|
+
border: none;
|
|
800
|
+
border-right: 1px solid color-mix(in srgb, var(--subtle-border) 65%, transparent);
|
|
801
|
+
background: transparent;
|
|
802
|
+
color: var(--muted-color);
|
|
803
|
+
font: inherit;
|
|
804
|
+
font-size: 11px;
|
|
805
|
+
font-weight: 600;
|
|
806
|
+
min-width: 22px;
|
|
807
|
+
padding: 0 5px;
|
|
808
|
+
cursor: pointer;
|
|
809
|
+
display: inline-flex;
|
|
810
|
+
align-items: center;
|
|
811
|
+
justify-content: center;
|
|
812
|
+
transition: background .1s ease, color .1s ease;
|
|
813
|
+
}
|
|
814
|
+
.rwcd-seg:last-child {
|
|
815
|
+
border-right: none;
|
|
816
|
+
}
|
|
817
|
+
.rwcd-seg:hover:not(:disabled) {
|
|
818
|
+
background: color-mix(in srgb, var(--accent-color, #4f46e5) 14%, transparent);
|
|
819
|
+
color: var(--content-color);
|
|
820
|
+
}
|
|
821
|
+
.rwcd-seg:disabled {
|
|
822
|
+
cursor: default;
|
|
823
|
+
}
|
|
824
|
+
.rwcd-slider.explicit .rwcd-seg.filled {
|
|
825
|
+
background: var(--accent-color, #4f46e5);
|
|
826
|
+
color: #ffffff;
|
|
827
|
+
border-right-color: rgba(255, 255, 255, 0.22);
|
|
828
|
+
}
|
|
829
|
+
.rwcd-slider.inherited .rwcd-seg.filled {
|
|
830
|
+
background: color-mix(in srgb, var(--accent-color, #4f46e5) 20%, var(--content-background));
|
|
831
|
+
color: var(--accent-color, #4f46e5);
|
|
832
|
+
border-right-color: color-mix(in srgb, var(--accent-color, #4f46e5) 25%, transparent);
|
|
833
|
+
}
|
|
834
|
+
.rwcd-slider.denied .rwcd-seg.seg-none {
|
|
835
|
+
background: color-mix(in srgb, var(--error-color, #dc2626) 18%, var(--content-background));
|
|
836
|
+
color: var(--error-color, #dc2626);
|
|
837
|
+
}
|
|
838
|
+
.rwcd-slider:not(.denied) .rwcd-seg.seg-none.active-none {
|
|
839
|
+
background: color-mix(in srgb, var(--subtle-background) 90%, transparent);
|
|
840
|
+
color: var(--content-color);
|
|
841
|
+
}
|
|
842
|
+
@media (max-width: 520px) {
|
|
843
|
+
.tree-row { padding: 5px 8px; }
|
|
844
|
+
.rwcd-seg { min-width: 20px; padding: 0 4px; font-size: 10.5px; }
|
|
845
|
+
}
|
|
846
|
+
</style>
|
|
847
|
+
|
|
848
|
+
<!-- Заголовок роли -->
|
|
849
|
+
<div class="tree-row role-row"
|
|
850
|
+
~class="{ 'drop-hover': dropHover }"
|
|
851
|
+
:style="'padding-left:' + (12 + depth * 20) + 'px'"
|
|
852
|
+
@dragover="onDragOver($event)"
|
|
853
|
+
@dragleave="dropHover = false"
|
|
854
|
+
@drop="onDrop($event)">
|
|
855
|
+
|
|
856
|
+
<span class="expander" @tap="toggleExpand()">
|
|
857
|
+
{{expanded ? '▾' : '▸'}}
|
|
858
|
+
</span>
|
|
859
|
+
<oda-icon :icon="role?.external ? 'icons:public' : 'fontawesome:s-user-tie'" icon-size="16"></oda-icon>
|
|
860
|
+
<span class="role-name" @tap="toggleExpand()" style="cursor:pointer;">{{role?.label || role?.id}}</span>
|
|
861
|
+
<span ~if="role?.external" class="badge ext">клиент</span>
|
|
862
|
+
<span ~if="role?.mine" class="badge">ваша роль</span>
|
|
863
|
+
|
|
864
|
+
<div ~if="canEdit" class="row-actions">
|
|
865
|
+
<button type="button" class="icon-btn" title="Переименовать роль" @tap="controller?.promptRenameRole(trail, role?.label || role?.id)">
|
|
866
|
+
<oda-icon icon="editor:mode-edit" icon-size="13"></oda-icon>
|
|
867
|
+
</button>
|
|
868
|
+
<button type="button" class="icon-btn" ~class="{ active: role?.external }" title="Внешний клиент (только свои данные)" @tap="controller?.toggleRoleExternal(trail, !role?.external)">
|
|
869
|
+
<oda-icon icon="icons:public" icon-size="13"></oda-icon>
|
|
870
|
+
</button>
|
|
871
|
+
<button type="button" class="icon-btn danger" title="Удалить роль" @tap="controller?.removeRole(trail, role?.label || role?.id)">
|
|
872
|
+
<oda-icon icon="icons:delete" icon-size="14"></oda-icon>
|
|
873
|
+
</button>
|
|
874
|
+
</div>
|
|
875
|
+
</div>
|
|
876
|
+
|
|
877
|
+
<!-- Подгруппа 1: Пользователи -->
|
|
878
|
+
<div ~if="expanded" class="tree-row subgroup-row users-group-row"
|
|
879
|
+
:style="'padding-left:' + (28 + depth * 20) + 'px'"
|
|
880
|
+
@dragover="onDragOver($event)"
|
|
881
|
+
@dragleave="dropHover = false"
|
|
882
|
+
@drop="onDrop($event)">
|
|
883
|
+
<span class="expander" @tap="usersExpanded = !usersExpanded">{{usersExpanded ? '▾' : '▸'}}</span>
|
|
884
|
+
<oda-icon icon="social:people" icon-size="15"></oda-icon>
|
|
885
|
+
<span class="sub-title" @tap="usersExpanded = !usersExpanded">Пользователи</span>
|
|
886
|
+
<span class="sub-count">({{memberEntries.length}})</span>
|
|
887
|
+
<div ~if="canEdit" class="row-actions">
|
|
888
|
+
<button type="button" class="icon-btn add-member-btn" title="Добавить пользователя, подразделение или узел сети" @tap.stop="controller?.openMemberDropdown($event, trail)">
|
|
889
|
+
<oda-icon icon="icons:add" icon-size="14"></oda-icon>
|
|
890
|
+
<span>Добавить</span>
|
|
891
|
+
</button>
|
|
892
|
+
</div>
|
|
893
|
+
</div>
|
|
894
|
+
|
|
895
|
+
<div ~if="expanded && usersExpanded">
|
|
896
|
+
<div class="tree-row member-row" ~for="memberEntries"
|
|
897
|
+
:style="'padding-left:' + (48 + depth * 20) + 'px'">
|
|
898
|
+
<oda-icon :round="$for.item.round" :icon="$for.item.icon" :icon-color="$for.item.iconColor" icon-size="17"></oda-icon>
|
|
899
|
+
<span class="member-name" :title="$for.item.title || $for.item.label" @tap="controller?.openMember($for.item)">{{$for.item.label}}</span>
|
|
900
|
+
<span ~if="$for.item.tag" class="member-tag" ~class="{ net: $for.item.isNetworkNode || $for.item.isRemote, node: $for.item.isNode }">{{$for.item.tag}}</span>
|
|
901
|
+
<button ~if="canEdit" type="button" class="icon-btn danger" title="Убрать из роли" @tap.stop="controller?.removeRoleMember(trail, $for.item.id)">
|
|
902
|
+
<oda-icon icon="icons:close" icon-size="13"></oda-icon>
|
|
903
|
+
</button>
|
|
904
|
+
</div>
|
|
905
|
+
<div ~if="!memberEntries.length" class="tree-row empty-row" :style="'padding-left:' + (48 + depth * 20) + 'px'">
|
|
906
|
+
Нет назначенных участников
|
|
907
|
+
</div>
|
|
908
|
+
</div>
|
|
909
|
+
|
|
910
|
+
<!-- Подгруппа 2: Классы -->
|
|
911
|
+
<div ~if="expanded" class="tree-row subgroup-row classes-group-row"
|
|
912
|
+
:style="'padding-left:' + (28 + depth * 20) + 'px'">
|
|
913
|
+
<span class="expander" @tap="classesExpanded = !classesExpanded">{{classesExpanded ? '▾' : '▸'}}</span>
|
|
914
|
+
<oda-icon icon="odant:class" icon-size="15"></oda-icon>
|
|
915
|
+
<span class="sub-title" @tap="classesExpanded = !classesExpanded">Классы</span>
|
|
916
|
+
<span class="sub-count">({{grantedLinksCount}})</span>
|
|
917
|
+
<div ~if="canEdit" class="row-actions">
|
|
918
|
+
<button type="button" class="icon-btn setup-classes-btn" ~class="{ active: setupMode }" title="Показать полное дерево классов для настройки прав RWCD" @tap.stop="toggleSetup()">
|
|
919
|
+
<oda-icon icon="icons:settings" icon-size="14"></oda-icon>
|
|
920
|
+
<span>Настройка</span>
|
|
921
|
+
</button>
|
|
922
|
+
</div>
|
|
923
|
+
</div>
|
|
924
|
+
|
|
925
|
+
<div ~if="expanded && classesExpanded">
|
|
926
|
+
<div class="class-slot" ~for="visibleClassRows">
|
|
927
|
+
<div class="tree-row class-row"
|
|
928
|
+
:style="'padding-left:' + (48 + (depth + $for.item.classDepth) * 20) + 'px'">
|
|
929
|
+
<span class="expander" @tap="toggleClassNode($for.item.id)">
|
|
930
|
+
{{$for.item.hasChildren ? ($for.item.expanded ? '▾' : '▸') : ''}}
|
|
931
|
+
</span>
|
|
932
|
+
<oda-icon :icon="$for.item.icon" icon-size="15"></oda-icon>
|
|
933
|
+
<span class="class-title"
|
|
934
|
+
~class="{ granted: $for.item.effectiveRank > 0, denied: $for.item.isExplicitDenied }"
|
|
935
|
+
:title="$for.item.id"
|
|
936
|
+
@tap="controller?.openClass($for.item.id)">{{$for.item.label}}</span>
|
|
937
|
+
|
|
938
|
+
<div class="rwcd-wrap">
|
|
939
|
+
<button ~if="canEdit && setupMode && $for.item.canResetInherit"
|
|
940
|
+
type="button"
|
|
941
|
+
class="rwcd-reset"
|
|
942
|
+
title="Сбросить переопределение и наследовать от родителя"
|
|
943
|
+
@tap.stop="onResetAccess($for.item)">↩</button>
|
|
944
|
+
<div class="rwcd-slider"
|
|
945
|
+
~class="{ explicit: $for.item.isExplicit && !$for.item.isExplicitDenied, inherited: $for.item.isInherited, denied: $for.item.isExplicitDenied }"
|
|
946
|
+
:data-access="$for.item.effectiveAccess"
|
|
947
|
+
:data-explicit="$for.item.isExplicit ? '1' : '0'">
|
|
948
|
+
<button type="button"
|
|
949
|
+
class="rwcd-seg seg-none"
|
|
950
|
+
~class="{ 'active-none': $for.item.effectiveRank === 0 }"
|
|
951
|
+
:disabled="!canEdit || !setupMode"
|
|
952
|
+
:title="$for.item.inheritedAccess ? 'Явно запретить доступ к этому классу (—)' : 'Нет доступа (—)'"
|
|
953
|
+
@tap.stop="onSelectAccess($for.item, 'none')">—</button>
|
|
954
|
+
<button type="button"
|
|
955
|
+
class="rwcd-seg seg-r"
|
|
956
|
+
~class="{ filled: $for.item.effectiveRank >= 1 }"
|
|
957
|
+
:disabled="!canEdit || !setupMode"
|
|
958
|
+
title="Чтение (R)"
|
|
959
|
+
@tap.stop="onSelectAccess($for.item, 'read')">R</button>
|
|
960
|
+
<button type="button"
|
|
961
|
+
class="rwcd-seg seg-w"
|
|
962
|
+
~class="{ filled: $for.item.effectiveRank >= 2 }"
|
|
963
|
+
:disabled="!canEdit || !setupMode"
|
|
964
|
+
title="Редактирование и проведение (W)"
|
|
965
|
+
@tap.stop="onSelectAccess($for.item, 'write')">W</button>
|
|
966
|
+
<button type="button"
|
|
967
|
+
class="rwcd-seg seg-c"
|
|
968
|
+
~class="{ filled: $for.item.effectiveRank >= 3 }"
|
|
969
|
+
:disabled="!canEdit || !setupMode"
|
|
970
|
+
title="Создание объектов и документов (C)"
|
|
971
|
+
@tap.stop="onSelectAccess($for.item, 'create')">C</button>
|
|
972
|
+
<button type="button"
|
|
973
|
+
class="rwcd-seg seg-d"
|
|
974
|
+
~class="{ filled: $for.item.effectiveRank >= 4 }"
|
|
975
|
+
:disabled="!canEdit || !setupMode"
|
|
976
|
+
title="Удаление и полный доступ к данным (D)"
|
|
977
|
+
@tap.stop="onSelectAccess($for.item, 'delete')">D</button>
|
|
978
|
+
</div>
|
|
979
|
+
</div>
|
|
980
|
+
</div>
|
|
981
|
+
</div>
|
|
982
|
+
<div ~if="!visibleClassRows.length" class="tree-row empty-row" :style="'padding-left:' + (48 + depth * 20) + 'px'">
|
|
983
|
+
{{canEdit ? 'Нет выданных классов — нажмите «Настройка»' : 'Нет выданных классов'}}
|
|
984
|
+
</div>
|
|
985
|
+
</div>
|
|
986
|
+
|
|
987
|
+
<!-- Совместимость со старыми вложенными подролями, если они есть в #security -->
|
|
988
|
+
<staff-role-node ~for="visibleChildRoles"
|
|
989
|
+
:role="$for.item"
|
|
990
|
+
:prefix="trail"
|
|
991
|
+
:depth="depth + 1"
|
|
992
|
+
:controller="controller"
|
|
993
|
+
:can-edit="canEdit"
|
|
994
|
+
:base-classes="baseClasses"
|
|
995
|
+
:user-map="userMap"
|
|
996
|
+
:structure-map="structureMap"
|
|
997
|
+
:network-node-map="networkNodeMap">
|
|
998
|
+
</staff-role-node>
|
|
999
|
+
`,
|
|
1000
|
+
role: null,
|
|
1001
|
+
prefix: '',
|
|
1002
|
+
depth: 0,
|
|
1003
|
+
controller: null,
|
|
1004
|
+
canEdit: false,
|
|
1005
|
+
baseClasses: [],
|
|
1006
|
+
userMap: {},
|
|
1007
|
+
structureMap: {},
|
|
1008
|
+
networkNodeMap: {},
|
|
1009
|
+
setupMode: false,
|
|
1010
|
+
expanded: true,
|
|
1011
|
+
usersExpanded: true,
|
|
1012
|
+
classesExpanded: true,
|
|
1013
|
+
expandedClasses: {},
|
|
1014
|
+
dropHover: false,
|
|
1015
|
+
get trail() {
|
|
1016
|
+
const id = this.role?.id || '';
|
|
1017
|
+
return this.prefix ? `${this.prefix}/${id}` : id;
|
|
1018
|
+
},
|
|
1019
|
+
get childRoles() {
|
|
1020
|
+
return Array.isArray(this.role?.ROLES) ? this.role.ROLES : [];
|
|
1021
|
+
},
|
|
1022
|
+
get visibleChildRoles() {
|
|
1023
|
+
return this.expanded ? this.childRoles : [];
|
|
1024
|
+
},
|
|
1025
|
+
get visibleClassRows() {
|
|
1026
|
+
return this.expanded && this.classesExpanded ? this.classRows : [];
|
|
1027
|
+
},
|
|
1028
|
+
get memberEntries() {
|
|
1029
|
+
return this.controller ? this.controller.buildMemberEntries(this.role?.USERS) : [];
|
|
1030
|
+
},
|
|
1031
|
+
get grantedLinksCount() {
|
|
1032
|
+
const links = Array.isArray(this.role?.LINKS) ? this.role.LINKS : [];
|
|
1033
|
+
return links.filter(l => {
|
|
1034
|
+
const a = normalizeAccess(l?.access);
|
|
1035
|
+
return a && a !== 'none';
|
|
1036
|
+
}).length;
|
|
1037
|
+
},
|
|
1038
|
+
get classRows() {
|
|
1039
|
+
const links = Array.isArray(this.role?.LINKS) ? this.role.LINKS : [];
|
|
1040
|
+
const explicitMap = new Map();
|
|
1041
|
+
for (const l of links) {
|
|
1042
|
+
if (!l?.id) continue;
|
|
1043
|
+
const acc = normalizeAccess(l.access);
|
|
1044
|
+
if (acc) explicitMap.set(normPath(l.id), acc);
|
|
1045
|
+
}
|
|
1046
|
+
const hasBaseTree = Array.isArray(this.baseClasses) && this.baseClasses.length > 0;
|
|
1047
|
+
const source = hasBaseTree ? this.baseClasses : buildFallbackClassTree(links);
|
|
1048
|
+
const setup = Boolean(this.setupMode);
|
|
1049
|
+
const filterNodes = (nodes, inheritedAccess = null) => {
|
|
1050
|
+
const res = [];
|
|
1051
|
+
for (const n of Array.isArray(nodes) ? nodes : []) {
|
|
1052
|
+
if (!n?.path) continue;
|
|
1053
|
+
const p = normPath(n.path);
|
|
1054
|
+
const explicitAccess = explicitMap.has(p) ? explicitMap.get(p) : null;
|
|
1055
|
+
const effectiveAccess = explicitAccess || inheritedAccess || 'none';
|
|
1056
|
+
const isExplicit = explicitAccess !== null;
|
|
1057
|
+
const isInherited = !isExplicit && Boolean(inheritedAccess && inheritedAccess !== 'none');
|
|
1058
|
+
const isExplicitDenied = isExplicit && explicitAccess === 'none' && Boolean(inheritedAccess && inheritedAccess !== 'none');
|
|
1059
|
+
const nextInherited = effectiveAccess !== 'none' ? effectiveAccess : null;
|
|
1060
|
+
const kids = filterNodes(n.children || [], nextInherited);
|
|
1061
|
+
const hasActiveDesc = kids.some(k => k.effectiveRank > 0 || k.isExplicitDenied || k.hasActiveDesc);
|
|
1062
|
+
const effectiveRank = RWCD_RANK[effectiveAccess] || 0;
|
|
1063
|
+
if (setup || effectiveRank > 0 || isExplicitDenied || kids.length > 0) {
|
|
1064
|
+
res.push({
|
|
1065
|
+
id: p,
|
|
1066
|
+
label: n.label || n.id,
|
|
1067
|
+
icon: n.icon || 'odant:class',
|
|
1068
|
+
explicitAccess,
|
|
1069
|
+
inheritedAccess: inheritedAccess && inheritedAccess !== 'none' ? inheritedAccess : '',
|
|
1070
|
+
effectiveAccess,
|
|
1071
|
+
effectiveRank,
|
|
1072
|
+
isExplicit,
|
|
1073
|
+
isInherited,
|
|
1074
|
+
isExplicitDenied,
|
|
1075
|
+
canResetInherit: isExplicit && Boolean(inheritedAccess && inheritedAccess !== 'none'),
|
|
1076
|
+
hasActiveDesc,
|
|
1077
|
+
children: kids
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
res.sort(compareClassNodes);
|
|
1082
|
+
return res;
|
|
1083
|
+
};
|
|
1084
|
+
const out = [];
|
|
1085
|
+
const pushRows = (nodes, classDepth) => {
|
|
1086
|
+
for (const n of nodes) {
|
|
1087
|
+
const hasChildren = Array.isArray(n.children) && n.children.length > 0;
|
|
1088
|
+
const explicitExp = this.expandedClasses?.[n.id];
|
|
1089
|
+
const defaultExpanded = setup ? classDepth === 0 || n.hasActiveDesc || n.effectiveRank > 0 : true;
|
|
1090
|
+
const expanded = typeof explicitExp === 'boolean' ? explicitExp : defaultExpanded;
|
|
1091
|
+
out.push({
|
|
1092
|
+
id: n.id,
|
|
1093
|
+
label: n.label,
|
|
1094
|
+
icon: n.icon,
|
|
1095
|
+
explicitAccess: n.explicitAccess,
|
|
1096
|
+
inheritedAccess: n.inheritedAccess,
|
|
1097
|
+
effectiveAccess: n.effectiveAccess,
|
|
1098
|
+
effectiveRank: n.effectiveRank,
|
|
1099
|
+
isExplicit: n.isExplicit,
|
|
1100
|
+
isInherited: n.isInherited,
|
|
1101
|
+
isExplicitDenied: n.isExplicitDenied,
|
|
1102
|
+
canResetInherit: n.canResetInherit,
|
|
1103
|
+
hasChildren,
|
|
1104
|
+
expanded,
|
|
1105
|
+
classDepth
|
|
1106
|
+
});
|
|
1107
|
+
if (hasChildren && expanded) pushRows(n.children, classDepth + 1);
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
pushRows(filterNodes(source, null), 0);
|
|
1111
|
+
return out;
|
|
1112
|
+
},
|
|
1113
|
+
toggleExpand() {
|
|
1114
|
+
this.expanded = !this.expanded;
|
|
1115
|
+
},
|
|
1116
|
+
toggleSetup() {
|
|
1117
|
+
this.setupMode = !this.setupMode;
|
|
1118
|
+
if (this.setupMode) {
|
|
1119
|
+
this.expanded = true;
|
|
1120
|
+
this.classesExpanded = true;
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
toggleClassNode(clsPath) {
|
|
1124
|
+
const row = (this.classRows || []).find(r => r.id === clsPath);
|
|
1125
|
+
const cur = row ? Boolean(row.expanded) : true;
|
|
1126
|
+
this.expandedClasses = {
|
|
1127
|
+
...this.expandedClasses,
|
|
1128
|
+
[clsPath]: !cur
|
|
1129
|
+
};
|
|
1130
|
+
},
|
|
1131
|
+
onSelectAccess(row, level) {
|
|
1132
|
+
if (!this.canEdit || !this.setupMode || !row?.id) return;
|
|
1133
|
+
this.controller?.setClassAccess(this.trail, row.id, level, row.inheritedAccess || '');
|
|
1134
|
+
},
|
|
1135
|
+
onResetAccess(row) {
|
|
1136
|
+
if (!this.canEdit || !this.setupMode || !row?.id) return;
|
|
1137
|
+
this.controller?.resetClassOverride(this.trail, row.id);
|
|
1138
|
+
},
|
|
1139
|
+
onDragOver(e) {
|
|
1140
|
+
if (!this.canEdit) return;
|
|
1141
|
+
e.preventDefault();
|
|
1142
|
+
if (e.dataTransfer) e.dataTransfer.dropEffect = 'copy';
|
|
1143
|
+
this.dropHover = true;
|
|
1144
|
+
},
|
|
1145
|
+
onDrop(e) {
|
|
1146
|
+
this.dropHover = false;
|
|
1147
|
+
this.controller?.onRoleDrop(e, this.trail);
|
|
1148
|
+
}
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// ---------------------------------------------------------------------------
|
|
1153
|
+
// Корневая вкладка «Система → Пользователи»
|
|
1154
|
+
// ---------------------------------------------------------------------------
|
|
1155
|
+
export default {
|
|
1156
|
+
label: 'Пользователи',
|
|
1157
|
+
icon: 'icons:supervisor-account',
|
|
1158
|
+
order: 20,
|
|
1159
|
+
component: {
|
|
1160
|
+
imports: 'oda//icon, oda//button',
|
|
1161
|
+
template: /*html*/`
|
|
1162
|
+
<style>
|
|
1163
|
+
:host {
|
|
1164
|
+
@apply --vertical;
|
|
1165
|
+
@apply --flex;
|
|
1166
|
+
padding: 14px 18px;
|
|
1167
|
+
gap: 10px;
|
|
1168
|
+
overflow-y: auto;
|
|
1169
|
+
background: var(--content-background);
|
|
1170
|
+
color: var(--content-color);
|
|
1171
|
+
font-size: 13px;
|
|
1172
|
+
box-sizing: border-box;
|
|
1173
|
+
}
|
|
1174
|
+
.tree-box {
|
|
1175
|
+
@apply --vertical;
|
|
1176
|
+
border: 1px solid var(--subtle-border);
|
|
1177
|
+
border-radius: 10px;
|
|
1178
|
+
background: var(--content-background);
|
|
1179
|
+
overflow: hidden;
|
|
1180
|
+
}
|
|
1181
|
+
.root-row {
|
|
1182
|
+
@apply --horizontal;
|
|
1183
|
+
align-items: center;
|
|
1184
|
+
gap: 8px;
|
|
1185
|
+
padding: 10px 14px;
|
|
1186
|
+
background: var(--subtle-background);
|
|
1187
|
+
border-bottom: 1px solid var(--subtle-border);
|
|
1188
|
+
flex-wrap: wrap;
|
|
1189
|
+
transition: background .15s;
|
|
1190
|
+
}
|
|
1191
|
+
.root-row.drop-hover {
|
|
1192
|
+
background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background));
|
|
1193
|
+
outline: 1px dashed var(--accent-color, #2563eb);
|
|
1194
|
+
outline-offset: -2px;
|
|
1195
|
+
}
|
|
1196
|
+
.root-title {
|
|
1197
|
+
font-weight: 700;
|
|
1198
|
+
font-size: 14px;
|
|
1199
|
+
margin-right: 4px;
|
|
1200
|
+
}
|
|
1201
|
+
.boss-label {
|
|
1202
|
+
font-size: 12px;
|
|
1203
|
+
color: var(--muted-color);
|
|
1204
|
+
}
|
|
1205
|
+
.boss-pill {
|
|
1206
|
+
@apply --horizontal;
|
|
1207
|
+
align-items: center;
|
|
1208
|
+
gap: 6px;
|
|
1209
|
+
padding: 3px 10px 3px 5px;
|
|
1210
|
+
border-radius: 16px;
|
|
1211
|
+
border: 1px solid color-mix(in srgb, var(--accent-color, #4f46e5) 28%, var(--subtle-border));
|
|
1212
|
+
background: var(--accent-soft);
|
|
1213
|
+
color: var(--content-color);
|
|
1214
|
+
font-size: 12.5px;
|
|
1215
|
+
max-width: 100%;
|
|
1216
|
+
box-sizing: border-box;
|
|
1217
|
+
transition: filter .12s ease, border-color .12s ease, background .12s ease;
|
|
1218
|
+
}
|
|
1219
|
+
.boss-pill.editable {
|
|
1220
|
+
cursor: pointer;
|
|
1221
|
+
}
|
|
1222
|
+
.boss-pill.editable:hover {
|
|
1223
|
+
border-color: var(--accent-color, #4f46e5);
|
|
1224
|
+
filter: brightness(0.97);
|
|
1225
|
+
}
|
|
1226
|
+
.boss-pill.inherited {
|
|
1227
|
+
opacity: .75;
|
|
1228
|
+
background: color-mix(in srgb, var(--subtle-background) 70%, var(--content-background));
|
|
1229
|
+
border-style: dashed;
|
|
1230
|
+
border-color: var(--subtle-border);
|
|
1231
|
+
}
|
|
1232
|
+
.boss-pill.inherited.editable:hover {
|
|
1233
|
+
opacity: 1;
|
|
1234
|
+
border-style: solid;
|
|
1235
|
+
border-color: var(--accent-color, #4f46e5);
|
|
1236
|
+
}
|
|
1237
|
+
.boss-pill .boss-name {
|
|
1238
|
+
font-weight: 500;
|
|
1239
|
+
overflow: hidden;
|
|
1240
|
+
text-overflow: ellipsis;
|
|
1241
|
+
white-space: nowrap;
|
|
1242
|
+
}
|
|
1243
|
+
.boss-pill .rm {
|
|
1244
|
+
font-weight: 700;
|
|
1245
|
+
opacity: .6;
|
|
1246
|
+
padding: 0 3px;
|
|
1247
|
+
cursor: pointer;
|
|
1248
|
+
border-radius: 4px;
|
|
1249
|
+
}
|
|
1250
|
+
.boss-pill .rm:hover {
|
|
1251
|
+
opacity: 1;
|
|
1252
|
+
color: var(--error-color, #dc2626);
|
|
1253
|
+
background: rgba(220, 38, 38, 0.08);
|
|
1254
|
+
}
|
|
1255
|
+
.boss-pill .chev {
|
|
1256
|
+
opacity: .6;
|
|
1257
|
+
flex-shrink: 0;
|
|
1258
|
+
}
|
|
1259
|
+
.icon-btn {
|
|
1260
|
+
border: 1px solid transparent;
|
|
1261
|
+
background: transparent;
|
|
1262
|
+
color: var(--muted-color);
|
|
1263
|
+
border-radius: 6px;
|
|
1264
|
+
padding: 4px 9px;
|
|
1265
|
+
font: inherit;
|
|
1266
|
+
font-size: 12.5px;
|
|
1267
|
+
cursor: pointer;
|
|
1268
|
+
display: inline-flex;
|
|
1269
|
+
align-items: center;
|
|
1270
|
+
gap: 4px;
|
|
1271
|
+
}
|
|
1272
|
+
.icon-btn:hover {
|
|
1273
|
+
background: var(--content-background);
|
|
1274
|
+
border-color: var(--subtle-border);
|
|
1275
|
+
color: var(--content-color);
|
|
1276
|
+
}
|
|
1277
|
+
.row-actions {
|
|
1278
|
+
@apply --horizontal;
|
|
1279
|
+
align-items: center;
|
|
1280
|
+
gap: 4px;
|
|
1281
|
+
margin-left: auto;
|
|
1282
|
+
flex-wrap: wrap;
|
|
1283
|
+
}
|
|
1284
|
+
.muted {
|
|
1285
|
+
color: var(--muted-color);
|
|
1286
|
+
font-size: 12px;
|
|
1287
|
+
}
|
|
1288
|
+
@media (max-width: 600px) {
|
|
1289
|
+
:host { padding: 8px 10px; }
|
|
1290
|
+
.root-row { padding: 8px 10px; }
|
|
1291
|
+
}
|
|
1292
|
+
</style>
|
|
1293
|
+
|
|
1294
|
+
<div class="tree-box">
|
|
1295
|
+
<!-- Корень дерева: Руководитель подразделения (BOSS) — сама плашка является кнопкой выбора -->
|
|
1296
|
+
<div class="root-row" ~class="{ 'drop-hover': bossDropHover }"
|
|
1297
|
+
@dragover="onBossDragOver" @dragleave="bossDropHover = false" @drop="onBossDrop">
|
|
1298
|
+
<oda-icon :icon="$item?.icon || 'odant:structure'" icon-size="20"></oda-icon>
|
|
1299
|
+
<span class="root-title">{{$item?.label || $item?.id}}</span>
|
|
1300
|
+
<span class="boss-label">Руководитель (BOSS):</span>
|
|
1301
|
+
|
|
1302
|
+
<div ~if="visibleCurrentBoss"
|
|
1303
|
+
class="boss-pill"
|
|
1304
|
+
~class="{ editable: canEdit }"
|
|
1305
|
+
:title="canEdit ? 'Нажмите, чтобы сменить руководителя (BOSS)' : visibleCurrentBoss.label"
|
|
1306
|
+
@tap="canEdit && openBossDropdown($event)">
|
|
1307
|
+
<oda-icon round :icon="visibleCurrentBoss.icon" :icon-color="visibleCurrentBoss.iconColor" icon-size="18"></oda-icon>
|
|
1308
|
+
<span class="boss-name">{{visibleCurrentBoss.label}}</span>
|
|
1309
|
+
<span ~if="canEdit" class="rm" title="Снять локального руководителя (наследовать сверху)" @tap.stop="clearBoss()">×</span>
|
|
1310
|
+
<oda-icon ~if="canEdit" class="chev" icon="icons:chevron-right:90" icon-size="14"></oda-icon>
|
|
1311
|
+
</div>
|
|
1312
|
+
|
|
1313
|
+
<div ~if="!visibleCurrentBoss && visibleInheritedBoss"
|
|
1314
|
+
class="boss-pill inherited"
|
|
1315
|
+
~class="{ editable: canEdit }"
|
|
1316
|
+
:title="canEdit ? 'Унаследовано из «' + inheritedBossInfo.fromLabel + '». Нажмите, чтобы назначить локального руководителя' : ('Унаследовано из «' + inheritedBossInfo.fromLabel + '»')"
|
|
1317
|
+
@tap="canEdit && openBossDropdown($event)">
|
|
1318
|
+
<oda-icon round :icon="visibleInheritedBoss.icon" :icon-color="visibleInheritedBoss.iconColor" icon-size="18"></oda-icon>
|
|
1319
|
+
<span class="boss-name">{{visibleInheritedBoss.label}}</span>
|
|
1320
|
+
<span class="muted">(из «{{inheritedBossInfo.fromLabel}}»)</span>
|
|
1321
|
+
<oda-icon ~if="canEdit" class="chev" icon="icons:chevron-right:90" icon-size="14"></oda-icon>
|
|
1322
|
+
</div>
|
|
1323
|
+
|
|
1324
|
+
<div ~if="!visibleCurrentBoss && !visibleInheritedBoss"
|
|
1325
|
+
class="boss-pill inherited empty-boss"
|
|
1326
|
+
~class="{ editable: canEdit }"
|
|
1327
|
+
:title="canEdit ? 'Нажмите, чтобы назначить руководителя (BOSS)' : ''"
|
|
1328
|
+
@tap="canEdit && openBossDropdown($event)">
|
|
1329
|
+
<oda-icon icon="icons:person" icon-size="16"></oda-icon>
|
|
1330
|
+
<span>{{canEdit ? 'Выбрать руководителя' : '—'}}</span>
|
|
1331
|
+
<oda-icon ~if="canEdit" class="chev" icon="icons:chevron-right:90" icon-size="14"></oda-icon>
|
|
1332
|
+
</div>
|
|
1333
|
+
|
|
1334
|
+
<div ~if="canEdit" class="row-actions">
|
|
1335
|
+
<button type="button" class="icon-btn add-role-btn" @tap="promptAddRole('')">
|
|
1336
|
+
<oda-icon icon="icons:add" icon-size="15"></oda-icon>
|
|
1337
|
+
<span>Роль</span>
|
|
1338
|
+
</button>
|
|
1339
|
+
</div>
|
|
1340
|
+
</div>
|
|
1341
|
+
|
|
1342
|
+
<div ~if="!rootRoles.length" class="muted" style="padding:16px;">Ролей пока нет</div>
|
|
1343
|
+
|
|
1344
|
+
<staff-role-node ~for="rootRoles"
|
|
1345
|
+
:role="$for.item"
|
|
1346
|
+
:prefix="''"
|
|
1347
|
+
:depth="0"
|
|
1348
|
+
:controller="selfRef"
|
|
1349
|
+
:can-edit="canEdit"
|
|
1350
|
+
:base-classes="baseClasses"
|
|
1351
|
+
:user-map="userMap"
|
|
1352
|
+
:structure-map="structureMap"
|
|
1353
|
+
:network-node-map="networkNodeMap">
|
|
1354
|
+
</staff-role-node>
|
|
1355
|
+
</div>
|
|
1356
|
+
|
|
1357
|
+
<div ~if="error" style="color:var(--error-color, #dc2626);font-size:12.5px;">{{error}}</div>
|
|
1358
|
+
`,
|
|
1359
|
+
$item: {
|
|
1360
|
+
$def: null,
|
|
1361
|
+
set(n) {
|
|
1362
|
+
if (n) this.reload();
|
|
1363
|
+
}
|
|
1364
|
+
},
|
|
1365
|
+
security: null,
|
|
1366
|
+
allUsers: [],
|
|
1367
|
+
usersTree: [],
|
|
1368
|
+
userMap: {},
|
|
1369
|
+
userMetaMap: {},
|
|
1370
|
+
availableStructures: [],
|
|
1371
|
+
organizationsTree: [],
|
|
1372
|
+
projectsTree: [],
|
|
1373
|
+
structureMap: {},
|
|
1374
|
+
availableNetworkNodes: [],
|
|
1375
|
+
networkNodeMap: {},
|
|
1376
|
+
remoteSubjectMetaMap: {},
|
|
1377
|
+
inheritedBossInfo: null,
|
|
1378
|
+
baseClasses: [],
|
|
1379
|
+
canEdit: false,
|
|
1380
|
+
focusedTrail: '',
|
|
1381
|
+
bossDropHover: false,
|
|
1382
|
+
error: '',
|
|
1383
|
+
get selfRef() {
|
|
1384
|
+
return this;
|
|
1385
|
+
},
|
|
1386
|
+
get rootRoles() {
|
|
1387
|
+
return Array.isArray(this.security?.ROLES) ? this.security.ROLES : [];
|
|
1388
|
+
},
|
|
1389
|
+
async attached() {
|
|
1390
|
+
if (this.$item) await this.reload();
|
|
1391
|
+
},
|
|
1392
|
+
async applyNav(nav = {}) {
|
|
1393
|
+
if (nav.place) this.focusedTrail = String(nav.place);
|
|
1394
|
+
await this.reload();
|
|
1395
|
+
},
|
|
1396
|
+
get currentBoss() {
|
|
1397
|
+
const list = Array.isArray(this.security?.BOSS) ? this.security.BOSS : [];
|
|
1398
|
+
return list[0] || '';
|
|
1399
|
+
},
|
|
1400
|
+
get visibleCurrentBoss() {
|
|
1401
|
+
const id = this.currentBoss;
|
|
1402
|
+
if (!id) return null;
|
|
1403
|
+
return {
|
|
1404
|
+
id,
|
|
1405
|
+
label: this.userMap?.[id] || id,
|
|
1406
|
+
icon: this.userIcon(id),
|
|
1407
|
+
iconColor: this.userColor(id)
|
|
1408
|
+
};
|
|
1409
|
+
},
|
|
1410
|
+
get visibleInheritedBoss() {
|
|
1411
|
+
const first = this.inheritedBossInfo?.users?.[0];
|
|
1412
|
+
if (!first?.id) return null;
|
|
1413
|
+
return {
|
|
1414
|
+
id: first.id,
|
|
1415
|
+
label: first.label || this.userMap?.[first.id] || first.id,
|
|
1416
|
+
icon: first.icon || this.userIcon(first.id),
|
|
1417
|
+
iconColor: first.iconColor || this.userColor(first.id),
|
|
1418
|
+
missing: Boolean(first.missing)
|
|
1419
|
+
};
|
|
1420
|
+
},
|
|
1421
|
+
buildMemberEntries(usersList) {
|
|
1422
|
+
const memberEntries = [];
|
|
1423
|
+
for (const id of Array.isArray(usersList) ? usersList : []) {
|
|
1424
|
+
if (typeof id !== 'string' || !id) continue;
|
|
1425
|
+
// Удалённый субъект внутри /NODES/<Узел>[/USERS/... | /ORGANIZATIONS/...]
|
|
1426
|
+
const remoteMatch = /^\/NODES\/([^/]+)(?:\/(.*))?$/i.exec(normPath(id));
|
|
1427
|
+
if (remoteMatch) {
|
|
1428
|
+
const nodeSeg = remoteMatch[1];
|
|
1429
|
+
const rest = remoteMatch[2] ? '/' + remoteMatch[2] : '';
|
|
1430
|
+
const nn = this.networkNodeMap?.[`/NODES/${nodeSeg}`] || this.networkNodeMap?.[nodeSeg] || this.networkNodeMap?.[nodeSeg.toUpperCase()];
|
|
1431
|
+
const nodeLabel = nn?.label || nodeSeg;
|
|
1432
|
+
const cached = this.remoteSubjectMetaMap?.[normPath(id)];
|
|
1433
|
+
if (!rest) {
|
|
1434
|
+
memberEntries.push({
|
|
1435
|
+
id,
|
|
1436
|
+
isNode: false,
|
|
1437
|
+
isNetworkNode: true,
|
|
1438
|
+
isRemote: true,
|
|
1439
|
+
isGroup: false,
|
|
1440
|
+
round: false,
|
|
1441
|
+
nodePath: nn?.path || `/NODES/${nodeSeg}`,
|
|
1442
|
+
label: nodeLabel,
|
|
1443
|
+
title: `/NODES/${nodeSeg}`,
|
|
1444
|
+
icon: nn?.icon || 'icons:dns',
|
|
1445
|
+
iconColor: '',
|
|
1446
|
+
tag: 'сервер сети'
|
|
1447
|
+
});
|
|
1448
|
+
} else {
|
|
1449
|
+
const isRemoteUser = /^\/USERS\/[^/]+$/i.test(rest);
|
|
1450
|
+
const segLabel = cached?.label || rest.split('/').filter(Boolean).pop() || id;
|
|
1451
|
+
memberEntries.push({
|
|
1452
|
+
id,
|
|
1453
|
+
isNode: !isRemoteUser,
|
|
1454
|
+
isNetworkNode: false,
|
|
1455
|
+
isRemote: true,
|
|
1456
|
+
isGroup: false,
|
|
1457
|
+
round: isRemoteUser,
|
|
1458
|
+
nodePath: normPath(id),
|
|
1459
|
+
label: segLabel,
|
|
1460
|
+
title: `${segLabel} (${nodeLabel}) — ${id}`,
|
|
1461
|
+
icon: cached?.icon || (isRemoteUser ? 'icons:person' : 'odant:structure'),
|
|
1462
|
+
iconColor: cached?.iconColor || '',
|
|
1463
|
+
tag: `${nodeLabel} · ${isRemoteUser ? 'пользователь' : 'подразделение'}`
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
continue;
|
|
1467
|
+
}
|
|
1468
|
+
if (id.startsWith('/')) {
|
|
1469
|
+
const st = this.structureMap?.[id] || this.structureMap?.[normPath(id)];
|
|
1470
|
+
const isBase = st?.type === '$organization' || /^\/ORGANIZATIONS\/[^/]+$/i.test(normPath(id));
|
|
1471
|
+
const isProj = st?.type === '$project' || /^\/PROJECTS\/[^/]+$/i.test(normPath(id));
|
|
1472
|
+
memberEntries.push({
|
|
1473
|
+
id,
|
|
1474
|
+
isNode: true,
|
|
1475
|
+
isNetworkNode: false,
|
|
1476
|
+
isRemote: false,
|
|
1477
|
+
isGroup: false,
|
|
1478
|
+
round: false,
|
|
1479
|
+
label: st?.label || id.split('/').pop() || id,
|
|
1480
|
+
title: id,
|
|
1481
|
+
icon: st?.icon || (isBase ? 'odant:base' : isProj ? 'odant:project' : 'odant:structure'),
|
|
1482
|
+
iconColor: '',
|
|
1483
|
+
tag: isBase ? 'организация' : isProj ? 'проект' : 'подразделение'
|
|
1484
|
+
});
|
|
1485
|
+
} else if (id === 'USERS') {
|
|
1486
|
+
memberEntries.push({
|
|
1487
|
+
id,
|
|
1488
|
+
isNode: false,
|
|
1489
|
+
isNetworkNode: false,
|
|
1490
|
+
isRemote: false,
|
|
1491
|
+
isGroup: true,
|
|
1492
|
+
round: false,
|
|
1493
|
+
label: 'Пользователи (/USERS)',
|
|
1494
|
+
title: 'Все зарегистрированные пользователи этого сервера',
|
|
1495
|
+
icon: 'social:people',
|
|
1496
|
+
iconColor: '',
|
|
1497
|
+
tag: 'сервер'
|
|
1498
|
+
});
|
|
1499
|
+
} else if (id === 'GUESTS') {
|
|
1500
|
+
memberEntries.push({
|
|
1501
|
+
id,
|
|
1502
|
+
isNode: false,
|
|
1503
|
+
isNetworkNode: false,
|
|
1504
|
+
isRemote: false,
|
|
1505
|
+
isGroup: true,
|
|
1506
|
+
round: false,
|
|
1507
|
+
label: 'Гости (GUESTS)',
|
|
1508
|
+
title: 'Устаревшая групповая запись GUESTS',
|
|
1509
|
+
icon: 'icons:public',
|
|
1510
|
+
iconColor: '',
|
|
1511
|
+
tag: 'группа'
|
|
1512
|
+
});
|
|
1513
|
+
} else if (this.networkNodeMap?.[id] || this.networkNodeMap?.[String(id).toUpperCase()]) {
|
|
1514
|
+
const nn = this.networkNodeMap[id] || this.networkNodeMap[String(id).toUpperCase()];
|
|
1515
|
+
memberEntries.push({
|
|
1516
|
+
id,
|
|
1517
|
+
isNode: false,
|
|
1518
|
+
isNetworkNode: true,
|
|
1519
|
+
isRemote: true,
|
|
1520
|
+
isGroup: false,
|
|
1521
|
+
round: false,
|
|
1522
|
+
nodePath: nn.path,
|
|
1523
|
+
label: nn.label || nn.id || id,
|
|
1524
|
+
title: nn.path || id,
|
|
1525
|
+
icon: nn.icon || 'icons:dns',
|
|
1526
|
+
iconColor: '',
|
|
1527
|
+
tag: 'сервер сети'
|
|
1528
|
+
});
|
|
1529
|
+
} else if (this.userMap?.[id]) {
|
|
1530
|
+
memberEntries.push({
|
|
1531
|
+
id,
|
|
1532
|
+
isNode: false,
|
|
1533
|
+
isNetworkNode: false,
|
|
1534
|
+
isRemote: false,
|
|
1535
|
+
isGroup: false,
|
|
1536
|
+
round: true,
|
|
1537
|
+
label: this.userLabel(id),
|
|
1538
|
+
title: `/USERS/${id}`,
|
|
1539
|
+
icon: this.userIcon(id),
|
|
1540
|
+
iconColor: this.userColor(id),
|
|
1541
|
+
tag: 'пользователь'
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
return memberEntries;
|
|
1546
|
+
},
|
|
1547
|
+
userLabel(uid) {
|
|
1548
|
+
return this.userMap?.[uid] || uid;
|
|
1549
|
+
},
|
|
1550
|
+
userIcon(uid) {
|
|
1551
|
+
const meta = this.userMetaMap?.[uid];
|
|
1552
|
+
if (meta?.icon) return meta.icon;
|
|
1553
|
+
const lbl = String(this.userLabel(uid) || uid || '').trim();
|
|
1554
|
+
const initials = lbl.split(/\s+/).slice(0, 2).map(s => s[0]).join('').toUpperCase();
|
|
1555
|
+
return initials ? '@:' + initials : 'icons:person';
|
|
1556
|
+
},
|
|
1557
|
+
userColor(uid) {
|
|
1558
|
+
const meta = this.userMetaMap?.[uid];
|
|
1559
|
+
const icon = this.userIcon(uid);
|
|
1560
|
+
if (typeof icon === 'string' && icon.startsWith('@')) return meta?.iconColor || '#3b82f6';
|
|
1561
|
+
return '';
|
|
1562
|
+
},
|
|
1563
|
+
async reload() {
|
|
1564
|
+
this.error = '';
|
|
1565
|
+
if (!this.$item) return;
|
|
1566
|
+
try {
|
|
1567
|
+
this.canEdit = !!(WORK?.DEV_MODE || (await this.$item.isBoss));
|
|
1568
|
+
if (this.canEdit) {
|
|
1569
|
+
const [body, ctx] = await Promise.all([this.$item.body, this.$item.fetch?.('agent_staff_context').catch(() => null)]);
|
|
1570
|
+
this.security = JSON.parse(JSON.stringify(body?.['#security'] || {}));
|
|
1571
|
+
if (ctx) {
|
|
1572
|
+
this._applyStaffContext(ctx);
|
|
1573
|
+
} else {
|
|
1574
|
+
await this.loadUsersFallback();
|
|
1575
|
+
}
|
|
1576
|
+
} else {
|
|
1577
|
+
const [bossList, placesRes] = await Promise.all([Promise.resolve(this.$item.bosses).catch(() => []), this.$item.fetch('places').catch(() => ({
|
|
1578
|
+
places: []
|
|
1579
|
+
})), this.loadUsersFallback()]);
|
|
1580
|
+
const toRoles = list => (Array.isArray(list) ? list : []).map(p => ({
|
|
1581
|
+
id: p.id,
|
|
1582
|
+
label: p.label || p.id,
|
|
1583
|
+
icon: p.icon || '',
|
|
1584
|
+
...(p.external ? {
|
|
1585
|
+
external: true
|
|
1586
|
+
} : {}),
|
|
1587
|
+
...(p.mine ? {
|
|
1588
|
+
mine: true
|
|
1589
|
+
} : {}),
|
|
1590
|
+
USERS: Array.isArray(p.users) ? p.users : [],
|
|
1591
|
+
LINKS: Array.isArray(p.links) ? p.links.map(l => ({
|
|
1592
|
+
id: l.id,
|
|
1593
|
+
access: l.access || 'read',
|
|
1594
|
+
...(l.scope ? {
|
|
1595
|
+
scope: l.scope
|
|
1596
|
+
} : {})
|
|
1597
|
+
})) : [],
|
|
1598
|
+
ROLES: toRoles(p.roles)
|
|
1599
|
+
}));
|
|
1600
|
+
this.security = {
|
|
1601
|
+
BOSS: Array.isArray(bossList) ? bossList.map(u => u?.id || u).filter(Boolean).slice(0, 1) : [],
|
|
1602
|
+
ROLES: toRoles(placesRes?.places)
|
|
1603
|
+
};
|
|
1604
|
+
this.baseClasses = [];
|
|
1605
|
+
this.availableStructures = [];
|
|
1606
|
+
this.organizationsTree = [];
|
|
1607
|
+
this.projectsTree = [];
|
|
1608
|
+
this.availableNetworkNodes = [];
|
|
1609
|
+
}
|
|
1610
|
+
} catch (e) {
|
|
1611
|
+
this.error = String(e?.message || e);
|
|
1612
|
+
}
|
|
1613
|
+
},
|
|
1614
|
+
_applyStaffContext(ctx) {
|
|
1615
|
+
const users = Array.isArray(ctx.users) ? ctx.users : [];
|
|
1616
|
+
const uMap = {};
|
|
1617
|
+
const uMeta = {};
|
|
1618
|
+
for (const u of users) {
|
|
1619
|
+
if (!u?.id) continue;
|
|
1620
|
+
uMap[u.id] = u.label || u.id;
|
|
1621
|
+
uMeta[u.id] = {
|
|
1622
|
+
icon: u.icon || '',
|
|
1623
|
+
iconColor: u.iconColor || '',
|
|
1624
|
+
label: u.label || u.id
|
|
1625
|
+
};
|
|
1626
|
+
}
|
|
1627
|
+
this.allUsers = users;
|
|
1628
|
+
this.usersTree = Array.isArray(ctx.usersTree) && ctx.usersTree.length ? ctx.usersTree : users.map(u => ({
|
|
1629
|
+
...u,
|
|
1630
|
+
path: `/USERS/${u.id}`,
|
|
1631
|
+
type: '$user',
|
|
1632
|
+
children: []
|
|
1633
|
+
}));
|
|
1634
|
+
this.userMap = uMap;
|
|
1635
|
+
this.userMetaMap = uMeta;
|
|
1636
|
+
const structs = Array.isArray(ctx.structures) ? ctx.structures : [];
|
|
1637
|
+
const sMap = {};
|
|
1638
|
+
const indexTree = nodes => {
|
|
1639
|
+
for (const n of Array.isArray(nodes) ? nodes : []) {
|
|
1640
|
+
if (n?.path) sMap[normPath(n.path)] = n;
|
|
1641
|
+
if (Array.isArray(n?.children) && n.children.length) indexTree(n.children);
|
|
1642
|
+
}
|
|
1643
|
+
};
|
|
1644
|
+
for (const s of structs) {
|
|
1645
|
+
if (s?.path) sMap[normPath(s.path)] = s;
|
|
1646
|
+
}
|
|
1647
|
+
this.organizationsTree = Array.isArray(ctx.organizationsTree) ? ctx.organizationsTree : [];
|
|
1648
|
+
this.projectsTree = Array.isArray(ctx.projectsTree) ? ctx.projectsTree : [];
|
|
1649
|
+
indexTree(this.organizationsTree);
|
|
1650
|
+
indexTree(this.projectsTree);
|
|
1651
|
+
this.availableStructures = structs;
|
|
1652
|
+
this.structureMap = sMap;
|
|
1653
|
+
const netNodes = Array.isArray(ctx.networkNodes) ? ctx.networkNodes : [];
|
|
1654
|
+
const nMap = {};
|
|
1655
|
+
for (const n of netNodes) {
|
|
1656
|
+
if (n?.principalId) {
|
|
1657
|
+
nMap[n.principalId] = n;
|
|
1658
|
+
nMap[String(n.principalId).toUpperCase()] = n;
|
|
1659
|
+
}
|
|
1660
|
+
if (n?.id) nMap[n.id] = n;
|
|
1661
|
+
if (n?.path) nMap[normPath(n.path)] = n;
|
|
1662
|
+
}
|
|
1663
|
+
this.availableNetworkNodes = netNodes;
|
|
1664
|
+
this.networkNodeMap = nMap;
|
|
1665
|
+
this.inheritedBossInfo = ctx.inheritedBoss || null;
|
|
1666
|
+
this.baseClasses = Array.isArray(ctx.baseClasses) ? ctx.baseClasses : [];
|
|
1667
|
+
},
|
|
1668
|
+
async loadUsersFallback() {
|
|
1669
|
+
try {
|
|
1670
|
+
const uRoot = (await WORK.get_item('/USERS')) || (await WORK.get_item('/users'));
|
|
1671
|
+
const items = (await uRoot?.items) || [];
|
|
1672
|
+
const list = [];
|
|
1673
|
+
const map = {};
|
|
1674
|
+
const metaMap = {};
|
|
1675
|
+
for (const u of items) {
|
|
1676
|
+
if (!u?.id || u.id[0] === '$') continue;
|
|
1677
|
+
const label = u.label || u.DATA?.label || u.id;
|
|
1678
|
+
list.push({
|
|
1679
|
+
id: u.id,
|
|
1680
|
+
label
|
|
1681
|
+
});
|
|
1682
|
+
map[u.id] = label;
|
|
1683
|
+
metaMap[u.id] = {
|
|
1684
|
+
icon: u.icon || u.DATA?.icon || '',
|
|
1685
|
+
iconColor: u.iconColor || '',
|
|
1686
|
+
label
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
this.allUsers = list;
|
|
1690
|
+
this.usersTree = list.map(u => ({
|
|
1691
|
+
...u,
|
|
1692
|
+
path: `/USERS/${u.id}`,
|
|
1693
|
+
type: '$user',
|
|
1694
|
+
children: []
|
|
1695
|
+
}));
|
|
1696
|
+
this.userMap = map;
|
|
1697
|
+
this.userMetaMap = metaMap;
|
|
1698
|
+
} catch {/* ignore */}
|
|
1699
|
+
},
|
|
1700
|
+
async persist(nextSec, auditTitle = '', auditSummary = '') {
|
|
1701
|
+
this.error = '';
|
|
1702
|
+
try {
|
|
1703
|
+
if (typeof this.$item?.fetch === 'function') {
|
|
1704
|
+
const res = await this.$item.fetch('security_update', {}, JSON.stringify({
|
|
1705
|
+
security: nextSec,
|
|
1706
|
+
title: auditTitle || 'Обновлены права и роли подразделения',
|
|
1707
|
+
summary: auditSummary || ''
|
|
1708
|
+
}));
|
|
1709
|
+
this.security = JSON.parse(JSON.stringify(res?.security || nextSec));
|
|
1710
|
+
} else {
|
|
1711
|
+
const body = await this.$item.body;
|
|
1712
|
+
body['#security'] = nextSec;
|
|
1713
|
+
await this.$item.save(body);
|
|
1714
|
+
this.security = JSON.parse(JSON.stringify(nextSec));
|
|
1715
|
+
}
|
|
1716
|
+
this.$item.reset?.();
|
|
1717
|
+
this.$item.fire?.('changed', {
|
|
1718
|
+
value: null
|
|
1719
|
+
});
|
|
1720
|
+
try {
|
|
1721
|
+
if (window.top && window.top !== window && window.top.CORE?.$item?.ITEMS) {
|
|
1722
|
+
const topItems = window.top.CORE.$item.ITEMS;
|
|
1723
|
+
const topItem = topItems[this.$item.path] || topItems[this.$item.short];
|
|
1724
|
+
if (topItem) {
|
|
1725
|
+
await topItem.fetch?.('info').catch(() => {});
|
|
1726
|
+
topItem.increaseVersion?.();
|
|
1727
|
+
topItem.fire?.('changed', {
|
|
1728
|
+
value: null
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
} catch {/* ignore cross-origin */}
|
|
1733
|
+
} catch (e) {
|
|
1734
|
+
this.error = String(e?.message || e);
|
|
1735
|
+
}
|
|
1736
|
+
},
|
|
1737
|
+
async openUser(uid) {
|
|
1738
|
+
if (!uid || uid === 'USERS' || uid === 'GUESTS' || typeof window?.execute !== 'function') return;
|
|
1739
|
+
const target = await WORK.get_item(`/USERS/${uid}`).catch(() => null);
|
|
1740
|
+
if (target) window.execute(target);
|
|
1741
|
+
},
|
|
1742
|
+
async openMember(entry) {
|
|
1743
|
+
if (!entry || entry.isGroup || typeof window?.execute !== 'function') return;
|
|
1744
|
+
if ((entry.isNetworkNode || entry.isRemote) && entry.nodePath) {
|
|
1745
|
+
const target = await WORK.get_item(entry.nodePath).catch(() => null);
|
|
1746
|
+
if (target) window.execute(target);
|
|
1747
|
+
return;
|
|
1748
|
+
}
|
|
1749
|
+
if (entry.isNode) {
|
|
1750
|
+
const target = await WORK.get_item(entry.id).catch(() => null);
|
|
1751
|
+
if (target) window.execute(target);
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
await this.openUser(entry.id);
|
|
1755
|
+
},
|
|
1756
|
+
async openClass(clsPath) {
|
|
1757
|
+
if (!clsPath || typeof window?.execute !== 'function') return;
|
|
1758
|
+
const target = await WORK.get_item(clsPath).catch(() => null);
|
|
1759
|
+
if (target) window.execute(target);
|
|
1760
|
+
},
|
|
1761
|
+
_enrichUsersTree(nodes) {
|
|
1762
|
+
return (Array.isArray(nodes) ? nodes : []).map(n => {
|
|
1763
|
+
const isUser = n.type === '$user' || !n.children?.length && !n.type;
|
|
1764
|
+
return {
|
|
1765
|
+
...n,
|
|
1766
|
+
icon: isUser ? this.userIcon(n.id) : n.icon || 'odant:folder',
|
|
1767
|
+
iconColor: isUser ? this.userColor(n.id) : '',
|
|
1768
|
+
children: this._enrichUsersTree(n.children || [])
|
|
1769
|
+
};
|
|
1770
|
+
});
|
|
1771
|
+
},
|
|
1772
|
+
async openBossDropdown(e) {
|
|
1773
|
+
const anchor = e?.currentTarget || e?.target || this;
|
|
1774
|
+
const users = (this.allUsers || []).map(u => ({
|
|
1775
|
+
id: u.id,
|
|
1776
|
+
label: u.label,
|
|
1777
|
+
icon: this.userIcon(u.id),
|
|
1778
|
+
iconColor: this.userColor(u.id)
|
|
1779
|
+
}));
|
|
1780
|
+
const el = ODA.createComponent('staff-boss-menu', {
|
|
1781
|
+
users,
|
|
1782
|
+
usersTree: this._enrichUsersTree(this.usersTree),
|
|
1783
|
+
currentId: this.currentBoss,
|
|
1784
|
+
hasLocalBoss: Boolean(this.currentBoss)
|
|
1785
|
+
});
|
|
1786
|
+
let picked;
|
|
1787
|
+
try {
|
|
1788
|
+
picked = await WORK.showDropdown(el, {
|
|
1789
|
+
TITLE: {
|
|
1790
|
+
label: 'Руководитель (BOSS)'
|
|
1791
|
+
},
|
|
1792
|
+
placement: 'bottom'
|
|
1793
|
+
}, anchor);
|
|
1794
|
+
} catch (err) {
|
|
1795
|
+
if (err instanceof WORK.CancelError) return;
|
|
1796
|
+
this.error = String(err?.message || err);
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
if (picked !== undefined) await this.setBoss(picked);
|
|
1800
|
+
},
|
|
1801
|
+
_buildMemberTreeRoots() {
|
|
1802
|
+
const mapUsers = nodes => (Array.isArray(nodes) ? nodes : []).map(n => {
|
|
1803
|
+
const isUser = n.type === '$user' || !n.children?.length && !n.type;
|
|
1804
|
+
return {
|
|
1805
|
+
key: isUser ? `user:${n.id}` : `ufolder:${n.path || n.id}`,
|
|
1806
|
+
value: isUser ? n.id : '',
|
|
1807
|
+
label: n.label || n.id,
|
|
1808
|
+
title: isUser ? `/USERS/${n.id}` : n.path || n.label,
|
|
1809
|
+
icon: isUser ? this.userIcon(n.id) : n.icon || 'odant:folder',
|
|
1810
|
+
iconColor: isUser ? this.userColor(n.id) : '',
|
|
1811
|
+
round: isUser,
|
|
1812
|
+
tag: isUser ? 'пользователь' : '',
|
|
1813
|
+
selectable: isUser,
|
|
1814
|
+
children: mapUsers(n.children || [])
|
|
1815
|
+
};
|
|
1816
|
+
});
|
|
1817
|
+
const mapStructures = nodes => (Array.isArray(nodes) ? nodes : []).map(s => ({
|
|
1818
|
+
key: `struct:${s.path}`,
|
|
1819
|
+
value: s.path,
|
|
1820
|
+
label: s.label || s.id,
|
|
1821
|
+
title: s.path,
|
|
1822
|
+
icon: s.icon || (s.type === '$organization' ? 'odant:base' : s.type === '$project' ? 'odant:project' : 'odant:structure'),
|
|
1823
|
+
iconColor: '',
|
|
1824
|
+
round: false,
|
|
1825
|
+
tag: s.isSelf ? 'текущий узел' : s.type === '$organization' ? 'организация' : s.type === '$project' ? 'проект' : 'подразделение',
|
|
1826
|
+
selectable: !s.isSelf,
|
|
1827
|
+
disabled: Boolean(s.isSelf && (!s.children || !s.children.length)),
|
|
1828
|
+
children: mapStructures(s.children || [])
|
|
1829
|
+
}));
|
|
1830
|
+
|
|
1831
|
+
// Если organizationsTree/projectsTree пусты (например, старый бэкенд или мок), собираем из плоского availableStructures
|
|
1832
|
+
let orgChildren = mapStructures(this.organizationsTree);
|
|
1833
|
+
let projChildren = mapStructures(this.projectsTree);
|
|
1834
|
+
if (!orgChildren.length && !projChildren.length && this.availableStructures?.length) {
|
|
1835
|
+
orgChildren = mapStructures(this.availableStructures.filter(s => !String(s.path || '').startsWith('/PROJECTS/')));
|
|
1836
|
+
projChildren = mapStructures(this.availableStructures.filter(s => String(s.path || '').startsWith('/PROJECTS/')));
|
|
1837
|
+
}
|
|
1838
|
+
const nodeChildren = (this.availableNetworkNodes || []).map(n => ({
|
|
1839
|
+
key: `net:${n.path || n.id}`,
|
|
1840
|
+
value: n.principalId || n.path || n.id,
|
|
1841
|
+
label: n.label || n.id,
|
|
1842
|
+
title: `${n.label || n.id} (${n.path || n.principalId})`,
|
|
1843
|
+
icon: n.icon || 'icons:dns',
|
|
1844
|
+
iconColor: '',
|
|
1845
|
+
round: false,
|
|
1846
|
+
tag: 'сервер сети',
|
|
1847
|
+
selectable: true,
|
|
1848
|
+
lazyPath: n.path ? normPath(n.path) : '',
|
|
1849
|
+
remoteNodeLabel: n.label || n.id,
|
|
1850
|
+
children: Array.isArray(n.children) ? n.children : []
|
|
1851
|
+
}));
|
|
1852
|
+
const roots = [{
|
|
1853
|
+
key: 'root:users',
|
|
1854
|
+
value: 'USERS',
|
|
1855
|
+
label: 'Пользователи',
|
|
1856
|
+
title: 'Выбрать всех пользователей (/USERS) или раскрыть список',
|
|
1857
|
+
icon: 'social:people',
|
|
1858
|
+
iconColor: '',
|
|
1859
|
+
round: false,
|
|
1860
|
+
tag: 'все на сервере',
|
|
1861
|
+
selectable: true,
|
|
1862
|
+
isGroupRoot: true,
|
|
1863
|
+
children: mapUsers(this.usersTree)
|
|
1864
|
+
}];
|
|
1865
|
+
if (orgChildren.length) {
|
|
1866
|
+
roots.push({
|
|
1867
|
+
key: 'root:orgs',
|
|
1868
|
+
value: '',
|
|
1869
|
+
label: 'Организации',
|
|
1870
|
+
icon: 'odant:base',
|
|
1871
|
+
iconColor: '',
|
|
1872
|
+
round: false,
|
|
1873
|
+
tag: '',
|
|
1874
|
+
selectable: false,
|
|
1875
|
+
isGroupRoot: true,
|
|
1876
|
+
children: orgChildren
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
if (projChildren.length) {
|
|
1880
|
+
roots.push({
|
|
1881
|
+
key: 'root:projects',
|
|
1882
|
+
value: '',
|
|
1883
|
+
label: 'Проекты',
|
|
1884
|
+
icon: 'odant:project',
|
|
1885
|
+
iconColor: '',
|
|
1886
|
+
round: false,
|
|
1887
|
+
tag: '',
|
|
1888
|
+
selectable: false,
|
|
1889
|
+
isGroupRoot: true,
|
|
1890
|
+
children: projChildren
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
if (nodeChildren.length) {
|
|
1894
|
+
roots.push({
|
|
1895
|
+
key: 'root:nodes',
|
|
1896
|
+
value: '',
|
|
1897
|
+
label: 'Сеть',
|
|
1898
|
+
icon: 'icons:dns',
|
|
1899
|
+
iconColor: '',
|
|
1900
|
+
round: false,
|
|
1901
|
+
tag: '',
|
|
1902
|
+
selectable: false,
|
|
1903
|
+
isGroupRoot: true,
|
|
1904
|
+
children: nodeChildren
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
return roots;
|
|
1908
|
+
},
|
|
1909
|
+
async openMemberDropdown(e, trail) {
|
|
1910
|
+
const anchor = e?.currentTarget || e?.target || this;
|
|
1911
|
+
const treeRoots = this._buildMemberTreeRoots();
|
|
1912
|
+
const el = ODA.createComponent('staff-member-menu', {
|
|
1913
|
+
treeRoots,
|
|
1914
|
+
remoteMetaCollector: (pathKey, meta) => {
|
|
1915
|
+
this.remoteSubjectMetaMap = {
|
|
1916
|
+
...this.remoteSubjectMetaMap,
|
|
1917
|
+
[normPath(pathKey)]: meta
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1920
|
+
});
|
|
1921
|
+
let picked;
|
|
1922
|
+
try {
|
|
1923
|
+
picked = await WORK.showDropdown(el, {
|
|
1924
|
+
TITLE: {
|
|
1925
|
+
label: 'Добавить участника'
|
|
1926
|
+
},
|
|
1927
|
+
placement: 'bottom'
|
|
1928
|
+
}, anchor);
|
|
1929
|
+
} catch (err) {
|
|
1930
|
+
if (err instanceof WORK.CancelError) return;
|
|
1931
|
+
this.error = String(err?.message || err);
|
|
1932
|
+
return;
|
|
1933
|
+
}
|
|
1934
|
+
if (picked) await this._addMemberToRole(trail, picked);
|
|
1935
|
+
},
|
|
1936
|
+
async setBoss(uid) {
|
|
1937
|
+
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
1938
|
+
const cleanUid = String(uid || '').trim();
|
|
1939
|
+
sec.BOSS = cleanUid ? [cleanUid] : [];
|
|
1940
|
+
const label = cleanUid ? this.userLabel(cleanUid) : 'наследуется сверху';
|
|
1941
|
+
await this.persist(sec, `Назначен руководитель: ${label}`, `В подразделении ${this.$item?.path || ''} руководитель (BOSS): ${label}.`);
|
|
1942
|
+
},
|
|
1943
|
+
async clearBoss() {
|
|
1944
|
+
await this.setBoss('');
|
|
1945
|
+
},
|
|
1946
|
+
onBossDragOver(e) {
|
|
1947
|
+
if (!this.canEdit) return;
|
|
1948
|
+
e.preventDefault();
|
|
1949
|
+
if (e.dataTransfer) e.dataTransfer.dropEffect = 'copy';
|
|
1950
|
+
this.bossDropHover = true;
|
|
1951
|
+
},
|
|
1952
|
+
async onBossDrop(e) {
|
|
1953
|
+
this.bossDropHover = false;
|
|
1954
|
+
if (!this.canEdit) return;
|
|
1955
|
+
e.preventDefault();
|
|
1956
|
+
const dropped = parseDroppedItem(e);
|
|
1957
|
+
if (!isDroppedUser(dropped)) {
|
|
1958
|
+
this.error = 'Для назначения руководителя перетащите пользователя из /USERS.';
|
|
1959
|
+
return;
|
|
1960
|
+
}
|
|
1961
|
+
const uid = dropped.id || dropped.path.split('/').pop();
|
|
1962
|
+
if (uid) await this.setBoss(uid);
|
|
1963
|
+
},
|
|
1964
|
+
async onRoleDrop(e, trail) {
|
|
1965
|
+
if (!this.canEdit) return;
|
|
1966
|
+
e.preventDefault();
|
|
1967
|
+
const dropped = parseDroppedItem(e);
|
|
1968
|
+
if (!dropped) return;
|
|
1969
|
+
if (isDroppedUser(dropped)) {
|
|
1970
|
+
const uid = dropped.id || dropped.path.split('/').pop();
|
|
1971
|
+
if (uid) await this._addMemberToRole(trail, uid);
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1974
|
+
if (isDroppedNetworkNode(dropped)) {
|
|
1975
|
+
const byMap = this.networkNodeMap?.[normPath(dropped.path)] || this.networkNodeMap?.[dropped.id];
|
|
1976
|
+
let memberId = byMap?.principalId || byMap?.path || dropped.path || '';
|
|
1977
|
+
if (!memberId && dropped.path) {
|
|
1978
|
+
const item = await WORK.get_item(dropped.path).catch(() => null);
|
|
1979
|
+
memberId = item?.DATA?.host_id ? String(item.DATA.host_id).toUpperCase() : item?.path || dropped.path;
|
|
1980
|
+
}
|
|
1981
|
+
if (memberId) await this._addMemberToRole(trail, memberId);
|
|
1982
|
+
return;
|
|
1983
|
+
}
|
|
1984
|
+
if (isDroppedRemoteSubject(dropped)) {
|
|
1985
|
+
await this._addMemberToRole(trail, normPath(dropped.path));
|
|
1986
|
+
return;
|
|
1987
|
+
}
|
|
1988
|
+
if (isDroppedStructure(dropped)) {
|
|
1989
|
+
if (dropped.path && normPath(dropped.path) !== normPath(this.$item?.path || '')) await this._addMemberToRole(trail, normPath(dropped.path));
|
|
1990
|
+
return;
|
|
1991
|
+
}
|
|
1992
|
+
if (isDroppedClass(dropped) && dropped.path) {
|
|
1993
|
+
await this.setClassAccess(trail, normPath(dropped.path), 'read', '');
|
|
1994
|
+
}
|
|
1995
|
+
},
|
|
1996
|
+
_findRoleMut(sec, trail) {
|
|
1997
|
+
const steps = String(trail || '').split('/').filter(Boolean);
|
|
1998
|
+
let list = Array.isArray(sec.ROLES) ? sec.ROLES : [];
|
|
1999
|
+
let node = null;
|
|
2000
|
+
for (const id of steps) {
|
|
2001
|
+
node = list.find(r => r?.id === id);
|
|
2002
|
+
if (!node) return null;
|
|
2003
|
+
list = Array.isArray(node.ROLES) ? node.ROLES : [];
|
|
2004
|
+
}
|
|
2005
|
+
return node;
|
|
2006
|
+
},
|
|
2007
|
+
async promptAddRole(parentTrail = '') {
|
|
2008
|
+
const raw = window.prompt(parentTrail ? 'Добавить подроль' : 'Добавить роль', 'Название');
|
|
2009
|
+
const label = String(raw || '').trim();
|
|
2010
|
+
if (!label || label === 'Название') return;
|
|
2011
|
+
const id = label.toLowerCase().replace(/[^a-zа-яё0-9_-]+/gi, '_').replace(/^_+|_+$/g, '') || 'role_' + Date.now();
|
|
2012
|
+
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
2013
|
+
const targetList = parentTrail ? (this._findRoleMut(sec, parentTrail) || {}).ROLES ??= [] : sec.ROLES ??= [];
|
|
2014
|
+
if (!targetList.some(r => r.id === id)) {
|
|
2015
|
+
targetList.push({
|
|
2016
|
+
id,
|
|
2017
|
+
label,
|
|
2018
|
+
USERS: [],
|
|
2019
|
+
LINKS: []
|
|
2020
|
+
});
|
|
2021
|
+
}
|
|
2022
|
+
await this.persist(sec, `Создана роль «${label}»`, `В подразделении ${this.$item?.path || ''} добавлена роль «${label}».`);
|
|
2023
|
+
},
|
|
2024
|
+
async promptRenameRole(trail, currentLabel = '') {
|
|
2025
|
+
const raw = window.prompt('Переименовать роль', currentLabel);
|
|
2026
|
+
const label = String(raw || '').trim();
|
|
2027
|
+
if (!label || label === currentLabel) return;
|
|
2028
|
+
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
2029
|
+
const node = this._findRoleMut(sec, trail);
|
|
2030
|
+
if (!node) return;
|
|
2031
|
+
node.label = label;
|
|
2032
|
+
await this.persist(sec, `Переименована роль «${label}»`, `Роль ${trail} переименована в «${label}».`);
|
|
2033
|
+
},
|
|
2034
|
+
async toggleRoleExternal(trail, checked) {
|
|
2035
|
+
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
2036
|
+
const node = this._findRoleMut(sec, trail);
|
|
2037
|
+
if (!node) return;
|
|
2038
|
+
if (checked) node.external = true;else delete node.external;
|
|
2039
|
+
await this.persist(sec, `Обновлена роль «${node.label || node.id}»`, `Роль «${node.label || node.id}»: внешний клиент = ${checked ? 'да' : 'нет'}.`);
|
|
2040
|
+
},
|
|
2041
|
+
async removeRole(trail, label = '') {
|
|
2042
|
+
const title = label || trail.split('/').pop();
|
|
2043
|
+
let confirmed = false;
|
|
2044
|
+
try {
|
|
2045
|
+
if (typeof WORK?.showConfirm === 'function') confirmed = await WORK.showConfirm(`Удалить роль «${title}»?`);else confirmed = window.confirm(`Удалить роль «${title}»?`);
|
|
2046
|
+
} catch {
|
|
2047
|
+
return;
|
|
2048
|
+
}
|
|
2049
|
+
if (!confirmed) return;
|
|
2050
|
+
const steps = String(trail || '').split('/').filter(Boolean);
|
|
2051
|
+
if (!steps.length) return;
|
|
2052
|
+
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
2053
|
+
const targetId = steps.pop();
|
|
2054
|
+
if (!steps.length) {
|
|
2055
|
+
sec.ROLES = (sec.ROLES || []).filter(r => r?.id !== targetId);
|
|
2056
|
+
} else {
|
|
2057
|
+
const parent = this._findRoleMut(sec, steps.join('/'));
|
|
2058
|
+
if (parent && Array.isArray(parent.ROLES)) parent.ROLES = parent.ROLES.filter(r => r?.id !== targetId);
|
|
2059
|
+
}
|
|
2060
|
+
await this.persist(sec, `Удалена роль «${title}»`, `Из подразделения ${this.$item?.path || ''} удалена роль «${title}».`);
|
|
2061
|
+
},
|
|
2062
|
+
async _addMemberToRole(trail, memberId) {
|
|
2063
|
+
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
2064
|
+
const node = this._findRoleMut(sec, trail);
|
|
2065
|
+
if (!node) return;
|
|
2066
|
+
node.USERS = Array.isArray(node.USERS) ? node.USERS : [];
|
|
2067
|
+
if (!node.USERS.includes(memberId)) node.USERS.push(memberId);
|
|
2068
|
+
await this.persist(sec, `В роль «${node.label || node.id}» добавлен участник`, `В роль «${node.label || node.id}» добавлен ${memberId}.`);
|
|
2069
|
+
},
|
|
2070
|
+
async removeRoleMember(trail, memberId) {
|
|
2071
|
+
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
2072
|
+
const node = this._findRoleMut(sec, trail);
|
|
2073
|
+
if (!node || !Array.isArray(node.USERS)) return;
|
|
2074
|
+
node.USERS = node.USERS.filter(id => id !== memberId);
|
|
2075
|
+
await this.persist(sec, `Из роли «${node.label || node.id}» исключён участник`, `Из роли «${node.label || node.id}» удалён ${memberId}.`);
|
|
2076
|
+
},
|
|
2077
|
+
async setClassAccess(trail, clsPath, level, inheritedAccess = '') {
|
|
2078
|
+
const acc = normalizeAccess(level);
|
|
2079
|
+
if (!acc) return;
|
|
2080
|
+
const cleanPath = normPath(clsPath);
|
|
2081
|
+
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
2082
|
+
const node = this._findRoleMut(sec, trail);
|
|
2083
|
+
if (!node) return;
|
|
2084
|
+
delete node.readonly;
|
|
2085
|
+
node.LINKS = Array.isArray(node.LINKS) ? node.LINKS : [];
|
|
2086
|
+
const existingIdx = node.LINKS.findIndex(l => normPath(l?.id) === cleanPath);
|
|
2087
|
+
const existingScope = existingIdx >= 0 ? node.LINKS[existingIdx]?.scope : undefined;
|
|
2088
|
+
if (acc === 'none' && !inheritedAccess) {
|
|
2089
|
+
// Без унаследованного права сверху просто убираем ссылку из роли
|
|
2090
|
+
if (existingIdx >= 0) node.LINKS.splice(existingIdx, 1);else return;
|
|
2091
|
+
} else {
|
|
2092
|
+
const nextEntry = {
|
|
2093
|
+
id: cleanPath,
|
|
2094
|
+
access: acc,
|
|
2095
|
+
...(existingScope ? {
|
|
2096
|
+
scope: existingScope
|
|
2097
|
+
} : {})
|
|
2098
|
+
};
|
|
2099
|
+
if (existingIdx >= 0) node.LINKS[existingIdx] = nextEntry;else node.LINKS.push(nextEntry);
|
|
2100
|
+
}
|
|
2101
|
+
await this.persist(sec, `Изменён доступ к классу в роли «${node.label || node.id}»`, `Роль «${node.label || node.id}»: класс ${cleanPath} → ${accessLabelRu(acc)}.`);
|
|
2102
|
+
},
|
|
2103
|
+
async resetClassOverride(trail, clsPath) {
|
|
2104
|
+
const cleanPath = normPath(clsPath);
|
|
2105
|
+
const sec = JSON.parse(JSON.stringify(this.security || {}));
|
|
2106
|
+
const node = this._findRoleMut(sec, trail);
|
|
2107
|
+
if (!node || !Array.isArray(node.LINKS)) return;
|
|
2108
|
+
const before = node.LINKS.length;
|
|
2109
|
+
node.LINKS = node.LINKS.filter(l => normPath(l?.id) !== cleanPath);
|
|
2110
|
+
if (node.LINKS.length === before) return;
|
|
2111
|
+
await this.persist(sec, `Сброшено переопределение класса в роли «${node.label || node.id}»`, `Роль «${node.label || node.id}»: класс ${cleanPath} возвращён к наследованию от родителя.`);
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
};
|