3333 </b-col >
3434
3535 <hr
36- v-if =" existingBlocks .length"
36+ v-if =" existingLayoutBlocks.length || selectableGlobalBlocks .length"
3737 class =" w-100"
3838 >
3939
4040 <b-col
41- v-if =" existingBlocks .length"
41+ v-if =" existingLayoutBlocks .length"
4242 cols =" 12"
43+ class =" mt-3"
4344 >
4445 <b-input-group class =" d-flex w-100" >
4546 <c-input-select
46- v-model =" selectedExistingBlock "
47+ v-model =" selectedLayoutBlock "
4748 :get-option-label =" getBlockLabel"
4849 :get-option-key =" b => b.blockID"
49- :options =" existingBlocks"
50+ :options =" existingLayoutBlocks"
51+ :reduce =" b => b.blockID"
5052 :placeholder =" $t('selector.selectableBlocks.placeholder')"
5153 />
5254
5355 <b-input-group-append >
5456 <b-button
5557 v-b-tooltip.noninteractive.hover =" { title: $t('selector.tooltip.clone.noRef'), container: '#body' }"
5658 variant =" extra-light"
57- :disabled =" !selectedExistingBlock "
59+ :disabled =" !selectedLayoutBlock "
5860 class =" d-flex align-items-center"
59- @click =" $emit('select', selectedExistingBlock.clone() )"
61+ @click =" selectBlock(selectedLayoutBlock, true )"
6062 >
6163 <font-awesome-icon
6264 :icon =" ['far', 'clone']"
6668 <b-button
6769 v-b-tooltip.noninteractive.hover =" { title: $t('selector.tooltip.clone.ref'), container: '#body' }"
6870 variant =" extra-light"
69- :disabled =" !selectedExistingBlock "
71+ :disabled =" !selectedLayoutBlock "
7072 class =" d-flex align-items-center"
71- @click =" $emit('select', selectedExistingBlock)"
73+ @click =" selectBlock(selectedLayoutBlock)"
74+ >
75+ <font-awesome-icon
76+ :icon =" ['far', 'copy']"
77+ />
78+ </b-button >
79+ </b-input-group-append >
80+ </b-input-group >
81+ </b-col >
82+
83+ <b-col
84+ v-if =" selectableGlobalBlocks.length"
85+ cols =" 12"
86+ >
87+ <b-input-group class =" d-flex w-100" >
88+ <c-input-select
89+ v-model =" selectedGlobalBlock"
90+ :get-option-label =" getBlockLabel"
91+ :get-option-key =" b => b.blockID"
92+ :options =" selectableGlobalBlocks"
93+ :reduce =" b => b.blockID"
94+ :placeholder =" $t('selector.selectableGlobalBlocks.placeholder')"
95+ />
96+
97+ <b-input-group-append >
98+ <b-button
99+ v-b-tooltip.noninteractive.hover =" { title: $t('selector.tooltip.clone.noRef'), container: '#body' }"
100+ variant =" extra-light"
101+ :disabled =" !selectedGlobalBlock"
102+ class =" d-flex align-items-center"
103+ @click =" selectBlock(selectedGlobalBlock, true)"
104+ >
105+ <font-awesome-icon
106+ :icon =" ['far', 'clone']"
107+ />
108+ </b-button >
109+
110+ <b-button
111+ v-b-tooltip.noninteractive.hover =" { title: $t('selector.tooltip.clone.ref'), container: '#body' }"
112+ variant =" extra-light"
113+ :disabled =" !selectedGlobalBlock"
114+ class =" d-flex align-items-center"
115+ @click =" selectBlock(selectedGlobalBlock)"
72116 >
73117 <font-awesome-icon
74118 :icon =" ['far', 'copy']"
@@ -101,7 +145,12 @@ export default {
101145 default : () => [],
102146 },
103147
104- existingBlocks: {
148+ existingLayoutBlocks: {
149+ type: Array ,
150+ default : () => [],
151+ },
152+
153+ selectableGlobalBlocks: {
105154 type: Array ,
106155 default : () => [],
107156 },
@@ -111,7 +160,8 @@ export default {
111160 return {
112161 current: undefined ,
113162
114- selectedExistingBlock: undefined ,
163+ selectedLayoutBlock: undefined ,
164+ selectedGlobalBlock: undefined ,
115165
116166 types: [
117167 {
@@ -220,9 +270,26 @@ export default {
220270
221271 setDefaultValues () {
222272 this .current = undefined
223- this .selectedExistingBlock = undefined
273+ this .selectedLayoutBlock = undefined
274+ this .selectedGlobalBlock = undefined
224275 this .types = []
225276 },
277+
278+ fetchBlockData (blockID ) {
279+ if (blockID .includes (' -' )) {
280+ return this .selectableGlobalBlocks .find ((b ) => b .blockID === blockID)
281+ }
282+
283+ return this .existingLayoutBlocks .find ((b ) => b .blockID === blockID)
284+ },
285+
286+ selectBlock (block , clone = false ) {
287+ if (clone) {
288+ this .$emit (' select' , this .fetchBlockData (block).clone ())
289+ } else {
290+ this .$emit (' select' , this .fetchBlockData (block))
291+ }
292+ },
226293 },
227294}
228295 </script >
0 commit comments