@@ -26,9 +26,10 @@ const sizeofFormat = require("./util").sizeofFormat;
2626const getLocalizedText = util . getLocalizedText ;
2727const normalizeText = util . normalizeText ;
2828
29- const logPrefix = '[metadata] ' ;
3029var filteredPages = [ ] ;
3130
31+ const logPrefix = '[metadata] ' ;
32+
3233const QuestionPage = oop . defclass ( {
3334 constructor : function ( schema , fileItem , options ) {
3435 const self = this ;
@@ -54,7 +55,7 @@ const QuestionPage = oop.defclass({
5455 filteredPages = [ ] ;
5556 filteredPages = ( self . schema . pages || [ ] ) . filter ( function ( page ) {
5657 return ( page . questions || [ ] ) . some ( function ( question ) {
57- return question . hide === true ;
58+ return question . concealment_page === "buttonHide" ;
5859 } )
5960 } ) . map ( function ( page ) {
6061 return page ;
@@ -190,6 +191,7 @@ const QuestionField = oop.extend(Emitter, {
190191
191192 create : function ( ) {
192193 const self = this ;
194+ self . element = $ ( '<div></div>' ) . addClass ( 'form-group' ) ;
193195 if ( filteredPages . length > 0 && filteredPages . length != 1 ) {
194196 const currentPage = filteredPages . filter ( function ( page ) {
195197 return ( page . questions || [ ] ) . some ( function ( question ) {
@@ -199,26 +201,26 @@ const QuestionField = oop.extend(Emitter, {
199201
200202 const filteredPageIds = currentPage . flatMap ( function ( page ) {
201203 return ( page . questions || [ ] ) . filter ( function ( question ) {
202- return question . hide === true ;
204+ return question . concealment_page === "buttonHide" ;
203205 } )
204206 . map ( function ( question ) {
205207 return question . qid . split ( ':' ) [ 1 ] ;
206208 } ) ;
207209 } ) ;
208210
209- const isHide = currentPage . some ( function ( page ) {
211+ const isConcealmentPage = currentPage . some ( function ( page ) {
210212 return ( page . questions || [ ] ) . some ( function ( question ) {
211213 return question . qid === self . question . qid && self . question . qid . split ( ':' ) [ 1 ] != filteredPageIds && self . question . required != true ;
212214 } )
213215 } ) ;
214216
215- if ( isHide && filteredPageIds . length == 1 ) {
216- self . element = $ ( '<div></div>' ) . addClass ( 'form-group -' + filteredPageIds ) . css ( 'height' , '0' ) . css ( 'overflow' , 'hidden' ) . css ( 'margin' , '0px ') ;
217+ if ( isConcealmentPage && filteredPageIds . length == 1 ) {
218+ self . element = $ ( '<div></div>' ) . addClass ( 'concealment-page -' + filteredPageIds ) . css ( 'height' , '0' ) . css ( 'overflow' , 'scroll ' ) ;
217219 } else {
218- self . element = $ ( '<div></div>' ) . addClass ( 'form-group' ) . css ( 'margin' , '0px' ) ;
220+ self . element = $ ( '<div></div>' ) . addClass ( 'form-group' ) ;
219221 }
220222 } else {
221- self . element = $ ( '<div></div>' ) . addClass ( 'form-group' ) . css ( 'margin' , '0px' ) ;
223+ self . element = $ ( '<div></div>' ) . addClass ( 'form-group' ) ;
222224 }
223225
224226 // construct header
@@ -228,10 +230,6 @@ const QuestionField = oop.extend(Emitter, {
228230 // construct label
229231 const label = $ ( '<label></label>' )
230232 . text ( self . question . title ? getLocalizedText ( self . question . title ) : self . question . label ) ;
231-
232- if ( self . question . auto_value ) {
233- label . append ( $ ( ' <span> ⟳</span> ' ) ) ;
234- }
235233 if ( self . question . required ) {
236234 label . append ( $ ( '<span></span>' )
237235 . css ( 'color' , 'red' )
@@ -240,18 +238,18 @@ const QuestionField = oop.extend(Emitter, {
240238 }
241239 header . append ( label ) ;
242240
243- if ( self . question . hasOwnProperty ( 'hide ' ) && self . question . hide ) {
241+ if ( self . question . hasOwnProperty ( 'concealment_page ' ) && self . question . concealment_page == "buttonHide" ) {
244242 const p = $ ( '<p></p>' ) ;
245243 const a = $ ( '<a></a>' ) . text ( '▼ ' + _ ( 'Show Items' ) ) ;
246244 p . on ( 'click' , function ( ) {
247- $ ( '.form-group -' + self . question . qid . split ( ':' ) [ 1 ] ) . each ( function ( ) {
245+ $ ( '.concealment-page -' + self . question . qid . split ( ':' ) [ 1 ] ) . each ( function ( ) {
248246 if ( $ ( this ) . height ( ) === 0 ) {
249247 $ ( this ) . animate ( { height : $ ( this ) . get ( 0 ) . scrollHeight } , 'fast' , function ( ) {
250- $ ( this ) . css ( 'height' , '' ) ;
248+ $ ( this ) . css ( 'height' , '' ) . addClass ( 'form-group' ) ;
251249 } ) ;
252250 a . text ( '▲ ' + _ ( 'Hide Items' ) ) ;
253251 } else {
254- $ ( this ) . animate ( { height : 0 } , 'fast' ) ;
252+ $ ( this ) . animate ( { height : 0 } , 'fast' ) . removeClass ( 'form-group' ) ;
255253 a . text ( '▼ ' + _ ( 'Show Items' ) ) ;
256254 }
257255 } ) ;
@@ -384,7 +382,7 @@ function createFormField(question, options, value) {
384382 formField = new TextFormField ( question , options ) ;
385383 }
386384 formField . create ( ) ;
387- if ( value != null && value !== '' ) {
385+ if ( value != null && value !== '' || ( question . hasOwnProperty ( 'initial_row_addition' ) && question . initial_row_addition ) ) {
388386 try {
389387 formField . setValue ( value ) ;
390388 } catch ( error ) {
@@ -729,11 +727,7 @@ const ArrayFormField = oop.extend(FormFieldInterface, {
729727 const headRow = $ ( '<tr>' ) ;
730728 const thead = $ ( '<thead>' ) . append ( headRow ) ;
731729 self . question . properties . forEach ( function ( prop ) {
732- if ( prop . auto_value ) {
733- headRow . append ( $ ( '<th>' + getLocalizedText ( prop . title ) + '<span> ⟳</span></th>' ) ) ;
734- } else {
735- headRow . append ( $ ( '<th>' + getLocalizedText ( prop . title ) + '</th>' ) ) ;
736- }
730+ headRow . append ( $ ( '<th>' + getLocalizedText ( prop . title ) + '</th>' ) ) ;
737731 } ) ;
738732 headRow . append ( $ ( '<th>' ) ) ; // remove button header
739733
@@ -846,6 +840,11 @@ const ArrayFormField = oop.extend(FormFieldInterface, {
846840 } else {
847841 rows = value || [ ] ;
848842 }
843+
844+ if ( self . question . hasOwnProperty ( 'initial_row_addition' ) && self . question . initial_row_addition ) {
845+ self . addRow ( ) ;
846+ }
847+
849848 rows . forEach ( function ( row ) {
850849 self . addRow ( row ) ;
851850 } ) ;
@@ -1145,8 +1144,8 @@ function createSuggestionButton(container, question, buttonSuggestions, options,
11451144 . then ( function ( value ) {
11461145 if ( value == 'error' ) {
11471146 return ;
1148- } else if ( value == 'auto-value -filesize-over-error' ) {
1149- var name = question . qid . split ( ':' ) [ 1 ] ;
1147+ } else if ( value == 'get -filesize-over-error' ) {
1148+ var name = question . qid . split ( ':' ) [ 1 ] . replace ( '/' , '-' ) ;
11501149 $ ( '.' + name ) . remove ( ) ;
11511150 container . after (
11521151 '<div class="' + name + '" style="color: red;">' + _ ( "File size exceeds the maximum allowed size." ) + '</div>'
0 commit comments