1 | import './component'; |
||
2 | import './config'; |
||
3 | import './preview'; |
||
4 | |||
5 | Shopware.Service('cmsService').registerCmsElement({ |
||
6 | name: 'image-slider', |
||
7 | label: 'sw-cms.elements.imageSlider.label', |
||
8 | component: 'sw-cms-el-image-slider', |
||
9 | configComponent: 'sw-cms-el-config-image-slider', |
||
10 | previewComponent: 'sw-cms-el-preview-image-slider', |
||
11 | defaultConfig: { |
||
12 | sliderItems: { |
||
13 | source: 'static', |
||
14 | value: [], |
||
15 | required: true, |
||
16 | entity: { |
||
17 | name: 'media' |
||
18 | } |
||
19 | }, |
||
20 | navigationArrows: { |
||
21 | source: 'static', |
||
22 | value: 'outside' |
||
23 | }, |
||
24 | navigationDots: { |
||
25 | source: 'static', |
||
26 | value: null |
||
27 | }, |
||
28 | displayMode: { |
||
29 | source: 'static', |
||
30 | value: 'standard' |
||
31 | }, |
||
32 | minHeight: { |
||
33 | source: 'static', |
||
34 | value: '300px' |
||
35 | }, |
||
36 | verticalAlign: { |
||
37 | source: 'static', |
||
38 | value: null |
||
39 | } |
||
40 | }, |
||
41 | View Code Duplication | enrich: function enrich(elem, data) { |
|
0 ignored issues
–
show
Duplication
introduced
by
![]() |
|||
42 | if (Object.keys(data).length < 1) { |
||
43 | return; |
||
44 | } |
||
45 | |||
46 | Object.keys(elem.config).forEach((configKey) => { |
||
47 | const entity = elem.config[configKey].entity; |
||
48 | |||
49 | if (!entity) { |
||
50 | return; |
||
51 | } |
||
52 | |||
53 | const entityKey = entity.name; |
||
54 | if (!data[`entity-${entityKey}`]) { |
||
55 | return; |
||
56 | } |
||
57 | |||
58 | elem.data[configKey] = []; |
||
59 | elem.config[configKey].value.forEach((sliderItem) => { |
||
60 | elem.data[configKey].push({ |
||
61 | newTab: sliderItem.newTab, |
||
62 | url: sliderItem.url, |
||
63 | media: data[`entity-${entityKey}`].get(sliderItem.mediaId) |
||
64 | }); |
||
65 | }); |
||
66 | }); |
||
67 | } |
||
68 | }); |
||
69 |