18
18
*
19
19
*/
20
20
21
+ import { ServerComponent } from '../server-component.js' ;
22
+
21
23
let template =
22
24
`
23
- <section class="container product" data-v-component-product>
25
+ <section class="container product" data-v-component-product data-v-product_id="1" >
24
26
25
27
26
28
<div class="row g-0">
27
29
<div class="col-md-6 col-sm-12">
28
30
29
31
<div id="product-gallery" class="carousel slide" data-bs-ride="carousel" data-bs-touch="true" data-v-product-images>
30
32
<div class="carousel-inner">
31
- <div class="carousel-item" data-v-product-image data-v-class-if-active="i = 0" >
33
+ <div class="carousel-item active">
34
+ <div class="zoom" data-v-product-main-image-background-image>
35
+ <img src="img/demo/product.jpg" loading="lazy" class="d-block w-100" alt="" data-v-product-main-image>
36
+ </div>
37
+ </div>
38
+ <div class="carousel-item" data-v-product-image>
32
39
<div class="zoom" data-v-product-image-background-image>
33
- <img src="img/demo/product.jpg" class="d-block w-100" alt="" data-v-product-image-src>
40
+ <img src="img/demo/product.jpg" loading="lazy" class="d-block w-100" alt="" data-v-product-image-src>
34
41
</div>
35
42
</div>
36
43
<div class="carousel-item" data-v-product-image>
37
44
<div class="zoom" data-v-product-image-background-image>
38
- <img src="img/demo/product-2.jpg" class="d-block w-100" alt="" data-v-product-image-src>
45
+ <img src="img/demo/product-2.jpg" loading="lazy" class="d-block w-100" alt="" data-v-product-image-src>
39
46
</div>
40
47
</div>
41
48
</div>
@@ -52,14 +59,17 @@ let template =
52
59
<div class="carousel">
53
60
54
61
<div class="carousel-thumbs" data-v-product-images>
55
- <button type="button" data-bs-target="#product-gallery" class="img-thumbnail" data-bs-slide-to="0" data-v-product-image >
56
- <img src="" alt="" class="d-block w-100" data-v-product-image-src >
62
+ <button type="button" data-bs-target="#product-gallery" class="img-thumbnail" data-bs-slide-to="0">
63
+ <img src="" alt="" class="d-block w-100" loading="lazy" data-v-product-main-image >
57
64
</button>
58
65
<button type="button" data-bs-target="#product-gallery" class="img-thumbnail" data-bs-slide-to="1" data-v-product-image>
59
- <img src="" alt="" class="d-block w-100" data-v-product-image-src>
66
+ <img src="" alt="" class="d-block w-100" loading="lazy" data-v-product-image-src>
60
67
</button>
61
68
<button type="button" data-bs-target="#product-gallery" class="img-thumbnail" data-bs-slide-to="2" data-v-product-image>
62
- <img src="" alt="" class="d-block w-100" data-v-product-image-src>
69
+ <img src="" alt="" class="d-block w-100" loading="lazy" data-v-product-image-src>
70
+ </button>
71
+ <button type="button" data-bs-target="#product-gallery" class="img-thumbnail" data-bs-slide-to="3" data-v-product-image>
72
+ <img src="" alt="" class="d-block w-100" loading="lazy" data-v-product-image-src>
63
73
</button>
64
74
</div>
65
75
@@ -280,176 +290,32 @@ let template =
280
290
</section>
281
291
` ;
282
292
283
- class ProductComponent {
284
- constructor ( )
285
- {
293
+ class ProductComponent extends ServerComponent {
294
+ constructor ( ) {
295
+ super ( ) ;
296
+
286
297
this . name = "Product" ;
287
298
this . attributes = [ "data-v-component-product" ] ,
288
299
289
300
this . image = "icons/product.svg" ;
290
301
this . html = template ;
291
302
292
303
this . properties = [ {
293
- name : false ,
294
- key : "source" ,
295
- inputtype : RadioButtonInput ,
296
- htmlAttr :"data-v-source" ,
297
- data : {
298
- inline : true ,
299
- extraclass :"btn-group-fullwidth" ,
300
- options : [ {
301
- value : "automatic" ,
302
- icon :"la la-cog" ,
303
- text : "Configuration" ,
304
- title : "Configuration" ,
305
- extraclass :"btn-sm" ,
306
- checked :true ,
307
- } , {
308
- value : "autocomplete" ,
309
- text : "Autocomplete" ,
310
- title : "Autocomplete" ,
311
- icon :"la la-search" ,
312
- extraclass :"btn-sm" ,
313
- } ] ,
314
- } ,
315
-
316
- setGroup : group => {
317
- document . querySelectorAll ( '.mb-3[data-group]' ) . forEach ( e => e . classList . add ( "d-none" ) ) ;
318
- document . querySelectorAll ( '.mb-3[data-group="' + group + '"].d-none' ) . forEach ( ( el , i ) => {
319
- el . classList . remove ( "d-none" ) ;
320
- } ) ;
321
-
322
- return element ;
323
- } ,
324
- onChange : function ( element , value , input ) {
325
- this . setGroup ( input . value ) ;
326
-
327
- return element ;
328
- } ,
329
- init : node => {
330
- console . log ( node , 'init' ) ;
331
- //return this.setGroup('autocomplete');
332
- //return 'autocomplete';
333
- return node . dataset . source ;
334
- } ,
335
- } , {
336
- name : "Product" ,
337
- key : "product" ,
304
+ name : "Product name <span class='text-muted'>(autocomplete)</span>" ,
305
+ key : "post" ,
338
306
group :"autocomplete" ,
339
- htmlAttr :"data-v-product" ,
340
- inline :false ,
341
- col :12 ,
342
- inputtype : AutocompleteList ,
343
- data : {
344
- url : "/admin/?module=editor/editor&action=productAutocomplete" ,
345
- } ,
346
- } , {
347
- name : "Nr. of product" ,
348
- group :"automatic" ,
349
- col :6 ,
350
- inline :false ,
351
- key : "limit" ,
352
- htmlAttr :"data-v-limit" ,
353
- inputtype : NumberInput ,
354
- data : {
355
- value : "8" , //default
356
- min : "1" ,
357
- max : "1024" ,
358
- step : "1"
359
- } ,
360
- getFromNode : node => 10
361
- ,
362
- } , {
363
- name : "Start from page" ,
364
- group :"automatic" ,
365
- col :6 ,
366
- inline :false ,
367
- key : "page" ,
368
- htmlAttr :"data-v-page" ,
369
- data : {
370
- value : "1" , //default
371
- min : "1" ,
372
- max : "1024" ,
373
- step : "1"
374
- } ,
375
- inputtype : NumberInput ,
376
- getFromNode : node => 0 ,
377
- } , {
378
- name : "Order by" ,
379
- group :"automatic" ,
380
- key : "order" ,
381
- htmlAttr :"data-v-order" ,
382
- inputtype : SelectInput ,
383
- data : {
384
- options : [ {
385
- value : "price_asc" ,
386
- text : "Price Ascending"
387
- } , {
388
- value : "price_desc" ,
389
- text : "Price Descending"
390
- } , {
391
- value : "date_asc" ,
392
- text : "Date Ascending"
393
- } , {
394
- value : "date_desc" ,
395
- text : "Date Descending"
396
- } , {
397
- value : "sales_asc" ,
398
- text : "Sales Ascending"
399
- } , {
400
- value : "sales_desc" ,
401
- text : "Sales Descending"
402
- } ]
403
- }
404
- } , {
405
- name : "Category" ,
406
- group :"automatic" ,
407
- key : "category" ,
408
- htmlAttr :"data-v-category" ,
307
+ htmlAttr :"data-v-product_id" ,
409
308
inline :false ,
410
309
col :12 ,
411
- inputtype : TagsInput ,
310
+ inputtype : AutocompleteInput ,
412
311
data : {
413
- url : "/admin/?module=editor&action=productAutocomplete " ,
312
+ url : "/admin/?module=editor/autocomplete &action=products&type= " ,
414
313
} ,
415
314
416
- } , {
417
- name : "Manufacturer" ,
418
- group :"automatic" ,
419
- key : "manufacturer" ,
420
- htmlAttr :"data-v-manufacturer" ,
421
- inline :false ,
422
- col :12 ,
423
- inputtype : TagsInput ,
424
- data : {
425
- url : "/admin/?module=editor&action=productAutocomplete" ,
426
- }
427
- } , {
428
- name : "Manufacturer 2" ,
429
- group :"automatic" ,
430
- key : "manufacturer 2" ,
431
- htmlAttr :"data-v-manufacturer2" ,
432
- inline :false ,
433
- col :12 ,
434
- inputtype : TagsInput ,
435
- data : {
436
- url : "/admin/?module=editor&action=productAutocomplete" ,
437
- } ,
438
- } ] ;
315
+ } ] ;
439
316
}
440
317
441
- init ( node )
442
- {
443
- document . querySelectorAll ( '.mb-3[data-group]' ) . forEach ( ( el , i ) => {
444
- el . classList . add ( "d-none" ) ;
445
- } ) ;
446
-
447
- let source = node . dataset . vSource ;
448
- if ( ! source ) {
449
- source = "automatic" ;
450
- }
451
-
452
- document . querySelectorAll ( '.mb-3[data-group="' + source + '"]' ) . forEach ( e => e . classList . remove ( "d-none" ) ) ;
318
+ init ( node ) {
453
319
}
454
320
}
455
321
0 commit comments