2022-04-29 18:29:42 +08:00
|
|
|
<template>
|
2022-05-11 17:18:40 +08:00
|
|
|
<div class="step-text-container" :class="{ 'edit': inEditMode }">
|
2022-06-21 17:32:27 +08:00
|
|
|
<div class="action-container" @click="enableEditMode($event)">
|
2022-06-03 17:52:10 +08:00
|
|
|
<div v-if="reorderElementUrl" class="element-grip" @click="$emit('reorder')">
|
2022-05-10 19:28:09 +08:00
|
|
|
<i class="fas fa-grip-vertical"></i>
|
|
|
|
</div>
|
|
|
|
<div class="buttons-container">
|
2022-06-03 17:52:10 +08:00
|
|
|
<button v-if="element.attributes.orderable.urls.update_url" class="btn icon-btn btn-light">
|
2022-05-10 19:28:09 +08:00
|
|
|
<i class="fas fa-pen"></i>
|
|
|
|
</button>
|
2022-06-03 17:52:10 +08:00
|
|
|
<button v-if="element.attributes.orderable.urls.delete_url" class="btn icon-btn btn-light" @click="showDeleteModal">
|
2022-05-10 19:28:09 +08:00
|
|
|
<i class="fas fa-trash"></i>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<Tinymce
|
2022-06-03 17:52:10 +08:00
|
|
|
v-if="element.attributes.orderable.urls.update_url"
|
2022-05-10 19:28:09 +08:00
|
|
|
: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"
|
|
|
|
/>
|
2022-06-03 17:52:10 +08:00
|
|
|
<div v-else v-html="element.attributes.orderable.text_view"></div>
|
2022-05-30 19:45:51 +08:00
|
|
|
<deleteElementModal v-if="confirmingDelete" @confirm="deleteElement($event)" @cancel="closeDeleteModal"/>
|
2022-04-29 18:29:42 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-05-03 21:15:49 +08:00
|
|
|
import DeleteMixin from 'vue/protocol/mixins/components/delete.js'
|
2022-05-30 19:45:51 +08:00
|
|
|
import deleteElementModal from 'vue/protocol/modals/delete_element.vue'
|
2022-05-10 19:28:09 +08:00
|
|
|
import Tinymce from 'vue/shared/tinymce.vue'
|
2022-05-04 16:25:53 +08:00
|
|
|
|
2022-04-29 18:29:42 +08:00
|
|
|
export default {
|
2022-05-03 21:15:49 +08:00
|
|
|
name: 'StepText',
|
2022-05-30 19:45:51 +08:00
|
|
|
components: { deleteElementModal, Tinymce },
|
2022-05-03 21:15:49 +08:00
|
|
|
mixins: [DeleteMixin],
|
|
|
|
props: {
|
|
|
|
element: {
|
|
|
|
type: Object,
|
|
|
|
required: true
|
2022-06-03 17:52:10 +08:00
|
|
|
},
|
2022-06-07 18:10:10 +08:00
|
|
|
inRepository: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
},
|
2022-06-03 17:52:10 +08:00
|
|
|
reorderElementUrl: {
|
|
|
|
type: String
|
2022-05-03 21:15:49 +08:00
|
|
|
}
|
2022-05-10 19:28:09 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
inEditMode: false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2022-06-21 17:32:27 +08:00
|
|
|
enableEditMode(e) {
|
2022-07-04 18:46:59 +08:00
|
|
|
if ($(e.target).hasClass('fas fa-grip-vertical') || $(e.target).hasClass('element-grip')) return
|
2022-06-03 17:52:10 +08:00
|
|
|
if (!this.element.attributes.orderable.urls.update_url) return
|
2022-05-10 19:28:09 +08:00
|
|
|
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
|
2022-06-22 00:20:52 +08:00
|
|
|
this.element.attributes.orderable.name = data.data.attributes.name
|
|
|
|
this.element.attributes.orderable.updated_at = data.data.attributes.updated_at
|
2022-05-10 19:28:09 +08:00
|
|
|
this.$emit('update', this.element, true)
|
|
|
|
}
|
2022-05-03 21:15:49 +08:00
|
|
|
}
|
2022-04-29 18:29:42 +08:00
|
|
|
}
|
2022-05-03 19:42:43 +08:00
|
|
|
</script>
|