2021-03-03 19:31:05 +01:00
|
|
|
<template>
|
|
|
|
<div class="tr" @click="selectRow($event, row._id)">
|
|
|
|
<div
|
|
|
|
v-for="(col, cKey) in row"
|
|
|
|
v-show="cKey !== '_id'"
|
|
|
|
:key="cKey"
|
|
|
|
class="td p-0"
|
|
|
|
tabindex="0"
|
|
|
|
@contextmenu.prevent="openContext($event, { id: row._id, field: cKey })"
|
|
|
|
>
|
|
|
|
<template v-if="cKey !== '_id'">
|
|
|
|
<span
|
|
|
|
v-if="!isInlineEditor[cKey]"
|
2021-08-16 19:44:55 +02:00
|
|
|
class="cell-content"
|
2021-03-03 19:31:05 +01:00
|
|
|
:class="`${isNull(col)} type-${typeof col === 'number' ? 'int' : 'varchar'}`"
|
|
|
|
@dblclick="dblClick(cKey)"
|
|
|
|
>{{ col | cutText }}</span>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
<ConfirmModal
|
2021-03-04 19:34:18 +01:00
|
|
|
v-if="isInfoModal"
|
2021-03-03 19:31:05 +01:00
|
|
|
:confirm-text="$t('word.update')"
|
2021-03-04 19:34:18 +01:00
|
|
|
:cancel-text="$t('word.close')"
|
2021-03-03 19:31:05 +01:00
|
|
|
size="medium"
|
2021-03-04 19:34:18 +01:00
|
|
|
:hide-footer="true"
|
|
|
|
@hide="hideInfoModal"
|
2021-03-03 19:31:05 +01:00
|
|
|
>
|
|
|
|
<template :slot="'header'">
|
|
|
|
<div class="d-flex">
|
2021-03-04 19:34:18 +01:00
|
|
|
<i class="mdi mdi-24px mdi-information-outline mr-1" /> {{ $t('message.processInfo') }}
|
2021-03-03 19:31:05 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div :slot="'body'">
|
2021-03-04 19:34:18 +01:00
|
|
|
<div>
|
2021-03-03 19:31:05 +01:00
|
|
|
<div>
|
|
|
|
<TextEditor
|
2021-03-05 17:23:13 +01:00
|
|
|
:value="row.info || ''"
|
2021-03-03 19:31:05 +01:00
|
|
|
editor-class="textarea-editor"
|
|
|
|
:mode="editorMode"
|
2021-03-04 19:34:18 +01:00
|
|
|
:read-only="true"
|
2021-03-03 19:31:05 +01:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</ConfirmModal>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import ConfirmModal from '@/components/BaseConfirmModal';
|
|
|
|
import TextEditor from '@/components/BaseTextEditor';
|
|
|
|
|
|
|
|
export default {
|
2021-08-12 09:54:13 +02:00
|
|
|
name: 'ModalProcessesListRow',
|
2021-03-03 19:31:05 +01:00
|
|
|
components: {
|
|
|
|
ConfirmModal,
|
|
|
|
TextEditor
|
|
|
|
},
|
|
|
|
filters: {
|
|
|
|
cutText (val) {
|
|
|
|
if (typeof val !== 'string') return val;
|
2021-03-04 19:34:18 +01:00
|
|
|
return val.length > 250 ? `${val.substring(0, 250)}[...]` : val;
|
2021-03-03 19:31:05 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
row: Object
|
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
isInlineEditor: {},
|
2021-03-04 19:34:18 +01:00
|
|
|
isInfoModal: false,
|
2021-03-03 19:31:05 +01:00
|
|
|
editorMode: 'sql'
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {},
|
|
|
|
watch: {
|
|
|
|
fields () {
|
|
|
|
Object.keys(this.fields).forEach(field => {
|
|
|
|
this.isInlineEditor[field.name] = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
isNull (value) {
|
|
|
|
return value === null ? ' is-null' : '';
|
|
|
|
},
|
|
|
|
selectRow (event, row) {
|
|
|
|
this.$emit('select-row', event, row);
|
|
|
|
},
|
|
|
|
openContext (event, payload) {
|
|
|
|
if (this.isEditable) {
|
|
|
|
payload.field = this.fields[payload.field].name;// Ensures field name only
|
|
|
|
this.$emit('contextmenu', event, payload);
|
|
|
|
}
|
|
|
|
},
|
2021-03-04 19:34:18 +01:00
|
|
|
hideInfoModal () {
|
|
|
|
this.isInfoModal = false;
|
|
|
|
},
|
2021-03-03 19:31:05 +01:00
|
|
|
dblClick (col) {
|
|
|
|
if (col !== 'info') return;
|
2021-03-04 19:34:18 +01:00
|
|
|
this.$emit('stop-refresh');
|
|
|
|
this.isInfoModal = true;
|
2021-03-03 19:31:05 +01:00
|
|
|
},
|
|
|
|
onKey (e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
if (e.key === 'Escape') {
|
|
|
|
this.isInlineEditor[this.editingField] = false;
|
|
|
|
this.editingField = null;
|
|
|
|
window.removeEventListener('keydown', this.onKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.editable-field {
|
|
|
|
margin: 0;
|
|
|
|
border: none;
|
|
|
|
line-height: 1;
|
|
|
|
width: 100%;
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.cell-content {
|
|
|
|
display: block;
|
2021-08-16 19:44:55 +02:00
|
|
|
padding: 0 0.2rem;
|
2021-03-03 19:31:05 +01:00
|
|
|
min-height: 0.8rem;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.textarea-editor {
|
|
|
|
height: 50vh !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.editor-field-info {
|
|
|
|
margin-top: 0.4rem;
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
white-space: normal;
|
|
|
|
}
|
|
|
|
|
|
|
|
.editor-buttons {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-evenly;
|
|
|
|
|
|
|
|
.btn {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|