scinote-web/app/javascript/vue/protocol/step_components/text.vue

69 lines
2.1 KiB
Vue
Raw Normal View History

<template>
2022-05-11 17:18:40 +08:00
<div class="step-text-container" :class="{ 'edit': inEditMode }">
2022-05-10 19:28:09 +08:00
<div class="action-container" @click="enableEditMode">
<div class="element-grip">
<i class="fas fa-grip-vertical"></i>
</div>
<div class="buttons-container">
<button class="btn icon-btn btn-light">
<i class="fas fa-pen"></i>
</button>
<button class="btn icon-btn btn-light" @click="showDeleteModal">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
<Tinymce
:inEditMode="inEditMode"
:value="element.attributes.orderable.text"
:value_html="element.attributes.orderable.text_view"
2022-05-11 17:18:40 +08:00
:placeholder="i18n.t('protocols.steps.text.placeholder')"
2022-05-10 19:28:09 +08:00
:updateUrl="element.attributes.orderable.urls.update_url"
:objectType="'StepText'"
:objectId="element.attributes.orderable.id"
:fieldName="'step_text[text]'"
:lastUpdated="element.attributes.orderable.updated_at"
@update="update"
@editingDisabled="disableEditMode"
/>
<deleteComponentModal v-if="confirmingDelete" @confirm="deleteComponent(event)" @cancel="closeDeleteModal"/>
</div>
</template>
<script>
import DeleteMixin from 'vue/protocol/mixins/components/delete.js'
2022-05-04 16:25:53 +08:00
import deleteComponentModal from 'vue/protocol/modals/delete_component.vue'
2022-05-10 19:28:09 +08:00
import Tinymce from 'vue/shared/tinymce.vue'
2022-05-04 16:25:53 +08:00
export default {
name: 'StepText',
2022-05-10 19:28:09 +08:00
components: { deleteComponentModal, Tinymce },
mixins: [DeleteMixin],
props: {
element: {
type: Object,
required: true
}
2022-05-10 19:28:09 +08:00
},
data() {
return {
inEditMode: false,
}
},
methods: {
enableEditMode() {
this.inEditMode = true
},
disableEditMode() {
this.inEditMode = false
},
update(data) {
this.element.attributes.orderable.text_view = data.data.attributes.text_view
this.element.attributes.orderable.text = data.data.attributes.text
this.element.attributes.orderable.udpated_at = data.data.attributes.udpated_at
this.$emit('update', this.element, true)
}
}
}
2022-05-03 19:42:43 +08:00
</script>