3333 </b-col >
3434
3535 <hr
36- v-if =" existingBlocks .length"
36+ v-if =" existingLayoutBlocks .length || selectableNamespaceGlobalBlocks "
3737 class =" w-100"
3838 >
3939
4040 <b-col
41- v-if =" existingBlocks .length"
41+ v-if =" selectableNamespaceGlobalBlocks .length"
4242 cols =" 12"
4343 >
4444 <b-input-group class =" d-flex w-100" >
4545 <c-input-select
46- v-model =" selectedExistingBlock"
46+ v-model =" selectedGlobalBlock"
47+ :get-option-label =" getBlockLabel"
48+ :get-option-key =" getOptionKey"
49+ :options =" selectableNamespaceGlobalBlocks"
50+ :reduce =" b => b.blockID"
51+ placeholder =" Select global block from other pages"
52+ />
53+
54+ <b-input-group-append >
55+ <b-button
56+ v-b-tooltip.noninteractive.hover =" { title: $t('selector.tooltip.clone.noRef'), container: '#body' }"
57+ variant =" extra-light"
58+ :disabled =" !selectedGlobalBlock"
59+ class =" d-flex align-items-center"
60+ @click =" $emit('select', fetchBlockData(selectedGlobalBlock).clone())"
61+ >
62+ <font-awesome-icon
63+ :icon =" ['far', 'clone']"
64+ />
65+ </b-button >
66+
67+ <b-button
68+ v-b-tooltip.noninteractive.hover =" { title: $t('selector.tooltip.clone.ref'), container: '#body' }"
69+ variant =" extra-light"
70+ :disabled =" !selectedGlobalBlock"
71+ class =" d-flex align-items-center"
72+ @click =" $emit('select', fetchBlockData(selectedGlobalBlock))"
73+ >
74+ <font-awesome-icon
75+ :icon =" ['far', 'copy']"
76+ />
77+ </b-button >
78+ </b-input-group-append >
79+ </b-input-group >
80+ </b-col >
81+
82+ <b-col
83+ v-if =" existingLayoutBlocks.length"
84+ cols =" 12"
85+ class =" mt-3"
86+ >
87+ <b-input-group class =" d-flex w-100" >
88+ <c-input-select
89+ v-model =" selectedLayoutExistingBlock"
4790 :get-option-label =" getBlockLabel"
4891 :get-option-key =" b => b.blockID"
49- :options =" existingBlocks"
92+ :options =" existingLayoutBlocks"
93+ :reduce =" b => b.blockID"
5094 :placeholder =" $t('selector.selectableBlocks.placeholder')"
5195 />
5296
5397 <b-input-group-append >
5498 <b-button
5599 v-b-tooltip.noninteractive.hover =" { title: $t('selector.tooltip.clone.noRef'), container: '#body' }"
56100 variant =" extra-light"
57- :disabled =" !selectedExistingBlock "
101+ :disabled =" !selectedLayoutExistingBlock "
58102 class =" d-flex align-items-center"
59- @click =" $emit('select', selectedExistingBlock .clone())"
103+ @click =" $emit('select', fetchBlockData(selectedLayoutExistingBlock) .clone())"
60104 >
61105 <font-awesome-icon
62106 :icon =" ['far', 'clone']"
66110 <b-button
67111 v-b-tooltip.noninteractive.hover =" { title: $t('selector.tooltip.clone.ref'), container: '#body' }"
68112 variant =" extra-light"
69- :disabled =" !selectedExistingBlock "
113+ :disabled =" !selectedLayoutExistingBlock "
70114 class =" d-flex align-items-center"
71- @click =" $emit('select', selectedExistingBlock )"
115+ @click =" $emit('select', fetchBlockData(selectedLayoutExistingBlock) )"
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+ selectableNamespaceGlobalBlocks: {
105154 type: Array ,
106155 default : () => [],
107156 },
@@ -111,7 +160,8 @@ export default {
111160 return {
112161 current: undefined ,
113162
114- selectedExistingBlock: undefined ,
163+ selectedLayoutExistingBlock: undefined ,
164+ selectedGlobalBlock: undefined ,
115165
116166 types: [
117167 {
@@ -225,9 +275,22 @@ export default {
225275
226276 setDefaultValues () {
227277 this .current = undefined
228- this .selectedExistingBlock = undefined
278+ this .selectedLayoutExistingBlock = undefined
279+ this .selectedGlobalBlock = undefined
229280 this .types = []
230281 },
282+
283+ getOptionKey ({ blockID }) {
284+ return blockID
285+ },
286+
287+ fetchBlockData (blockID ) {
288+ if (blockID .includes (' -' )) {
289+ return this .selectableNamespaceGlobalBlocks .find ((b ) => b .blockID === blockID)
290+ }
291+
292+ return this .existingLayoutBlocks .find ((b ) => b .blockID === blockID)
293+ },
231294 },
232295}
233296 </script >
0 commit comments