odant-work 1.0.105 → 1.0.107

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 (30) hide show
  1. package/$server/$folder/$class/$structure/$user/handlers/pages/form/calendar/$handler/class.js +12 -0
  2. package/$server/$folder/$class/$structure/$user/handlers/pages/form/email/$handler/class.js +12 -0
  3. package/$server/$folder/$class/$structure/$user/handlers/pages/form/folder/$handler/class.js +12 -0
  4. package/$server/$folder/$class/$structure/$user/handlers/pages/form/search/$handler/class.js +12 -0
  5. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/$handler/class.js +14 -0
  6. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +5 -4
  7. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/skills/$handler/class.js +5 -4
  8. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/tokens/$handler/class.js +8 -2
  9. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +73 -22
  10. package/$server/$folder/handlers/pages/form/$handler/class.js +255 -100
  11. package/$server/$folder/lib/consultant/consultant.js +123 -66
  12. package/$server/$folder/lib/explorer/explorer.js +19 -22
  13. package/$server/$folder/lib/icon/icon.js +4 -1
  14. package/$server/$folder/lib/prompt-bar/prompt-bar.js +24 -1
  15. package/$server/$folder/lib/tree/tree.js +5 -5
  16. package/MODULES/$domain/class.js +1 -0
  17. package/package.json +1 -1
  18. package/sources/client.js +30 -2
  19. package/sources/host/auth-methods.js +25 -14
  20. package/sources/host/http-server.js +1 -0
  21. package/sources/host/websocket.js +11 -8
  22. package/sources/modules/call/call.js +5 -1
  23. package/sources/modules/user-profile/user-profile.js +9 -1
  24. package/sources/server/access/gateway.js +3 -7
  25. package/sources/server/chat-threads.js +32 -3
  26. package/sources/server/class/feed.js +25 -13
  27. package/sources/server/class/security.js +97 -31
  28. package/sources/server/logs.js +17 -10
  29. package/sources/server/server.js +17 -6
  30. package/sources/server/user.js +20 -5
