architwin 1.12.4 → 1.13.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/CORE_FEATURES.md +35 -0
- package/ONBOARDING.md +115 -0
- package/lib/architwin.d.ts +98 -6
- package/lib/architwin.js +1 -1
- package/lib/atwinui/components/toolbar/collapse.d.ts +18 -0
- package/lib/atwinui/components/toolbar/collapse.js +62 -0
- package/lib/atwinui/components/toolbar/i18n.js +52 -2
- package/lib/atwinui/components/toolbar/index.js +11 -1
- package/lib/atwinui/components/toolbar/menuBar.d.ts +1 -0
- package/lib/atwinui/components/toolbar/menuBar.js +11 -0
- package/lib/atwinui/components/toolbar/pipeFormPane.d.ts +31 -0
- package/lib/atwinui/components/toolbar/pipeFormPane.js +545 -0
- package/lib/atwinui/components/toolbar/pipeListPane.d.ts +19 -0
- package/lib/atwinui/components/toolbar/pipeListPane.js +388 -0
- package/lib/atwinui/components/toolbar/spaceUserListPane.d.ts +3 -0
- package/lib/atwinui/components/toolbar/spaceUserListPane.js +95 -0
- package/lib/atwinui/components/toolbar/tagIotForm.d.ts +20 -0
- package/lib/atwinui/components/toolbar/tagIotForm.js +391 -0
- package/lib/atwinui/components/toolbar/tagIotFormPane.d.ts +62 -0
- package/lib/atwinui/components/toolbar/tagIotFormPane.js +606 -0
- package/lib/atwinui/components/toolbar/tagMessagingPane.d.ts +4 -0
- package/lib/atwinui/components/toolbar/tagMessagingPane.js +117 -10
- package/lib/atwinui/components/toolbar/usersPane.d.ts +14 -0
- package/lib/atwinui/components/toolbar/usersPane.js +273 -0
- package/lib/atwinui/components/toolbar/viewingRemoteSpace.d.ts +7 -0
- package/lib/atwinui/components/toolbar/viewingRemoteSpace.js +77 -0
- package/lib/atwinui/events.d.ts +4 -1
- package/lib/atwinui/events.js +106 -26
- package/lib/atwinui/helpers.d.ts +15 -0
- package/lib/atwinui/helpers.js +49 -0
- package/lib/atwinui/index.js +2 -0
- package/lib/loaders/curosrMarkerLoader.d.ts +25 -0
- package/lib/loaders/curosrMarkerLoader.js +86 -0
- package/lib/loaders/index.d.ts +2 -1
- package/lib/loaders/index.js +2 -1
- package/lib/loaders/pathLoader.d.ts +99 -0
- package/lib/loaders/pathLoader.js +451 -0
- package/lib/tag.d.ts +1 -1
- package/lib/tag.js +2 -0
- package/lib/types.d.ts +80 -1
- package/lib/types.js +35 -0
- package/package.json +1 -1
- package/static/atwinui.css +267 -0
- package/static/utility.css +81 -1
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { _3DXObjects, _pipeCategories, _pipes, _selectedPipe, _selectedPipeCategory, cancelDraw, dispatchSpaceEvent, disposeModel, enableVerticeControls, getCurrentCameraPose, moveToSweep, redoDrawAction, renderPath, setModelVisibility, setPathLineOptions, setPipeCategories, setPipeIsDrawingMode, setPipes, startDraw, undoDrawAction } from "../../../architwin";
|
|
11
|
+
import i18n from './i18n';
|
|
12
|
+
import { COLLAPSE, SPACE_EVENTS } from "../../../types";
|
|
13
|
+
import { Collapse } from "./collapse";
|
|
14
|
+
import { notyf, toggleDisplayPane } from "../../events";
|
|
15
|
+
import { observeInputToUpdate, waitForChange } from "../../helpers";
|
|
16
|
+
import { getShortcutTooltipHTML } from "./static/common";
|
|
17
|
+
import { setModalAction, toggleModal } from "./modal";
|
|
18
|
+
export class PipeForm {
|
|
19
|
+
// Initialize collapse UI and color category
|
|
20
|
+
constructor() {
|
|
21
|
+
this.category = {};
|
|
22
|
+
this.collapse = new Collapse(undefined);
|
|
23
|
+
this.colorCategory = ['dark-red', 'red', 'amber', 'light-chartreuse', 'chartreuse', 'light-green', 'dark-green', 'sky-blue', 'purple', 'dark-purple'];
|
|
24
|
+
}
|
|
25
|
+
// Render the main form pane
|
|
26
|
+
renderPane() {
|
|
27
|
+
const element = document.createElement('div');
|
|
28
|
+
element.className = 'at_container at_w-12 at_h-responsive-64';
|
|
29
|
+
element.id = 'at-pipe-form-pane';
|
|
30
|
+
element.setAttribute('data-cy', 'at-pipe-form-pane');
|
|
31
|
+
element.innerHTML = `
|
|
32
|
+
<div class="at_panel_header at_flex at_justify_between at_items_center at_mb_4">
|
|
33
|
+
<span class="mdi mdi-keyboard at_pull_left at_icon_hover ">
|
|
34
|
+
${getShortcutTooltipHTML()}
|
|
35
|
+
</span>
|
|
36
|
+
<div id="at_pipe_title"></div>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="">
|
|
39
|
+
<input id="at_pipe_type_name_input" class="at_pipe_input" type="text" name="pipe-name" required>
|
|
40
|
+
<label class="at_pipe_label" for="at_pipe_type_name_input">${i18n.t('PipeTypeName')}</label>
|
|
41
|
+
</div>
|
|
42
|
+
<div class="at_h-responsive-224">
|
|
43
|
+
<div class="at_py-3">
|
|
44
|
+
<span class="">${i18n.t('CategoryColor')}</span>
|
|
45
|
+
<div class="at_py-3 ">
|
|
46
|
+
${this.colorCategory.map(color => `
|
|
47
|
+
<div class="at_circle at_pipe_category-bg-${color}" id="at-color-pipe-category-btn-${color}" data-cy="at-color-btn-${color}"></div>
|
|
48
|
+
`).join('')}
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
<div class="at_pipe_container at_h-responsive-600">
|
|
52
|
+
<div class="at_py-2">
|
|
53
|
+
<div class="at_pipe_content at_rounded at_mb_2">
|
|
54
|
+
<span class="mdi mdi-pipe"></span>
|
|
55
|
+
${i18n.t('Pipes')}
|
|
56
|
+
</div>
|
|
57
|
+
<div id="at-pipe-form-collapse-html-element"></div>
|
|
58
|
+
<div class="at_flex at_gap_2 at_pt-2">
|
|
59
|
+
<div class="at_button at_ghost at_draw_pipe_btn" id="at-draw-pipe-btn" data-cy="at-draw-pipe-btn">${i18n.t('DrawPipe')}</div>
|
|
60
|
+
<div class="at_button at_ghost" id="at-pipe-undo-btn"><span class="mdi mdi-undo"></span></div>
|
|
61
|
+
<div class="at_button at_ghost" id="at-pipe-redo-btn"><span class="mdi mdi-redo"></span></div>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
<div class="at_flex at_justify_between">
|
|
67
|
+
<div class="at_button at_ghost" id="at-cancel-pipe-btn" data-cy="at-cancel-pipe-btn" target-pane="at-pipe-list-pane">
|
|
68
|
+
${i18n.t('Cancel')}
|
|
69
|
+
<span class="mdi mdi-close-circle-outline"></span>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="at_button at_ghost" id="at-save-pipe-btn" data-cy="at-save-pipe-btn" target-pane="at-pipe-list-pane">
|
|
72
|
+
${i18n.t('Save')}
|
|
73
|
+
<span class="mdi mdi-plus-circle-outline"></span>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
`;
|
|
77
|
+
return element;
|
|
78
|
+
}
|
|
79
|
+
// Creates collapse pipe under a category
|
|
80
|
+
createCollapseElement(category, pipes) {
|
|
81
|
+
const element = document.createElement('div');
|
|
82
|
+
element.id = 'at-pipe-pane';
|
|
83
|
+
element.setAttribute('data-cy', 'at-pipe-pane');
|
|
84
|
+
element.innerHTML = pipes != undefined && (pipes === null || pipes === void 0 ? void 0 : pipes.filter(pipe => pipe.category_uuid === category.uuid).length)
|
|
85
|
+
? `
|
|
86
|
+
<div class="at_collapse-content at_flex at_flex_column at_field at_scrollable_container at_h-responsive-650 at_mb_3">
|
|
87
|
+
${pipes === null || pipes === void 0 ? void 0 : pipes.filter(pipe => pipe.category_uuid === category.uuid).sort((a, b) => new Date(a.created_on).getTime() - new Date(b.created_on).getTime()).map(pipe => {
|
|
88
|
+
var _a, _b, _c;
|
|
89
|
+
return `
|
|
90
|
+
<div id="at-collapsible-${COLLAPSE.HEADER}-${pipe.uuid}" class="at_accent_forest at_rounded">
|
|
91
|
+
<div id="at-input-name-container-${pipe.uuid}" class="at_hidden">
|
|
92
|
+
<div class="at_flex at_justify_between at_items_center">
|
|
93
|
+
<input id="at_pipe_name_input_${pipe.uuid}" class="at_pipe_input" data-uuid="${pipe.uuid}" type="text" value="${pipe.name}" required>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
<div class="at_collapsible_section at_pipe_content at_rounded">
|
|
97
|
+
<div class="at_collapsible_header" id="at-header-collapse-">
|
|
98
|
+
<div class="at_flex at_justify_between at_items_center">
|
|
99
|
+
<span class="mdi mdi-ray-start-vertex-end at_text_xl at_pipe-dots-bg at_px-1 at_rounded" id="at-pipe-color-indicator-${pipe.uuid}" style="background-color:${(_a = JSON.parse(category.json_data)) === null || _a === void 0 ? void 0 : _a.color}"></span>
|
|
100
|
+
<div class="at_px-2 at_flex at_justify_center at_items_center at_w-half at_mx-w-8 at_accent_forest at_rounded">
|
|
101
|
+
<span id="at_pipe_name_label_${pipe.uuid}" class="at_px-2">${pipe.name}</span>
|
|
102
|
+
<div id="${COLLAPSE.TOGGLE_ID}"></div>
|
|
103
|
+
<span class="mdi mdi-pen" id="at-edit-btn-${COLLAPSE.HEADER}-${pipe.uuid}" data-uuid="${pipe.uuid}"></span>
|
|
104
|
+
</div>
|
|
105
|
+
<span class="mdi mdi-trash-can-outline at_text_xl" id="at-delete-btn-${COLLAPSE.HEADER}-${pipe.uuid}" data-uuid="${pipe.uuid}" data-type="${COLLAPSE.HEADER}"></span>
|
|
106
|
+
<span class="mdi mdi-check-bold at_text_xl at_hidden at_pipe-save-btn at_rounded" id="at-save-edit-btn-${COLLAPSE.HEADER}-${pipe.uuid}" data-uuid="${pipe.uuid}"></span>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div class="at_collapsible_content" id="${COLLAPSE.CONTENT_ID}">
|
|
111
|
+
<div class="at_p-2">
|
|
112
|
+
${JSON.parse(pipe.json_data) != undefined && JSON.parse(pipe.json_data).vertices.length ?
|
|
113
|
+
(_c = (_b = JSON.parse(pipe.json_data)) === null || _b === void 0 ? void 0 : _b.vertices) === null || _c === void 0 ? void 0 : _c.map((vertex, index) => {
|
|
114
|
+
var _a;
|
|
115
|
+
return `
|
|
116
|
+
|
|
117
|
+
<div class="at_flex at_justify_between at_items_center at_accent_forest at_px-2 at_rounded at_mb_1" id="at-collapsible-${COLLAPSE.LIST}-${vertex.x}">
|
|
118
|
+
<span id="at-vertex-color-indicator-${index}" class="mdi mdi-vector-line at_text_xl at_pipe-vertex-bg at_rounded" style="background-color:${(_a = JSON.parse(category.json_data)) === null || _a === void 0 ? void 0 : _a.color}"></span>
|
|
119
|
+
<span class="at_mr_3"> ${i18n.t('Vertex')} ${index + 1}</span>
|
|
120
|
+
<span class="mdi mdi-trash-can-outline at_text_xl" id="at-delete-btn-${COLLAPSE.LIST}-${vertex.x}" data-uuid="${vertex.x}" data-index="${index}" data-type="${COLLAPSE.LIST}"></span>
|
|
121
|
+
</div>
|
|
122
|
+
`;
|
|
123
|
+
}).join('')
|
|
124
|
+
:
|
|
125
|
+
`<div class="at_flex at_justify_center at_items_center at_flex_column">
|
|
126
|
+
<div><span class="mdi mdi-ray-start-vertex-end at_pipe_category-container"></span></div>
|
|
127
|
+
<div>${i18n.t('NoVertexToDisplay')}</div>
|
|
128
|
+
</div>`}
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
`;
|
|
134
|
+
}).join('')}
|
|
135
|
+
</div>
|
|
136
|
+
` : `
|
|
137
|
+
<div class="at_flex at_justify_center at_items_center at_flex_column at_h-responsive-650">
|
|
138
|
+
<div><span class="mdi mdi-pipe-disconnected at_pipe_category-container"></span></div>
|
|
139
|
+
<div> ${i18n.t('NoPipesToDisplay')}</div>
|
|
140
|
+
</div>
|
|
141
|
+
`;
|
|
142
|
+
return element;
|
|
143
|
+
}
|
|
144
|
+
// Initializes the form with the selected category and its pipes
|
|
145
|
+
init(category, pipes) {
|
|
146
|
+
var _a;
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
this.resetInteractionState();
|
|
149
|
+
// this.category = category
|
|
150
|
+
const pipeNameInput = document.getElementById('at_pipe_type_name_input');
|
|
151
|
+
if (!pipeNameInput)
|
|
152
|
+
return;
|
|
153
|
+
pipeNameInput.value = (_a = category === null || category === void 0 ? void 0 : category.name) !== null && _a !== void 0 ? _a : '';
|
|
154
|
+
const container = document.getElementById('at-pipe-form-collapse-html-element');
|
|
155
|
+
if (!container)
|
|
156
|
+
return;
|
|
157
|
+
const element = this.createCollapseElement(category, pipes);
|
|
158
|
+
this.collapse.setElement(element);
|
|
159
|
+
container.replaceChildren(this.collapse.render());
|
|
160
|
+
this.collapse.init();
|
|
161
|
+
// Setup event listeners
|
|
162
|
+
this.edit();
|
|
163
|
+
this.delete();
|
|
164
|
+
this.setColorListeners();
|
|
165
|
+
this.renderPipePath();
|
|
166
|
+
this.observeInput();
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
observeInput() {
|
|
170
|
+
const categoryNameInput = document.getElementById('at_pipe_type_name_input');
|
|
171
|
+
observeInputToUpdate(categoryNameInput, () => _selectedPipeCategory, 'name');
|
|
172
|
+
}
|
|
173
|
+
//setup pipe edit listener
|
|
174
|
+
edit() {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
+
document.querySelectorAll(`[id^="at-edit-btn-${COLLAPSE.HEADER}"]`).forEach((btn, index) => {
|
|
177
|
+
btn.addEventListener('click', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
var _a;
|
|
179
|
+
const target = e.currentTarget;
|
|
180
|
+
const uuid = target.dataset.uuid;
|
|
181
|
+
const selectedPipe = _pipes.find(pipe => pipe.uuid == uuid);
|
|
182
|
+
const parsed = JSON.parse((_a = selectedPipe.json_data) !== null && _a !== void 0 ? _a : '{}');
|
|
183
|
+
this.setEditMode(uuid);
|
|
184
|
+
if (parsed.vertices) {
|
|
185
|
+
moveToSweep(parsed.sweepId, parsed.rotation);
|
|
186
|
+
_3DXObjects.filter(obj => obj.object.uuid != uuid).forEach(targetObj => {
|
|
187
|
+
if (targetObj) {
|
|
188
|
+
setModelVisibility(targetObj.object.id);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}));
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
// enables edit mode for a selected pipe
|
|
197
|
+
setEditMode(uuid) {
|
|
198
|
+
var _a;
|
|
199
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
+
yield dispatchSpaceEvent(SPACE_EVENTS.PIPE_SELECTED, uuid);
|
|
201
|
+
// this.renderPipePath(_selectedPipe.uuid)
|
|
202
|
+
this.collapse.setExpand(true);
|
|
203
|
+
this.populateFormCollapse(_selectedPipeCategory, _selectedPipe);
|
|
204
|
+
this.savePipe();
|
|
205
|
+
this.delete();
|
|
206
|
+
const inputName = document.getElementById(`at-input-name-container-${uuid}`);
|
|
207
|
+
const editBtn = document.getElementById(`at-edit-btn-${COLLAPSE.HEADER}-${uuid}`);
|
|
208
|
+
const deleteBtn = document.getElementById(`at-delete-btn-${COLLAPSE.HEADER}-${uuid}`);
|
|
209
|
+
const saveBtn = document.getElementById(`at-save-edit-btn-${COLLAPSE.HEADER}-${uuid}`);
|
|
210
|
+
if (editBtn && deleteBtn && saveBtn) {
|
|
211
|
+
editBtn.classList.add('at_hidden');
|
|
212
|
+
deleteBtn.classList.add('at_hidden');
|
|
213
|
+
saveBtn.classList.remove('at_hidden');
|
|
214
|
+
inputName === null || inputName === void 0 ? void 0 : inputName.classList.remove('at_hidden');
|
|
215
|
+
}
|
|
216
|
+
this.getDrawButton((_a = JSON.parse(_selectedPipeCategory.json_data)) === null || _a === void 0 ? void 0 : _a.color, 'black');
|
|
217
|
+
const labels = document.querySelectorAll("[id*=at_pipe_name_label_]");
|
|
218
|
+
document.querySelectorAll('[id*="at_pipe_name_input_"]').forEach((input, index) => {
|
|
219
|
+
input.addEventListener('keyup', (e) => {
|
|
220
|
+
const inputValue = e.target.value;
|
|
221
|
+
labels[index].textContent = inputValue;
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
//setup save edited pipe listener
|
|
227
|
+
savePipe() {
|
|
228
|
+
document.querySelectorAll(`[id^="at-save-edit-btn-${COLLAPSE.HEADER}"]`).forEach(btn => {
|
|
229
|
+
btn.addEventListener('click', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
var _a;
|
|
231
|
+
const target = e.currentTarget;
|
|
232
|
+
const uuid = target.dataset.uuid;
|
|
233
|
+
if (this.getDrawButton((_a = JSON.parse(_selectedPipeCategory.json_data)) === null || _a === void 0 ? void 0 : _a.color, 'black').classList.contains('active')) {
|
|
234
|
+
notyf.error(`${i18n.t('DrawingModeIsActive!')}`);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const input = document.getElementById(`at_pipe_name_input_${uuid}`);
|
|
238
|
+
_selectedPipe.name = input.value;
|
|
239
|
+
console.log("SAVE PIPE =>", _selectedPipe);
|
|
240
|
+
yield this.savePiPeEventHandler();
|
|
241
|
+
}));
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
savePiPeEventHandler() {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
+
yield dispatchSpaceEvent(SPACE_EVENTS.PIPE_SAVED, Object.assign({}, _selectedPipe));
|
|
247
|
+
~(_pipes.findIndex((c, i) => c.uuid === _selectedPipe.uuid && (setPipes((_pipes[i] = _selectedPipe, _pipes)), 1)));
|
|
248
|
+
notyf.success(`${i18n.t('PipeSavedSuccessfully')}`);
|
|
249
|
+
this.init(_selectedPipeCategory, _pipes);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
setPipeVertices(payload) {
|
|
253
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
254
|
+
const updated = { vertices: payload, sweepId: getCurrentCameraPose().sweep, rotation: getCurrentCameraPose().rotation };
|
|
255
|
+
_selectedPipe.json_data = JSON.stringify(updated);
|
|
256
|
+
yield dispatchSpaceEvent(SPACE_EVENTS.PIPE_SAVED, Object.assign({}, _selectedPipe));
|
|
257
|
+
~(_pipes.findIndex((c, i) => c.uuid === _selectedPipe.uuid && (setPipes((_pipes[i] = _selectedPipe, _pipes)), 1)));
|
|
258
|
+
this.populateFormCollapse(_selectedPipeCategory, _selectedPipe);
|
|
259
|
+
this.setEditMode(_selectedPipe.uuid);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
// save category listener
|
|
263
|
+
save() {
|
|
264
|
+
const btn = document.getElementById('at-save-pipe-btn');
|
|
265
|
+
if (!btn)
|
|
266
|
+
return;
|
|
267
|
+
btn.addEventListener('click', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
268
|
+
const target = e.currentTarget;
|
|
269
|
+
if (_selectedPipe.uuid) {
|
|
270
|
+
notyf.error(`${i18n.t('SaveTheCurrentPipeBeforeProceeding')}`);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
// const payload = await this.extractCategoryPayload()
|
|
274
|
+
this.getDrawButton(null, 'white').classList.remove('active');
|
|
275
|
+
yield dispatchSpaceEvent(SPACE_EVENTS.PIPE_CATEGORY_SAVED, Object.assign({}, _selectedPipeCategory));
|
|
276
|
+
~(_pipeCategories.findIndex((c, i) => c.uuid === _selectedPipeCategory.uuid && (setPipeCategories((_pipeCategories[i] = _selectedPipeCategory, _pipeCategories)), 1)));
|
|
277
|
+
notyf.success(`${i18n.t('CategorySuccessfullySaved')}`);
|
|
278
|
+
yield toggleDisplayPane(target.id);
|
|
279
|
+
}));
|
|
280
|
+
}
|
|
281
|
+
cancel() {
|
|
282
|
+
const btn = document.getElementById('at-cancel-pipe-btn');
|
|
283
|
+
if (!btn)
|
|
284
|
+
return;
|
|
285
|
+
btn.addEventListener('click', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
286
|
+
const target = e.currentTarget;
|
|
287
|
+
const titleElement = document.getElementById('at_pipe_title');
|
|
288
|
+
const pipes = _pipes.filter(p => p.category_uuid === _selectedPipeCategory.uuid);
|
|
289
|
+
console.log("delete _selectedPipeCategory", pipes.length);
|
|
290
|
+
if (titleElement.textContent !== i18n.t('EditPipeType')) {
|
|
291
|
+
dispatchSpaceEvent(SPACE_EVENTS.PIPE_CATEGORY_REMOVED, _selectedPipeCategory.uuid);
|
|
292
|
+
~(_pipeCategories.findIndex((c, i) => c.uuid === _selectedPipeCategory.uuid && (setPipeCategories((_pipeCategories.splice(i, 1), _pipeCategories)), 1)));
|
|
293
|
+
}
|
|
294
|
+
yield toggleDisplayPane(target.id);
|
|
295
|
+
}));
|
|
296
|
+
}
|
|
297
|
+
// delete pipe/vertex listener
|
|
298
|
+
delete() {
|
|
299
|
+
document.querySelectorAll('[id^="at-delete-btn"]').forEach(el => {
|
|
300
|
+
el.addEventListener('click', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
301
|
+
const target = e.currentTarget;
|
|
302
|
+
const type = target.dataset.type;
|
|
303
|
+
const uuid = target.dataset.uuid;
|
|
304
|
+
toggleModal();
|
|
305
|
+
setModalAction({
|
|
306
|
+
title: `${i18n.t('DeletePipe')}`,
|
|
307
|
+
description: `${i18n.t('ConfirmDeletePipe')}`,
|
|
308
|
+
buttonLabel: `${i18n.t('YesDelete')}`
|
|
309
|
+
}, () => {
|
|
310
|
+
var _a;
|
|
311
|
+
if (uuid) {
|
|
312
|
+
if (type == COLLAPSE.HEADER) {
|
|
313
|
+
dispatchSpaceEvent(SPACE_EVENTS.PIPE_REMOVED, uuid);
|
|
314
|
+
const targetObj = _3DXObjects.find(obj => obj.object.uuid == uuid);
|
|
315
|
+
if (targetObj) {
|
|
316
|
+
disposeModel(targetObj);
|
|
317
|
+
}
|
|
318
|
+
notyf.success(`${i18n.t('PipeSuccessfullyDeleted!')}`);
|
|
319
|
+
toggleModal(false);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
dispatchSpaceEvent(SPACE_EVENTS.PIPE_VERTEX_REMOVED, uuid);
|
|
323
|
+
const index = Number(target.dataset.index);
|
|
324
|
+
console.log("INDEx =>", index);
|
|
325
|
+
this.renderPipePath(_selectedPipe.uuid);
|
|
326
|
+
if (this.getDrawButton((_a = JSON.parse(_selectedPipeCategory.json_data)) === null || _a === void 0 ? void 0 : _a.color, 'black').classList.contains('active')) {
|
|
327
|
+
const targetObj = _3DXObjects.find(obj => obj.object.uuid == _selectedPipe.uuid);
|
|
328
|
+
// deleteVertex(index)
|
|
329
|
+
enableVerticeControls(targetObj.component);
|
|
330
|
+
}
|
|
331
|
+
notyf.success(`${i18n.t('VertexDeletedSuccessfully!')}`);
|
|
332
|
+
toggleModal(false);
|
|
333
|
+
}
|
|
334
|
+
this.collapse.removeElement(uuid, type);
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}));
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
// draw pipe listener
|
|
341
|
+
draw() {
|
|
342
|
+
const btn = this.getDrawButton(null, 'white');
|
|
343
|
+
if (!btn)
|
|
344
|
+
return;
|
|
345
|
+
btn.addEventListener('click', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
346
|
+
var _a, _b;
|
|
347
|
+
const target = e.currentTarget;
|
|
348
|
+
const uuid = target.dataset.uuid;
|
|
349
|
+
const categoryData = JSON.parse((_a = _selectedPipeCategory === null || _selectedPipeCategory === void 0 ? void 0 : _selectedPipeCategory.json_data) !== null && _a !== void 0 ? _a : '{}');
|
|
350
|
+
const color = categoryData === null || categoryData === void 0 ? void 0 : categoryData.color;
|
|
351
|
+
if (!color) {
|
|
352
|
+
notyf.error(`${i18n.t('CannotDrawNoColorSelected')}`);
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
target.classList.toggle('active');
|
|
356
|
+
if (target.classList.contains('active')) {
|
|
357
|
+
target.style.backgroundColor = (_b = JSON.parse(_selectedPipeCategory.json_data)) === null || _b === void 0 ? void 0 : _b.color;
|
|
358
|
+
target.style.color = 'black';
|
|
359
|
+
target.textContent = `${i18n.t('DoneDrawing')}`;
|
|
360
|
+
_pipes.forEach(pipe => {
|
|
361
|
+
const targetObj = _3DXObjects.find(obj => obj.object.uuid === pipe.uuid);
|
|
362
|
+
if (targetObj) {
|
|
363
|
+
setModelVisibility(targetObj.object.id, false);
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
setPipeIsDrawingMode(true);
|
|
367
|
+
startDraw();
|
|
368
|
+
notyf.success(`${i18n.t('DrawingModeIsNowActive')}`);
|
|
369
|
+
if (_selectedPipe.uuid) {
|
|
370
|
+
console.log("EDIT PIPE ACTIVE", _selectedPipe.uuid);
|
|
371
|
+
const targetObject = _3DXObjects.find(obj => obj.object.uuid === _selectedPipe.uuid);
|
|
372
|
+
console.log("OBJECT", _3DXObjects, targetObject);
|
|
373
|
+
if (!targetObject)
|
|
374
|
+
return;
|
|
375
|
+
enableVerticeControls(targetObject.component);
|
|
376
|
+
this.setEditMode(_selectedPipe.uuid);
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
yield dispatchSpaceEvent(SPACE_EVENTS.PIPE_SAVED, {});
|
|
380
|
+
const newPipe = yield waitForChange(() => _selectedPipe);
|
|
381
|
+
this.setEditMode(newPipe.uuid);
|
|
382
|
+
}
|
|
383
|
+
console.log("selectedPipeCategory. ==>", _selectedPipeCategory);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
this.savePiPeEventHandler();
|
|
387
|
+
cancelDraw();
|
|
388
|
+
setPipeIsDrawingMode(false);
|
|
389
|
+
this.renderPipePath(uuid);
|
|
390
|
+
target.textContent = i18n.t('DrawPipe');
|
|
391
|
+
target.style.backgroundColor = null;
|
|
392
|
+
target.style.color = 'white';
|
|
393
|
+
}
|
|
394
|
+
}));
|
|
395
|
+
}
|
|
396
|
+
// undo pipe listener
|
|
397
|
+
undoEventHandler() {
|
|
398
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
399
|
+
yield dispatchSpaceEvent(SPACE_EVENTS.DRAW_PIPE_UNDO);
|
|
400
|
+
this.populateFormCollapse(_selectedPipeCategory, _selectedPipe);
|
|
401
|
+
this.setEditMode(_selectedPipe.uuid);
|
|
402
|
+
undoDrawAction();
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
redoEventHandler() {
|
|
406
|
+
dispatchSpaceEvent(SPACE_EVENTS.DRAW_PIPE_REDO, _selectedPipe);
|
|
407
|
+
this.populateFormCollapse(_selectedPipeCategory, _selectedPipe);
|
|
408
|
+
this.setEditMode(_selectedPipe.uuid);
|
|
409
|
+
// this.renderPipePath()
|
|
410
|
+
redoDrawAction();
|
|
411
|
+
}
|
|
412
|
+
undo() {
|
|
413
|
+
const btn = document.getElementById('at-pipe-undo-btn');
|
|
414
|
+
if (!btn)
|
|
415
|
+
return;
|
|
416
|
+
btn.addEventListener('click', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
417
|
+
var _a;
|
|
418
|
+
if (!this.getDrawButton((_a = JSON.parse(_selectedPipeCategory.json_data)) === null || _a === void 0 ? void 0 : _a.color, 'black').classList.contains('active')) {
|
|
419
|
+
notyf.error(`${i18n.t('DrawingModeIsCurrentlyInactive')}`);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
this.undoEventHandler();
|
|
423
|
+
}));
|
|
424
|
+
}
|
|
425
|
+
// redo pipe listener
|
|
426
|
+
redo() {
|
|
427
|
+
const btn = document.getElementById('at-pipe-redo-btn');
|
|
428
|
+
if (!btn)
|
|
429
|
+
return;
|
|
430
|
+
btn.addEventListener('click', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
431
|
+
var _a;
|
|
432
|
+
if (!this.getDrawButton((_a = JSON.parse(_selectedPipeCategory.json_data)) === null || _a === void 0 ? void 0 : _a.color, 'black').classList.contains('active')) {
|
|
433
|
+
notyf.error(`${i18n.t('DrawingModeIsCurrentlyInactive')}`);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
this.redoEventHandler();
|
|
437
|
+
}));
|
|
438
|
+
}
|
|
439
|
+
// Sets listeners on color buttons to update selection and styling
|
|
440
|
+
setColorListeners() {
|
|
441
|
+
document.querySelectorAll('[id^="at-color-pipe-category-btn-"]').forEach(el => {
|
|
442
|
+
el.classList.remove('selected');
|
|
443
|
+
if (JSON.parse(_selectedPipeCategory === null || _selectedPipeCategory === void 0 ? void 0 : _selectedPipeCategory.json_data) && getComputedStyle(el).backgroundColor === JSON.parse(_selectedPipeCategory.json_data).color) {
|
|
444
|
+
el.classList.add('selected');
|
|
445
|
+
}
|
|
446
|
+
el.addEventListener('click', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
447
|
+
var _a;
|
|
448
|
+
const target = e.currentTarget;
|
|
449
|
+
if (!target.classList.contains('at_circle'))
|
|
450
|
+
return;
|
|
451
|
+
document.querySelectorAll('.at_circle.selected').forEach(el => el.classList.remove('selected'));
|
|
452
|
+
target.classList.add('selected');
|
|
453
|
+
console.log("clicked");
|
|
454
|
+
const bgColor = getComputedStyle(target).backgroundColor;
|
|
455
|
+
console.log("CAHNGE COLOR ==>", bgColor);
|
|
456
|
+
this.getDrawButton(bgColor, 'black');
|
|
457
|
+
const obj = { color: bgColor };
|
|
458
|
+
_selectedPipeCategory.json_data = JSON.stringify(obj);
|
|
459
|
+
document.querySelectorAll('[id*="at-pipe-color-indicator"]').forEach(el => {
|
|
460
|
+
el.style.backgroundColor = bgColor;
|
|
461
|
+
});
|
|
462
|
+
document.querySelectorAll('[id*="at-vertex-color-indicator"]').forEach(el => {
|
|
463
|
+
el.style.backgroundColor = bgColor;
|
|
464
|
+
});
|
|
465
|
+
yield dispatchSpaceEvent(SPACE_EVENTS.PIPE_CATEGORY_SAVED, Object.assign({}, _selectedPipeCategory));
|
|
466
|
+
~(_pipeCategories.findIndex((c, i) => c.uuid === _selectedPipeCategory.uuid && (setPipeCategories((_pipeCategories[i] = _selectedPipeCategory, _pipeCategories)), 1)));
|
|
467
|
+
if (!this.getDrawButton((_a = JSON.parse(_selectedPipeCategory.json_data)) === null || _a === void 0 ? void 0 : _a.color, 'black').classList.contains('active')) {
|
|
468
|
+
const uuid = _selectedPipe ? _selectedPipe.uuid : null;
|
|
469
|
+
this.renderPipePath(uuid);
|
|
470
|
+
}
|
|
471
|
+
else {
|
|
472
|
+
const updatedOptions = {
|
|
473
|
+
textColor: bgColor
|
|
474
|
+
//...other properties you want to update
|
|
475
|
+
};
|
|
476
|
+
setPathLineOptions(undefined, updatedOptions);
|
|
477
|
+
}
|
|
478
|
+
}));
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
// Gets the draw button and sets its color
|
|
482
|
+
getDrawButton(background, color) {
|
|
483
|
+
const btn = document.getElementById('at-draw-pipe-btn');
|
|
484
|
+
if (!btn)
|
|
485
|
+
return;
|
|
486
|
+
if (btn === null || btn === void 0 ? void 0 : btn.classList.contains('active')) {
|
|
487
|
+
console.log("DRAW BUTTON ===>", btn.classList);
|
|
488
|
+
btn.style.backgroundColor = background;
|
|
489
|
+
btn.style.color = color;
|
|
490
|
+
}
|
|
491
|
+
return btn;
|
|
492
|
+
}
|
|
493
|
+
// Renders updated pipe items during edit mode
|
|
494
|
+
populateFormCollapse(categories, pipes) {
|
|
495
|
+
const container = document.getElementById('at-pipe-form-collapse-html-element');
|
|
496
|
+
if (!container)
|
|
497
|
+
return;
|
|
498
|
+
const element = this.createCollapseElement(categories, [pipes]);
|
|
499
|
+
this.collapse.setElement(element);
|
|
500
|
+
container.replaceChildren(this.collapse.render());
|
|
501
|
+
this.collapse.init();
|
|
502
|
+
}
|
|
503
|
+
// Resets internal state (form mode, collapse state)
|
|
504
|
+
resetInteractionState() {
|
|
505
|
+
this.collapse.setExpand(false);
|
|
506
|
+
cancelDraw();
|
|
507
|
+
setPipeIsDrawingMode(false);
|
|
508
|
+
dispatchSpaceEvent(SPACE_EVENTS.PIPE_SELECTED, null);
|
|
509
|
+
if (this.getDrawButton(null, 'white').classList.contains('active')) {
|
|
510
|
+
this.getDrawButton(null, 'white').classList.remove('active');
|
|
511
|
+
}
|
|
512
|
+
document.querySelectorAll('[id^="at-color-pipe-category-btn"]').forEach(color => {
|
|
513
|
+
if (color.classList.contains('at_disabled')) {
|
|
514
|
+
color.classList.remove('at_disabled');
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
// toggle pane tittle
|
|
519
|
+
setPipeTitle(text) {
|
|
520
|
+
const titleElement = document.getElementById('at_pipe_title');
|
|
521
|
+
if (!titleElement)
|
|
522
|
+
return;
|
|
523
|
+
titleElement.textContent = i18n.t(text);
|
|
524
|
+
}
|
|
525
|
+
// render specific pipe category and its pipes
|
|
526
|
+
renderPipePath(uuid) {
|
|
527
|
+
var _a;
|
|
528
|
+
_3DXObjects.filter(x => x.type === 'PATH').forEach(disposeModel);
|
|
529
|
+
const category = JSON.parse((_a = _selectedPipeCategory === null || _selectedPipeCategory === void 0 ? void 0 : _selectedPipeCategory.json_data) !== null && _a !== void 0 ? _a : '{}');
|
|
530
|
+
const targetPipes = uuid
|
|
531
|
+
? _pipes.filter(p => p.uuid === uuid)
|
|
532
|
+
: _pipes.filter(p => p.category_uuid === _selectedPipeCategory.uuid);
|
|
533
|
+
targetPipes.forEach(pipe => {
|
|
534
|
+
var _a;
|
|
535
|
+
const data = JSON.parse((_a = pipe === null || pipe === void 0 ? void 0 : pipe.json_data) !== null && _a !== void 0 ? _a : '{}');
|
|
536
|
+
if (!(data === null || data === void 0 ? void 0 : data.vertices))
|
|
537
|
+
return;
|
|
538
|
+
renderPath(data.vertices, {
|
|
539
|
+
uuid: pipe.uuid,
|
|
540
|
+
fillColor: 'none',
|
|
541
|
+
textColor: category.color,
|
|
542
|
+
});
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class PipeList {
|
|
2
|
+
private form;
|
|
3
|
+
private collapse;
|
|
4
|
+
private categories;
|
|
5
|
+
private pipes;
|
|
6
|
+
constructor();
|
|
7
|
+
renderPane(): HTMLElement;
|
|
8
|
+
private createCollapseElement;
|
|
9
|
+
init(): Promise<void>;
|
|
10
|
+
private eventHandler;
|
|
11
|
+
private handleClickItem;
|
|
12
|
+
locate(): void;
|
|
13
|
+
add(): void;
|
|
14
|
+
edit(): void;
|
|
15
|
+
toggle(): void;
|
|
16
|
+
delete(): void;
|
|
17
|
+
renderPipePaths(): void;
|
|
18
|
+
initDropdown(options: string[]): void;
|
|
19
|
+
}
|