@lv-x-software-house/x_view 1.2.7 → 1.2.8-dev.2
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/index.js +173 -111
- package/dist/index.mjs +173 -111
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2223,7 +2223,7 @@ var userActionHandlers = {
|
|
|
2223
2223
|
}
|
|
2224
2224
|
},
|
|
2225
2225
|
handleSaveNodeDetails: async (context, updatedNode, keepOpen = false) => {
|
|
2226
|
-
var _a, _b, _c;
|
|
2226
|
+
var _a, _b, _c, _d;
|
|
2227
2227
|
const { graphDataRef, sceneDataRef, stateRef, setters } = context;
|
|
2228
2228
|
if (!graphDataRef.current || !sceneDataRef.current) return;
|
|
2229
2229
|
const {
|
|
@@ -2350,23 +2350,40 @@ var userActionHandlers = {
|
|
|
2350
2350
|
...nodeToSave
|
|
2351
2351
|
};
|
|
2352
2352
|
}
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2353
|
+
if (nodeToSave.is_quest && context.actions.save_quest_action) {
|
|
2354
|
+
await context.actions.save_quest_action(context.ownerId, context.sceneConfigId, nodeToSave, sceneDataRef.current.quest_counter);
|
|
2355
|
+
if (isNewDone && ((_d = nodeToSave.recurrence_config) == null ? void 0 : _d.enabled)) {
|
|
2356
|
+
const createdRecurrenceQuest = specificParentData.nodes[specificParentData.nodes.length - 1];
|
|
2357
|
+
if (createdRecurrenceQuest && String(createdRecurrenceQuest.id) !== String(nodeToSave.id)) {
|
|
2358
|
+
await context.actions.save_quest_action(context.ownerId, context.sceneConfigId, createdRecurrenceQuest, sceneDataRef.current.quest_counter);
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
const viewFilePayload = {
|
|
2362
|
+
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
2363
|
+
nodes: sceneDataRef.current.nodes,
|
|
2364
|
+
links: sceneDataRef.current.links,
|
|
2365
|
+
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
2366
|
+
};
|
|
2367
|
+
await context.actions.save_view_data(context.sceneSaveUrl, viewFilePayload);
|
|
2368
|
+
} else {
|
|
2369
|
+
const viewFilePayload = {
|
|
2370
|
+
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
2371
|
+
nodes: sceneDataRef.current.nodes,
|
|
2372
|
+
links: sceneDataRef.current.links,
|
|
2373
|
+
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
2374
|
+
};
|
|
2375
|
+
const questFilePayload = {
|
|
2376
|
+
nodes: specificParentData.nodes,
|
|
2377
|
+
links: specificParentData.links,
|
|
2378
|
+
milestones: sceneDataRef.current.milestones || []
|
|
2379
|
+
};
|
|
2380
|
+
await context.actions.save_view_data(
|
|
2381
|
+
context.sceneSaveUrl,
|
|
2382
|
+
viewFilePayload
|
|
2383
|
+
);
|
|
2384
|
+
const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
|
|
2385
|
+
await context.actions.save_view_data(questSaveUrl, questFilePayload);
|
|
2386
|
+
}
|
|
2370
2387
|
} else {
|
|
2371
2388
|
const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
|
|
2372
2389
|
await context.actions.save_view_data(
|
|
@@ -15477,7 +15494,14 @@ function XViewScene({
|
|
|
15477
15494
|
check_user_permission,
|
|
15478
15495
|
get_view_members,
|
|
15479
15496
|
create_google_doc_action,
|
|
15480
|
-
open_google_picker_action
|
|
15497
|
+
open_google_picker_action,
|
|
15498
|
+
// Firestore Atomic Actions (Quests & Milestones)
|
|
15499
|
+
save_quest_action,
|
|
15500
|
+
delete_quest_action,
|
|
15501
|
+
save_quest_link_action,
|
|
15502
|
+
delete_quest_link_action,
|
|
15503
|
+
save_milestone_action,
|
|
15504
|
+
delete_milestone_action
|
|
15481
15505
|
}) {
|
|
15482
15506
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
15483
15507
|
const { data: session, status } = (0, import_react34.useSession)();
|
|
@@ -17984,7 +18008,13 @@ function XViewScene({
|
|
|
17984
18008
|
get_single_parent_file,
|
|
17985
18009
|
get_scene_view_data,
|
|
17986
18010
|
upload_file: upload_file_action,
|
|
17987
|
-
delete_file: delete_file_action
|
|
18011
|
+
delete_file: delete_file_action,
|
|
18012
|
+
save_quest_action,
|
|
18013
|
+
delete_quest_action,
|
|
18014
|
+
save_quest_link_action,
|
|
18015
|
+
delete_quest_link_action,
|
|
18016
|
+
save_milestone_action,
|
|
18017
|
+
delete_milestone_action
|
|
17988
18018
|
}
|
|
17989
18019
|
};
|
|
17990
18020
|
},
|
|
@@ -18003,7 +18033,13 @@ function XViewScene({
|
|
|
18003
18033
|
get_single_parent_file,
|
|
18004
18034
|
get_scene_view_data,
|
|
18005
18035
|
upload_file_action,
|
|
18006
|
-
delete_file_action
|
|
18036
|
+
delete_file_action,
|
|
18037
|
+
save_quest_action,
|
|
18038
|
+
delete_quest_action,
|
|
18039
|
+
save_quest_link_action,
|
|
18040
|
+
delete_quest_link_action,
|
|
18041
|
+
save_milestone_action,
|
|
18042
|
+
delete_milestone_action
|
|
18007
18043
|
]
|
|
18008
18044
|
);
|
|
18009
18045
|
const handleStartVersioning = (nodeData) => {
|
|
@@ -18209,26 +18245,28 @@ function XViewScene({
|
|
|
18209
18245
|
parentDataRef.current[sceneConfigId].nodes[parentIndex].quest_abstraction_tree = formattedAbstractionTree;
|
|
18210
18246
|
}
|
|
18211
18247
|
}
|
|
18212
|
-
|
|
18213
|
-
|
|
18214
|
-
|
|
18215
|
-
|
|
18216
|
-
|
|
18217
|
-
|
|
18218
|
-
|
|
18219
|
-
|
|
18220
|
-
|
|
18221
|
-
|
|
18222
|
-
|
|
18223
|
-
|
|
18224
|
-
|
|
18225
|
-
|
|
18226
|
-
|
|
18227
|
-
|
|
18228
|
-
|
|
18229
|
-
|
|
18230
|
-
|
|
18231
|
-
|
|
18248
|
+
if (save_quest_action) {
|
|
18249
|
+
const updatedNodeData2 = sceneData.quest_nodes[questIndex];
|
|
18250
|
+
await save_quest_action(ownerId, sceneConfigId, updatedNodeData2, sceneData.quest_counter || 1);
|
|
18251
|
+
} else {
|
|
18252
|
+
const sceneFileData = {
|
|
18253
|
+
...sceneData,
|
|
18254
|
+
nodes: sceneData.nodes || [],
|
|
18255
|
+
links: sceneData.links || [],
|
|
18256
|
+
quest_counter: sceneData.quest_counter || 1
|
|
18257
|
+
};
|
|
18258
|
+
const questFileData = {
|
|
18259
|
+
nodes: sceneData.quest_nodes || [],
|
|
18260
|
+
links: sceneData.quest_links || [],
|
|
18261
|
+
milestones: sceneData.milestones || []
|
|
18262
|
+
};
|
|
18263
|
+
await save_view_data(sceneSaveUrl, sceneFileData);
|
|
18264
|
+
const questSaveUrl = sceneSaveUrl.replace(
|
|
18265
|
+
"x_view_scenes",
|
|
18266
|
+
"x_view_quests"
|
|
18267
|
+
);
|
|
18268
|
+
await save_view_data(questSaveUrl, questFileData);
|
|
18269
|
+
}
|
|
18232
18270
|
}
|
|
18233
18271
|
const updatedNodeData = sceneData.quest_nodes[questIndex];
|
|
18234
18272
|
const nodeMesh = (_a2 = stateRef.current.nodeObjects) == null ? void 0 : _a2[String(questNodeId)];
|
|
@@ -18309,18 +18347,20 @@ function XViewScene({
|
|
|
18309
18347
|
...sceneDataRef2.current,
|
|
18310
18348
|
quest_counter: currentCounter + 1
|
|
18311
18349
|
};
|
|
18312
|
-
delete sceneFileData.quest_nodes;
|
|
18313
|
-
delete sceneFileData.quest_links;
|
|
18314
|
-
delete sceneFileData.milestones;
|
|
18315
|
-
const questFileData = {
|
|
18316
|
-
nodes: graphDataRef2.current[sceneConfigId2].nodes,
|
|
18317
|
-
links: graphDataRef2.current[sceneConfigId2].links,
|
|
18318
|
-
milestones: sceneDataRef2.current.milestones || []
|
|
18319
|
-
};
|
|
18320
18350
|
try {
|
|
18321
|
-
|
|
18322
|
-
|
|
18323
|
-
|
|
18351
|
+
if (actions.save_quest_action) {
|
|
18352
|
+
await actions.save_quest_action(ownerId2, sceneConfigId2, newNode, currentCounter + 1);
|
|
18353
|
+
await actions.save_view_data(sceneSaveUrl2, sceneFileData);
|
|
18354
|
+
} else {
|
|
18355
|
+
const questFileData = {
|
|
18356
|
+
nodes: graphDataRef2.current[sceneConfigId2].nodes,
|
|
18357
|
+
links: graphDataRef2.current[sceneConfigId2].links,
|
|
18358
|
+
milestones: sceneDataRef2.current.milestones || []
|
|
18359
|
+
};
|
|
18360
|
+
await actions.save_view_data(sceneSaveUrl2, sceneFileData);
|
|
18361
|
+
const questSaveUrl = sceneSaveUrl2.replace("x_view_scenes", "x_view_quests");
|
|
18362
|
+
await actions.save_view_data(questSaveUrl, questFileData);
|
|
18363
|
+
}
|
|
18324
18364
|
sceneDataRef2.current.quest_counter = currentCounter + 1;
|
|
18325
18365
|
stateRef2.current.nodeIdToParentFileMap.set(String(newNode.id), {
|
|
18326
18366
|
parentFileId: sceneConfigId2,
|
|
@@ -18396,24 +18436,25 @@ function XViewScene({
|
|
|
18396
18436
|
if (parentFileIdToSave === sceneConfigId2) {
|
|
18397
18437
|
const specificParentData = graphDataRef2.current[sceneConfigId2];
|
|
18398
18438
|
specificParentData.links.push(newLink);
|
|
18399
|
-
|
|
18400
|
-
|
|
18401
|
-
|
|
18402
|
-
|
|
18403
|
-
|
|
18404
|
-
|
|
18405
|
-
|
|
18406
|
-
|
|
18407
|
-
|
|
18408
|
-
|
|
18409
|
-
|
|
18410
|
-
|
|
18411
|
-
|
|
18412
|
-
|
|
18413
|
-
|
|
18414
|
-
|
|
18415
|
-
|
|
18416
|
-
|
|
18439
|
+
if (context.actions.save_quest_link_action && (isSourceQuest || isTargetQuest)) {
|
|
18440
|
+
await context.actions.save_quest_link_action(ownerId2, sceneConfigId2, newLink);
|
|
18441
|
+
} else {
|
|
18442
|
+
const viewFilePayload = {
|
|
18443
|
+
...sceneDataRef2.current,
|
|
18444
|
+
quest_counter: sceneDataRef2.current.quest_counter || 1
|
|
18445
|
+
};
|
|
18446
|
+
const questFilePayload = {
|
|
18447
|
+
nodes: specificParentData.nodes,
|
|
18448
|
+
links: specificParentData.links,
|
|
18449
|
+
milestones: sceneDataRef2.current.milestones || []
|
|
18450
|
+
};
|
|
18451
|
+
await context.actions.save_view_data(sceneSaveUrl2, viewFilePayload);
|
|
18452
|
+
const questSaveUrl = sceneSaveUrl2.replace(
|
|
18453
|
+
"x_view_scenes",
|
|
18454
|
+
"x_view_quests"
|
|
18455
|
+
);
|
|
18456
|
+
await context.actions.save_view_data(questSaveUrl, questFilePayload);
|
|
18457
|
+
}
|
|
18417
18458
|
} else {
|
|
18418
18459
|
const specificParentData = JSON.parse(
|
|
18419
18460
|
JSON.stringify(graphDataRef2.current[parentFileIdToSave])
|
|
@@ -20121,36 +20162,58 @@ function XViewScene({
|
|
|
20121
20162
|
async (newMilestones) => {
|
|
20122
20163
|
var _a2, _b2, _c2;
|
|
20123
20164
|
if (!sceneDataRef.current) return;
|
|
20165
|
+
const oldMilestones = sceneDataRef.current.milestones || [];
|
|
20166
|
+
const removedMilestones = oldMilestones.filter(
|
|
20167
|
+
(oldM) => !newMilestones.some((newM) => String(newM.id) === String(oldM.id))
|
|
20168
|
+
);
|
|
20169
|
+
const addedOrUpdatedMilestones = newMilestones.filter(
|
|
20170
|
+
(newM) => !oldMilestones.some((oldM) => JSON.stringify(oldM) === JSON.stringify(newM))
|
|
20171
|
+
);
|
|
20124
20172
|
sceneDataRef.current.milestones = newMilestones;
|
|
20125
20173
|
setSceneVersion((v) => v + 1);
|
|
20126
20174
|
const isView = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
|
|
20127
20175
|
if (!isView || !save_view_data || !sceneSaveUrl) return;
|
|
20128
|
-
const sceneFileData = {
|
|
20129
|
-
...sceneDataRef.current,
|
|
20130
|
-
nodes: sceneDataRef.current.nodes || [],
|
|
20131
|
-
links: sceneDataRef.current.links || [],
|
|
20132
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20133
|
-
};
|
|
20134
|
-
delete sceneFileData.quest_nodes;
|
|
20135
|
-
delete sceneFileData.quest_links;
|
|
20136
|
-
delete sceneFileData.milestones;
|
|
20137
|
-
const questFileData = {
|
|
20138
|
-
nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
|
|
20139
|
-
links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
|
|
20140
|
-
milestones: newMilestones
|
|
20141
|
-
};
|
|
20142
20176
|
try {
|
|
20143
|
-
|
|
20144
|
-
|
|
20145
|
-
|
|
20146
|
-
|
|
20147
|
-
|
|
20148
|
-
|
|
20177
|
+
if (save_milestone_action) {
|
|
20178
|
+
const promises = [];
|
|
20179
|
+
if (delete_milestone_action) {
|
|
20180
|
+
removedMilestones.forEach((m) => promises.push(delete_milestone_action(ownerId, sceneConfigId, m.id)));
|
|
20181
|
+
}
|
|
20182
|
+
if (addedOrUpdatedMilestones.length > 0) {
|
|
20183
|
+
addedOrUpdatedMilestones.forEach((m) => promises.push(save_milestone_action(ownerId, sceneConfigId, m)));
|
|
20184
|
+
}
|
|
20185
|
+
await Promise.all(promises);
|
|
20186
|
+
const sceneFileData = {
|
|
20187
|
+
...sceneDataRef.current,
|
|
20188
|
+
nodes: sceneDataRef.current.nodes || [],
|
|
20189
|
+
links: sceneDataRef.current.links || [],
|
|
20190
|
+
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20191
|
+
};
|
|
20192
|
+
await save_view_data(sceneSaveUrl, sceneFileData);
|
|
20193
|
+
} else {
|
|
20194
|
+
const sceneFileData = {
|
|
20195
|
+
...sceneDataRef.current,
|
|
20196
|
+
nodes: sceneDataRef.current.nodes || [],
|
|
20197
|
+
links: sceneDataRef.current.links || [],
|
|
20198
|
+
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20199
|
+
};
|
|
20200
|
+
const questFileData = {
|
|
20201
|
+
nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
|
|
20202
|
+
links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
|
|
20203
|
+
milestones: newMilestones
|
|
20204
|
+
};
|
|
20205
|
+
await save_view_data(sceneSaveUrl, sceneFileData);
|
|
20206
|
+
const questSaveUrl = sceneSaveUrl.replace(
|
|
20207
|
+
"x_view_scenes",
|
|
20208
|
+
"x_view_quests"
|
|
20209
|
+
);
|
|
20210
|
+
await save_view_data(questSaveUrl, questFileData);
|
|
20211
|
+
}
|
|
20149
20212
|
} catch (error) {
|
|
20150
20213
|
console.error("Erro ao salvar milestones:", error);
|
|
20151
20214
|
}
|
|
20152
20215
|
},
|
|
20153
|
-
[sceneConfigId, sceneSaveUrl, save_view_data, viewParams == null ? void 0 : viewParams.type]
|
|
20216
|
+
[sceneConfigId, sceneSaveUrl, save_view_data, save_milestone_action, delete_milestone_action, viewParams == null ? void 0 : viewParams.type]
|
|
20154
20217
|
);
|
|
20155
20218
|
const handleSaveCurrentView = (0, import_react33.useCallback)(async () => {
|
|
20156
20219
|
var _a2, _b2, _c2;
|
|
@@ -20186,9 +20249,6 @@ function XViewScene({
|
|
|
20186
20249
|
links: currentLinks,
|
|
20187
20250
|
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20188
20251
|
};
|
|
20189
|
-
delete sceneFileData.quest_nodes;
|
|
20190
|
-
delete sceneFileData.quest_links;
|
|
20191
|
-
delete sceneFileData.milestones;
|
|
20192
20252
|
const questFileData = {
|
|
20193
20253
|
nodes: isView ? ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || [] : sceneDataRef.current.quest_nodes || [],
|
|
20194
20254
|
links: isView ? ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || [] : sceneDataRef.current.quest_links || [],
|
|
@@ -21059,7 +21119,7 @@ async function save_view_data_logic(db_services, filename, data) {
|
|
|
21059
21119
|
}
|
|
21060
21120
|
}
|
|
21061
21121
|
async function get_scene_view_data_logic(db_services, scene_config, owner_id, type, session, focusNodeId = null, focusAncestryId = null) {
|
|
21062
|
-
var _a, _b
|
|
21122
|
+
var _a, _b;
|
|
21063
21123
|
try {
|
|
21064
21124
|
if (!session || !session.user) {
|
|
21065
21125
|
return { success: false, error: "Usu\xE1rio n\xE3o autenticado." };
|
|
@@ -21086,35 +21146,37 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21086
21146
|
const parentResponsesPromises = parentDbObjects.map(
|
|
21087
21147
|
(db_info) => db_services.get_file(`x_view_dbs/${db_info.owner_id}/${db_info.db_id}`)
|
|
21088
21148
|
);
|
|
21089
|
-
if (isView) {
|
|
21090
|
-
parentResponsesPromises.push(
|
|
21091
|
-
db_services.get_file(`x_view_quests/${owner_id}/${scene_config}`)
|
|
21092
|
-
);
|
|
21093
|
-
}
|
|
21094
21149
|
const parentResponsesResults = await Promise.allSettled(parentResponsesPromises);
|
|
21095
21150
|
const parentData = {};
|
|
21096
21151
|
let questDataObj = null;
|
|
21097
21152
|
for (let i = 0; i < parentResponsesResults.length; i++) {
|
|
21098
21153
|
const result = parentResponsesResults[i];
|
|
21099
|
-
if (isView && i === parentResponsesResults.length - 1) {
|
|
21100
|
-
if (result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.success)) {
|
|
21101
|
-
questDataObj = result.value.data;
|
|
21102
|
-
}
|
|
21103
|
-
continue;
|
|
21104
|
-
}
|
|
21105
21154
|
const db_info = parentDbObjects[i];
|
|
21106
|
-
if (result.status === "fulfilled" && ((
|
|
21155
|
+
if (result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.success)) {
|
|
21107
21156
|
parentData[db_info.db_id] = result.value.data;
|
|
21108
21157
|
} else {
|
|
21109
21158
|
console.warn(
|
|
21110
21159
|
`Arquivo pai n\xE3o carregado: ${db_info.db_id}. Pode ter sido deletado.`,
|
|
21111
|
-
result.status === "rejected" ? result.reason : (
|
|
21160
|
+
result.status === "rejected" ? result.reason : (_b = result.value) == null ? void 0 : _b.error
|
|
21112
21161
|
);
|
|
21113
21162
|
}
|
|
21114
21163
|
}
|
|
21115
|
-
|
|
21116
|
-
|
|
21117
|
-
|
|
21164
|
+
if (isView) {
|
|
21165
|
+
if (db_services.get_x_view_quests_data) {
|
|
21166
|
+
const questDataRes = await db_services.get_x_view_quests_data(session, owner_id, scene_config);
|
|
21167
|
+
if (questDataRes && questDataRes.success) {
|
|
21168
|
+
questDataObj = questDataRes.data;
|
|
21169
|
+
}
|
|
21170
|
+
} else {
|
|
21171
|
+
const questDataRes = await db_services.get_file(`x_view_quests/${owner_id}/${scene_config}`);
|
|
21172
|
+
if (questDataRes && questDataRes.success) {
|
|
21173
|
+
questDataObj = questDataRes.data;
|
|
21174
|
+
}
|
|
21175
|
+
}
|
|
21176
|
+
}
|
|
21177
|
+
const currentQuestNodes = (questDataObj == null ? void 0 : questDataObj.nodes) || [];
|
|
21178
|
+
const currentQuestLinks = (questDataObj == null ? void 0 : questDataObj.links) || [];
|
|
21179
|
+
const currentMilestones = (questDataObj == null ? void 0 : questDataObj.milestones) || [];
|
|
21118
21180
|
if (isView) {
|
|
21119
21181
|
parentData[scene_config] = {
|
|
21120
21182
|
dataset_name: "Quests Internas (View)",
|
package/dist/index.mjs
CHANGED
|
@@ -2184,7 +2184,7 @@ var userActionHandlers = {
|
|
|
2184
2184
|
}
|
|
2185
2185
|
},
|
|
2186
2186
|
handleSaveNodeDetails: async (context, updatedNode, keepOpen = false) => {
|
|
2187
|
-
var _a, _b, _c;
|
|
2187
|
+
var _a, _b, _c, _d;
|
|
2188
2188
|
const { graphDataRef, sceneDataRef, stateRef, setters } = context;
|
|
2189
2189
|
if (!graphDataRef.current || !sceneDataRef.current) return;
|
|
2190
2190
|
const {
|
|
@@ -2311,23 +2311,40 @@ var userActionHandlers = {
|
|
|
2311
2311
|
...nodeToSave
|
|
2312
2312
|
};
|
|
2313
2313
|
}
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2314
|
+
if (nodeToSave.is_quest && context.actions.save_quest_action) {
|
|
2315
|
+
await context.actions.save_quest_action(context.ownerId, context.sceneConfigId, nodeToSave, sceneDataRef.current.quest_counter);
|
|
2316
|
+
if (isNewDone && ((_d = nodeToSave.recurrence_config) == null ? void 0 : _d.enabled)) {
|
|
2317
|
+
const createdRecurrenceQuest = specificParentData.nodes[specificParentData.nodes.length - 1];
|
|
2318
|
+
if (createdRecurrenceQuest && String(createdRecurrenceQuest.id) !== String(nodeToSave.id)) {
|
|
2319
|
+
await context.actions.save_quest_action(context.ownerId, context.sceneConfigId, createdRecurrenceQuest, sceneDataRef.current.quest_counter);
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
const viewFilePayload = {
|
|
2323
|
+
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
2324
|
+
nodes: sceneDataRef.current.nodes,
|
|
2325
|
+
links: sceneDataRef.current.links,
|
|
2326
|
+
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
2327
|
+
};
|
|
2328
|
+
await context.actions.save_view_data(context.sceneSaveUrl, viewFilePayload);
|
|
2329
|
+
} else {
|
|
2330
|
+
const viewFilePayload = {
|
|
2331
|
+
parent_dbs: sceneDataRef.current.parent_dbs,
|
|
2332
|
+
nodes: sceneDataRef.current.nodes,
|
|
2333
|
+
links: sceneDataRef.current.links,
|
|
2334
|
+
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
2335
|
+
};
|
|
2336
|
+
const questFilePayload = {
|
|
2337
|
+
nodes: specificParentData.nodes,
|
|
2338
|
+
links: specificParentData.links,
|
|
2339
|
+
milestones: sceneDataRef.current.milestones || []
|
|
2340
|
+
};
|
|
2341
|
+
await context.actions.save_view_data(
|
|
2342
|
+
context.sceneSaveUrl,
|
|
2343
|
+
viewFilePayload
|
|
2344
|
+
);
|
|
2345
|
+
const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
|
|
2346
|
+
await context.actions.save_view_data(questSaveUrl, questFilePayload);
|
|
2347
|
+
}
|
|
2331
2348
|
} else {
|
|
2332
2349
|
const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
|
|
2333
2350
|
await context.actions.save_view_data(
|
|
@@ -15540,7 +15557,14 @@ function XViewScene({
|
|
|
15540
15557
|
check_user_permission,
|
|
15541
15558
|
get_view_members,
|
|
15542
15559
|
create_google_doc_action,
|
|
15543
|
-
open_google_picker_action
|
|
15560
|
+
open_google_picker_action,
|
|
15561
|
+
// Firestore Atomic Actions (Quests & Milestones)
|
|
15562
|
+
save_quest_action,
|
|
15563
|
+
delete_quest_action,
|
|
15564
|
+
save_quest_link_action,
|
|
15565
|
+
delete_quest_link_action,
|
|
15566
|
+
save_milestone_action,
|
|
15567
|
+
delete_milestone_action
|
|
15544
15568
|
}) {
|
|
15545
15569
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
15546
15570
|
const { data: session, status } = useSession();
|
|
@@ -18047,7 +18071,13 @@ function XViewScene({
|
|
|
18047
18071
|
get_single_parent_file,
|
|
18048
18072
|
get_scene_view_data,
|
|
18049
18073
|
upload_file: upload_file_action,
|
|
18050
|
-
delete_file: delete_file_action
|
|
18074
|
+
delete_file: delete_file_action,
|
|
18075
|
+
save_quest_action,
|
|
18076
|
+
delete_quest_action,
|
|
18077
|
+
save_quest_link_action,
|
|
18078
|
+
delete_quest_link_action,
|
|
18079
|
+
save_milestone_action,
|
|
18080
|
+
delete_milestone_action
|
|
18051
18081
|
}
|
|
18052
18082
|
};
|
|
18053
18083
|
},
|
|
@@ -18066,7 +18096,13 @@ function XViewScene({
|
|
|
18066
18096
|
get_single_parent_file,
|
|
18067
18097
|
get_scene_view_data,
|
|
18068
18098
|
upload_file_action,
|
|
18069
|
-
delete_file_action
|
|
18099
|
+
delete_file_action,
|
|
18100
|
+
save_quest_action,
|
|
18101
|
+
delete_quest_action,
|
|
18102
|
+
save_quest_link_action,
|
|
18103
|
+
delete_quest_link_action,
|
|
18104
|
+
save_milestone_action,
|
|
18105
|
+
delete_milestone_action
|
|
18070
18106
|
]
|
|
18071
18107
|
);
|
|
18072
18108
|
const handleStartVersioning = (nodeData) => {
|
|
@@ -18272,26 +18308,28 @@ function XViewScene({
|
|
|
18272
18308
|
parentDataRef.current[sceneConfigId].nodes[parentIndex].quest_abstraction_tree = formattedAbstractionTree;
|
|
18273
18309
|
}
|
|
18274
18310
|
}
|
|
18275
|
-
|
|
18276
|
-
|
|
18277
|
-
|
|
18278
|
-
|
|
18279
|
-
|
|
18280
|
-
|
|
18281
|
-
|
|
18282
|
-
|
|
18283
|
-
|
|
18284
|
-
|
|
18285
|
-
|
|
18286
|
-
|
|
18287
|
-
|
|
18288
|
-
|
|
18289
|
-
|
|
18290
|
-
|
|
18291
|
-
|
|
18292
|
-
|
|
18293
|
-
|
|
18294
|
-
|
|
18311
|
+
if (save_quest_action) {
|
|
18312
|
+
const updatedNodeData2 = sceneData.quest_nodes[questIndex];
|
|
18313
|
+
await save_quest_action(ownerId, sceneConfigId, updatedNodeData2, sceneData.quest_counter || 1);
|
|
18314
|
+
} else {
|
|
18315
|
+
const sceneFileData = {
|
|
18316
|
+
...sceneData,
|
|
18317
|
+
nodes: sceneData.nodes || [],
|
|
18318
|
+
links: sceneData.links || [],
|
|
18319
|
+
quest_counter: sceneData.quest_counter || 1
|
|
18320
|
+
};
|
|
18321
|
+
const questFileData = {
|
|
18322
|
+
nodes: sceneData.quest_nodes || [],
|
|
18323
|
+
links: sceneData.quest_links || [],
|
|
18324
|
+
milestones: sceneData.milestones || []
|
|
18325
|
+
};
|
|
18326
|
+
await save_view_data(sceneSaveUrl, sceneFileData);
|
|
18327
|
+
const questSaveUrl = sceneSaveUrl.replace(
|
|
18328
|
+
"x_view_scenes",
|
|
18329
|
+
"x_view_quests"
|
|
18330
|
+
);
|
|
18331
|
+
await save_view_data(questSaveUrl, questFileData);
|
|
18332
|
+
}
|
|
18295
18333
|
}
|
|
18296
18334
|
const updatedNodeData = sceneData.quest_nodes[questIndex];
|
|
18297
18335
|
const nodeMesh = (_a2 = stateRef.current.nodeObjects) == null ? void 0 : _a2[String(questNodeId)];
|
|
@@ -18372,18 +18410,20 @@ function XViewScene({
|
|
|
18372
18410
|
...sceneDataRef2.current,
|
|
18373
18411
|
quest_counter: currentCounter + 1
|
|
18374
18412
|
};
|
|
18375
|
-
delete sceneFileData.quest_nodes;
|
|
18376
|
-
delete sceneFileData.quest_links;
|
|
18377
|
-
delete sceneFileData.milestones;
|
|
18378
|
-
const questFileData = {
|
|
18379
|
-
nodes: graphDataRef2.current[sceneConfigId2].nodes,
|
|
18380
|
-
links: graphDataRef2.current[sceneConfigId2].links,
|
|
18381
|
-
milestones: sceneDataRef2.current.milestones || []
|
|
18382
|
-
};
|
|
18383
18413
|
try {
|
|
18384
|
-
|
|
18385
|
-
|
|
18386
|
-
|
|
18414
|
+
if (actions.save_quest_action) {
|
|
18415
|
+
await actions.save_quest_action(ownerId2, sceneConfigId2, newNode, currentCounter + 1);
|
|
18416
|
+
await actions.save_view_data(sceneSaveUrl2, sceneFileData);
|
|
18417
|
+
} else {
|
|
18418
|
+
const questFileData = {
|
|
18419
|
+
nodes: graphDataRef2.current[sceneConfigId2].nodes,
|
|
18420
|
+
links: graphDataRef2.current[sceneConfigId2].links,
|
|
18421
|
+
milestones: sceneDataRef2.current.milestones || []
|
|
18422
|
+
};
|
|
18423
|
+
await actions.save_view_data(sceneSaveUrl2, sceneFileData);
|
|
18424
|
+
const questSaveUrl = sceneSaveUrl2.replace("x_view_scenes", "x_view_quests");
|
|
18425
|
+
await actions.save_view_data(questSaveUrl, questFileData);
|
|
18426
|
+
}
|
|
18387
18427
|
sceneDataRef2.current.quest_counter = currentCounter + 1;
|
|
18388
18428
|
stateRef2.current.nodeIdToParentFileMap.set(String(newNode.id), {
|
|
18389
18429
|
parentFileId: sceneConfigId2,
|
|
@@ -18459,24 +18499,25 @@ function XViewScene({
|
|
|
18459
18499
|
if (parentFileIdToSave === sceneConfigId2) {
|
|
18460
18500
|
const specificParentData = graphDataRef2.current[sceneConfigId2];
|
|
18461
18501
|
specificParentData.links.push(newLink);
|
|
18462
|
-
|
|
18463
|
-
|
|
18464
|
-
|
|
18465
|
-
|
|
18466
|
-
|
|
18467
|
-
|
|
18468
|
-
|
|
18469
|
-
|
|
18470
|
-
|
|
18471
|
-
|
|
18472
|
-
|
|
18473
|
-
|
|
18474
|
-
|
|
18475
|
-
|
|
18476
|
-
|
|
18477
|
-
|
|
18478
|
-
|
|
18479
|
-
|
|
18502
|
+
if (context.actions.save_quest_link_action && (isSourceQuest || isTargetQuest)) {
|
|
18503
|
+
await context.actions.save_quest_link_action(ownerId2, sceneConfigId2, newLink);
|
|
18504
|
+
} else {
|
|
18505
|
+
const viewFilePayload = {
|
|
18506
|
+
...sceneDataRef2.current,
|
|
18507
|
+
quest_counter: sceneDataRef2.current.quest_counter || 1
|
|
18508
|
+
};
|
|
18509
|
+
const questFilePayload = {
|
|
18510
|
+
nodes: specificParentData.nodes,
|
|
18511
|
+
links: specificParentData.links,
|
|
18512
|
+
milestones: sceneDataRef2.current.milestones || []
|
|
18513
|
+
};
|
|
18514
|
+
await context.actions.save_view_data(sceneSaveUrl2, viewFilePayload);
|
|
18515
|
+
const questSaveUrl = sceneSaveUrl2.replace(
|
|
18516
|
+
"x_view_scenes",
|
|
18517
|
+
"x_view_quests"
|
|
18518
|
+
);
|
|
18519
|
+
await context.actions.save_view_data(questSaveUrl, questFilePayload);
|
|
18520
|
+
}
|
|
18480
18521
|
} else {
|
|
18481
18522
|
const specificParentData = JSON.parse(
|
|
18482
18523
|
JSON.stringify(graphDataRef2.current[parentFileIdToSave])
|
|
@@ -20184,36 +20225,58 @@ function XViewScene({
|
|
|
20184
20225
|
async (newMilestones) => {
|
|
20185
20226
|
var _a2, _b2, _c2;
|
|
20186
20227
|
if (!sceneDataRef.current) return;
|
|
20228
|
+
const oldMilestones = sceneDataRef.current.milestones || [];
|
|
20229
|
+
const removedMilestones = oldMilestones.filter(
|
|
20230
|
+
(oldM) => !newMilestones.some((newM) => String(newM.id) === String(oldM.id))
|
|
20231
|
+
);
|
|
20232
|
+
const addedOrUpdatedMilestones = newMilestones.filter(
|
|
20233
|
+
(newM) => !oldMilestones.some((oldM) => JSON.stringify(oldM) === JSON.stringify(newM))
|
|
20234
|
+
);
|
|
20187
20235
|
sceneDataRef.current.milestones = newMilestones;
|
|
20188
20236
|
setSceneVersion((v) => v + 1);
|
|
20189
20237
|
const isView = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
|
|
20190
20238
|
if (!isView || !save_view_data || !sceneSaveUrl) return;
|
|
20191
|
-
const sceneFileData = {
|
|
20192
|
-
...sceneDataRef.current,
|
|
20193
|
-
nodes: sceneDataRef.current.nodes || [],
|
|
20194
|
-
links: sceneDataRef.current.links || [],
|
|
20195
|
-
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20196
|
-
};
|
|
20197
|
-
delete sceneFileData.quest_nodes;
|
|
20198
|
-
delete sceneFileData.quest_links;
|
|
20199
|
-
delete sceneFileData.milestones;
|
|
20200
|
-
const questFileData = {
|
|
20201
|
-
nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
|
|
20202
|
-
links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
|
|
20203
|
-
milestones: newMilestones
|
|
20204
|
-
};
|
|
20205
20239
|
try {
|
|
20206
|
-
|
|
20207
|
-
|
|
20208
|
-
|
|
20209
|
-
|
|
20210
|
-
|
|
20211
|
-
|
|
20240
|
+
if (save_milestone_action) {
|
|
20241
|
+
const promises = [];
|
|
20242
|
+
if (delete_milestone_action) {
|
|
20243
|
+
removedMilestones.forEach((m) => promises.push(delete_milestone_action(ownerId, sceneConfigId, m.id)));
|
|
20244
|
+
}
|
|
20245
|
+
if (addedOrUpdatedMilestones.length > 0) {
|
|
20246
|
+
addedOrUpdatedMilestones.forEach((m) => promises.push(save_milestone_action(ownerId, sceneConfigId, m)));
|
|
20247
|
+
}
|
|
20248
|
+
await Promise.all(promises);
|
|
20249
|
+
const sceneFileData = {
|
|
20250
|
+
...sceneDataRef.current,
|
|
20251
|
+
nodes: sceneDataRef.current.nodes || [],
|
|
20252
|
+
links: sceneDataRef.current.links || [],
|
|
20253
|
+
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20254
|
+
};
|
|
20255
|
+
await save_view_data(sceneSaveUrl, sceneFileData);
|
|
20256
|
+
} else {
|
|
20257
|
+
const sceneFileData = {
|
|
20258
|
+
...sceneDataRef.current,
|
|
20259
|
+
nodes: sceneDataRef.current.nodes || [],
|
|
20260
|
+
links: sceneDataRef.current.links || [],
|
|
20261
|
+
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20262
|
+
};
|
|
20263
|
+
const questFileData = {
|
|
20264
|
+
nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
|
|
20265
|
+
links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
|
|
20266
|
+
milestones: newMilestones
|
|
20267
|
+
};
|
|
20268
|
+
await save_view_data(sceneSaveUrl, sceneFileData);
|
|
20269
|
+
const questSaveUrl = sceneSaveUrl.replace(
|
|
20270
|
+
"x_view_scenes",
|
|
20271
|
+
"x_view_quests"
|
|
20272
|
+
);
|
|
20273
|
+
await save_view_data(questSaveUrl, questFileData);
|
|
20274
|
+
}
|
|
20212
20275
|
} catch (error) {
|
|
20213
20276
|
console.error("Erro ao salvar milestones:", error);
|
|
20214
20277
|
}
|
|
20215
20278
|
},
|
|
20216
|
-
[sceneConfigId, sceneSaveUrl, save_view_data, viewParams == null ? void 0 : viewParams.type]
|
|
20279
|
+
[sceneConfigId, sceneSaveUrl, save_view_data, save_milestone_action, delete_milestone_action, viewParams == null ? void 0 : viewParams.type]
|
|
20217
20280
|
);
|
|
20218
20281
|
const handleSaveCurrentView = useCallback7(async () => {
|
|
20219
20282
|
var _a2, _b2, _c2;
|
|
@@ -20249,9 +20312,6 @@ function XViewScene({
|
|
|
20249
20312
|
links: currentLinks,
|
|
20250
20313
|
quest_counter: sceneDataRef.current.quest_counter || 1
|
|
20251
20314
|
};
|
|
20252
|
-
delete sceneFileData.quest_nodes;
|
|
20253
|
-
delete sceneFileData.quest_links;
|
|
20254
|
-
delete sceneFileData.milestones;
|
|
20255
20315
|
const questFileData = {
|
|
20256
20316
|
nodes: isView ? ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || [] : sceneDataRef.current.quest_nodes || [],
|
|
20257
20317
|
links: isView ? ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || [] : sceneDataRef.current.quest_links || [],
|
|
@@ -21122,7 +21182,7 @@ async function save_view_data_logic(db_services, filename, data) {
|
|
|
21122
21182
|
}
|
|
21123
21183
|
}
|
|
21124
21184
|
async function get_scene_view_data_logic(db_services, scene_config, owner_id, type, session, focusNodeId = null, focusAncestryId = null) {
|
|
21125
|
-
var _a, _b
|
|
21185
|
+
var _a, _b;
|
|
21126
21186
|
try {
|
|
21127
21187
|
if (!session || !session.user) {
|
|
21128
21188
|
return { success: false, error: "Usu\xE1rio n\xE3o autenticado." };
|
|
@@ -21149,35 +21209,37 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
|
|
|
21149
21209
|
const parentResponsesPromises = parentDbObjects.map(
|
|
21150
21210
|
(db_info) => db_services.get_file(`x_view_dbs/${db_info.owner_id}/${db_info.db_id}`)
|
|
21151
21211
|
);
|
|
21152
|
-
if (isView) {
|
|
21153
|
-
parentResponsesPromises.push(
|
|
21154
|
-
db_services.get_file(`x_view_quests/${owner_id}/${scene_config}`)
|
|
21155
|
-
);
|
|
21156
|
-
}
|
|
21157
21212
|
const parentResponsesResults = await Promise.allSettled(parentResponsesPromises);
|
|
21158
21213
|
const parentData = {};
|
|
21159
21214
|
let questDataObj = null;
|
|
21160
21215
|
for (let i = 0; i < parentResponsesResults.length; i++) {
|
|
21161
21216
|
const result = parentResponsesResults[i];
|
|
21162
|
-
if (isView && i === parentResponsesResults.length - 1) {
|
|
21163
|
-
if (result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.success)) {
|
|
21164
|
-
questDataObj = result.value.data;
|
|
21165
|
-
}
|
|
21166
|
-
continue;
|
|
21167
|
-
}
|
|
21168
21217
|
const db_info = parentDbObjects[i];
|
|
21169
|
-
if (result.status === "fulfilled" && ((
|
|
21218
|
+
if (result.status === "fulfilled" && ((_a = result.value) == null ? void 0 : _a.success)) {
|
|
21170
21219
|
parentData[db_info.db_id] = result.value.data;
|
|
21171
21220
|
} else {
|
|
21172
21221
|
console.warn(
|
|
21173
21222
|
`Arquivo pai n\xE3o carregado: ${db_info.db_id}. Pode ter sido deletado.`,
|
|
21174
|
-
result.status === "rejected" ? result.reason : (
|
|
21223
|
+
result.status === "rejected" ? result.reason : (_b = result.value) == null ? void 0 : _b.error
|
|
21175
21224
|
);
|
|
21176
21225
|
}
|
|
21177
21226
|
}
|
|
21178
|
-
|
|
21179
|
-
|
|
21180
|
-
|
|
21227
|
+
if (isView) {
|
|
21228
|
+
if (db_services.get_x_view_quests_data) {
|
|
21229
|
+
const questDataRes = await db_services.get_x_view_quests_data(session, owner_id, scene_config);
|
|
21230
|
+
if (questDataRes && questDataRes.success) {
|
|
21231
|
+
questDataObj = questDataRes.data;
|
|
21232
|
+
}
|
|
21233
|
+
} else {
|
|
21234
|
+
const questDataRes = await db_services.get_file(`x_view_quests/${owner_id}/${scene_config}`);
|
|
21235
|
+
if (questDataRes && questDataRes.success) {
|
|
21236
|
+
questDataObj = questDataRes.data;
|
|
21237
|
+
}
|
|
21238
|
+
}
|
|
21239
|
+
}
|
|
21240
|
+
const currentQuestNodes = (questDataObj == null ? void 0 : questDataObj.nodes) || [];
|
|
21241
|
+
const currentQuestLinks = (questDataObj == null ? void 0 : questDataObj.links) || [];
|
|
21242
|
+
const currentMilestones = (questDataObj == null ? void 0 : questDataObj.milestones) || [];
|
|
21181
21243
|
if (isView) {
|
|
21182
21244
|
parentData[scene_config] = {
|
|
21183
21245
|
dataset_name: "Quests Internas (View)",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lv-x-software-house/x_view",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8-dev.2",
|
|
4
4
|
"description": "Pacote privado contendo os componentes e lógica de renderização 3D do X View.",
|
|
5
5
|
"author": "iv.x - Engenharia de Software - ivxsoftwarehouse@gmail.com",
|
|
6
6
|
"license": "UNLICENSED",
|