@@ -939,7 +939,7 @@ ODA({is: 'work-form',
939
939
  <div ~if="!isTaskForm" flex></div>
940
940
  <oda-button ~if="showConsultantBtn" id="consultantBtn" shadow icon="bootstrap:robot" @tap="askConsultant" title="Спросить ИИ-консультанта по текущей форме" :icon-size info class="consultant-btn"
941
941
  :style="'border-radius: 50%; flex-shrink: 0; margin-right: ' + (ODA.states?.mobileMode ? '0px' : '4px') + ';'"></oda-button>
942
- <oda-button ~if="!isTaskForm" shadow icon="communication:call" @tap="call" title="Call..." :icon-size success class="call-btn"
942
+ <oda-button ~if="showCallBtn" shadow icon="communication:call" @tap="call" title="Позвонить" :icon-size success class="call-btn"
943
943
  :style="'border-radius: 50%; flex-shrink: 0; margin-right: ' + (ODA.states?.mobileMode ? '0px' : '24px') + ';'"></oda-button>
944
944
  <slot name="top-panel"></slot>
945
945
  <div ~if="!isTaskForm || visibleFormViews.length > 1 || allowSave" class="view-selector" no-flex horizontal
@@ -1037,16 +1037,25 @@ ODA({is: 'work-form',
1037
1037
  </div>
1038
1038
  `,
1039
1039
  async call(e) {
1040
- const el = ODA.createComponent('call-users-list');
1041
- const users = await el.users;
1042
- if (users.length === 1) {
1043
- el.selectedUsers.push(users[0]);
1040
+ const cur = this.currentItem || await this.$item;
1041
+ if (cur?.DATA?.isUser && WORK?.uid && cur.id && cur.id !== WORK.uid) {
1042
+ WORK.top.RTCCaller.startCall(cur, [cur.id]);
1043
+ return;
1044
+ }
1045
+ const candidates = Array.isArray(this._callCandidates) && this._callCandidates.length
1046
+ ? this._callCandidates
1047
+ : await this._resolveCallCandidates(cur);
1048
+ if (!candidates.length)
1049
+ return;
1050
+ const el = ODA.createComponent('call-users-list', { users: candidates });
1051
+ if (candidates.length === 1) {
1052
+ el.selectedUsers = [candidates[0]];
1044
1053
  }
1045
1054
  const updateEnable = () => {
1046
- const cond = el.selectedUsers.length > 0;
1047
- if (el.domParent) {
1048
- if (cond) {
1049
- el.domParent.OK.label = 'Позвонить [' + el.selectedUsers.length + ']';
1055
+ const count = el.selectedUsers.length;
1056
+ if (el.domParent?.OK) {
1057
+ if (count > 0) {
1058
+ el.domParent.OK.label = `Позвонить (${count})`;
1050
1059
  el.domParent.OK.icon = 'communication:call';
1051
1060
  }
1052
1061
  else {
@@ -1057,26 +1066,29 @@ ODA({is: 'work-form',
1057
1066
  };
1058
1067
  el.addEventListener('changed', updateEnable);
1059
1068
  try {
1060
- this.async(() => { updateEnable() }, 100);
1069
+ this.async(() => { updateEnable(); }, 50);
1061
1070
  const res = await WORK.showDialog(el, {
1062
- TITLE: { label: 'Выбор собеседников', icon: 'communication:call' },
1063
- OK: { label: 'позвонить', icon: 'communication:call' },
1071
+ allowClose: true,
1072
+ TITLE: { label: 'Позвонить', icon: 'communication:call' },
1073
+ OK: { label: 'Позвонить', icon: 'communication:call' },
1074
+ CANCEL: { label: 'Отмена', icon: 'icons:close' },
1064
1075
  });
1065
1076
  if (res === 'ok') {
1066
1077
  const receivers = el.selectedUsers;
1067
1078
  if (receivers.length > 0) {
1068
- WORK.top.RTCCaller.startCall(await this.$item, receivers.map(u => u.id));
1079
+ WORK.top.RTCCaller.startCall(cur, receivers.map(u => u.id));
1069
1080
  }
1070
1081
  else {
1071
- WORK.top.RTCCaller.startRecord(await this.$item);
1082
+ WORK.top.RTCCaller.startRecord(cur);
1072
1083
  }
1073
1084
  }
1074
1085
  }
1075
1086
  catch (err) {
1076
- console.log(err);
1087
+ if (!(err instanceof WORK.CancelError))
1088
+ console.log(err);
1077
1089
  }
1078
1090
  finally {
1079
- el.removeEventListener('selected-users-changed', updateEnable);
1091
+ el.removeEventListener('changed', updateEnable);
1080
1092
  }
1081
1093
  },
1082
1094
  allowZoom: true,
@@ -1571,11 +1583,21 @@ ODA({is: 'work-form',
1571
1583
  return [];
1572
1584
  return this.loadFormViews($item, role);
1573
1585
  },
1586
+ _myScope: null,
1574
1587
  get visibleFormViews() {
1575
1588
  const views = this.formViews;
1576
1589
  if (!Array.isArray(views))
1577
1590
  return [];
1578
- return views.filter(v => !(v?.DATA?.hidden || v?.hidden) || v?.id === this.view?.id);
1591
+ const hideSystemForUnassigned = Boolean(
1592
+ this._myScope?.isUnassigned
1593
+ && this.currentItem?.DATA?.isUser
1594
+ && !this.currentItem?.DATA?.usersContainer
1595
+ );
1596
+ return views.filter(v => {
1597
+ if (hideSystemForUnassigned && v?.id === 'system')
1598
+ return false;
1599
+ return !(v?.DATA?.hidden || v?.hidden) || v?.id === this.view?.id;
1600
+ });
1579
1601
  },
1580
1602
  async loadFormViews($item, role) {
1581
1603
  try {
@@ -1694,6 +1716,13 @@ ODA({is: 'work-form',
1694
1716
  this._appliedRoleItem = n;
1695
1717
  this._appliedRole = n.role || '';
1696
1718
  this._rootHasChildClasses = await this._detectHasChildClasses(n);
1719
+ if (globalThis.WORK?.uid && !globalThis.WORK?.DEV_MODE && (n?.DATA?.isUser || n?.isUser) && !n?.DATA?.usersContainer) {
1720
+ this._myScope = await globalThis.WORK.fetch('/', 'my_scope').catch(() => null);
1721
+ }
1722
+ else {
1723
+ this._myScope = null;
1724
+ }
1725
+ this._callCandidates = await this._resolveCallCandidates(n);
1697
1726
  }
1698
1727
  finally {
1699
1728
  this._initializingItem = false;
@@ -1742,6 +1771,35 @@ ODA({is: 'work-form',
1742
1771
  get isEmbeddedNoTree() {
1743
1772
  return typeof location !== 'undefined' && new URLSearchParams(location.search).get('noTree') === '1';
1744
1773
  },
1774
+ _callCandidates: [],
1775
+ get showCallBtn() {
1776
+ return Boolean(!this.isTaskForm && Array.isArray(this._callCandidates) && this._callCandidates.length > 0);
1777
+ },
1778
+ async _resolveCallCandidates(n) {
1779
+ if (!n || n.DATA?.usersContainer || n.DATA?.container || n.DATA?.objects)
1780
+ return [];
1781
+ if (n.DATA?.isUser || n.isUser) {
1782
+ return (WORK?.uid && n.id && n.id !== WORK.uid) ? [n] : [];
1783
+ }
1784
+ if (!n.DATA?.isStructure)
1785
+ return [];
1786
+ try {
1787
+ const raw = typeof n.fetch === 'function' ? await n.fetch('assignedUsers').catch(() => []) : [];
1788
+ const seen = new Set();
1789
+ const out = [];
1790
+ for (const u of (Array.isArray(raw) ? raw : [])) {
1791
+ const id = u?.id;
1792
+ if (!id || id === WORK?.uid || seen.has(id))
1793
+ continue;
1794
+ seen.add(id);
1795
+ out.push(u);
1796
+ }
1797
+ return out;
1798
+ }
1799
+ catch {
1800
+ return [];
1801
+ }
1802
+ },
1745
1803
  get showConsultantBtn() {
1746
1804
  if (!this.currentItem || this.isTaskForm)
1747
1805
  return false;
@@ -2770,107 +2828,204 @@ ODA({
2770
2828
  is: 'call-users-list',
2771
2829
  template: /*html*/`
2772
2830
  <style>
2773
- :host{
2831
+ :host {
2774
2832
  @apply --vertical;
2833
+ width: min(420px, 92vw);
2834
+ max-height: min(460px, 70vh);
2775
2835
  overflow: hidden;
2776
- min-width: 300px;
2777
-
2778
- .filter-box{
2779
- @apply --horizontal;
2780
- @apply --header;
2781
- @apply --no-flex;
2782
- padding: 4px;
2783
-
2784
- input{
2785
- @apply --flex;
2786
- @apply --content;
2787
- margin: auto;
2788
- padding: 8px;
2789
- width: 0px;
2790
- border: none;
2791
- outline: none;
2792
- border-radius: 2em;
2793
- }
2794
- }
2795
-
2796
- .users-box{
2797
- @apply --vertical;
2798
- overflow-x: hidden;
2799
- text-overflow: ellipsis;
2800
- overflow-y: auto;
2801
- gap: 4px;
2802
- padding: 8px;
2803
- min-height: calc(52px * 5);
2804
-
2805
- .user-row{
2806
- @apply --horizontal;
2807
- align-items: center;
2808
- min-height: fit-content;
2809
- flex-wrap: nowrap;
2810
- overflow: hidden;
2811
- text-overflow: ellipsis;
2812
- border-radius: 0em;
2813
- padding: 0px 3px;
2814
- transition: border-radius, background-color 0.3s ease;
2815
-
2816
- &[selected]{
2817
- border-radius: 2em;
2818
- }
2819
-
2820
- item-node{
2821
- pointer-events: none;
2822
- }
2823
- }
2824
- .nope-row{
2825
- text-align: center;
2826
- opacity: 0.25;
2827
- }
2828
-
2829
- }
2836
+ background: var(--content-background, #ffffff);
2837
+ color: var(--content-color, #0f172a);
2838
+ box-sizing: border-box;
2839
+ }
2840
+ .search-wrap {
2841
+ display: flex;
2842
+ align-items: center;
2843
+ gap: 8px;
2844
+ margin: 10px 12px 6px;
2845
+ padding: 6px 10px;
2846
+ border-radius: 10px;
2847
+ border: 1px solid var(--border-color, #cbd5e1);
2848
+ background: var(--subtle-background, #f8fafc);
2849
+ flex-shrink: 0;
2850
+ }
2851
+ .search-wrap input {
2852
+ flex: 1 1 auto;
2853
+ min-width: 0;
2854
+ border: none;
2855
+ outline: none;
2856
+ background: transparent;
2857
+ color: inherit;
2858
+ font: inherit;
2859
+ font-size: 13.5px;
2860
+ }
2861
+ .bar-meta {
2862
+ display: flex;
2863
+ align-items: center;
2864
+ justify-content: space-between;
2865
+ padding: 2px 14px 6px;
2866
+ font-size: 12px;
2867
+ color: var(--muted-color, #64748b);
2868
+ flex-shrink: 0;
2869
+ }
2870
+ .toggle-all {
2871
+ border: none;
2872
+ background: transparent;
2873
+ color: var(--accent-color, #2563eb);
2874
+ font: inherit;
2875
+ font-size: 12px;
2876
+ font-weight: 600;
2877
+ cursor: pointer;
2878
+ padding: 2px 4px;
2879
+ border-radius: 6px;
2880
+ }
2881
+ .toggle-all:hover {
2882
+ background: color-mix(in oklch, var(--accent-color, #2563eb) 10%, transparent);
2883
+ }
2884
+ .users-box {
2885
+ @apply --vertical;
2886
+ flex: 1 1 auto;
2887
+ min-height: 120px;
2888
+ overflow-y: auto;
2889
+ gap: 4px;
2890
+ padding: 4px 12px 12px;
2891
+ box-sizing: border-box;
2892
+ }
2893
+ .user-row {
2894
+ display: flex;
2895
+ align-items: center;
2896
+ gap: 10px;
2897
+ padding: 8px 10px;
2898
+ border-radius: 10px;
2899
+ border: 1px solid transparent;
2900
+ cursor: pointer;
2901
+ user-select: none;
2902
+ transition: background-color 0.15s ease, border-color 0.15s ease;
2903
+ }
2904
+ .user-row:hover {
2905
+ background: var(--subtle-background, rgba(148, 163, 184, 0.12));
2906
+ }
2907
+ .user-row[selected] {
2908
+ background: color-mix(in oklch, var(--accent-color, #2563eb) 10%, transparent);
2909
+ border-color: color-mix(in oklch, var(--accent-color, #2563eb) 40%, transparent);
2910
+ }
2911
+ .avatar-wrap {
2912
+ position: relative;
2913
+ flex-shrink: 0;
2914
+ width: 36px;
2915
+ height: 36px;
2916
+ display: flex;
2917
+ align-items: center;
2918
+ justify-content: center;
2919
+ }
2920
+ .online-dot {
2921
+ position: absolute;
2922
+ right: -1px;
2923
+ bottom: -1px;
2924
+ width: 10px;
2925
+ height: 10px;
2926
+ border-radius: 50%;
2927
+ background: #22c55e;
2928
+ border: 2px solid var(--content-background, #ffffff);
2929
+ box-sizing: border-box;
2930
+ }
2931
+ .user-info {
2932
+ flex: 1 1 auto;
2933
+ min-width: 0;
2934
+ display: flex;
2935
+ flex-direction: column;
2936
+ gap: 1px;
2937
+ }
2938
+ .user-name {
2939
+ font-size: 13.5px;
2940
+ font-weight: 600;
2941
+ white-space: nowrap;
2942
+ overflow: hidden;
2943
+ text-overflow: ellipsis;
2944
+ }
2945
+ .user-sub {
2946
+ font-size: 11.5px;
2947
+ color: var(--muted-color, #64748b);
2948
+ white-space: nowrap;
2949
+ overflow: hidden;
2950
+ text-overflow: ellipsis;
2951
+ }
2952
+ .check-ic {
2953
+ flex-shrink: 0;
2954
+ color: var(--muted-color, #94a3b8);
2955
+ }
2956
+ .user-row[selected] .check-ic {
2957
+ color: var(--accent-color, #2563eb);
2958
+ }
2959
+ .empty-msg {
2960
+ padding: 28px 12px;
2961
+ text-align: center;
2962
+ font-size: 13px;
2963
+ color: var(--muted-color, #64748b);
2830
2964
  }
2831
2965
  </style>
2832
- <div ~if="users?.length" class="filter-box">
2833
- <input type="search" ::value="filterVal" placeholder="filter">
2834
- </div>
2835
- <div ~if="users?.length" class="users-box">
2836
- <div class="user-row" ~for="filteredUsers" @click="select_user($for.item)" :selected="isSelected($for.item)">
2837
- <oda-icon :icon="isSelected($for.item) ? 'icons:check' : ''" icon-size="48" :success="isSelected($for.item)" style="border-radius: 50%;"></oda-icon>
2838
- <item-node :$item="$for.item" icon-size="48"></item-node>
2966
+ <div class="wrap" style="display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden;">
2967
+ <div ~if="users?.length" class="search-wrap">
2968
+ <oda-icon icon="carbon:search" :icon-size="15" style="opacity: 0.6;"></oda-icon>
2969
+ <input type="search" ::value="filterVal" placeholder="Поиск сотрудника…">
2970
+ </div>
2971
+ <div ~if="users?.length > 1" class="bar-meta">
2972
+ <span>Выбрано: {{selectedUsers.length}} из {{users.length}}</span>
2973
+ <button type="button" class="toggle-all" @tap="toggleAll()">
2974
+ {{selectedUsers.length === users.length ? 'Снять выбор' : 'Выбрать всех'}}
2975
+ </button>
2839
2976
  </div>
2840
- <h2 ~if="filteredUsers.length === 0" class="nope-row">не найдено</h2>
2977
+ <div ~if="users?.length" class="users-box">
2978
+ <div class="user-row" ~for="filteredUsers" @tap="select_user($for.item)" :selected="isSelected($for.item)">
2979
+ <div class="avatar-wrap">
2980
+ <oda-icon round :icon="$for.item.icon || 'icons:account-circle'" :icon-size="36" :style="'background:' + ($for.item.iconColor || 'transparent') + ';color:white;fill:white;'"></oda-icon>
2981
+ <span ~if="$for.item.online" class="online-dot" title="В сети"></span>
2982
+ </div>
2983
+ <div class="user-info">
2984
+ <span class="user-name">{{$for.item.label || $for.item.DATA?.label || $for.item.id}}</span>
2985
+ <span ~if="$for.item.email || $for.item.DATA?.email" class="user-sub">{{$for.item.email || $for.item.DATA?.email}}</span>
2986
+ </div>
2987
+ <oda-icon class="check-ic" :icon="isSelected($for.item) ? 'icons:check-box' : 'icons:check-box-outline-blank'" :icon-size="20"></oda-icon>
2988
+ </div>
2989
+ <div ~if="filteredUsers.length === 0" class="empty-msg">Никого не найдено</div>
2990
+ </div>
2991
+ <div ~if="!users" class="empty-msg">Загрузка списка…</div>
2992
+ <div ~if="users?.length === 0" class="empty-msg">Нет доступных собеседников</div>
2841
2993
  </div>
2842
- <h1 center ~if="!users">Загрузка...</h1>
2843
- <h1 center ~if="users?.length === 0">пользователи не найдены</h1>
2844
2994
  `,
2845
- get users() {
2846
- return (async () => {
2847
- const $users = await WORK.get_item('/USERS');
2848
- const users = await $users.items;
2849
- return (users || []).filter(u => u.id !== WORK.uid);
2850
- })();
2851
- },
2995
+ users: [],
2852
2996
  filterVal: '',
2853
2997
  get filteredUsers() {
2854
- if (!this.users) return;
2855
- return this.filterVal
2856
- ? this.users.filter(u => [u.label, u.id].some(s => s.includes(this.filterVal)))
2857
- : this.users;
2998
+ const list = Array.isArray(this.users) ? this.users : [];
2999
+ const q = String(this.filterVal || '').trim().toLowerCase();
3000
+ if (!q)
3001
+ return list;
3002
+ return list.filter(u => {
3003
+ const lbl = String(u?.label || u?.DATA?.label || '').toLowerCase();
3004
+ const eml = String(u?.email || u?.DATA?.email || '').toLowerCase();
3005
+ const id = String(u?.id || '').toLowerCase();
3006
+ return lbl.includes(q) || eml.includes(q) || id.includes(q);
3007
+ });
2858
3008
  },
2859
3009
  selectedUsers: [],
2860
3010
  getIndex($user) {
2861
- return this.selectedUsers.findIndex(u => u.id === $user.id)
3011
+ return this.selectedUsers.findIndex(u => u.id === $user.id);
2862
3012
  },
2863
3013
  isSelected($user) {
2864
3014
  return this.getIndex($user) > -1;
2865
3015
  },
2866
3016
  select_user($user) {
2867
3017
  const idx = this.getIndex($user);
2868
- if (idx > -1) {
2869
- this.selectedUsers.splice(idx, 1);
2870
- }
2871
- else {
2872
- this.selectedUsers.push($user);
2873
- }
3018
+ const next = [...this.selectedUsers];
3019
+ if (idx > -1)
3020
+ next.splice(idx, 1);
3021
+ else
3022
+ next.push($user);
3023
+ this.selectedUsers = next;
3024
+ this.fire('changed');
3025
+ },
3026
+ toggleAll() {
3027
+ const list = Array.isArray(this.users) ? this.users : [];
3028
+ this.selectedUsers = this.selectedUsers.length === list.length ? [] : [...list];
2874
3029
  this.fire('changed');
2875
3030
  }
2876
3031
  });