2022-04-29 18:29:42 +08:00
|
|
|
<template>
|
2022-07-21 21:49:03 +08:00
|
|
|
<div class="step-text-container" :class="{ 'edit': inEditMode, 'step-element--locked': !element.attributes.orderable.urls.update_url }" @keyup.enter="enableEditMode($event)" tabindex="0">
|
2022-07-20 16:14:23 +08:00
|
|
|
<div v-if="reorderElementUrl" class="step-element-grip" @click="$emit('reorder')">
|
2023-06-15 21:12:51 +08:00
|
|
|
<i class="sn-icon sn-icon-sort"></i>
|
2022-07-08 18:51:43 +08:00
|
|
|
</div>
|
2022-07-11 18:31:54 +08:00
|
|
|
<div v-else class="step-element-grip-placeholder"></div>
|
2022-07-08 18:51:43 +08:00
|
|
|
<div class="buttons-container">
|
2023-01-03 19:25:22 +08:00
|
|
|
<button v-if="element.attributes.orderable.urls.update_url" class="btn icon-btn btn-light" tabindex="0" @click="enableEditMode($event)">
|
2023-06-15 21:12:51 +08:00
|
|
|
<i class="sn-icon sn-icon-edit"></i>
|
2022-07-08 18:51:43 +08:00
|
|
|
</button>
|
2023-01-03 19:25:22 +08:00
|
|
|
<button v-if="element.attributes.orderable.urls.duplicate_url" class="btn icon-btn btn-light" tabindex="0" @click="duplicateElement">
|
2023-06-08 14:33:37 +08:00
|
|
|
<i class="sn-icon sn-icon-duplicate"></i>
|
2022-08-22 20:02:19 +08:00
|
|
|
</button>
|
2023-01-03 19:25:22 +08:00
|
|
|
<button v-if="element.attributes.orderable.urls.delete_url" class="btn icon-btn btn-light" @click="showDeleteModal" tabindex="0">
|
2023-06-08 14:33:37 +08:00
|
|
|
<i class="sn-icon sn-icon-delete"></i>
|
2022-07-08 18:51:43 +08:00
|
|
|
</button>
|
2022-05-10 19:28:09 +08:00
|
|
|
</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
|
|
|
:value="element.attributes.orderable.text"
|
|
|
|
:value_html="element.attributes.orderable.text_view"
|
2022-07-13 21:15:01 +08:00
|
|
|
:placeholder="element.attributes.orderable.placeholder"
|
2022-07-14 03:09:30 +08:00
|
|
|
:inEditMode="inEditMode || isNew"
|
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"
|
2023-04-25 21:12:19 +08:00
|
|
|
:assignableMyModuleId="assignableMyModuleId"
|
2023-05-17 17:40:14 +08:00
|
|
|
:characterLimit="1000000"
|
2022-05-10 19:28:09 +08:00
|
|
|
@update="update"
|
|
|
|
@editingDisabled="disableEditMode"
|
2022-07-08 18:51:43 +08:00
|
|
|
@editingEnabled="enableEditMode"
|
2022-05-10 19:28:09 +08:00
|
|
|
/>
|
2022-09-20 21:44:52 +08:00
|
|
|
<div class="view-text-element" v-else-if="element.attributes.orderable.text_view" v-html="element.attributes.orderable.text_view"></div>
|
2022-07-15 20:58:06 +08:00
|
|
|
<div v-else class="empty-text-element">
|
|
|
|
{{ i18n.t("protocols.steps.text.empty_text") }}
|
|
|
|
</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>
|
2023-03-30 19:27:10 +08:00
|
|
|
import DeleteMixin from '../mixins/components/delete.js'
|
|
|
|
import DuplicateMixin from '../mixins/components/duplicate.js'
|
|
|
|
import deleteElementModal from '../modals/delete_element.vue'
|
|
|
|
import Tinymce from '../../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-08-30 21:26:52 +08:00
|
|
|
mixins: [DeleteMixin, DuplicateMixin],
|
2022-05-03 21:15:49 +08:00
|
|
|
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-07-07 19:43:29 +08:00
|
|
|
},
|
|
|
|
isNew: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
2023-04-25 21:12:19 +08:00
|
|
|
},
|
|
|
|
assignableMyModuleId: {
|
|
|
|
type: Number,
|
|
|
|
required: false
|
2022-05-03 21:15:49 +08:00
|
|
|
}
|
2022-05-10 19:28:09 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
inEditMode: false,
|
|
|
|
}
|
|
|
|
},
|
2022-07-07 19:43:29 +08:00
|
|
|
mounted() {
|
|
|
|
if (this.isNew) {
|
2022-12-14 21:32:23 +08:00
|
|
|
this.enableEditMode();
|
2022-07-07 19:43:29 +08:00
|
|
|
}
|
|
|
|
},
|
2022-05-10 19:28:09 +08:00
|
|
|
methods: {
|
2022-07-07 19:43:29 +08:00
|
|
|
enableEditMode() {
|
2022-06-03 17:52:10 +08:00
|
|
|
if (!this.element.attributes.orderable.urls.update_url) return
|
2022-12-09 19:52:18 +08:00
|
|
|
if (this.inEditMode) return
|
2022-05-10 19:28:09 +08:00
|
|
|
this.inEditMode = true
|
|
|
|
},
|
|
|
|
disableEditMode() {
|
|
|
|
this.inEditMode = false
|
|
|
|
},
|
|
|
|
update(data) {
|
2022-12-09 19:52:18 +08:00
|
|
|
this.element.attributes.orderable.text_view = data.attributes.text_view
|
|
|
|
this.element.attributes.orderable.text = data.attributes.text
|
|
|
|
this.element.attributes.orderable.name = data.attributes.name
|
|
|
|
this.element.attributes.orderable.updated_at = 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>
|