codeapp-js 0.1.0 → 0.2.1
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/codeApp/dist/codeapp.js +326 -72
- package/codeApp/dist/icon-512.png +0 -0
- package/codeApp/dist/index.html +1 -0
- package/codeApp/dist/index.js +1 -1
- package/codeApp/dist/power-apps-data.js +2952 -2531
- package/codeApp/power.config.json +1 -1
- package/dev files/customConnector.js +98 -0
- package/dev files/dataverse.js +33 -7
- package/dev files/environmentVar.js +1 -1
- package/dev files/office365groups.js +1 -1
- package/dev files/office365users.js +1 -1
- package/dev files/outlook.js +1 -1
- package/dev files/power-apps-data.js +2952 -0
- package/dev files/sharepoint.js +1 -1
- package/examples/combined demo/dist/codeapp.js +1098 -0
- package/examples/combined demo/dist/index.js +470 -515
- package/examples/combined demo/dist/power-apps-data.js +3007 -2531
- package/examples/dataverse Demo/dist/codeapp.js +1085 -0
- package/examples/dataverse Demo/dist/index.js +38 -26
- package/examples/dataverse Demo/dist/power-apps-data.js +2912 -2531
- package/examples/groups Demo/dist/codeapp.js +1085 -0
- package/examples/groups Demo/dist/index.js +113 -113
- package/examples/groups Demo/dist/power-apps-data.js +2912 -2531
- package/examples/groups Demo/power.config.json +3 -2
- package/examples/kanban/dist/power-apps-data.js +2953 -2531
- package/examples/myProfile/dist/power-apps-data.js +2953 -2531
- package/examples/outlook Demo/dist/codeapp.js +1085 -0
- package/examples/outlook Demo/dist/index.js +39 -35
- package/examples/outlook Demo/dist/power-apps-data.js +2912 -2531
- package/examples/planning Poker/dist/power-apps-data.js +2953 -2531
- package/examples/sharePoint Demo/dist/codeapp.js +1085 -0
- package/examples/sharePoint Demo/dist/index.js +262 -269
- package/examples/sharePoint Demo/dist/power-apps-data.js +2912 -2531
- package/examples/solution explorer/agent/decision-log.md +27 -0
- package/examples/solution explorer/agent/mockup-01-swiss-grid.html +452 -0
- package/examples/solution explorer/agent/mockup-02-dark-glass.html +496 -0
- package/examples/solution explorer/agent/mockup-03-paper-console.html +510 -0
- package/examples/solution explorer/agent/mockup-04-neon-noir.html +546 -0
- package/examples/solution explorer/agent/mockup-05-zen-garden.html +534 -0
- package/examples/solution explorer/dist/codeapp.js +1098 -0
- package/examples/solution explorer/dist/icon-512.png +0 -0
- package/examples/solution explorer/dist/index.html +80 -0
- package/examples/solution explorer/dist/index.js +735 -0
- package/examples/solution explorer/dist/power-apps-data.js +3007 -0
- package/examples/solution explorer/dist/styles.css +571 -0
- package/examples/solution explorer/power.config.json +151 -0
- package/examples/todo/dist/power-apps-data.js +2953 -2531
- package/package.json +1 -8
- package/.github/instructions/wyattdave.instructions.md +0 -39
- package/examples/combined demo/dist/dataverse.js +0 -86
- package/examples/combined demo/dist/environmentVar.js +0 -55
- package/examples/combined demo/dist/office365groups.js +0 -97
- package/examples/combined demo/dist/office365users.js +0 -169
- package/examples/combined demo/dist/outlook.js +0 -162
- package/examples/combined demo/dist/sharepoint.js +0 -339
- package/examples/dataverse Demo/dist/dataverse.js +0 -86
- package/examples/groups Demo/dist/dataverse.js +0 -86
- package/examples/groups Demo/dist/environmentVar.js +0 -55
- package/examples/groups Demo/dist/office365groups.js +0 -97
- package/examples/groups Demo/dist/office365users.js +0 -169
- package/examples/groups Demo/dist/outlook.js +0 -162
- package/examples/groups Demo/dist/sharepoint.js +0 -339
- package/examples/sharePoint Demo/dist/dataverse.js +0 -94
- package/examples/sharePoint Demo/dist/environmentVar.js +0 -55
- package/examples/sharePoint Demo/dist/office365groups.js +0 -97
- package/examples/sharePoint Demo/dist/office365users.js +0 -169
- package/examples/sharePoint Demo/dist/outlook.js +0 -162
- package/examples/sharePoint Demo/dist/sharepoint.js +0 -339
- package/scripts/build-power-sdk.mjs +0 -69
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
|
|
2
|
+
import { initDataSources, registerTable, listItems, getItem, callUnboundAction, enableDebugger } from './codeapp.js';
|
|
3
|
+
|
|
4
|
+
enableDebugger();
|
|
5
|
+
|
|
6
|
+
/* ── Data Sources (tables used by this app) ─────────────────── */
|
|
7
|
+
function dsEntry(sPrimaryKey) {
|
|
8
|
+
return { tableId: '', version: '', primaryKey: sPrimaryKey, dataSourceType: 'Dataverse', apis: {} };
|
|
9
|
+
}
|
|
10
|
+
initDataSources({
|
|
11
|
+
solutions: dsEntry('solutionid'),
|
|
12
|
+
solutioncomponents: dsEntry('solutioncomponentid'),
|
|
13
|
+
entities: dsEntry('entityid'),
|
|
14
|
+
roles: dsEntry('roleid'),
|
|
15
|
+
workflows: dsEntry('workflowid'),
|
|
16
|
+
reports: dsEntry('reportid'),
|
|
17
|
+
connectionroles: dsEntry('connectionroleid'),
|
|
18
|
+
systemforms: dsEntry('formid'),
|
|
19
|
+
savedqueryvisualizations: dsEntry('savedqueryvisualizationid'),
|
|
20
|
+
savedqueries: dsEntry('savedqueryid'),
|
|
21
|
+
webresourceset: dsEntry('webresourceid'),
|
|
22
|
+
plugintypes: dsEntry('plugintypeid'),
|
|
23
|
+
pluginassemblies: dsEntry('pluginassemblyid'),
|
|
24
|
+
sdkmessageprocessingsteps: dsEntry('sdkmessageprocessingstepid'),
|
|
25
|
+
customcontrols: dsEntry('customcontrolid'),
|
|
26
|
+
appmodules: dsEntry('appmoduleid'),
|
|
27
|
+
canvasapps: dsEntry('canvasappid'),
|
|
28
|
+
sitemaps: dsEntry('sitemapid'),
|
|
29
|
+
connectionreferences: dsEntry('connectionreferenceid'),
|
|
30
|
+
environmentvariabledefinitions: dsEntry('environmentvariabledefinitionid'),
|
|
31
|
+
environmentvariablevalues: dsEntry('environmentvariablevalueid'),
|
|
32
|
+
fxexpressions: dsEntry('fxexpressionid'),
|
|
33
|
+
systemusers: dsEntry('systemuserid'),
|
|
34
|
+
teams: dsEntry('teamid')
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/* ── Well-known Component Types (hardcoded table mappings) ─── */
|
|
38
|
+
var oComponentTypes = {
|
|
39
|
+
1: { sLabel: 'Entity', sTable: 'entities', sPrimaryKey: 'entityid' },
|
|
40
|
+
2: { sLabel: 'Attribute', sTable: null },
|
|
41
|
+
9: { sLabel: 'Option Set', sTable: null },
|
|
42
|
+
10: { sLabel: 'Entity Relationship', sTable: null },
|
|
43
|
+
20: { sLabel: 'Security Role', sTable: 'roles', sPrimaryKey: 'roleid' },
|
|
44
|
+
24: { sLabel: 'Form', sTable: 'systemforms', sPrimaryKey: 'formid' },
|
|
45
|
+
26: { sLabel: 'View', sTable: 'savedqueries', sPrimaryKey: 'savedqueryid' },
|
|
46
|
+
29: { sLabel: 'Workflow', sTable: 'workflows', sPrimaryKey: 'workflowid' },
|
|
47
|
+
31: { sLabel: 'Report', sTable: 'reports', sPrimaryKey: 'reportid' },
|
|
48
|
+
59: { sLabel: 'Chart', sTable: 'savedqueryvisualizations', sPrimaryKey: 'savedqueryvisualizationid' },
|
|
49
|
+
60: { sLabel: 'System Form', sTable: 'systemforms', sPrimaryKey: 'formid' },
|
|
50
|
+
61: { sLabel: 'Web Resource', sTable: 'webresourceset', sPrimaryKey: 'webresourceid' },
|
|
51
|
+
62: { sLabel: 'Site Map', sTable: 'sitemaps', sPrimaryKey: 'sitemapid' },
|
|
52
|
+
63: { sLabel: 'Connection Role', sTable: 'connectionroles', sPrimaryKey: 'connectionroleid' },
|
|
53
|
+
66: { sLabel: 'Custom Control', sTable: 'customcontrols', sPrimaryKey: 'customcontrolid' },
|
|
54
|
+
70: { sLabel: 'Model-driven App', sTable: 'appmodules', sPrimaryKey: 'appmoduleid' },
|
|
55
|
+
71: { sLabel: 'Plugin Type', sTable: 'plugintypes', sPrimaryKey: 'plugintypeid' },
|
|
56
|
+
72: { sLabel: 'Plugin Assembly', sTable: 'pluginassemblies', sPrimaryKey: 'pluginassemblyid' },
|
|
57
|
+
80: { sLabel: 'Model-driven App', sTable: 'appmodules', sPrimaryKey: 'appmoduleid' },
|
|
58
|
+
91: { sLabel: 'SDK Message Step', sTable: 'sdkmessageprocessingsteps', sPrimaryKey: 'sdkmessageprocessingstepid' },
|
|
59
|
+
300: { sLabel: 'Canvas App', sTable: 'canvasapps', sPrimaryKey: 'canvasappid' }
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/* ── Dynamic Entity Cache (componenttype → discovered metadata) */
|
|
63
|
+
var oEntityCache = {};
|
|
64
|
+
|
|
65
|
+
/* ── State ──────────────────────────────────────────────────── */
|
|
66
|
+
var aSolutions = [];
|
|
67
|
+
var sActiveId = '';
|
|
68
|
+
|
|
69
|
+
/* ── DOM References ─────────────────────────────────────────── */
|
|
70
|
+
const eSolList = document.getElementById('solList');
|
|
71
|
+
const eSolCount = document.getElementById('solCount');
|
|
72
|
+
const eDetailPanel = document.getElementById('detailPanel');
|
|
73
|
+
const eSearchInput = document.getElementById('searchInput');
|
|
74
|
+
const eManagedFilter = document.getElementById('managedFilter');
|
|
75
|
+
|
|
76
|
+
/* ── Register Core Tables ───────────────────────────────────── */
|
|
77
|
+
function registerCoreTables() {
|
|
78
|
+
registerTable('solutions', 'solutionid');
|
|
79
|
+
registerTable('solutioncomponents', 'solutioncomponentid');
|
|
80
|
+
registerTable('entities', 'entityid');
|
|
81
|
+
|
|
82
|
+
registerTable('systemusers', 'systemuserid');
|
|
83
|
+
registerTable('teams', 'teamid');
|
|
84
|
+
|
|
85
|
+
/* Register well-known component tables */
|
|
86
|
+
var oRegistered = {};
|
|
87
|
+
Object.keys(oComponentTypes).forEach(function(sKey) {
|
|
88
|
+
var oDef = oComponentTypes[sKey];
|
|
89
|
+
if (oDef.sTable && !oRegistered[oDef.sTable]) {
|
|
90
|
+
registerTable(oDef.sTable, oDef.sPrimaryKey);
|
|
91
|
+
oRegistered[oDef.sTable] = true;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* ── Lookup entity metadata for an unknown componenttype ────── */
|
|
97
|
+
async function lookupEntityType(iType) {
|
|
98
|
+
if (oEntityCache[iType]) return oEntityCache[iType];
|
|
99
|
+
var oResult = await listItems('entities', 'entityid', {
|
|
100
|
+
filter: 'objecttypecode eq ' + iType,
|
|
101
|
+
select: ['logicalcollectionname', 'logicalname', 'originallocalizedname'],
|
|
102
|
+
top: 1
|
|
103
|
+
});
|
|
104
|
+
var aEntities = oResult.entities || [];
|
|
105
|
+
if (aEntities.length > 0) {
|
|
106
|
+
var oEnt = aEntities[0];
|
|
107
|
+
oEntityCache[iType] = {
|
|
108
|
+
sLabel: oEnt.originallocalizedname || oEnt.logicalname,
|
|
109
|
+
sTable: oEnt.logicalcollectionname,
|
|
110
|
+
sPrimaryKey: oEnt.logicalname + 'id'
|
|
111
|
+
};
|
|
112
|
+
return oEntityCache[iType];
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* ── Extract display name from a record ─────────────────────── */
|
|
118
|
+
var aNameFields = ['name', 'displayname', 'friendlyname', 'sitemapname', 'fullname', 'title', 'subject'];
|
|
119
|
+
function extractName(oRecord) {
|
|
120
|
+
for (var i = 0; i < aNameFields.length; i++) {
|
|
121
|
+
if (oRecord[aNameFields[i]]) return oRecord[aNameFields[i]];
|
|
122
|
+
}
|
|
123
|
+
/* Fallback: first string value that is not a guid, url, or odata field */
|
|
124
|
+
var sGuidPattern = new RegExp('^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$', 'i');
|
|
125
|
+
var aKeys = Object.keys(oRecord);
|
|
126
|
+
for (var j = 0; j < aKeys.length; j++) {
|
|
127
|
+
var sKey = aKeys[j];
|
|
128
|
+
if (sKey.indexOf('@') === 0) continue;
|
|
129
|
+
if (sKey.indexOf('_') === 0) continue;
|
|
130
|
+
var val = oRecord[sKey];
|
|
131
|
+
if (typeof val === 'string' && val.length > 0 && val.length < 200 && !sGuidPattern.test(val) && val.indexOf('http') !== 0 && val.indexOf('/') === -1) return val;
|
|
132
|
+
}
|
|
133
|
+
return '';
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* ── Load Solutions ─────────────────────────────────────────── */
|
|
137
|
+
async function loadSolutions() {
|
|
138
|
+
var oResult = await listItems('solutions', 'solutionid', {
|
|
139
|
+
select: ['solutionid', 'friendlyname', 'uniquename', 'version', 'ismanaged', 'modifiedon', 'description'],
|
|
140
|
+
orderBy: ['friendlyname asc'],
|
|
141
|
+
top: 5000
|
|
142
|
+
});
|
|
143
|
+
return oResult.entities || [];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* ── Load Solution Components ───────────────────────────────── */
|
|
147
|
+
async function loadComponents(sSolutionId) {
|
|
148
|
+
var oResult = await listItems('solutioncomponents', 'solutioncomponentid', {
|
|
149
|
+
filter: '_solutionid_value eq ' + sSolutionId,
|
|
150
|
+
select: ['solutioncomponentid', 'componenttype', 'objectid'],
|
|
151
|
+
top: 5000
|
|
152
|
+
});
|
|
153
|
+
return oResult.entities || [];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* ── Resolve a single component name ─────────────────────────── */
|
|
157
|
+
function resolveOneComponent(oItem, oDef) {
|
|
158
|
+
/* Entity (type 1) does not support Retrieve — must use filter */
|
|
159
|
+
if (oItem.iType === 1) {
|
|
160
|
+
return listItems('entities', 'entityid', {
|
|
161
|
+
filter: 'entityid eq ' + oItem.sObjectId,
|
|
162
|
+
select: ['name', 'logicalname', 'originallocalizedname'],
|
|
163
|
+
top: 1
|
|
164
|
+
})
|
|
165
|
+
.then(function(oResult) {
|
|
166
|
+
var aRows = oResult.entities || [];
|
|
167
|
+
if (aRows.length > 0) {
|
|
168
|
+
oItem.sName = aRows[0].originallocalizedname || aRows[0].name || aRows[0].logicalname || oItem.sObjectId;
|
|
169
|
+
} else {
|
|
170
|
+
oItem.sName = oItem.sObjectId;
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
.catch(function() {
|
|
174
|
+
oItem.sName = oItem.sObjectId;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/* All other types — direct retrieve by ID */
|
|
178
|
+
return getItem(oDef.sTable, oDef.sPrimaryKey, oItem.sObjectId)
|
|
179
|
+
.then(function(oRecord) {
|
|
180
|
+
oItem.sName = extractName(oRecord) || oItem.sObjectId;
|
|
181
|
+
})
|
|
182
|
+
.catch(function() {
|
|
183
|
+
oItem.sName = (oDef.sLabel || oDef.sTable) + ' (' + oItem.sObjectId.substring(0, 8) + '…)';
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* ── Resolve Component Names ────────────────────────────────── */
|
|
188
|
+
async function resolveComponentNames(aComponents) {
|
|
189
|
+
var aResolved = aComponents.map(function(oComp) {
|
|
190
|
+
return {
|
|
191
|
+
iType: oComp.componenttype,
|
|
192
|
+
sObjectId: oComp.objectid,
|
|
193
|
+
sName: ''
|
|
194
|
+
};
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
/* Discover unknown types via entity metadata */
|
|
198
|
+
var oUnknown = {};
|
|
199
|
+
aResolved.forEach(function(oItem) {
|
|
200
|
+
if (!oComponentTypes[oItem.iType] && !oUnknown[oItem.iType]) {
|
|
201
|
+
oUnknown[oItem.iType] = true;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
var aLookups = Object.keys(oUnknown).map(function(sKey) {
|
|
205
|
+
return lookupEntityType(parseInt(sKey)).catch(function() { return null; });
|
|
206
|
+
});
|
|
207
|
+
await Promise.allSettled(aLookups);
|
|
208
|
+
|
|
209
|
+
/* Register dynamically discovered tables */
|
|
210
|
+
var oRegistered = {};
|
|
211
|
+
Object.keys(oEntityCache).forEach(function(sKey) {
|
|
212
|
+
var oDef = oEntityCache[sKey];
|
|
213
|
+
if (oDef && oDef.sTable && !oRegistered[oDef.sTable]) {
|
|
214
|
+
registerTable(oDef.sTable, oDef.sPrimaryKey);
|
|
215
|
+
oRegistered[oDef.sTable] = true;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
/* Build lookup promises */
|
|
220
|
+
var aPromises = aResolved.map(function(oItem) {
|
|
221
|
+
var oDef = oComponentTypes[oItem.iType] || oEntityCache[oItem.iType];
|
|
222
|
+
if (!oDef || !oDef.sTable) {
|
|
223
|
+
oItem.sName = oItem.sObjectId;
|
|
224
|
+
return Promise.resolve();
|
|
225
|
+
}
|
|
226
|
+
return resolveOneComponent(oItem, oDef);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
await Promise.allSettled(aPromises);
|
|
230
|
+
return aResolved;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* ── Format Date ────────────────────────────────────────────── */
|
|
234
|
+
function formatDate(sISO) {
|
|
235
|
+
if (!sISO) return '';
|
|
236
|
+
var d = new Date(sISO);
|
|
237
|
+
return d.toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' });
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/* ── Render Solutions List ──────────────────────────────────── */
|
|
241
|
+
function renderSolutions(aFiltered) {
|
|
242
|
+
eSolList.innerHTML = '';
|
|
243
|
+
eSolCount.textContent = aFiltered.length;
|
|
244
|
+
|
|
245
|
+
if (aFiltered.length === 0) {
|
|
246
|
+
eSolList.innerHTML = '<div class="loading-msg">No solutions found</div>';
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
aFiltered.forEach(function(oSol, i) {
|
|
251
|
+
var eItem = document.createElement('div');
|
|
252
|
+
eItem.className = 'sol-item' + (oSol.ismanaged ? ' managed' : '');
|
|
253
|
+
if (oSol.solutionid === sActiveId) {
|
|
254
|
+
eItem.classList.add('active');
|
|
255
|
+
}
|
|
256
|
+
eItem.style.animationDelay = (i * 0.04) + 's';
|
|
257
|
+
eItem.innerHTML =
|
|
258
|
+
'<div class="sol-indicator"></div>' +
|
|
259
|
+
'<div>' +
|
|
260
|
+
'<div class="sol-name">' + oSol.friendlyname + '</div>' +
|
|
261
|
+
'<div class="sol-version">' + oSol.uniquename + ' · v' + oSol.version + '</div>' +
|
|
262
|
+
'</div>' +
|
|
263
|
+
'<div>' +
|
|
264
|
+
'<div class="sol-managed">' + (oSol.ismanaged ? 'Managed' : 'Unmanaged') + '</div>' +
|
|
265
|
+
'<div class="sol-modified">' + formatDate(oSol.modifiedon) + '</div>' +
|
|
266
|
+
'</div>';
|
|
267
|
+
eItem.addEventListener('click', function() {
|
|
268
|
+
sActiveId = oSol.solutionid;
|
|
269
|
+
renderSolutions(aFiltered);
|
|
270
|
+
showDetail(oSol);
|
|
271
|
+
});
|
|
272
|
+
eSolList.appendChild(eItem);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/* ── Show Detail Panel ──────────────────────────────────────── */
|
|
277
|
+
async function showDetail(oSol) {
|
|
278
|
+
eDetailPanel.innerHTML =
|
|
279
|
+
'<div class="detail-header">' +
|
|
280
|
+
'<h2>' + oSol.friendlyname + '</h2>' +
|
|
281
|
+
'<div class="detail-meta">' +
|
|
282
|
+
'<span>Unique Name: <b>' + oSol.uniquename + '</b></span>' +
|
|
283
|
+
'<span>Version: <b>' + oSol.version + '</b></span>' +
|
|
284
|
+
'<span>' + (oSol.ismanaged ? 'Managed' : 'Unmanaged') + '</span>' +
|
|
285
|
+
'</div>' +
|
|
286
|
+
'</div>' +
|
|
287
|
+
(oSol.description ? '<div class="detail-desc">' + oSol.description + '</div>' : '') +
|
|
288
|
+
'<div class="comp-bar"><span>Components</span><span class="comp-total">Loading…</span></div>';
|
|
289
|
+
|
|
290
|
+
try {
|
|
291
|
+
var aRawComps = await loadComponents(oSol.solutionid);
|
|
292
|
+
var aComps = await resolveComponentNames(aRawComps);
|
|
293
|
+
|
|
294
|
+
/* Group by type label */
|
|
295
|
+
var oGroups = {};
|
|
296
|
+
aComps.forEach(function(oComp) {
|
|
297
|
+
var oDef = oComponentTypes[oComp.iType] || oEntityCache[oComp.iType];
|
|
298
|
+
var sLabel = oDef ? oDef.sLabel : 'Type ' + oComp.iType;
|
|
299
|
+
if (!oGroups[sLabel]) {
|
|
300
|
+
oGroups[sLabel] = [];
|
|
301
|
+
}
|
|
302
|
+
oGroups[sLabel].push(oComp);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
/* Build components HTML */
|
|
306
|
+
var sCompHTML =
|
|
307
|
+
'<div class="comp-bar">' +
|
|
308
|
+
'<span>Components</span>' +
|
|
309
|
+
'<span class="comp-total">' + aComps.length + ' items</span>' +
|
|
310
|
+
'</div>' +
|
|
311
|
+
'<div class="comp-groups">';
|
|
312
|
+
|
|
313
|
+
var iGroupIdx = 0;
|
|
314
|
+
Object.keys(oGroups).sort().forEach(function(sType) {
|
|
315
|
+
sCompHTML +=
|
|
316
|
+
'<div class="comp-group" style="animation-delay:' + (iGroupIdx * 0.08) + 's">' +
|
|
317
|
+
'<div class="comp-group-title">' + sType + ' (' + oGroups[sType].length + ')</div>';
|
|
318
|
+
oGroups[sType].forEach(function(oComp) {
|
|
319
|
+
var sEscName = oComp.sName.replace(/'/g, "\\'").replace(/"/g, '"');
|
|
320
|
+
sCompHTML +=
|
|
321
|
+
'<div class="comp-row" onclick="window._openShareModal(\'' + sEscName + '\', \'' + oComp.sObjectId + '\', ' + oComp.iType + ')">' +
|
|
322
|
+
'<span class="comp-row-name">' + oComp.sName + '</span>' +
|
|
323
|
+
'<span class="comp-row-id">' + oComp.sObjectId + '</span>' +
|
|
324
|
+
'</div>';
|
|
325
|
+
});
|
|
326
|
+
sCompHTML += '</div>';
|
|
327
|
+
iGroupIdx++;
|
|
328
|
+
});
|
|
329
|
+
sCompHTML += '</div>';
|
|
330
|
+
|
|
331
|
+
/* Replace only the components section */
|
|
332
|
+
eDetailPanel.innerHTML =
|
|
333
|
+
'<div class="detail-header">' +
|
|
334
|
+
'<h2>' + oSol.friendlyname + '</h2>' +
|
|
335
|
+
'<div class="detail-meta">' +
|
|
336
|
+
'<span>Unique Name: <b>' + oSol.uniquename + '</b></span>' +
|
|
337
|
+
'<span>Version: <b>' + oSol.version + '</b></span>' +
|
|
338
|
+
'<span>' + (oSol.ismanaged ? 'Managed' : 'Unmanaged') + '</span>' +
|
|
339
|
+
'</div>' +
|
|
340
|
+
'</div>' +
|
|
341
|
+
(oSol.description ? '<div class="detail-desc">' + oSol.description + '</div>' : '') +
|
|
342
|
+
sCompHTML;
|
|
343
|
+
|
|
344
|
+
} catch (oErr) {
|
|
345
|
+
eDetailPanel.querySelector('.comp-bar .comp-total').textContent = 'Error loading components';
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/* ── Filter Solutions ───────────────────────────────────────── */
|
|
350
|
+
function filterSolutions(sQuery, sManagedValue) {
|
|
351
|
+
return aSolutions.filter(function(oSol) {
|
|
352
|
+
var bMatchesSearch = !sQuery ||
|
|
353
|
+
oSol.friendlyname.toLowerCase().indexOf(sQuery) !== -1 ||
|
|
354
|
+
oSol.uniquename.toLowerCase().indexOf(sQuery) !== -1;
|
|
355
|
+
var bMatchesManaged = sManagedValue === 'all' ||
|
|
356
|
+
(sManagedValue === 'managed' && oSol.ismanaged) ||
|
|
357
|
+
(sManagedValue === 'unmanaged' && !oSol.ismanaged);
|
|
358
|
+
return bMatchesSearch && bMatchesManaged;
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/* ── Search & Filter Handlers ──────────────────────────────── */
|
|
363
|
+
function applyFilters() {
|
|
364
|
+
var sQuery = eSearchInput.value.toLowerCase();
|
|
365
|
+
var sManagedValue = eManagedFilter.value;
|
|
366
|
+
renderSolutions(filterSolutions(sQuery, sManagedValue));
|
|
367
|
+
}
|
|
368
|
+
eSearchInput.addEventListener('input', applyFilters);
|
|
369
|
+
eManagedFilter.addEventListener('change', applyFilters);
|
|
370
|
+
|
|
371
|
+
/* ── Boot ────────────────────────────────────────────────────── */
|
|
372
|
+
async function boot() {
|
|
373
|
+
try {
|
|
374
|
+
registerCoreTables();
|
|
375
|
+
aSolutions = await loadSolutions();
|
|
376
|
+
renderSolutions(aSolutions);
|
|
377
|
+
} catch (oErr) {
|
|
378
|
+
eSolList.innerHTML = '<div class="error-msg">Failed to load solutions: ' + oErr.message + '</div>';
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
boot();
|
|
383
|
+
|
|
384
|
+
/* ══════════════════════════════════════════════════════════════
|
|
385
|
+
Share Component Modal
|
|
386
|
+
══════════════════════════════════════════════════════════════ */
|
|
387
|
+
|
|
388
|
+
/* ── Share Modal State ──────────────────────────────────────── */
|
|
389
|
+
let oShareContext = { sComponentName: '', sObjectId: '', iType: 0 };
|
|
390
|
+
let sShareTab = 'user';
|
|
391
|
+
let aShareSelected = []; // { sId, sName, sType ('user'|'team'), sDetail }
|
|
392
|
+
let iShareSearchTimer = 0;
|
|
393
|
+
|
|
394
|
+
/* ── Share Modal DOM References ─────────────────────────────── */
|
|
395
|
+
const eShareBackdrop = document.getElementById('shareBackdrop');
|
|
396
|
+
const eShareModalTitle = document.getElementById('shareModalTitle');
|
|
397
|
+
const eShareCloseBtn = document.getElementById('shareCloseBtn');
|
|
398
|
+
const eShareSearchInput = document.getElementById('shareSearchInput');
|
|
399
|
+
const eShareResults = document.getElementById('shareResults');
|
|
400
|
+
const eShareSelectedSection = document.getElementById('shareSelectedSection');
|
|
401
|
+
const eShareSelectedList = document.getElementById('shareSelectedList');
|
|
402
|
+
const eShareCancelBtn = document.getElementById('shareCancelBtn');
|
|
403
|
+
const eShareConfirmBtn = document.getElementById('shareConfirmBtn');
|
|
404
|
+
const aShareTabs = document.querySelectorAll('.share-tab');
|
|
405
|
+
|
|
406
|
+
/* ── Open Share Modal ───────────────────────────────────────── */
|
|
407
|
+
function openShareModal(sComponentName, sObjectId, iType) {
|
|
408
|
+
oShareContext = { sComponentName, sObjectId, iType };
|
|
409
|
+
aShareSelected = [];
|
|
410
|
+
sShareTab = 'user';
|
|
411
|
+
|
|
412
|
+
eShareModalTitle.textContent = 'Share — ' + sComponentName;
|
|
413
|
+
eShareSearchInput.value = '';
|
|
414
|
+
eShareSearchInput.placeholder = 'Search users…';
|
|
415
|
+
eShareResults.innerHTML = '<div class="share-empty-msg">Type to search</div>';
|
|
416
|
+
renderShareSelected();
|
|
417
|
+
updateShareTabs();
|
|
418
|
+
|
|
419
|
+
eShareBackdrop.classList.add('open');
|
|
420
|
+
setTimeout(() => eShareSearchInput.focus(), 100);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/* ── Close Share Modal ──────────────────────────────────────── */
|
|
424
|
+
function closeShareModal() {
|
|
425
|
+
eShareBackdrop.classList.remove('open');
|
|
426
|
+
oShareContext = { sComponentName: '', sObjectId: '', iType: 0 };
|
|
427
|
+
aShareSelected = [];
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/* ── Tab Switching ──────────────────────────────────────────── */
|
|
431
|
+
function updateShareTabs() {
|
|
432
|
+
aShareTabs.forEach((eTab) => {
|
|
433
|
+
if (eTab.dataset.tab === sShareTab) {
|
|
434
|
+
eTab.classList.add('active');
|
|
435
|
+
} else {
|
|
436
|
+
eTab.classList.remove('active');
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
aShareTabs.forEach((eTab) => {
|
|
442
|
+
eTab.addEventListener('click', () => {
|
|
443
|
+
sShareTab = eTab.dataset.tab;
|
|
444
|
+
updateShareTabs();
|
|
445
|
+
eShareSearchInput.value = '';
|
|
446
|
+
eShareSearchInput.placeholder = sShareTab === 'user' ? 'Search users…' : 'Search teams…';
|
|
447
|
+
eShareResults.innerHTML = '<div class="share-empty-msg">Type to search</div>';
|
|
448
|
+
eShareSearchInput.focus();
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
/* ── Search Users (Dataverse systemusers) ───────────────────── */
|
|
453
|
+
async function searchUsers(sQuery) {
|
|
454
|
+
try {
|
|
455
|
+
const oResult = await listItems('systemusers', 'systemuserid', {
|
|
456
|
+
filter: "contains(fullname,'" + sQuery.replace(/'/g, "''") + "') and isdisabled eq false",
|
|
457
|
+
select: ['systemuserid', 'fullname', 'internalemailaddress', 'jobtitle'],
|
|
458
|
+
orderBy: ['fullname asc'],
|
|
459
|
+
top: 20
|
|
460
|
+
});
|
|
461
|
+
return (oResult.entities || []).map((oUser) => ({
|
|
462
|
+
sId: oUser.systemuserid,
|
|
463
|
+
sName: oUser.fullname || 'Unknown',
|
|
464
|
+
sDetail: oUser.internalemailaddress || oUser.jobtitle || '',
|
|
465
|
+
sType: 'user'
|
|
466
|
+
}));
|
|
467
|
+
} catch (oErr) {
|
|
468
|
+
console.error('User search failed:', oErr);
|
|
469
|
+
return [];
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/* ── Search Teams (Dataverse teams) ─────────────────────────── */
|
|
474
|
+
async function searchTeams(sQuery) {
|
|
475
|
+
try {
|
|
476
|
+
const oResult = await listItems('teams', 'teamid', {
|
|
477
|
+
filter: "contains(name,'" + sQuery.replace(/'/g, "''") + "')",
|
|
478
|
+
select: ['teamid', 'name', 'description', 'teamtype'],
|
|
479
|
+
orderBy: ['name asc'],
|
|
480
|
+
top: 20
|
|
481
|
+
});
|
|
482
|
+
const aTeamTypeLabels = { 0: 'Owner', 1: 'Access', 2: 'AAD Security', 3: 'AAD Office' };
|
|
483
|
+
return (oResult.entities || []).map((oTeam) => ({
|
|
484
|
+
sId: oTeam.teamid,
|
|
485
|
+
sName: oTeam.name || 'Unknown',
|
|
486
|
+
sDetail: aTeamTypeLabels[oTeam.teamtype] || ('Type ' + oTeam.teamtype),
|
|
487
|
+
sType: 'team'
|
|
488
|
+
}));
|
|
489
|
+
} catch (oErr) {
|
|
490
|
+
console.error('Team search failed:', oErr);
|
|
491
|
+
return [];
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/* ── Render Search Results ──────────────────────────────────── */
|
|
496
|
+
function renderShareResults(aResults) {
|
|
497
|
+
if (!aResults || aResults.length === 0) {
|
|
498
|
+
eShareResults.innerHTML = '<div class="share-empty-msg">No results found</div>';
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
eShareResults.innerHTML = '';
|
|
503
|
+
aResults.forEach((oItem) => {
|
|
504
|
+
const bSelected = aShareSelected.some((s) => s.sId === oItem.sId);
|
|
505
|
+
const eRow = document.createElement('div');
|
|
506
|
+
eRow.className = 'share-result-item' + (bSelected ? ' selected' : '');
|
|
507
|
+
|
|
508
|
+
const sInitials = getInitials(oItem.sName);
|
|
509
|
+
const sAvatarClass = oItem.sType === 'team' ? 'share-result-avatar team-avatar' : 'share-result-avatar';
|
|
510
|
+
|
|
511
|
+
eRow.innerHTML =
|
|
512
|
+
'<div class="' + sAvatarClass + '">' + sInitials + '</div>' +
|
|
513
|
+
'<div class="share-result-info">' +
|
|
514
|
+
'<div class="share-result-name">' + escapeHtml(oItem.sName) + '</div>' +
|
|
515
|
+
'<div class="share-result-detail">' + escapeHtml(oItem.sDetail) + '</div>' +
|
|
516
|
+
'</div>' +
|
|
517
|
+
'<div class="share-result-check">' + (bSelected ? '✓' : '') + '</div>';
|
|
518
|
+
|
|
519
|
+
eRow.addEventListener('click', () => {
|
|
520
|
+
toggleShareSelection(oItem);
|
|
521
|
+
renderShareResults(aResults);
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
eShareResults.appendChild(eRow);
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/* ── Toggle Selection ───────────────────────────────────────── */
|
|
529
|
+
function toggleShareSelection(oItem) {
|
|
530
|
+
const iIdx = aShareSelected.findIndex((s) => s.sId === oItem.sId);
|
|
531
|
+
if (iIdx >= 0) {
|
|
532
|
+
aShareSelected.splice(iIdx, 1);
|
|
533
|
+
} else {
|
|
534
|
+
aShareSelected.push(oItem);
|
|
535
|
+
}
|
|
536
|
+
renderShareSelected();
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/* ── Render Selected Chips ──────────────────────────────────── */
|
|
540
|
+
function renderShareSelected() {
|
|
541
|
+
if (aShareSelected.length === 0) {
|
|
542
|
+
eShareSelectedSection.style.display = 'none';
|
|
543
|
+
eShareConfirmBtn.disabled = true;
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
eShareSelectedSection.style.display = '';
|
|
548
|
+
eShareConfirmBtn.disabled = false;
|
|
549
|
+
|
|
550
|
+
eShareSelectedList.innerHTML = '';
|
|
551
|
+
aShareSelected.forEach((oItem) => {
|
|
552
|
+
const eChip = document.createElement('span');
|
|
553
|
+
eChip.className = 'share-selected-chip';
|
|
554
|
+
eChip.innerHTML =
|
|
555
|
+
escapeHtml(oItem.sName) +
|
|
556
|
+
'<span class="share-chip-remove" data-id="' + oItem.sId + '">×</span>';
|
|
557
|
+
eShareSelectedList.appendChild(eChip);
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
eShareSelectedList.querySelectorAll('.share-chip-remove').forEach((eBtn) => {
|
|
561
|
+
eBtn.addEventListener('click', (e) => {
|
|
562
|
+
e.stopPropagation();
|
|
563
|
+
const sRemoveId = eBtn.dataset.id;
|
|
564
|
+
aShareSelected = aShareSelected.filter((s) => s.sId !== sRemoveId);
|
|
565
|
+
renderShareSelected();
|
|
566
|
+
/* Re-render results if visible */
|
|
567
|
+
const aCurrentRows = eShareResults.querySelectorAll('.share-result-item');
|
|
568
|
+
if (aCurrentRows.length > 0) {
|
|
569
|
+
const sCurrentQuery = eShareSearchInput.value.trim();
|
|
570
|
+
if (sCurrentQuery.length >= 2) {
|
|
571
|
+
doShareSearch(sCurrentQuery);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/* ── Debounced Search ───────────────────────────────────────── */
|
|
579
|
+
eShareSearchInput.addEventListener('input', () => {
|
|
580
|
+
clearTimeout(iShareSearchTimer);
|
|
581
|
+
const sQuery = eShareSearchInput.value.trim();
|
|
582
|
+
if (sQuery.length < 2) {
|
|
583
|
+
eShareResults.innerHTML = '<div class="share-empty-msg">Type to search</div>';
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
eShareResults.innerHTML = '<div class="share-loading">Searching</div>';
|
|
587
|
+
iShareSearchTimer = setTimeout(() => doShareSearch(sQuery), 350);
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
async function doShareSearch(sQuery) {
|
|
591
|
+
let aResults = [];
|
|
592
|
+
if (sShareTab === 'user') {
|
|
593
|
+
aResults = await searchUsers(sQuery);
|
|
594
|
+
} else {
|
|
595
|
+
aResults = await searchTeams(sQuery);
|
|
596
|
+
}
|
|
597
|
+
renderShareResults(aResults);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/* ── Resolve entity logical name from component type ────────── */
|
|
601
|
+
const oTypeToLogicalName = {
|
|
602
|
+
1: 'entity',
|
|
603
|
+
20: 'role',
|
|
604
|
+
24: 'systemform',
|
|
605
|
+
26: 'savedquery',
|
|
606
|
+
29: 'workflow',
|
|
607
|
+
31: 'report',
|
|
608
|
+
59: 'savedqueryvisualization',
|
|
609
|
+
60: 'systemform',
|
|
610
|
+
61: 'webresource',
|
|
611
|
+
62: 'sitemap',
|
|
612
|
+
63: 'connectionrole',
|
|
613
|
+
66: 'customcontrol',
|
|
614
|
+
70: 'appmodule',
|
|
615
|
+
71: 'plugintype',
|
|
616
|
+
72: 'pluginassembly',
|
|
617
|
+
80: 'appmodule',
|
|
618
|
+
91: 'sdkmessageprocessingstep',
|
|
619
|
+
300: 'canvasapp'
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
function getLogicalNameForType(iType) {
|
|
623
|
+
if (oTypeToLogicalName[iType]) return oTypeToLogicalName[iType];
|
|
624
|
+
/* Try the entity cache for dynamically discovered types */
|
|
625
|
+
if (oEntityCache[iType] && oEntityCache[iType].sTable) {
|
|
626
|
+
/* logicalname is singular; sTable is the collection name */
|
|
627
|
+
const sDef = oEntityCache[iType];
|
|
628
|
+
/* sPrimaryKey is usually "<logicalname>id", so strip "id" */
|
|
629
|
+
if (sDef.sPrimaryKey && sDef.sPrimaryKey.endsWith('id')) {
|
|
630
|
+
return sDef.sPrimaryKey.slice(0, -2);
|
|
631
|
+
}
|
|
632
|
+
return sDef.sTable;
|
|
633
|
+
}
|
|
634
|
+
return null;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/* ── Call GrantAccess for one principal ──────────────────────── */
|
|
638
|
+
async function grantAccess(sTargetLogicalName, sTargetId, sPrincipalType, sPrincipalId) {
|
|
639
|
+
const sPrincipalLogical = sPrincipalType === 'user' ? 'systemuser' : 'team';
|
|
640
|
+
const sPrincipalKeyField = sPrincipalType === 'user' ? 'systemuserid' : 'teamid';
|
|
641
|
+
|
|
642
|
+
const oParams = {
|
|
643
|
+
Target: {
|
|
644
|
+
[sTargetLogicalName + 'id']: sTargetId,
|
|
645
|
+
'@odata.type': 'Microsoft.Dynamics.CRM.' + sTargetLogicalName
|
|
646
|
+
},
|
|
647
|
+
PrincipalAccess: {
|
|
648
|
+
Principal: {
|
|
649
|
+
[sPrincipalKeyField]: sPrincipalId,
|
|
650
|
+
'@odata.type': 'Microsoft.Dynamics.CRM.' + sPrincipalLogical
|
|
651
|
+
},
|
|
652
|
+
AccessMask: 'ReadAccess,WriteAccess,AppendAccess,AppendToAccess,ShareAccess,AssignAccess'
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
return await callUnboundAction('', '', 'GrantAccess', oParams);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/* ── Confirm Share ──────────────────────────────────────────── */
|
|
660
|
+
eShareConfirmBtn.addEventListener('click', async () => {
|
|
661
|
+
if (aShareSelected.length === 0) return;
|
|
662
|
+
|
|
663
|
+
const sLogicalName = getLogicalNameForType(oShareContext.iType);
|
|
664
|
+
if (!sLogicalName) {
|
|
665
|
+
showShareToast('Error: Cannot share this component type (type ' + oShareContext.iType + ')');
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/* Disable button while processing */
|
|
670
|
+
eShareConfirmBtn.disabled = true;
|
|
671
|
+
eShareConfirmBtn.textContent = 'Sharing…';
|
|
672
|
+
|
|
673
|
+
const aResults = await Promise.allSettled(
|
|
674
|
+
aShareSelected.map((oItem) =>
|
|
675
|
+
grantAccess(sLogicalName, oShareContext.sObjectId, oItem.sType, oItem.sId)
|
|
676
|
+
)
|
|
677
|
+
);
|
|
678
|
+
|
|
679
|
+
const aFailed = aResults.filter((r) => r.status === 'rejected');
|
|
680
|
+
const aSucceeded = aResults.filter((r) => r.status === 'fulfilled');
|
|
681
|
+
|
|
682
|
+
if (aFailed.length === 0) {
|
|
683
|
+
const sNames = aShareSelected.map((s) => s.sName).join(', ');
|
|
684
|
+
showShareToast('Shared "' + oShareContext.sComponentName + '" with ' + sNames);
|
|
685
|
+
} else if (aSucceeded.length > 0) {
|
|
686
|
+
showShareToast(
|
|
687
|
+
aSucceeded.length + ' shared OK, ' + aFailed.length + ' failed: ' +
|
|
688
|
+
(aFailed[0].reason?.message || 'Unknown error')
|
|
689
|
+
);
|
|
690
|
+
} else {
|
|
691
|
+
showShareToast('Share failed: ' + (aFailed[0].reason?.message || 'Unknown error'));
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
eShareConfirmBtn.textContent = 'Share';
|
|
695
|
+
eShareConfirmBtn.disabled = false;
|
|
696
|
+
closeShareModal();
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
/* ── Close Handlers ─────────────────────────────────────────── */
|
|
700
|
+
eShareCloseBtn.addEventListener('click', closeShareModal);
|
|
701
|
+
eShareCancelBtn.addEventListener('click', closeShareModal);
|
|
702
|
+
eShareBackdrop.addEventListener('click', (e) => {
|
|
703
|
+
if (e.target === eShareBackdrop) closeShareModal();
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
/* ── Toast Notification ─────────────────────────────────────── */
|
|
707
|
+
function showShareToast(sMessage) {
|
|
708
|
+
let eToast = document.querySelector('.share-toast');
|
|
709
|
+
if (!eToast) {
|
|
710
|
+
eToast = document.createElement('div');
|
|
711
|
+
eToast.className = 'share-toast';
|
|
712
|
+
document.body.appendChild(eToast);
|
|
713
|
+
}
|
|
714
|
+
eToast.textContent = sMessage;
|
|
715
|
+
eToast.classList.remove('show');
|
|
716
|
+
void eToast.offsetWidth; /* force reflow */
|
|
717
|
+
eToast.classList.add('show');
|
|
718
|
+
setTimeout(() => eToast.classList.remove('show'), 3000);
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/* ── Utilities ──────────────────────────────────────────────── */
|
|
722
|
+
function getInitials(sName) {
|
|
723
|
+
if (!sName) return '?';
|
|
724
|
+
const aParts = sName.trim().split(/\s+/);
|
|
725
|
+
if (aParts.length >= 2) return (aParts[0][0] + aParts[aParts.length - 1][0]).toUpperCase();
|
|
726
|
+
return sName.substring(0, 2).toUpperCase();
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
function escapeHtml(sStr) {
|
|
730
|
+
if (typeof sStr !== 'string') return '';
|
|
731
|
+
return sStr.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/* ── Expose openShareModal to the detail panel ──────────────── */
|
|
735
|
+
window._openShareModal = openShareModal;
|