|
18 | 18 | </f7-subnavbar>
|
19 | 19 | </f7-navbar>
|
20 | 20 | <f7-toolbar class="contextual-toolbar" :class="{ 'navbar': $theme.md }" v-if="showCheckboxes" bottom-ios bottom-aurora>
|
21 |
| - <f7-link color="red" v-show="selectedItems.length" v-if="!$theme.md" class="delete" icon-ios="f7:trash" icon-aurora="f7:trash" @click="removeSelected"> |
| 21 | + <f7-link color="red" v-show="selectedItems.length" v-if="!$theme.md" class="delete right-margin" icon-ios="f7:trash" icon-aurora="f7:trash" @click="removeSelected"> |
22 | 22 | Remove {{ selectedItems.length }}
|
23 | 23 | </f7-link>
|
| 24 | + <f7-link color="blue" v-show="selectedItems.length" v-if="!$theme.md" class="copy" icon-ios="f7:square_on_square" icon-aurora="f7:square_on_square" @click="copySelected"> |
| 25 | + Copy DSL Definitions |
| 26 | + </f7-link> |
24 | 27 | <f7-link v-if="$theme.md" icon-md="material:close" icon-color="white" @click="showCheckboxes = false" />
|
25 | 28 | <div class="title" v-if="$theme.md">
|
26 | 29 | {{ selectedItems.length }} selected
|
27 | 30 | </div>
|
28 |
| - <div class="right" v-if="$theme.md"> |
29 |
| - <f7-link v-show="selectedItems.length" icon-md="material:delete" icon-color="white" @click="removeSelected" /> |
| 31 | + <div class="right" v-if="$theme.md && selectedItems.length"> |
| 32 | + <f7-link icon-md="material:delete" icon-color="white" @click="removeSelected" /> |
| 33 | + <f7-link icon-md="material:content_copy" icon-color="white" @click="copySelected" /> |
30 | 34 | </div>
|
31 | 35 | </f7-toolbar>
|
32 | 36 |
|
|
135 | 139 | </style>
|
136 | 140 |
|
137 | 141 | <script>
|
| 142 | +import Vue from 'vue' |
| 143 | +import Clipboard from 'v-clipboard' |
| 144 | +
|
| 145 | +Vue.use(Clipboard) |
| 146 | +
|
138 | 147 | import ItemMixin from '@/components/item/item-mixin'
|
139 | 148 |
|
140 | 149 | export default {
|
@@ -273,6 +282,21 @@ export default {
|
273 | 282 | this.selectedItems.push(item)
|
274 | 283 | }
|
275 | 284 | },
|
| 285 | + copySelected () { |
| 286 | + const promises = this.selectedItems.map((itemName) => this.$oh.api.getPlain({ |
| 287 | + url: '/rest/file-format/items/' + itemName, |
| 288 | + headers: { accept: 'text/vnd.openhab.dsl.item' } |
| 289 | + })) |
| 290 | + Promise.all(promises).then((data) => { |
| 291 | + if (this.$clipboard(data.join('\n'))) { |
| 292 | + this.$f7.toast.create({ |
| 293 | + text: 'DSL definitions copied to clipboard', |
| 294 | + destroyOnClose: true, |
| 295 | + closeTimeout: 2000 |
| 296 | + }).open() |
| 297 | + } |
| 298 | + }) |
| 299 | + }, |
276 | 300 | removeSelected () {
|
277 | 301 | const vm = this
|
278 | 302 |
|
|
0 commit comments