Skip to content

Commit

Permalink
widgets: ImageView: persist url in widget options
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani authored and rafaellehmkuhl committed Jun 2, 2023
1 parent 9f93964 commit 9dde368
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions src/components/widgets/ImageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
<v-card class="pa-2">
<v-card-title>Image URL</v-card-title>
<v-card-text>
<v-text-field v-model="src" label="Image URL" outlined></v-text-field>
<v-text-field
label="Image URL"
:model-value="widget.options.src"
outlined
@change="widget.options.src = $event.srcElement.value"
></v-text-field>
</v-card-text>
<v-card-actions>
<v-btn color="primary" text @click="showOptionsDialog = false">Close</v-btn>
Expand All @@ -24,10 +29,29 @@
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { computed, onBeforeMount, ref, toRefs } from 'vue'
import type { Widget } from '@/types/widgets'
const src = ref<string | undefined>()
const showOptionsDialog = ref(false)
const props = defineProps<{
/**
* Widget reference
*/
widget: Widget
}>()
const widget = toRefs(props).widget
onBeforeMount(() => {
// Set initial widget options if they don't exist
if (Object.keys(widget.value.options).length === 0) {
widget.value.options = {
src: '',
}
}
})
const src = computed(() => widget.value.options.src ?? '')
</script>

<style scoped>
Expand Down

0 comments on commit 9dde368

Please sign in to comment.