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