@esvndev/es-data-sharing 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component/master-info/master-card.d.ts +0 -3
- package/dist/component/modal/batch-master-card.d.ts +2 -3
- package/dist/component/modal/sharing-helpers.d.ts +5 -0
- package/dist/component/org-scope/org-table.d.ts +2 -0
- package/dist/index.d.ts +8 -9
- package/dist/index.js +177 -128
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +178 -129
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +249 -72
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/modal.css +50 -12
- package/dist/styles/modal.css.map +1 -1
- package/dist/types/index.d.ts +5 -3
- package/package.json +1 -1
|
@@ -4,9 +4,6 @@ interface Props {
|
|
|
4
4
|
title: string;
|
|
5
5
|
fields: ISharingFieldDef[];
|
|
6
6
|
data: Record<string, any>;
|
|
7
|
-
isGlobalShared: boolean;
|
|
8
|
-
onToggleGlobalShared: (val: boolean) => void;
|
|
9
|
-
showGlobalSharedSwitch?: boolean;
|
|
10
7
|
}
|
|
11
8
|
export declare const MasterCard: React.FC<Props>;
|
|
12
9
|
export {};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ISharingFieldDef } from '../../types';
|
|
2
3
|
interface Props {
|
|
3
4
|
title: string;
|
|
4
5
|
items: Record<string, any>[];
|
|
5
|
-
|
|
6
|
-
onToggleGlobalShared: (val: boolean) => void;
|
|
7
|
-
showGlobalSharedSwitch?: boolean;
|
|
6
|
+
fields?: ISharingFieldDef[];
|
|
8
7
|
}
|
|
9
8
|
export declare const BatchMasterCard: React.FC<Props>;
|
|
10
9
|
export {};
|
|
@@ -10,3 +10,8 @@ export declare function buildDataSharingPayload(params: {
|
|
|
10
10
|
orgList: IOrgSharingItem[];
|
|
11
11
|
detailData: Record<string, Record<string, any>[]>;
|
|
12
12
|
}): IDataSharingPayload;
|
|
13
|
+
export declare function resolveCurrentOrgName(params: {
|
|
14
|
+
parentOrgName?: string;
|
|
15
|
+
organizationId?: string;
|
|
16
|
+
orgList?: IOrgSharingItem[];
|
|
17
|
+
}): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -48,15 +48,17 @@ interface ISharingSectionVisibility {
|
|
|
48
48
|
showOverrideTab?: boolean;
|
|
49
49
|
/** Hiện/ẩn tab Tổng hợp phân quyền (mặc định: true) */
|
|
50
50
|
showSummaryTab?: boolean;
|
|
51
|
-
/** Hiện/ẩn nút gạt "Danh mục dùng chung toàn tập đoàn" (mặc định: true) */
|
|
52
|
-
showGlobalSharedSwitch?: boolean;
|
|
53
51
|
}
|
|
54
52
|
interface ISharingMetadataConfig extends ISharingSectionVisibility {
|
|
55
53
|
entityType: string;
|
|
56
54
|
title: string;
|
|
57
55
|
masterCardTitle?: string;
|
|
58
|
-
/**
|
|
56
|
+
/** Nhãn hiển thị trước tên công ty ở khối Phạm vi chia sẻ */
|
|
57
|
+
parentOrgLabel?: string;
|
|
58
|
+
/** Tên/mã công ty hiển thị trên thanh tiêu đề của Phạm vi chia sẻ */
|
|
59
59
|
parentOrgName?: string;
|
|
60
|
+
/** ID hoặc mã tổ chức hiện tại để tự động map tên/mã hiển thị */
|
|
61
|
+
organizationId?: string;
|
|
60
62
|
masterFields?: ISharingFieldDef[];
|
|
61
63
|
overrideColumns?: ISharingFieldDef[];
|
|
62
64
|
detailTabs?: ISharingDetailTabConfig[];
|
|
@@ -147,6 +149,8 @@ interface Props$4 {
|
|
|
147
149
|
orgList: IOrgSharingItem[];
|
|
148
150
|
onChangeOrg: (updatedList: IOrgSharingItem[]) => void;
|
|
149
151
|
parentOrgName?: string;
|
|
152
|
+
parentOrgLabel?: string;
|
|
153
|
+
organizationId?: string;
|
|
150
154
|
}
|
|
151
155
|
declare const OrgTable: React.FC<Props$4>;
|
|
152
156
|
|
|
@@ -154,18 +158,13 @@ interface Props$3 {
|
|
|
154
158
|
title: string;
|
|
155
159
|
fields: ISharingFieldDef[];
|
|
156
160
|
data: Record<string, any>;
|
|
157
|
-
isGlobalShared: boolean;
|
|
158
|
-
onToggleGlobalShared: (val: boolean) => void;
|
|
159
|
-
showGlobalSharedSwitch?: boolean;
|
|
160
161
|
}
|
|
161
162
|
declare const MasterCard: React.FC<Props$3>;
|
|
162
163
|
|
|
163
164
|
interface Props$2 {
|
|
164
165
|
title: string;
|
|
165
166
|
items: Record<string, any>[];
|
|
166
|
-
|
|
167
|
-
onToggleGlobalShared: (val: boolean) => void;
|
|
168
|
-
showGlobalSharedSwitch?: boolean;
|
|
167
|
+
fields?: ISharingFieldDef[];
|
|
169
168
|
}
|
|
170
169
|
declare const BatchMasterCard: React.FC<Props$2>;
|
|
171
170
|
|
package/dist/index.js
CHANGED
|
@@ -6,8 +6,8 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var reactI18next = require('react-i18next');
|
|
8
8
|
var reactstrap = require('reactstrap');
|
|
9
|
-
var esGridTemplate = require('es-grid-template');
|
|
10
9
|
var becoxyIcons = require('becoxy-icons');
|
|
10
|
+
var esGridTemplate = require('es-grid-template');
|
|
11
11
|
|
|
12
12
|
var classnames$1 = {exports: {}};
|
|
13
13
|
|
|
@@ -88,26 +88,154 @@ var classnames$1 = {exports: {}};
|
|
|
88
88
|
|
|
89
89
|
var classnames = classnames$1.exports;
|
|
90
90
|
|
|
91
|
-
const MasterCard = ({ title, fields, data
|
|
91
|
+
const MasterCard = ({ title, fields, data }) => {
|
|
92
92
|
const { t } = reactI18next.useTranslation();
|
|
93
|
-
return (jsxRuntime.jsx(reactstrap.Card, { className: "border h-100 shadow-none mb-0 es-data-sharing-master-card", children: jsxRuntime.jsxs(reactstrap.CardBody, { className: "d-flex flex-column", children: [jsxRuntime.jsxs("div", { className: "d-flex align-items-center es-master-header", children: [jsxRuntime.jsx("div", { className: "avatar bg-light-primary me-2 es-master-avatar", children: jsxRuntime.jsx(
|
|
93
|
+
return (jsxRuntime.jsx(reactstrap.Card, { className: "border h-100 shadow-none mb-0 es-data-sharing-master-card", children: jsxRuntime.jsxs(reactstrap.CardBody, { className: "d-flex flex-column", children: [jsxRuntime.jsxs("div", { className: "d-flex align-items-center es-master-header", children: [jsxRuntime.jsx("div", { className: "avatar bg-light-primary me-2 es-master-avatar", children: jsxRuntime.jsx(becoxyIcons.FileText, { fontSize: 18 }) }), jsxRuntime.jsx("h5", { className: "mb-0 fw-bolder", children: t(title) })] }), jsxRuntime.jsx("div", { className: "master-fields-list flex-grow-1", children: fields.map(f => (jsxRuntime.jsxs("div", { className: "row mx-0 align-items-center es-master-field-row", children: [jsxRuntime.jsxs("label", { className: "col-5 ps-0 text-muted small mb-0", children: [t(f.label), ":"] }), jsxRuntime.jsx("div", { className: "col-7 pe-0 fw-bold text-truncate text-dark", title: data[f.key] ? String(data[f.key]) : '', children: data[f.key] !== undefined && data[f.key] !== null && data[f.key] !== '' ? String(data[f.key]) : '-' })] }, f.key))) })] }) }));
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
const BatchMasterCard = ({ title, items,
|
|
96
|
+
const BatchMasterCard = ({ title, items, fields = [] }) => {
|
|
97
97
|
const { t } = reactI18next.useTranslation();
|
|
98
|
-
|
|
98
|
+
const codeLabel = fields.find(f => f.key === 'code' || f.key === 'Code')?.label;
|
|
99
|
+
const nameLabel = fields.find(f => f.key === 'name' || f.key === 'Name')?.label;
|
|
100
|
+
const taxField = fields.find(f => f.key === 'taxCode' || f.key === 'TaxCode');
|
|
101
|
+
const primaryHeader = codeLabel && nameLabel
|
|
102
|
+
? `${t(codeLabel)} / ${t(nameLabel)}`
|
|
103
|
+
: t('DataSharing_BatchItemName', 'Mã / Tên');
|
|
104
|
+
const showTaxColumn = Boolean(taxField) || items.some(item => Boolean(item.taxCode || item.TaxCode));
|
|
105
|
+
const taxHeader = taxField
|
|
106
|
+
? t(taxField.label)
|
|
107
|
+
: t('DataSharing_TaxCode', 'Mã số thuế');
|
|
108
|
+
return (jsxRuntime.jsx(reactstrap.Card, { className: "border h-100 shadow-none mb-0 es-data-sharing-master-card", children: jsxRuntime.jsxs(reactstrap.CardBody, { className: "d-flex flex-column", children: [jsxRuntime.jsxs("div", { className: "d-flex align-items-center justify-content-between es-master-header", children: [jsxRuntime.jsxs("div", { className: "d-flex align-items-center", children: [jsxRuntime.jsx("div", { className: "avatar bg-light-primary me-2 es-master-avatar", children: jsxRuntime.jsx(becoxyIcons.FileText, { fontSize: 18 }) }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("h5", { className: "mb-0 fw-bolder", children: t(title) }), jsxRuntime.jsx("small", { className: "text-muted", children: t('DataSharing_BatchModeSubtitle', 'Chế độ chia sẻ hàng loạt') })] })] }), jsxRuntime.jsxs(reactstrap.Badge, { color: "primary", pill: true, className: "es-batch-count-badge", children: [items.length, " ", t('DataSharing_SelectedItems', 'đối tượng')] })] }), jsxRuntime.jsxs("div", { className: "flex-grow-1 es-batch-items-list", children: [jsxRuntime.jsxs("div", { className: "es-batch-items-header d-flex align-items-center justify-content-between px-2 py-2 border-bottom", children: [jsxRuntime.jsx("span", { className: "fw-semibold", children: primaryHeader }), showTaxColumn && (jsxRuntime.jsx("span", { className: "fw-semibold text-nowrap ms-2", children: taxHeader }))] }), jsxRuntime.jsx("div", { className: "px-2", children: items.map((item, idx) => (jsxRuntime.jsxs("div", { className: "es-batch-row d-flex align-items-center justify-content-between py-2 border-bottom last-no-border", children: [jsxRuntime.jsxs("div", { className: "text-truncate me-2", children: [jsxRuntime.jsx("span", { className: "fw-bold es-batch-code me-1", children: item.code || item.Code || '-' }), jsxRuntime.jsx("span", { className: "small text-dark", children: item.name || item.Name || '' })] }), showTaxColumn && (jsxRuntime.jsx("small", { className: "text-muted text-nowrap", children: item.taxCode || item.TaxCode || '-' }))] }, item.id || item.Id || idx))) })] })] }) }));
|
|
99
109
|
};
|
|
100
110
|
|
|
101
|
-
|
|
111
|
+
function applyGlobalSharedToOrgList(orgList, checked, sharingLabel) {
|
|
112
|
+
if (!checked)
|
|
113
|
+
return orgList;
|
|
114
|
+
return orgList.map(o => ({
|
|
115
|
+
...o,
|
|
116
|
+
isSelected: true,
|
|
117
|
+
status: 1,
|
|
118
|
+
statusText: sharingLabel
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
function updateOrgOverrideValue(orgList, targetOrgId, fieldKey, value) {
|
|
122
|
+
return orgList.map(item => {
|
|
123
|
+
if (item.targetOrgId !== targetOrgId)
|
|
124
|
+
return item;
|
|
125
|
+
return {
|
|
126
|
+
...item,
|
|
127
|
+
overrideData: {
|
|
128
|
+
...item.overrideData,
|
|
129
|
+
[fieldKey]: value
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function applyFirstOverrideToAll(orgList) {
|
|
135
|
+
const editableOrgs = orgList.filter(o => o.isSelected && o.canOverrideConfig);
|
|
136
|
+
if (editableOrgs.length < 2)
|
|
137
|
+
return orgList;
|
|
138
|
+
const firstData = editableOrgs[0].overrideData ?? {};
|
|
139
|
+
return orgList.map(item => {
|
|
140
|
+
if (!item.isSelected || !item.canOverrideConfig)
|
|
141
|
+
return item;
|
|
142
|
+
return {
|
|
143
|
+
...item,
|
|
144
|
+
overrideData: {
|
|
145
|
+
...firstData
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function buildDataSharingPayload(params) {
|
|
151
|
+
const { config, entityId, entityIds, isGlobalShared, orgList, detailData } = params;
|
|
152
|
+
const isBatchMode = (entityIds?.length ?? 0) > 1;
|
|
153
|
+
const detailTabs = config.detailTabs ?? [];
|
|
154
|
+
return {
|
|
155
|
+
entityType: config.entityType,
|
|
156
|
+
entityId,
|
|
157
|
+
...(isBatchMode ? { entityIds } : {}),
|
|
158
|
+
isGlobalShared,
|
|
159
|
+
sharingList: orgList
|
|
160
|
+
.filter(o => o.isSelected)
|
|
161
|
+
.map(o => ({
|
|
162
|
+
TargetOrgId: o.targetOrgId,
|
|
163
|
+
IsInheritMaster: o.isInheritMaster,
|
|
164
|
+
CanOverrideConfig: o.canOverrideConfig,
|
|
165
|
+
EffectiveFrom: o.effectiveFrom || null,
|
|
166
|
+
EffectiveTo: o.effectiveTo || null,
|
|
167
|
+
Status: 1
|
|
168
|
+
})),
|
|
169
|
+
orgConfigList: orgList
|
|
170
|
+
.filter(o => o.isSelected && o.canOverrideConfig)
|
|
171
|
+
.map(o => ({
|
|
172
|
+
OrganizationId: o.targetOrgId,
|
|
173
|
+
...o.overrideData
|
|
174
|
+
})),
|
|
175
|
+
...(detailTabs.length > 0 ? { detailData } : {})
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function findOrgInList(list, targetId) {
|
|
179
|
+
for (const item of list ?? []) {
|
|
180
|
+
if (item?.value === targetId ||
|
|
181
|
+
item?.id === targetId ||
|
|
182
|
+
item?.targetOrgId === targetId ||
|
|
183
|
+
item?.key === targetId ||
|
|
184
|
+
item?.code === targetId ||
|
|
185
|
+
item?.orgCode === targetId) {
|
|
186
|
+
return item;
|
|
187
|
+
}
|
|
188
|
+
if (Array.isArray(item?.children) && item.children.length > 0) {
|
|
189
|
+
const child = findOrgInList(item.children, targetId);
|
|
190
|
+
if (child)
|
|
191
|
+
return child;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
function formatOrgDisplay(org) {
|
|
197
|
+
if (!org)
|
|
198
|
+
return '';
|
|
199
|
+
const name = org.label ?? org.name ?? org.text ?? org.orgName ?? '';
|
|
200
|
+
const code = org.key ?? org.code ?? org.orgCode ?? '';
|
|
201
|
+
if (!name && !code)
|
|
202
|
+
return '';
|
|
203
|
+
return code ? `${name} (${code})` : String(name);
|
|
204
|
+
}
|
|
205
|
+
function resolveCurrentOrgName(params) {
|
|
206
|
+
const { parentOrgName, organizationId, orgList = [] } = params;
|
|
207
|
+
if (parentOrgName)
|
|
208
|
+
return parentOrgName;
|
|
209
|
+
if (organizationId) {
|
|
210
|
+
const matchedFromList = findOrgInList(orgList, organizationId);
|
|
211
|
+
const formatted = formatOrgDisplay(matchedFromList);
|
|
212
|
+
if (formatted)
|
|
213
|
+
return formatted;
|
|
214
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
215
|
+
try {
|
|
216
|
+
const raw = window.localStorage.getItem('organization');
|
|
217
|
+
if (raw) {
|
|
218
|
+
const stored = JSON.parse(raw);
|
|
219
|
+
if (stored && (stored.id === organizationId || stored.code === organizationId)) {
|
|
220
|
+
const storedFormatted = formatOrgDisplay(stored);
|
|
221
|
+
if (storedFormatted)
|
|
222
|
+
return storedFormatted;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
// Bỏ qua lỗi parse localStorage
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return '';
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const OrgTable = ({ orgList, onChangeOrg, parentOrgName, parentOrgLabel, organizationId }) => {
|
|
102
235
|
const { t, i18n } = reactI18next.useTranslation();
|
|
103
236
|
const [search, setSearch] = react.useState('');
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
const matchSearch = o.orgName.toLowerCase().includes(search.toLowerCase()) ||
|
|
107
|
-
o.orgCode.toLowerCase().includes(search.toLowerCase());
|
|
108
|
-
const matchType = filterType === 'ALL' || o.orgType === filterType;
|
|
109
|
-
return matchSearch && matchType;
|
|
110
|
-
}), [orgList, search, filterType]);
|
|
237
|
+
const filtered = react.useMemo(() => orgList.filter(o => o.orgName.toLowerCase().includes(search.toLowerCase()) ||
|
|
238
|
+
o.orgCode.toLowerCase().includes(search.toLowerCase())), [orgList, search]);
|
|
111
239
|
const gridDataSource = react.useMemo(() => filtered.map(o => ({
|
|
112
240
|
...o,
|
|
113
241
|
rowId: o.targetOrgId,
|
|
@@ -120,26 +248,21 @@ const OrgTable = ({ orgList, onChangeOrg, parentOrgName }) => {
|
|
|
120
248
|
const allFilteredSelected = filtered.length > 0 && filtered.every(o => o.isSelected);
|
|
121
249
|
const selectedFiltered = filtered.filter(o => o.isSelected);
|
|
122
250
|
const allFilteredOverride = selectedFiltered.length > 0 && selectedFiltered.every(o => o.canOverrideConfig);
|
|
123
|
-
const resolvedParentOrg = react.useMemo(() => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
251
|
+
const resolvedParentOrg = react.useMemo(() => resolveCurrentOrgName({
|
|
252
|
+
parentOrgName,
|
|
253
|
+
organizationId,
|
|
254
|
+
orgList
|
|
255
|
+
}), [parentOrgName, organizationId, orgList]);
|
|
256
|
+
const applyOrgSelection = (item, checked) => ({
|
|
257
|
+
...item,
|
|
258
|
+
isSelected: checked,
|
|
259
|
+
canOverrideConfig: checked ? item.canOverrideConfig : false,
|
|
260
|
+
status: checked ? 1 : 0,
|
|
261
|
+
statusText: checked ? t('DataSharing_Sharing', 'Đang chia sẻ') : t('DataSharing_NotShared', 'Chưa chia sẻ')
|
|
262
|
+
});
|
|
131
263
|
const handleToggleSelectAll = (checked) => {
|
|
132
264
|
const filteredIds = new Set(filtered.map(f => f.targetOrgId));
|
|
133
|
-
const next = orgList.map(item =>
|
|
134
|
-
if (!filteredIds.has(item.targetOrgId))
|
|
135
|
-
return item;
|
|
136
|
-
return {
|
|
137
|
-
...item,
|
|
138
|
-
isSelected: checked,
|
|
139
|
-
status: checked ? 1 : 0,
|
|
140
|
-
statusText: checked ? t('DataSharing_Sharing', 'Đang chia sẻ') : t('DataSharing_NotShared', 'Chưa chia sẻ')
|
|
141
|
-
};
|
|
142
|
-
});
|
|
265
|
+
const next = orgList.map(item => filteredIds.has(item.targetOrgId) ? applyOrgSelection(item, checked) : item);
|
|
143
266
|
onChangeOrg(next);
|
|
144
267
|
};
|
|
145
268
|
const handleToggleAllOverride = (enable) => {
|
|
@@ -150,17 +273,7 @@ const OrgTable = ({ orgList, onChangeOrg, parentOrgName }) => {
|
|
|
150
273
|
onChangeOrg(next);
|
|
151
274
|
};
|
|
152
275
|
const handleSelectRow = (targetOrgId, checked) => {
|
|
153
|
-
const next = orgList.map(item =>
|
|
154
|
-
if (item.targetOrgId === targetOrgId) {
|
|
155
|
-
return {
|
|
156
|
-
...item,
|
|
157
|
-
isSelected: checked,
|
|
158
|
-
status: checked ? 1 : 0,
|
|
159
|
-
statusText: checked ? t('DataSharing_Sharing', 'Đang chia sẻ') : t('DataSharing_NotShared', 'Chưa chia sẻ')
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
return item;
|
|
163
|
-
});
|
|
276
|
+
const next = orgList.map(item => item.targetOrgId === targetOrgId ? applyOrgSelection(item, checked) : item);
|
|
164
277
|
onChangeOrg(next);
|
|
165
278
|
};
|
|
166
279
|
const handleFieldChange = (targetOrgId, field, value) => {
|
|
@@ -181,9 +294,9 @@ const OrgTable = ({ orgList, onChangeOrg, parentOrgName }) => {
|
|
|
181
294
|
{
|
|
182
295
|
field: 'isSelected',
|
|
183
296
|
headerText: '',
|
|
184
|
-
width:
|
|
185
|
-
minWidth:
|
|
186
|
-
maxWidth:
|
|
297
|
+
width: 38,
|
|
298
|
+
minWidth: 38,
|
|
299
|
+
maxWidth: 38,
|
|
187
300
|
textAlign: 'center',
|
|
188
301
|
allowFiltering: false,
|
|
189
302
|
allowSortering: false,
|
|
@@ -277,7 +390,7 @@ const OrgTable = ({ orgList, onChangeOrg, parentOrgName }) => {
|
|
|
277
390
|
template: (props) => props.rowData?.isSelected ? (jsxRuntime.jsx("span", { className: "badge bg-light-success text-success", children: t('DataSharing_Sharing', 'Đang chia sẻ') })) : (jsxRuntime.jsx("span", { className: "badge bg-light-secondary text-secondary", children: t('DataSharing_NotShared', 'Chưa chia sẻ') }))
|
|
278
391
|
}
|
|
279
392
|
], [allFilteredSelected, allFilteredOverride, selectedFiltered.length, orgList, filtered, t]);
|
|
280
|
-
return (jsxRuntime.jsx(reactstrap.Card, { className: "border h-100 shadow-none mb-0 es-data-sharing-org-scope", children: jsxRuntime.jsxs(reactstrap.CardBody, { className: "d-flex flex-column", children: [jsxRuntime.jsxs("div", { className: "d-flex flex-wrap justify-content-between align-items-center mb-2 gap-2", children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("h5", { className: "mb-0 fw-bolder", children: t('DataSharing_OrgScope', 'Phạm vi chia sẻ xuống đơn vị') }), jsxRuntime.jsxs("div", { className: "d-flex align-items-center gap-2 mt-1", children: [jsxRuntime.jsxs(reactstrap.Badge, { color: "light-primary", className: "
|
|
393
|
+
return (jsxRuntime.jsx(reactstrap.Card, { className: "border h-100 shadow-none mb-0 es-data-sharing-org-scope", children: jsxRuntime.jsxs(reactstrap.CardBody, { className: "d-flex flex-column", children: [jsxRuntime.jsxs("div", { className: "d-flex flex-wrap justify-content-between align-items-center mb-2 gap-2", children: [jsxRuntime.jsxs("div", { className: "d-flex align-items-start gap-2", children: [jsxRuntime.jsx("div", { className: "es-org-scope-avatar", children: jsxRuntime.jsx(becoxyIcons.BeOrganization, { fontSize: 18 }) }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("h5", { className: "mb-0 fw-bolder", children: t('DataSharing_OrgScope', 'Phạm vi chia sẻ xuống đơn vị') }), jsxRuntime.jsxs("div", { className: "d-flex align-items-center gap-2 mt-1", children: [jsxRuntime.jsxs(reactstrap.Badge, { color: "light-primary", className: "es-badge-sharing", children: [t('DataSharing_Sharing', 'Đang chia sẻ'), ": ", selectedCount, "/", orgList.length] }), jsxRuntime.jsxs(reactstrap.Badge, { color: "light-info", className: "es-badge-override", children: [t('DataSharing_CanOverride', 'Cấu hình riêng'), ": ", overrideCount] })] })] })] }), jsxRuntime.jsxs("div", { className: "d-flex align-items-center es-org-search-wrap", style: { minWidth: '220px' }, children: [jsxRuntime.jsx(becoxyIcons.Search, { fontSize: 15, className: "es-org-search-icon" }), jsxRuntime.jsx(reactstrap.Input, { type: "search", bsSize: "sm", placeholder: t('DataSharing_SearchOrg', 'Tìm kiếm đơn vị...'), value: search, onChange: e => setSearch(e.target.value) })] })] }), resolvedParentOrg && (jsxRuntime.jsx("div", { className: "mb-2", children: jsxRuntime.jsxs("div", { className: "es-parent-org-pill", children: [jsxRuntime.jsx(becoxyIcons.BecoxyOffice, { fontSize: 14, className: "text-muted flex-shrink-0" }), jsxRuntime.jsxs("span", { className: "text-muted", children: [parentOrgLabel ?? t('DataSharing_CurrentOrg', 'Công ty'), ":"] }), jsxRuntime.jsx("span", { className: "fw-bold es-parent-org-name", children: resolvedParentOrg })] }) })), jsxRuntime.jsx("div", { className: "flex-grow-1 es-data-sharing-grid-wrap", style: { minHeight: 0 }, children: jsxRuntime.jsx(esGridTemplate.GridComponent, { dataSource: gridDataSource, editAble: false, rowEditable: (rowData) => Boolean(rowData?.isSelected), lang: i18n.language || 'vi', showToolbar: false, toolbarItems: [], columns: headerColumns, onCellChange: handleCellChange, onRowStyles: (rowData) => rowData?.isSelected ? { backgroundColor: 'rgba(242, 101, 34, 0.08)' } : {}, height: 360, allowResizing: true, t: t, showEmptyText: false }, "DataSharingOrgScopeGrid") })] }) }));
|
|
281
394
|
};
|
|
282
395
|
|
|
283
396
|
function resolveFieldDisplayValue(field, rowData, rawVal) {
|
|
@@ -444,7 +557,7 @@ const OverrideTable = ({ orgList, overrideColumns, masterData, onChangeOverride,
|
|
|
444
557
|
decimalSeparator: '.',
|
|
445
558
|
thousandSeparator: ',',
|
|
446
559
|
decimalScale: 0
|
|
447
|
-
}, showEmptyText: false }, "DataSharingOverrideGrid") })), jsxRuntime.jsxs("div", { className: "d-flex align-items-center mt-2 es-override-note", children: [jsxRuntime.jsx(
|
|
560
|
+
}, showEmptyText: false }, "DataSharingOverrideGrid") })), jsxRuntime.jsxs("div", { className: "d-flex align-items-center gap-1 mt-2 es-override-note", children: [jsxRuntime.jsx(becoxyIcons.Info, { fontSize: 15, className: "flex-shrink-0" }), jsxRuntime.jsx("span", { children: t('DataSharing_OverrideNote', 'Thông tin gốc do công ty mẹ quản lý. Các đơn vị được bật "Cấu hình riêng" sẽ có thể nhập thông số riêng tại đây.') })] })] }));
|
|
448
561
|
};
|
|
449
562
|
|
|
450
563
|
const DetailTabTable = ({ tabConfig, orgList, rows, onChangeRows }) => {
|
|
@@ -607,14 +720,13 @@ const DetailTabTable = ({ tabConfig, orgList, rows, onChangeRows }) => {
|
|
|
607
720
|
}, showEmptyText: false }, `DataSharingDetailGrid_${tabConfig.key}`) }));
|
|
608
721
|
};
|
|
609
722
|
|
|
610
|
-
const DataSharingContent = ({ config, masterData = {}, masterDataList = [], parentOrgName, isBatchMode = false, orgList, setOrgList, detailData, setDetailData, isGlobalShared, onToggleGlobalShared, onChangeOverride, onApplyFirstToAll, showMasterCard: propShowMasterCard, showOrgScope: propShowOrgScope, showConfigTabs: propShowConfigTabs, showOverrideTab: propShowOverrideTab, showSummaryTab: propShowSummaryTab
|
|
723
|
+
const DataSharingContent = ({ config, masterData = {}, masterDataList = [], parentOrgName, isBatchMode = false, orgList, setOrgList, detailData, setDetailData, isGlobalShared, onToggleGlobalShared, onChangeOverride, onApplyFirstToAll, showMasterCard: propShowMasterCard, showOrgScope: propShowOrgScope, showConfigTabs: propShowConfigTabs, showOverrideTab: propShowOverrideTab, showSummaryTab: propShowSummaryTab }) => {
|
|
611
724
|
const { t } = reactI18next.useTranslation();
|
|
612
725
|
const showMasterCard = propShowMasterCard ?? config.showMasterCard ?? true;
|
|
613
726
|
const showOrgScope = propShowOrgScope ?? config.showOrgScope ?? true;
|
|
614
727
|
const showConfigTabs = propShowConfigTabs ?? config.showConfigTabs ?? true;
|
|
615
728
|
const showOverrideTab = propShowOverrideTab ?? config.showOverrideTab ?? true;
|
|
616
729
|
const showSummaryTab = propShowSummaryTab ?? config.showSummaryTab ?? true;
|
|
617
|
-
const showGlobalSharedSwitch = propShowGlobalSharedSwitch ?? config.showGlobalSharedSwitch ?? true;
|
|
618
730
|
const detailTabs = config.detailTabs ?? [];
|
|
619
731
|
const hasVisibleTabs = showConfigTabs && (showOverrideTab || detailTabs.length > 0 || showSummaryTab);
|
|
620
732
|
const getFirstVisibleTab = () => {
|
|
@@ -640,10 +752,10 @@ const DataSharingContent = ({ config, masterData = {}, masterDataList = [], pare
|
|
|
640
752
|
const showTopRow = showMasterCard || showOrgScope;
|
|
641
753
|
const masterColMd = showOrgScope ? 5 : 12;
|
|
642
754
|
const orgColMd = showMasterCard ? 7 : 12;
|
|
643
|
-
return (jsxRuntime.jsxs("div", { className: "es-data-sharing-content", children: [showTopRow && (jsxRuntime.jsxs(reactstrap.Row, { className: hasVisibleTabs ? 'mb-3' : 'mb-0', children: [showMasterCard && (jsxRuntime.jsx(reactstrap.Col, { md: masterColMd, className: showOrgScope ? 'mb-2 mb-md-0' : '', children: isBatchMode ? (jsxRuntime.jsx(BatchMasterCard, { title: config.masterCardTitle ?? config.title, items: masterDataList,
|
|
755
|
+
return (jsxRuntime.jsxs("div", { className: "es-data-sharing-content", children: [showTopRow && (jsxRuntime.jsxs(reactstrap.Row, { className: hasVisibleTabs ? 'mb-3' : 'mb-0', children: [showMasterCard && (jsxRuntime.jsx(reactstrap.Col, { md: masterColMd, className: showOrgScope ? 'mb-2 mb-md-0' : '', children: isBatchMode ? (jsxRuntime.jsx(BatchMasterCard, { title: config.masterCardTitle ?? config.title, items: masterDataList, fields: config.masterFields ?? [] })) : (jsxRuntime.jsx(MasterCard, { title: config.masterCardTitle ?? config.title, fields: config.masterFields ?? [], data: masterData })) })), showOrgScope && (jsxRuntime.jsx(reactstrap.Col, { md: orgColMd, children: jsxRuntime.jsx(OrgTable, { orgList: orgList, onChangeOrg: setOrgList, parentOrgName: parentOrgName ?? config.parentOrgName, parentOrgLabel: config.parentOrgLabel, organizationId: config.organizationId }) }))] })), hasVisibleTabs && (jsxRuntime.jsxs("div", { className: "es-data-sharing-tabs-section", children: [jsxRuntime.jsxs(reactstrap.Nav, { tabs: true, className: "mb-2", children: [showOverrideTab && (jsxRuntime.jsx(reactstrap.NavItem, { children: jsxRuntime.jsxs(reactstrap.NavLink, { className: classnames('d-inline-flex align-items-center gap-1', { active: activeTab === 'override' }), onClick: () => setActiveTab('override'), style: { cursor: 'pointer' }, children: [jsxRuntime.jsx(becoxyIcons.Settings, { fontSize: 15 }), jsxRuntime.jsx("span", { children: t('DataSharing_OrgConfigTab', 'Cấu hình theo đơn vị') }), selectedOrgs.length > 0 && (jsxRuntime.jsx(reactstrap.Badge, { color: "light-primary", className: "ms-1 text-primary", children: selectedOrgs.length }))] }) })), detailTabs.map(tab => {
|
|
644
756
|
const activeCount = (detailData[tab.key] ?? []).filter(r => !r._deleted).length;
|
|
645
|
-
return (jsxRuntime.jsx(reactstrap.NavItem, { children: jsxRuntime.jsxs(reactstrap.NavLink, { className: classnames({ active: activeTab === `detail:${tab.key}` }), onClick: () => setActiveTab(`detail:${tab.key}`), style: { cursor: 'pointer' }, children: [tab.icon ?
|
|
646
|
-
}), showSummaryTab && (jsxRuntime.jsx(reactstrap.NavItem, { children: jsxRuntime.jsxs(reactstrap.NavLink, { className: classnames({ active: activeTab === 'summary' }), onClick: () => setActiveTab('summary'), style: { cursor: 'pointer' }, children: [
|
|
757
|
+
return (jsxRuntime.jsx(reactstrap.NavItem, { children: jsxRuntime.jsxs(reactstrap.NavLink, { className: classnames('d-inline-flex align-items-center gap-1', { active: activeTab === `detail:${tab.key}` }), onClick: () => setActiveTab(`detail:${tab.key}`), style: { cursor: 'pointer' }, children: [tab.icon ? jsxRuntime.jsx("span", { children: tab.icon }) : jsxRuntime.jsx(becoxyIcons.FileText, { fontSize: 15 }), jsxRuntime.jsx("span", { children: t(tab.title) }), jsxRuntime.jsx(reactstrap.Badge, { color: "light-info", className: "ms-1 text-info", children: activeCount })] }) }, tab.key));
|
|
758
|
+
}), showSummaryTab && (jsxRuntime.jsx(reactstrap.NavItem, { children: jsxRuntime.jsxs(reactstrap.NavLink, { className: classnames('d-inline-flex align-items-center gap-1', { active: activeTab === 'summary' }), onClick: () => setActiveTab('summary'), style: { cursor: 'pointer' }, children: [jsxRuntime.jsx(becoxyIcons.Clock, { fontSize: 15 }), jsxRuntime.jsx("span", { children: t('DataSharing_SummaryTab', 'Tổng hợp phân quyền') })] }) }))] }), jsxRuntime.jsxs(reactstrap.TabContent, { activeTab: activeTab, children: [showOverrideTab && (jsxRuntime.jsx(reactstrap.TabPane, { tabId: "override", children: jsxRuntime.jsx(OverrideTable, { orgList: orgList, overrideColumns: config.overrideColumns ?? [], masterData: isBatchMode ? undefined : masterData, onChangeOverride: onChangeOverride, onApplyFirstToAll: onApplyFirstToAll }) })), detailTabs.map(tab => (jsxRuntime.jsx(reactstrap.TabPane, { tabId: `detail:${tab.key}`, children: jsxRuntime.jsx(DetailTabTable, { tabConfig: tab, orgList: orgList, rows: detailData[tab.key] ?? [], onChangeRows: updatedRows => setDetailData(prev => ({
|
|
647
759
|
...prev,
|
|
648
760
|
[tab.key]: updatedRows
|
|
649
761
|
})) }) }, tab.key))), showSummaryTab && (jsxRuntime.jsx(reactstrap.TabPane, { tabId: "summary", children: jsxRuntime.jsxs("div", { className: "es-data-sharing-summary-box", children: [jsxRuntime.jsx("div", { className: "fw-bold mb-2 small text-dark", children: t('DataSharing_SummaryTitle', 'Tóm tắt cấu hình chuẩn bị áp dụng') }), jsxRuntime.jsxs("div", { className: "es-summary-grid", children: [jsxRuntime.jsxs("div", { className: "es-summary-item", children: [jsxRuntime.jsx("div", { className: "es-summary-label", children: t('DataSharing_SummaryScope', 'Phạm vi') }), jsxRuntime.jsx("div", { className: "es-summary-value", children: isGlobalShared
|
|
@@ -651,73 +763,7 @@ const DataSharingContent = ({ config, masterData = {}, masterDataList = [], pare
|
|
|
651
763
|
: `${selectedOrgs.length} ${t('DataSharing_Organization', 'Đơn vị')}` })] }), jsxRuntime.jsxs("div", { className: "es-summary-item", children: [jsxRuntime.jsx("div", { className: "es-summary-label", children: t('DataSharing_SummaryOverride', 'Đơn vị cho phép cấu hình riêng') }), jsxRuntime.jsx("div", { className: "es-summary-value", children: selectedOrgs.filter(o => o.canOverrideConfig).length })] }), detailTabs.map(tab => (jsxRuntime.jsxs("div", { className: "es-summary-item", children: [jsxRuntime.jsx("div", { className: "es-summary-label", children: t(tab.title) }), jsxRuntime.jsx("div", { className: "es-summary-value", children: (detailData[tab.key] ?? []).filter(r => !r._deleted).length })] }, tab.key)))] })] }) }))] })] }))] }));
|
|
652
764
|
};
|
|
653
765
|
|
|
654
|
-
|
|
655
|
-
if (!checked)
|
|
656
|
-
return orgList;
|
|
657
|
-
return orgList.map(o => ({
|
|
658
|
-
...o,
|
|
659
|
-
isSelected: true,
|
|
660
|
-
status: 1,
|
|
661
|
-
statusText: sharingLabel
|
|
662
|
-
}));
|
|
663
|
-
}
|
|
664
|
-
function updateOrgOverrideValue(orgList, targetOrgId, fieldKey, value) {
|
|
665
|
-
return orgList.map(item => {
|
|
666
|
-
if (item.targetOrgId !== targetOrgId)
|
|
667
|
-
return item;
|
|
668
|
-
return {
|
|
669
|
-
...item,
|
|
670
|
-
overrideData: {
|
|
671
|
-
...item.overrideData,
|
|
672
|
-
[fieldKey]: value
|
|
673
|
-
}
|
|
674
|
-
};
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
function applyFirstOverrideToAll(orgList) {
|
|
678
|
-
const editableOrgs = orgList.filter(o => o.isSelected && o.canOverrideConfig);
|
|
679
|
-
if (editableOrgs.length < 2)
|
|
680
|
-
return orgList;
|
|
681
|
-
const firstData = editableOrgs[0].overrideData ?? {};
|
|
682
|
-
return orgList.map(item => {
|
|
683
|
-
if (!item.isSelected || !item.canOverrideConfig)
|
|
684
|
-
return item;
|
|
685
|
-
return {
|
|
686
|
-
...item,
|
|
687
|
-
overrideData: {
|
|
688
|
-
...firstData
|
|
689
|
-
}
|
|
690
|
-
};
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
function buildDataSharingPayload(params) {
|
|
694
|
-
const { config, entityId, entityIds, isGlobalShared, orgList, detailData } = params;
|
|
695
|
-
const isBatchMode = (entityIds?.length ?? 0) > 1;
|
|
696
|
-
const detailTabs = config.detailTabs ?? [];
|
|
697
|
-
return {
|
|
698
|
-
entityType: config.entityType,
|
|
699
|
-
entityId,
|
|
700
|
-
...(isBatchMode ? { entityIds } : {}),
|
|
701
|
-
isGlobalShared,
|
|
702
|
-
sharingList: orgList.map(o => ({
|
|
703
|
-
TargetOrgId: o.targetOrgId,
|
|
704
|
-
IsInheritMaster: o.isInheritMaster,
|
|
705
|
-
CanOverrideConfig: o.canOverrideConfig,
|
|
706
|
-
EffectiveFrom: o.effectiveFrom || null,
|
|
707
|
-
EffectiveTo: o.effectiveTo || null,
|
|
708
|
-
Status: o.isSelected ? 1 : 0
|
|
709
|
-
})),
|
|
710
|
-
orgConfigList: orgList
|
|
711
|
-
.filter(o => o.isSelected && o.canOverrideConfig)
|
|
712
|
-
.map(o => ({
|
|
713
|
-
OrganizationId: o.targetOrgId,
|
|
714
|
-
...o.overrideData
|
|
715
|
-
})),
|
|
716
|
-
...(detailTabs.length > 0 ? { detailData } : {})
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
const ModalSharingView = ({ isOpen, toggle, config, masterData, masterDataList = [], parentOrgName, entityId, entityIds, orgList, setOrgList, detailData, setDetailData, isGlobalShared, setIsGlobalShared, onSave, loading = false, showMasterCard, showOrgScope, showConfigTabs, showOverrideTab, showSummaryTab, showGlobalSharedSwitch }) => {
|
|
766
|
+
const ModalSharingView = ({ isOpen, toggle, config, masterData, masterDataList = [], parentOrgName, entityId, entityIds, orgList, setOrgList, detailData, setDetailData, isGlobalShared, setIsGlobalShared, onSave, loading = false, showMasterCard, showOrgScope, showConfigTabs, showOverrideTab, showSummaryTab }) => {
|
|
721
767
|
const { t } = reactI18next.useTranslation();
|
|
722
768
|
const [saving, setSaving] = react.useState(false);
|
|
723
769
|
const isBatchMode = (entityIds?.length ?? 0) > 1;
|
|
@@ -750,10 +796,10 @@ const ModalSharingView = ({ isOpen, toggle, config, masterData, masterDataList =
|
|
|
750
796
|
setSaving(false);
|
|
751
797
|
}
|
|
752
798
|
};
|
|
753
|
-
return (jsxRuntime.jsxs(reactstrap.Modal, { isOpen: isOpen, toggle: toggle, className: "modal-dialog-centered modal-xl es-data-sharing-modal", children: [jsxRuntime.jsx(reactstrap.ModalHeader, { toggle: toggle, children: jsxRuntime.jsxs("div", { className: "d-flex align-items-center", children: [jsxRuntime.jsx("span", { className: "me-2 es-data-sharing-header-icon", children:
|
|
799
|
+
return (jsxRuntime.jsxs(reactstrap.Modal, { isOpen: isOpen, toggle: toggle, className: "modal-dialog-centered modal-xl es-data-sharing-modal", children: [jsxRuntime.jsx(reactstrap.ModalHeader, { toggle: toggle, children: jsxRuntime.jsxs("div", { className: "d-flex align-items-center", children: [jsxRuntime.jsx("span", { className: "me-2 es-data-sharing-header-icon", children: jsxRuntime.jsx(becoxyIcons.Link2, { fontSize: 18 }) }), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", { className: "d-flex align-items-center gap-2", children: [jsxRuntime.jsx("h4", { className: "mb-0 fw-bolder", children: t(config.title) }), isBatchMode && (jsxRuntime.jsxs(reactstrap.Badge, { color: "primary", className: "es-batch-badge", children: [t('DataSharing_BatchSharing', 'Chia sẻ hàng loạt'), " (", entityIds?.length, ")"] }))] }), jsxRuntime.jsx("small", { className: "text-muted", children: t('DataSharing_Subtitle', 'Quản lý chia sẻ dữ liệu và phân quyền theo đơn vị thành viên') })] })] }) }), jsxRuntime.jsx(reactstrap.ModalBody, { children: loading ? (jsxRuntime.jsxs("div", { className: "text-center py-5", children: [jsxRuntime.jsx("div", { className: "spinner-border text-primary", role: "status", children: jsxRuntime.jsx("span", { className: "visually-hidden", children: "Loading..." }) }), jsxRuntime.jsx("div", { className: "mt-2 text-muted", children: t('DataSharing_Loading', 'Đang tải dữ liệu chia sẻ...') })] })) : (jsxRuntime.jsx(DataSharingContent, { config: config, masterData: masterData, masterDataList: masterDataList, parentOrgName: parentOrgName, isBatchMode: isBatchMode, orgList: orgList, setOrgList: setOrgList, detailData: detailData, setDetailData: setDetailData, isGlobalShared: isGlobalShared, onToggleGlobalShared: handleToggleGlobalShared, onChangeOverride: handleChangeOverride, onApplyFirstToAll: handleApplyFirstToAll, showMasterCard: showMasterCard, showOrgScope: showOrgScope, showConfigTabs: showConfigTabs, showOverrideTab: showOverrideTab, showSummaryTab: showSummaryTab })) }), jsxRuntime.jsxs(reactstrap.ModalFooter, { children: [jsxRuntime.jsx(reactstrap.Button, { color: "primary", onClick: handleSubmit, disabled: saving || loading, children: saving ? t('DataSharing_Saving', 'Đang lưu...') : t('DataSharing_Save', 'Cập nhật chia sẻ') }), jsxRuntime.jsx(reactstrap.Button, { color: "secondary", outline: true, onClick: toggle, disabled: saving || loading, children: t('DataSharing_Cancel', 'Hủy') })] })] }));
|
|
754
800
|
};
|
|
755
801
|
|
|
756
|
-
const DataSharingPanel = ({ config, masterData = {}, masterDataList = [], parentOrgName, isBatchMode = false, orgList, onChangeOrgList, detailData: controlledDetailData, onChangeDetailData, isGlobalShared: controlledGlobalShared = false, onChangeGlobalShared, showMasterCard, showOrgScope, showConfigTabs, showOverrideTab, showSummaryTab
|
|
802
|
+
const DataSharingPanel = ({ config, masterData = {}, masterDataList = [], parentOrgName, isBatchMode = false, orgList, onChangeOrgList, detailData: controlledDetailData, onChangeDetailData, isGlobalShared: controlledGlobalShared = false, onChangeGlobalShared, showMasterCard, showOrgScope, showConfigTabs, showOverrideTab, showSummaryTab }) => {
|
|
757
803
|
const { t } = reactI18next.useTranslation();
|
|
758
804
|
const [internalDetailData, setInternalDetailData] = react.useState({});
|
|
759
805
|
const detailData = controlledDetailData ?? internalDetailData;
|
|
@@ -769,9 +815,9 @@ const DataSharingPanel = ({ config, masterData = {}, masterDataList = [], parent
|
|
|
769
815
|
const handleApplyFirstToAll = () => {
|
|
770
816
|
onChangeOrgList(prev => applyFirstOverrideToAll(prev));
|
|
771
817
|
};
|
|
772
|
-
return (jsxRuntime.jsx(DataSharingContent, { config: config, masterData: masterData, masterDataList: masterDataList, parentOrgName: parentOrgName, isBatchMode: isBatchMode, orgList: orgList, setOrgList: onChangeOrgList, detailData: detailData, setDetailData: setDetailData, isGlobalShared: controlledGlobalShared, onToggleGlobalShared: handleToggleGlobalShared, onChangeOverride: handleChangeOverride, onApplyFirstToAll: handleApplyFirstToAll, showMasterCard: showMasterCard, showOrgScope: showOrgScope, showConfigTabs: showConfigTabs, showOverrideTab: showOverrideTab, showSummaryTab: showSummaryTab
|
|
818
|
+
return (jsxRuntime.jsx(DataSharingContent, { config: config, masterData: masterData, masterDataList: masterDataList, parentOrgName: parentOrgName, isBatchMode: isBatchMode, orgList: orgList, setOrgList: onChangeOrgList, detailData: detailData, setDetailData: setDetailData, isGlobalShared: controlledGlobalShared, onToggleGlobalShared: handleToggleGlobalShared, onChangeOverride: handleChangeOverride, onApplyFirstToAll: handleApplyFirstToAll, showMasterCard: showMasterCard, showOrgScope: showOrgScope, showConfigTabs: showConfigTabs, showOverrideTab: showOverrideTab, showSummaryTab: showSummaryTab }));
|
|
773
819
|
};
|
|
774
|
-
const DataSharingComponent = react.forwardRef(({ database, parentOrgName, fetchSharingData, onSave, onSuccess, showMasterCard, showOrgScope, showConfigTabs, showOverrideTab, showSummaryTab
|
|
820
|
+
const DataSharingComponent = react.forwardRef(({ database, parentOrgName, fetchSharingData, onSave, onSuccess, showMasterCard, showOrgScope, showConfigTabs, showOverrideTab, showSummaryTab }, ref) => {
|
|
775
821
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
776
822
|
const [loading, setLoading] = react.useState(false);
|
|
777
823
|
const [config, setConfig] = react.useState(null);
|
|
@@ -795,7 +841,7 @@ const DataSharingComponent = react.forwardRef(({ database, parentOrgName, fetchS
|
|
|
795
841
|
setConfig(params.config);
|
|
796
842
|
setMasterData(params.masterData ?? params.masterDataList?.[0] ?? {});
|
|
797
843
|
setMasterDataList(params.masterDataList ?? (params.masterData ? [params.masterData] : []));
|
|
798
|
-
setActiveParentOrgName(params.parentOrgName ?? parentOrgName);
|
|
844
|
+
setActiveParentOrgName(params.parentOrgName ?? params.config?.parentOrgName ?? parentOrgName);
|
|
799
845
|
setEntityId(primaryEntityId);
|
|
800
846
|
setEntityIds(isBatch ? ids : undefined);
|
|
801
847
|
setActiveDatabase(targetDb);
|
|
@@ -806,14 +852,17 @@ const DataSharingComponent = react.forwardRef(({ database, parentOrgName, fetchS
|
|
|
806
852
|
showOrgScope: params.showOrgScope,
|
|
807
853
|
showConfigTabs: params.showConfigTabs,
|
|
808
854
|
showOverrideTab: params.showOverrideTab,
|
|
809
|
-
showSummaryTab: params.showSummaryTab
|
|
810
|
-
showGlobalSharedSwitch: params.showGlobalSharedSwitch
|
|
855
|
+
showSummaryTab: params.showSummaryTab
|
|
811
856
|
});
|
|
812
857
|
if (fetchSharingData && primaryEntityId) {
|
|
813
858
|
setLoading(true);
|
|
814
859
|
try {
|
|
815
860
|
const res = await fetchSharingData(params.entityType, primaryEntityId, targetDb);
|
|
816
|
-
if (
|
|
861
|
+
if (!params.parentOrgName &&
|
|
862
|
+
!params.config?.parentOrgName &&
|
|
863
|
+
!params.config?.organizationId &&
|
|
864
|
+
!parentOrgName &&
|
|
865
|
+
res.parentOrgName) {
|
|
817
866
|
setActiveParentOrgName(res.parentOrgName);
|
|
818
867
|
}
|
|
819
868
|
if (isBatch) {
|
|
@@ -857,7 +906,7 @@ const DataSharingComponent = react.forwardRef(({ database, parentOrgName, fetchS
|
|
|
857
906
|
onSuccess();
|
|
858
907
|
}
|
|
859
908
|
};
|
|
860
|
-
return (jsxRuntime.jsx(ModalSharingView, { isOpen: isOpen, toggle: () => setIsOpen(false), config: config, masterData: masterData, masterDataList: masterDataList, parentOrgName: activeParentOrgName ?? parentOrgName, entityId: entityId, entityIds: entityIds, orgList: orgList, setOrgList: setOrgList, detailData: detailData, setDetailData: setDetailData, isGlobalShared: isGlobalShared, setIsGlobalShared: setIsGlobalShared, onSave: handleSave, loading: loading, showMasterCard: openVisibility.showMasterCard ?? showMasterCard, showOrgScope: openVisibility.showOrgScope ?? showOrgScope, showConfigTabs: openVisibility.showConfigTabs ?? showConfigTabs, showOverrideTab: openVisibility.showOverrideTab ?? showOverrideTab, showSummaryTab: openVisibility.showSummaryTab ?? showSummaryTab
|
|
909
|
+
return (jsxRuntime.jsx(ModalSharingView, { isOpen: isOpen, toggle: () => setIsOpen(false), config: config, masterData: masterData, masterDataList: masterDataList, parentOrgName: activeParentOrgName ?? parentOrgName, entityId: entityId, entityIds: entityIds, orgList: orgList, setOrgList: setOrgList, detailData: detailData, setDetailData: setDetailData, isGlobalShared: isGlobalShared, setIsGlobalShared: setIsGlobalShared, onSave: handleSave, loading: loading, showMasterCard: openVisibility.showMasterCard ?? showMasterCard, showOrgScope: openVisibility.showOrgScope ?? showOrgScope, showConfigTabs: openVisibility.showConfigTabs ?? showConfigTabs, showOverrideTab: openVisibility.showOverrideTab ?? showOverrideTab, showSummaryTab: openVisibility.showSummaryTab ?? showSummaryTab }));
|
|
861
910
|
});
|
|
862
911
|
|
|
863
912
|
exports.BatchMasterCard = BatchMasterCard;
|