@@ -117,11 +117,11 @@ export default class TemplateBuilderComponent extends Component {
117117 super ( owner , args ) ;
118118 const cloned = this . _cloneTemplate ( args . template ) ;
119119 const { content, queries, ...meta } = cloned ;
120- this . _meta = meta ;
120+ this . _meta = meta ;
121121 this . _content = Array . isArray ( content ) ? content : [ ] ;
122122 // Seed queries from the template relationship (loaded via hasMany).
123123 // When the template is new (unsaved), this will be an empty array.
124- this . queries = Array . isArray ( queries ) ? queries : [ ] ;
124+ this . queries = Array . isArray ( queries ) ? queries : [ ] ;
125125 }
126126
127127 // -------------------------------------------------------------------------
@@ -157,12 +157,12 @@ export default class TemplateBuilderComponent extends Component {
157157
158158 const queriesSchema = {
159159 namespace : '__queries__' ,
160- label : 'Queries' ,
161- icon : 'database' ,
160+ label : 'Queries' ,
161+ icon : 'database' ,
162162 variables : this . queries . map ( ( q ) => ( {
163- path : q . variable_name ,
164- label : q . label ,
165- type : 'array' ,
163+ path : q . variable_name ,
164+ label : q . label ,
165+ type : 'array' ,
166166 example : `[{ ... }] (${ q . resource_type_label ?? q . model_type ?? '' } )` ,
167167 } ) ) ,
168168 } ;
@@ -188,17 +188,17 @@ export default class TemplateBuilderComponent extends Component {
188188
189189 const defaults = this . _defaultsForType ( type ) ;
190190 const newElement = {
191- uuid : guidFor ( { } ) ,
191+ uuid : guidFor ( { } ) ,
192192 type,
193- label : null ,
194- visible : true ,
195- x : 20 ,
196- y : 20 ,
197- width : defaults . width ,
198- height : defaults . height ,
199- z_index : this . _content . length + 1 ,
193+ label : null ,
194+ visible : true ,
195+ x : 20 ,
196+ y : 20 ,
197+ width : defaults . width ,
198+ height : defaults . height ,
199+ z_index : this . _content . length + 1 ,
200200 rotation : 0 ,
201- opacity : 1 ,
201+ opacity : 1 ,
202202 ...defaults . props ,
203203 } ;
204204
@@ -278,7 +278,7 @@ export default class TemplateBuilderComponent extends Component {
278278 if ( ! el ) return ;
279279 const current = el . rotation ?? 0 ;
280280 // Normalise to [0, 360)
281- const next = ( ( current + deltaDegrees ) % 360 + 360 ) % 360 ;
281+ const next = ( ( ( current + deltaDegrees ) % 360 ) + 360 ) % 360 ;
282282 this . updateElement ( uuid , { rotation : next } ) ;
283283 }
284284
@@ -296,11 +296,11 @@ export default class TemplateBuilderComponent extends Component {
296296 this . _pushUndo ( ) ;
297297
298298 const elements = this . _content ;
299- const element = elements . find ( ( el ) => el . uuid === uuid ) ;
299+ const element = elements . find ( ( el ) => el . uuid === uuid ) ;
300300 if ( ! element ) return ;
301301
302302 const currentZ = element . z_index ?? 1 ;
303- const sorted = [ ...elements ] . sort ( ( a , b ) => ( a . z_index ?? 0 ) - ( b . z_index ?? 0 ) ) ;
303+ const sorted = [ ...elements ] . sort ( ( a , b ) => ( a . z_index ?? 0 ) - ( b . z_index ?? 0 ) ) ;
304304 const sortedIndex = sorted . findIndex ( ( el ) => el . uuid === uuid ) ;
305305
306306 let swapElement = null ;
@@ -315,7 +315,7 @@ export default class TemplateBuilderComponent extends Component {
315315 const swapZ = swapElement . z_index ?? 1 ;
316316
317317 // Mutate z_index in-place on both objects
318- element . z_index = swapZ ;
318+ element . z_index = swapZ ;
319319 swapElement . z_index = currentZ ;
320320
321321 // Replace array reference to trigger reactivity
@@ -382,15 +382,15 @@ export default class TemplateBuilderComponent extends Component {
382382 @action
383383 openVariablePicker ( targetProp , callback ) {
384384 this . variablePickerTargetProp = targetProp ;
385- this . variablePickerCallback = callback ;
386- this . variablePickerOpen = true ;
385+ this . variablePickerCallback = callback ;
386+ this . variablePickerOpen = true ;
387387 }
388388
389389 @action
390390 closeVariablePicker ( ) {
391- this . variablePickerOpen = false ;
391+ this . variablePickerOpen = false ;
392392 this . variablePickerTargetProp = null ;
393- this . variablePickerCallback = null ;
393+ this . variablePickerCallback = null ;
394394 }
395395
396396 @action
@@ -454,14 +454,11 @@ export default class TemplateBuilderComponent extends Component {
454454 const merged = Object . assign ( { } , this . _meta , changes ) ;
455455
456456 if ( changes . paper_size !== undefined || changes . orientation !== undefined ) {
457- const dims = this . _dimensionsForPaperSize (
458- merged . paper_size ?? 'A4' ,
459- merged . orientation ?? 'portrait'
460- ) ;
457+ const dims = this . _dimensionsForPaperSize ( merged . paper_size ?? 'A4' , merged . orientation ?? 'portrait' ) ;
461458 if ( dims ) {
462- merged . width = dims . width ;
459+ merged . width = dims . width ;
463460 merged . height = dims . height ;
464- merged . unit = dims . unit ;
461+ merged . unit = dims . unit ;
465462 }
466463 }
467464
@@ -477,19 +474,19 @@ export default class TemplateBuilderComponent extends Component {
477474 */
478475 _dimensionsForPaperSize ( paperSize , orientation ) {
479476 const sizes = {
480- A4 : { width : 210 , height : 297 } ,
481- A3 : { width : 297 , height : 420 } ,
482- A5 : { width : 148 , height : 210 } ,
477+ A4 : { width : 210 , height : 297 } ,
478+ A3 : { width : 297 , height : 420 } ,
479+ A5 : { width : 148 , height : 210 } ,
483480 Letter : { width : 216 , height : 279 } ,
484- Legal : { width : 216 , height : 356 } ,
481+ Legal : { width : 216 , height : 356 } ,
485482 } ;
486483 const base = sizes [ paperSize ] ;
487484 if ( ! base ) return null ;
488485 const isLandscape = orientation === 'landscape' ;
489486 return {
490- width : isLandscape ? base . height : base . width ,
491- height : isLandscape ? base . width : base . height ,
492- unit : 'mm' ,
487+ width : isLandscape ? base . height : base . width ,
488+ height : isLandscape ? base . width : base . height ,
489+ unit : 'mm' ,
493490 } ;
494491 }
495492
@@ -513,9 +510,7 @@ export default class TemplateBuilderComponent extends Component {
513510 const plain = { } ;
514511 template . eachAttribute ( ( name ) => {
515512 const val = template [ name ] ;
516- plain [ name ] = val !== null && val !== undefined
517- ? JSON . parse ( JSON . stringify ( val ) )
518- : val ;
513+ plain [ name ] = val !== null && val !== undefined ? JSON . parse ( JSON . stringify ( val ) ) : val ;
519514 } ) ;
520515 plain . uuid = template . uuid ?? template . id ?? null ;
521516 return plain ;
@@ -526,13 +521,13 @@ export default class TemplateBuilderComponent extends Component {
526521
527522 _defaultsForType ( type ) {
528523 const map = {
529- text : { width : 200 , height : 40 , props : { content : 'Text' , font_size : 14 , font_family : 'Inter, sans-serif' , font_weight : '400' , color : '#000000' , text_align : 'left' } } ,
530- image : { width : 150 , height : 100 , props : { src : '' , alt : '' , object_fit : 'cover' } } ,
531- table : { width : 400 , height : 200 , props : { columns : [ ] , rows : [ ] , border_color : '#e5e7eb' , header_background : '#f9fafb' , header_color : '#111827' , cell_padding : 6 } } ,
532- line : { width : 200 , height : 2 , props : { color : '#000000' , line_width : 1 , line_style : 'solid' } } ,
533- shape : { width : 100 , height : 100 , props : { shape : 'rectangle' , background_color : '#e5e7eb' , border_width : 0 , border_color : '#000000' , border_radius : 0 } } ,
534- qr_code : { width : 80 , height : 80 , props : { value : '' } } ,
535- barcode : { width : 200 , height : 60 , props : { value : '' , barcode_format : 'CODE128' } } ,
524+ text : { width : 200 , height : 40 , props : { content : 'Text' , font_size : 14 , font_family : 'Inter, sans-serif' , font_weight : '400' , color : '#000000' , text_align : 'left' } } ,
525+ image : { width : 150 , height : 100 , props : { src : '' , alt : '' , object_fit : 'cover' } } ,
526+ table : { width : 400 , height : 200 , props : { columns : [ ] , rows : [ ] , border_color : '#e5e7eb' , header_background : '#f9fafb' , header_color : '#111827' , cell_padding : 6 } } ,
527+ line : { width : 200 , height : 2 , props : { color : '#000000' , line_width : 1 , line_style : 'solid' } } ,
528+ shape : { width : 100 , height : 100 , props : { shape : 'rectangle' , background_color : '#e5e7eb' , border_width : 0 , border_color : '#000000' , border_radius : 0 } } ,
529+ qr_code : { width : 80 , height : 80 , props : { value : '' } } ,
530+ barcode : { width : 200 , height : 60 , props : { value : '' , barcode_format : 'CODE128' } } ,
536531 } ;
537532 return map [ type ] ?? { width : 100 , height : 40 , props : { } } ;
538533 }
0 commit comments