polarvo-layout 1.0.19 → 1.0.21
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/package.json +1 -1
- package/src/components/FastMenu/DesignFastmenu.vue +2 -2
- package/src/components/FastMenu/DisplayFastMenu.vue +2 -2
- package/src/components/FastMenu/LayoutFastMenu.vue +18 -10
- package/src/components/Layout/CanvasContainer.vue +30 -6
- package/src/components/SideBar/ElementSideBar.vue +2 -2
- package/src/components/SideBar/LayoutSettingSideBar.vue +18 -10
- package/src/components/SideBar/LayoutSideBar.vue +19 -8
- package/src/configs/index.js +1 -0
- package/src/core/engines/DisplayEngine.js +72 -64
- package/src/core/engines/FreeDropEngine.js +40 -42
- package/src/core/engines/GridDropEngine.js +33 -43
- package/src/core/engines/HistoryEngine.js +55 -51
- package/src/core/engines/LayoutEngine.js +89 -68
- package/src/core/engines/originals/FreeDropEngine_0402.js +786 -0
- package/src/core/engines/originals/GridDropEngine_0402.js +557 -0
- package/src/core/managers/EngineManager.js +93 -131
- package/src/core/managers/originals/EngineManager_0402.js +826 -0
- package/src/library/DisplayLibrary.js +14 -17
- package/src/library/FreeDropLibrary.js +6 -4
- package/src/library/GridDropLibrary.js +3 -5
- package/src/library/LayoutLibrary.js +45 -48
- package/src/library/originals/DisplayLibrary_0402.js +137 -0
- package/src/library/originals/FreeDropLibrary_0402.js +185 -0
- package/src/library/originals/GridDropLibrary_0402.js +202 -0
- package/src/library/originals/HistoryLibrary_0402.js +98 -0
- package/src/library/originals/LayoutLibrary_0402.js +264 -0
- package/src/utils/index.js +8 -3
|
@@ -32,29 +32,38 @@ class LayoutEngine {
|
|
|
32
32
|
/** [내부함수] 구독 설정 */
|
|
33
33
|
_setupSubscriptions() {
|
|
34
34
|
// 초기화 완료 이벤트 구독 - from EngineManager
|
|
35
|
-
this._subscribe('system:engineInitialized', () => {});
|
|
36
|
-
|
|
37
|
-
this._subscribe('system:
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
// this._subscribe('system:engineInitialized', () => {});
|
|
36
|
+
|
|
37
|
+
this._subscribe('system:updateActiveSectionConfig', ({ $section, changes }) => {
|
|
38
|
+
Object.keys(changes).forEach((key) => {
|
|
39
|
+
if (!(key in this.layoutData[$section])) {
|
|
40
|
+
if (key == 'elementIds') {
|
|
41
|
+
this.layoutData[$section][key] = [];
|
|
42
|
+
} else {
|
|
43
|
+
this.layoutData[$section][key] = null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
this.layoutData =
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
// 원본 데이터 업데이트
|
|
49
|
+
this.layoutData[$section] = {
|
|
50
|
+
...this.layoutData[$section],
|
|
51
|
+
...changes,
|
|
52
|
+
};
|
|
45
53
|
|
|
46
|
-
|
|
47
|
-
this.layoutData = layoutData;
|
|
54
|
+
const activeData = this.layoutData[$section];
|
|
48
55
|
|
|
49
|
-
this.eventBus.emit('layout:
|
|
50
|
-
layoutData:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
this.eventBus.emit('layout:updateLayoutData', {
|
|
57
|
+
$layoutData: this.layoutData,
|
|
58
|
+
$section: $section,
|
|
59
|
+
$mode: activeData?.mode,
|
|
60
|
+
$config: activeData?.config,
|
|
61
|
+
timestamp: Date.now(),
|
|
54
62
|
});
|
|
55
63
|
});
|
|
56
64
|
|
|
57
65
|
this._subscribe('system:restoredState', ({ stateData }) => {
|
|
66
|
+
if (!stateData?.layoutData) return;
|
|
58
67
|
Object.assign(this.layoutData, stateData.layoutData);
|
|
59
68
|
});
|
|
60
69
|
}
|
|
@@ -76,6 +85,8 @@ class LayoutEngine {
|
|
|
76
85
|
}
|
|
77
86
|
});
|
|
78
87
|
|
|
88
|
+
this.reset();
|
|
89
|
+
|
|
79
90
|
this._subscriptions = [];
|
|
80
91
|
this.eventBus = null;
|
|
81
92
|
this.resource = null;
|
|
@@ -170,21 +181,23 @@ class LayoutEngine {
|
|
|
170
181
|
// 초기 설정인 경우 설정값 전파
|
|
171
182
|
if (screenConfig) {
|
|
172
183
|
this.eventBus.emit('layout:setLayoutName', {
|
|
173
|
-
screenConfig:
|
|
174
|
-
|
|
175
|
-
|
|
184
|
+
$screenConfig: screenConfig,
|
|
185
|
+
$layoutData: this.layoutData,
|
|
186
|
+
$gridNumber: this.gridNumber,
|
|
187
|
+
$gridRatio: this.gridRatio,
|
|
176
188
|
timestamp: Date.now(),
|
|
177
189
|
});
|
|
178
|
-
}
|
|
190
|
+
}
|
|
179
191
|
// 그 외 레이아웃 변경인 경우 레이아웃 정보 전파
|
|
180
192
|
else {
|
|
181
193
|
this.eventBus.emit('layout:updateLayoutName', {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
194
|
+
$layoutName: this.layoutName,
|
|
195
|
+
$layoutData: this.layoutData,
|
|
196
|
+
$gridNumber: this.gridNumber,
|
|
197
|
+
$gridRatio: this.gridRatio,
|
|
198
|
+
$gapSize: this.gapSize,
|
|
199
|
+
timestamp: Date.now(),
|
|
200
|
+
});
|
|
188
201
|
}
|
|
189
202
|
}
|
|
190
203
|
|
|
@@ -197,27 +210,17 @@ class LayoutEngine {
|
|
|
197
210
|
|
|
198
211
|
const newLayoutData = cloneDeep(this.resource[name].sections);
|
|
199
212
|
|
|
200
|
-
// userData 있는 경우 우선 병합
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
else if (this.layoutData) {
|
|
210
|
-
{
|
|
211
|
-
Object.keys(newLayoutData).forEach((sectionKey) => {
|
|
212
|
-
if (this.layoutData[sectionKey]) {
|
|
213
|
-
newLayoutData[sectionKey] = {
|
|
214
|
-
...newLayoutData[sectionKey],
|
|
215
|
-
...this.layoutData[sectionKey],
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
});
|
|
213
|
+
// userData 있는 경우 우선 병합 - 기존 데이터 유지하면서 userData로 덮어쓰기
|
|
214
|
+
const mergeSource = userData || this.layoutData;
|
|
215
|
+
|
|
216
|
+
Object.keys(newLayoutData).forEach((sectionKey) => {
|
|
217
|
+
if (mergeSource[sectionKey]) {
|
|
218
|
+
newLayoutData[sectionKey] = {
|
|
219
|
+
...newLayoutData[sectionKey],
|
|
220
|
+
...mergeSource[sectionKey],
|
|
221
|
+
};
|
|
219
222
|
}
|
|
220
|
-
}
|
|
223
|
+
});
|
|
221
224
|
|
|
222
225
|
this.layoutData = newLayoutData;
|
|
223
226
|
}
|
|
@@ -236,18 +239,26 @@ class LayoutEngine {
|
|
|
236
239
|
this.gridRatio.column = gridRatio.column;
|
|
237
240
|
} else {
|
|
238
241
|
this.gridRatio.column = columnNumber === 1 ? [100] : Array(columnNumber).fill(Math.floor(100 / columnNumber));
|
|
242
|
+
|
|
243
|
+
if (columnNumber === 3) {
|
|
244
|
+
this.gridRatio.column[2] = 100 - this.gridRatio.column[0] - this.gridRatio.column[1];
|
|
245
|
+
}
|
|
239
246
|
}
|
|
240
247
|
|
|
241
248
|
if (gridRatio?.row) {
|
|
242
249
|
this.gridRatio.row = gridRatio.row;
|
|
243
250
|
} else {
|
|
244
251
|
this.gridRatio.row = rowNumber === 1 ? [100] : Array(rowNumber).fill(Math.floor(100 / rowNumber));
|
|
252
|
+
|
|
253
|
+
if (rowNumber === 3) {
|
|
254
|
+
this.gridRatio.row[2] = 100 - this.gridRatio.row[0] - this.gridRatio.row[1];
|
|
255
|
+
}
|
|
245
256
|
}
|
|
246
257
|
|
|
247
258
|
this.gridNumber.column = columnNumber;
|
|
248
259
|
this.gridNumber.row = rowNumber;
|
|
249
260
|
|
|
250
|
-
if (gapSize) {
|
|
261
|
+
if (gapSize != null) {
|
|
251
262
|
this.gapSize = gapSize;
|
|
252
263
|
}
|
|
253
264
|
}
|
|
@@ -256,10 +267,12 @@ class LayoutEngine {
|
|
|
256
267
|
* @param {number} size - 새로운 갭 사이즈
|
|
257
268
|
*/
|
|
258
269
|
setGapSize(size) {
|
|
270
|
+
if (Number(size) < 0 || isNaN(Number(size))) return;
|
|
271
|
+
|
|
259
272
|
this.gapSize = size;
|
|
260
273
|
|
|
261
274
|
this.eventBus.emit('layout:updateGapSize', {
|
|
262
|
-
gapSize: this.gapSize,
|
|
275
|
+
$gapSize: this.gapSize,
|
|
263
276
|
timestamp: Date.now(),
|
|
264
277
|
});
|
|
265
278
|
}
|
|
@@ -270,7 +283,7 @@ class LayoutEngine {
|
|
|
270
283
|
* @param {number} ratio - 새로운 비율 값
|
|
271
284
|
*/
|
|
272
285
|
setRatio(type, index, ratio) {
|
|
273
|
-
const ratioArray =
|
|
286
|
+
const ratioArray = this.gridRatio[type];
|
|
274
287
|
ratioArray[index] = Number(ratio);
|
|
275
288
|
|
|
276
289
|
const totalWithout = ratioArray.reduce((sum, val, idx) => {
|
|
@@ -283,34 +296,42 @@ class LayoutEngine {
|
|
|
283
296
|
}
|
|
284
297
|
|
|
285
298
|
const total = totalWithout + ratioArray[index];
|
|
299
|
+
const result = { result: true, message: '비율이 성공적으로 변경되었습니다.' };
|
|
300
|
+
|
|
286
301
|
if (total == 100) {
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
302
|
+
return result;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (ratioArray.length == 2) {
|
|
306
|
+
index == 0 ? (ratioArray[1] = 100 - ratioArray[0]) : (ratioArray[0] = 100 - ratioArray[1]);
|
|
307
|
+
} else if (ratioArray.length == 3) {
|
|
308
|
+
const remaining = 100 - total;
|
|
309
|
+
if (remaining < 0) {
|
|
310
|
+
result.result = false;
|
|
311
|
+
result.message = '비율의 합은 100을 초과할 수 없습니다.';
|
|
312
|
+
}
|
|
296
313
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
314
|
+
if (index == 2) {
|
|
315
|
+
ratioArray[0] = ratioArray[0] - Math.abs(remaining);
|
|
316
|
+
} else {
|
|
317
|
+
ratioArray[index + 1] = ratioArray[index + 1] - Math.abs(remaining);
|
|
318
|
+
|
|
319
|
+
if (ratioArray[index + 1] < 0) {
|
|
320
|
+
ratioArray[index + 1] = 0;
|
|
321
|
+
ratioArray[2] = 100 - ratioArray[0] - ratioArray[1];
|
|
301
322
|
}
|
|
302
323
|
}
|
|
303
324
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
} else if (type === 'row') {
|
|
307
|
-
this.gridRatio.row = ratioArray;
|
|
308
|
-
}
|
|
325
|
+
|
|
326
|
+
this.gridRatio[type] = ratioArray;
|
|
309
327
|
|
|
310
328
|
this.eventBus.emit('layout:updateRatio', {
|
|
311
|
-
|
|
329
|
+
$type: type,
|
|
330
|
+
$gridRatio: this.gridRatio,
|
|
312
331
|
timestamp: Date.now(),
|
|
313
332
|
});
|
|
333
|
+
|
|
334
|
+
return result;
|
|
314
335
|
}
|
|
315
336
|
}
|
|
316
337
|
|