@@ -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 ) => {
0 commit comments