Skip to content

Commit 0fe7565

Browse files
authored
Merge pull request #3060 from entrylabs/issue/10179
리스트 변수 항목 수 5,000개 제한 기능 추가
2 parents af2bc1b + 5aef640 commit 0fe7565

6 files changed

Lines changed: 62 additions & 11 deletions

File tree

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"jquery": true,
2727
},
2828
"parserOptions": {
29+
"requireConfigFile": false,
2930
"ecmaVersion": 2020,
3031
"sourceType": "module",
3132
"ecmaFeatures": {

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"trailingComma": "es5",
66
"bracketSpacing": true,
77
"semi": true,
8-
"arrowParens": "always"
8+
"arrowParens": "always",
9+
"endOfLine": "auto"
910
}

extern/lang/en.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5635,6 +5635,11 @@ Lang.Workspace = {
56355635
variable_name_auto_edited_content: 'variable name cannot exceed 10 characters',
56365636
list_name_auto_edited_title: 'list name auto-edited',
56375637
list_name_auto_edited_content: 'list name cannot exceed 10 characters',
5638+
list_cant_add_item: 'Warning',
5639+
list_max_length_exceeded: 'You can add up to 5,000 items to a list.',
5640+
list_truncated_on_load:
5641+
'The number of list items in this project exceeds 5,000, so some may not be displayed.\n\nFor stable use,\nplease reduce the list to 5,000 or fewer.',
5642+
list_truncated_on_load_title: 'Notice',
56385643
cloned_scene: 'Cloned_',
56395644
default_mode: 'Standard',
56405645
practical_course_mode: 'Textbook',

extern/lang/ko.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6014,6 +6014,11 @@ Lang.Workspace = {
60146014
variable_name_auto_edited_content: '변수의 이름은 10글자를 넘을 수 없습니다.',
60156015
list_name_auto_edited_title: '리스트 이름 자동 변경',
60166016
list_name_auto_edited_content: '리스트의 이름은 10글자를 넘을 수 없습니다.',
6017+
list_cant_add_item: '경고',
6018+
list_max_length_exceeded: '리스트 항목은 최대 5,000개까지 추가할 수 있어요.',
6019+
list_truncated_on_load:
6020+
'이 작품의 리스트 항목 수가 5,000개를 초과하여 일부가 표시되지 않을 수 있습니다.\n\n안정적인 이용을 위해\n리스트를 5,000개 이하로 줄여주세요.',
6021+
list_truncated_on_load_title: '알림',
60176022
cloned_scene: '복제본_',
60186023
default_mode: '기본형',
60196024
practical_course_mode: '교과형',

src/class/variable/listVariable.js

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,37 @@ class ListVariable extends Variable {
77
return 5000;
88
}
99

10+
_trimToMaxLength() {
11+
if (this.array_ && this.array_.length > this.LIST_MAX_LENGTH) {
12+
this.array_ = this.array_.slice(-this.LIST_MAX_LENGTH);
13+
this._showListFullWarning();
14+
}
15+
}
16+
17+
_showListFullWarning() {
18+
Entry.toast?.alert(
19+
Lang?.Workspace?.list_cant_add_item || 'Warning',
20+
Lang?.Workspace?.list_max_length_exceeded ||
21+
`You can add up to ${this.LIST_MAX_LENGTH} items to a list.`
22+
);
23+
}
24+
1025
constructor(variable) {
1126
Entry.assert(variable.variableType === 'list', 'Invalid variable type given');
1227
super(variable);
13-
this.array_ = variable.array ? variable.array : [];
28+
29+
let array = variable.array ? variable.array : [];
30+
if (array.length > this.LIST_MAX_LENGTH) {
31+
array = array.slice(-this.LIST_MAX_LENGTH);
32+
setTimeout(() => {
33+
Entry.modal?.alert(
34+
Lang?.Workspace?.list_truncated_on_load ||
35+
`The list exceeded ${this.LIST_MAX_LENGTH} items.`,
36+
Lang?.Workspace?.list_truncated_on_load_title || 'Notice'
37+
);
38+
}, 100);
39+
}
40+
this.array_ = array;
1441

1542
if (!variable.isClone) {
1643
this.width_ = variable.width ? variable.width : 100;
@@ -62,11 +89,11 @@ class ListVariable extends Variable {
6289
this.resizeHandle_.list = this;
6390

6491
GEDragHelper.handleDrag(this.resizeHandle_);
65-
this.resizeHandle_.on(GEDragHelper.types.OVER, function() {
92+
this.resizeHandle_.on(GEDragHelper.types.OVER, function () {
6693
this.cursor = 'nwse-resize';
6794
});
6895

69-
this.resizeHandle_.on(GEDragHelper.types.DOWN, function(evt) {
96+
this.resizeHandle_.on(GEDragHelper.types.DOWN, function (evt) {
7097
// if(Entry.type != 'workspace') return;
7198
this.list.isResizing = true;
7299
this.offset = {
@@ -75,18 +102,18 @@ class ListVariable extends Variable {
75102
};
76103
this.parent.cursor = 'nwse-resize';
77104
});
78-
this.resizeHandle_.on(GEDragHelper.types.MOVE, function(evt) {
105+
this.resizeHandle_.on(GEDragHelper.types.MOVE, function (evt) {
79106
// if(Entry.type != 'workspace') return;
80107
this.list.setWidth(evt.stageX * 0.75 - this.offset.x);
81108
this.list.setHeight(evt.stageY * 0.75 - this.offset.y);
82109
this.list.updateView();
83110
});
84111

85-
this.view_.on(GEDragHelper.types.OVER, function() {
112+
this.view_.on(GEDragHelper.types.OVER, function () {
86113
this.cursor = 'move';
87114
});
88115

89-
this.view_.on(GEDragHelper.types.DOWN, function(evt) {
116+
this.view_.on(GEDragHelper.types.DOWN, function (evt) {
90117
if (Entry.type !== 'workspace' || this.variable.isResizing) {
91118
return;
92119
}
@@ -97,12 +124,12 @@ class ListVariable extends Variable {
97124
this.cursor = 'move';
98125
});
99126

100-
this.view_.on(GEDragHelper.types.UP, function() {
127+
this.view_.on(GEDragHelper.types.UP, function () {
101128
this.cursor = 'initial';
102129
this.variable.isResizing = false;
103130
});
104131

105-
this.view_.on(GEDragHelper.types.MOVE, function(evt) {
132+
this.view_.on(GEDragHelper.types.MOVE, function (evt) {
106133
if (Entry.type !== 'workspace' || this.variable.isResizing) {
107134
return;
108135
}
@@ -122,12 +149,12 @@ class ListVariable extends Variable {
122149
this.scrollButton_.y = 25;
123150

124151
this.scrollButton_.list = this;
125-
this.scrollButton_.on(GEDragHelper.types.DOWN, function(evt) {
152+
this.scrollButton_.on(GEDragHelper.types.DOWN, function (evt) {
126153
// if(Entry.type != 'workspace') return;
127154
this.list.isResizing = true;
128155
this.offsetY = evt.stageY - this.y / 0.75;
129156
});
130-
this.scrollButton_.on(GEDragHelper.types.MOVE, function(evt) {
157+
this.scrollButton_.on(GEDragHelper.types.MOVE, function (evt) {
131158
// if(Entry.type != 'workspace') return;
132159

133160
const stageY = evt.stageY;
@@ -200,6 +227,7 @@ class ListVariable extends Variable {
200227
this.array_.push({
201228
data: value,
202229
});
230+
this._trimToMaxLength();
203231
this.updateView();
204232
} else {
205233
return new Promise(async (resolve, reject) => {
@@ -256,6 +284,7 @@ class ListVariable extends Variable {
256284
insertValue(index, data) {
257285
if (!this.isRealTime_) {
258286
this.array_.splice(index - 1, 0, { data });
287+
this._trimToMaxLength();
259288
this.updateView();
260289
} else {
261290
return new Promise(async (resolve, reject) => {

src/class/variable_container.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,6 +3053,11 @@ Entry.VariableContainer = class VariableContainer {
30533053

30543054
if (value >= limitValue) {
30553055
value = limitValue;
3056+
Entry.toast?.alert(
3057+
Lang?.Workspace?.list_cant_add_item || 'Warning',
3058+
Lang?.Workspace?.list_max_length_exceeded ||
3059+
'You can add up to 5,000 items to a list.'
3060+
);
30563061
}
30573062

30583063
Entry.do('listChangeLength', v.id_, Number(value));
@@ -3079,6 +3084,11 @@ Entry.VariableContainer = class VariableContainer {
30793084
const selectedLength = array_.length;
30803085

30813086
if (selectedLength >= limitValue) {
3087+
Entry.toast?.alert(
3088+
Lang?.Workspace?.list_cant_add_item || 'Warning',
3089+
Lang?.Workspace?.list_max_length_exceeded ||
3090+
'You can add up to 5,000 items to a list.'
3091+
);
30823092
Entry.do('listChangeLength', id_, '');
30833093
} else {
30843094
Entry.do('listChangeLength', id_, 'plus');

0 commit comments

Comments
 (0)