mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
708 lines
21 KiB
708 lines
21 KiB
4 years ago
|
<template>
|
||
|
<v-card width="1000" max-width="100%">
|
||
|
<v-toolbar height="55" class="elevation-1">
|
||
2 years ago
|
<div class="header d-100 d-flex">
|
||
4 years ago
|
<h5 class="title text-center">
|
||
2 years ago
|
<v-icon :color="iconColor"> mdi-table-arrow-right </v-icon>
|
||
3 years ago
|
|
||
|
<template v-if="meta">
|
||
3 years ago
|
{{ meta.title }}
|
||
3 years ago
|
</template>
|
||
|
<template v-else>
|
||
|
{{ table }}
|
||
3 years ago
|
</template>
|
||
3 years ago
|
: {{ primaryValue() }}
|
||
4 years ago
|
</h5>
|
||
3 years ago
|
<v-spacer />
|
||
4 years ago
|
<v-btn small text @click="reload">
|
||
2 years ago
|
<v-icon small> mdi-reload </v-icon>
|
||
4 years ago
|
</v-btn>
|
||
|
<x-icon
|
||
3 years ago
|
v-if="!isNew && _isUIAllowed('rowComments')"
|
||
2 years ago
|
icon-class="ml-1 mr-2 px-1 py-1"
|
||
4 years ago
|
tooltip="Toggle comments"
|
||
3 years ago
|
small
|
||
|
text
|
||
|
@click="toggleDrawer = !toggleDrawer"
|
||
|
>
|
||
2 years ago
|
{{ toggleDrawer ? 'mdi-door-open' : 'mdi-door-closed' }}
|
||
4 years ago
|
</x-icon>
|
||
|
|
||
3 years ago
|
<v-btn small @click="$emit('cancel')">
|
||
3 years ago
|
<!-- Cancel -->
|
||
2 years ago
|
{{ $t('general.cancel') }}
|
||
3 years ago
|
</v-btn>
|
||
2 years ago
|
<v-btn :disabled="!_isUIAllowed('tableRowUpdate')" small color="primary" @click="save">
|
||
3 years ago
|
<!--Save Row-->
|
||
2 years ago
|
{{ $t('activity.saveRow') }}
|
||
4 years ago
|
</v-btn>
|
||
|
</div>
|
||
|
</v-toolbar>
|
||
3 years ago
|
<div class="form-container">
|
||
3 years ago
|
<v-card-text
|
||
3 years ago
|
class="py-0 px-0"
|
||
3 years ago
|
:class="{
|
||
3 years ago
|
'px-10': isNew || !toggleDrawer,
|
||
3 years ago
|
}"
|
||
|
>
|
||
|
<v-breadcrumbs
|
||
|
v-if="localBreadcrumbs && localBreadcrumbs.length"
|
||
|
class="caption pt-0 pb-2 justify-center d-100"
|
||
2 years ago
|
:items="localBreadcrumbs.map(text => ({ text }))"
|
||
3 years ago
|
/>
|
||
4 years ago
|
|
||
3 years ago
|
<v-container fluid style="height: 70vh" class="py-0">
|
||
4 years ago
|
<v-row class="h-100">
|
||
2 years ago
|
<v-col class="h-100 px-10" style="overflow-y: auto" cols="8" :offset="isNew || !toggleDrawer ? 2 : 0">
|
||
3 years ago
|
<div v-if="showNextPrev" class="d-flex my-4">
|
||
2 years ago
|
<x-icon tooltip="Previous record" small outlined @click="$emit('prev', localState)">
|
||
3 years ago
|
mdi-arrow-left-bold-outline
|
||
|
</x-icon>
|
||
|
<span class="flex-grow-1" />
|
||
2 years ago
|
<x-icon tooltip="Next record" small outlined @click="$emit('next', localState)">
|
||
3 years ago
|
mdi-arrow-right-bold-outline
|
||
|
</x-icon>
|
||
|
</div>
|
||
|
|
||
3 years ago
|
<template v-for="(col, i) in fields">
|
||
3 years ago
|
<div
|
||
3 years ago
|
v-if="!col.lk && (!showFields || showFields[col.title])"
|
||
3 years ago
|
:key="i"
|
||
|
:class="{
|
||
3 years ago
|
'active-row': active === col.title,
|
||
|
required: isValid(col, localState),
|
||
3 years ago
|
}"
|
||
3 years ago
|
class="row-col my-4"
|
||
3 years ago
|
>
|
||
|
<div>
|
||
2 years ago
|
<label :for="`data-table-form-${col.title}`" class="body-2 text-capitalize">
|
||
3 years ago
|
<virtual-header-cell
|
||
3 years ago
|
v-if="col.colOptions"
|
||
3 years ago
|
:column="col"
|
||
|
:nodes="nodes"
|
||
|
:is-form="true"
|
||
|
:meta="meta"
|
||
|
/>
|
||
|
<header-cell
|
||
|
v-else
|
||
|
:is-form="true"
|
||
3 years ago
|
:is-foreign-key="col.type === UITypes.ForeignKey"
|
||
|
:value="col.title"
|
||
3 years ago
|
:column="col"
|
||
|
:sql-ui="sqlUi"
|
||
|
/>
|
||
|
</label>
|
||
|
<virtual-cell
|
||
3 years ago
|
v-if="isVirtualCol(col)"
|
||
3 years ago
|
ref="virtual"
|
||
|
:disabled-columns="disabledColumns"
|
||
4 years ago
|
:column="col"
|
||
3 years ago
|
:row="localState"
|
||
4 years ago
|
:nodes="nodes"
|
||
|
:meta="meta"
|
||
3 years ago
|
:api="api"
|
||
|
:active="true"
|
||
|
:is-new="isNew"
|
||
|
:is-form="true"
|
||
|
:breadcrumbs="localBreadcrumbs"
|
||
|
@updateCol="updateCol"
|
||
3 years ago
|
@newRecordsSaved="$listeners.loadTableData || reload"
|
||
3 years ago
|
/>
|
||
3 years ago
|
|
||
|
<div
|
||
2 years ago
|
v-else-if="col.ai || (col.pk && !isNew) || disabledColumns[col.title]"
|
||
3 years ago
|
style="height: 100%; width: 100%"
|
||
3 years ago
|
class="caption xc-input"
|
||
2 years ago
|
@click="col.ai && $toast.info('Auto Increment field is not editable').goAway(3000)"
|
||
3 years ago
|
>
|
||
2 years ago
|
<input style="height: 100%; width: 100%" readonly disabled :value="localState[col.title]" />
|
||
3 years ago
|
</div>
|
||
|
|
||
|
<editable-cell
|
||
4 years ago
|
v-else
|
||
3 years ago
|
:id="`data-table-form-${col.title}`"
|
||
|
v-model="localState[col.title]"
|
||
3 years ago
|
:db-alias="dbAlias"
|
||
4 years ago
|
:column="col"
|
||
3 years ago
|
class="xc-input body-2"
|
||
|
:meta="meta"
|
||
3 years ago
|
:sql-ui="sqlUi"
|
||
3 years ago
|
:is-form="true"
|
||
3 years ago
|
:is-locked="isLocked"
|
||
3 years ago
|
@focus="active = col.title"
|
||
3 years ago
|
@blur="active = ''"
|
||
3 years ago
|
@input="$set(changedColumns, col.title, true)"
|
||
3 years ago
|
/>
|
||
4 years ago
|
</div>
|
||
|
</div>
|
||
3 years ago
|
</template>
|
||
4 years ago
|
</v-col>
|
||
3 years ago
|
<v-col
|
||
|
v-if="!isNew && toggleDrawer"
|
||
|
cols="4"
|
||
3 years ago
|
class="d-flex flex-column h-100 flex-grow-1 blue-grey"
|
||
3 years ago
|
:class="{
|
||
3 years ago
|
'lighten-5': !$vuetify.theme.dark,
|
||
|
'darken-4': $vuetify.theme.dark,
|
||
3 years ago
|
}"
|
||
|
>
|
||
2 years ago
|
<v-skeleton-loader v-if="loadingLogs && !logs" type="list-item-avatar-two-line@8" />
|
||
3 years ago
|
|
||
|
<v-list
|
||
|
v-else
|
||
|
ref="commentsList"
|
||
|
width="100%"
|
||
|
style="overflow-y: auto; overflow-x: auto"
|
||
3 years ago
|
class="blue-grey"
|
||
3 years ago
|
:class="{
|
||
3 years ago
|
'lighten-5': !$vuetify.theme.dark,
|
||
|
'darken-4': $vuetify.theme.dark,
|
||
3 years ago
|
}"
|
||
|
>
|
||
3 years ago
|
<div>
|
||
|
<v-list-item v-for="log in logs" :key="log.id" class="d-flex">
|
||
|
<v-list-item-icon class="ma-0 mr-2">
|
||
2 years ago
|
<v-icon :color="isYou(log.user) ? 'pink lighten-2' : 'blue lighten-2'">
|
||
3 years ago
|
mdi-account-circle
|
||
|
</v-icon>
|
||
|
</v-list-item-icon>
|
||
|
<div class="flex-grow-1" style="min-width: 0">
|
||
|
<p class="mb-1 caption edited-text">
|
||
2 years ago
|
{{ isYou(log.user) ? 'You' : log.user == null ? 'Shared base' : log.user }}
|
||
3 years ago
|
{{
|
||
2 years ago
|
log.op_type === 'COMMENT' ? 'commented' : log.op_sub_type === 'INSERT' ? 'created' : 'edited'
|
||
3 years ago
|
}}
|
||
|
</p>
|
||
3 years ago
|
<p
|
||
|
v-if="log.op_type === 'COMMENT'"
|
||
|
class="caption mb-0 nc-chip"
|
||
|
:style="{ background: colors[2] }"
|
||
|
>
|
||
3 years ago
|
{{ log.description }}
|
||
|
</p>
|
||
|
|
||
2 years ago
|
<p v-else v-dompurify-html="log.details" class="caption mb-0" style="word-break: break-all" />
|
||
3 years ago
|
|
||
|
<p class="time text-right mb-0">
|
||
|
{{ calculateDiff(log.created_at) }}
|
||
|
</p>
|
||
|
</div>
|
||
|
</v-list-item>
|
||
|
</div>
|
||
4 years ago
|
</v-list>
|
||
|
|
||
3 years ago
|
<v-spacer />
|
||
|
<v-divider />
|
||
3 years ago
|
<div class="d-flex align-center justify-center">
|
||
3 years ago
|
<v-switch
|
||
|
v-model="commentsOnly"
|
||
3 years ago
|
v-t="['c:row-expand:comment-only']"
|
||
3 years ago
|
class="mt-1"
|
||
|
dense
|
||
|
hide-details
|
||
|
@change="getAuditsAndComments"
|
||
|
>
|
||
3 years ago
|
<template #label>
|
||
|
<span class="caption grey--text">Comments only</span>
|
||
|
</template>
|
||
|
</v-switch>
|
||
|
</div>
|
||
4 years ago
|
<div class="flex-shrink-1 mt-2 d-flex pl-4">
|
||
2 years ago
|
<v-icon color="pink lighten-2" class="mr-2"> mdi-account-circle </v-icon>
|
||
4 years ago
|
<v-text-field
|
||
3 years ago
|
v-model="comment"
|
||
4 years ago
|
dense
|
||
|
placeholder="Comment"
|
||
3 years ago
|
flat
|
||
|
solo
|
||
4 years ago
|
hide-details
|
||
|
class="caption comment-box"
|
||
3 years ago
|
:class="{ focus: showborder }"
|
||
|
@focusin="showborder = true"
|
||
|
@focusout="showborder = false"
|
||
3 years ago
|
@keyup.enter.prevent="saveComment"
|
||
|
>
|
||
|
<template v-if="comment" #append>
|
||
2 years ago
|
<x-icon tooltip="Save" small @click="saveComment"> mdi-keyboard-return </x-icon>
|
||
4 years ago
|
</template>
|
||
|
</v-text-field>
|
||
|
</div>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
</v-container>
|
||
|
</v-card-text>
|
||
|
</div>
|
||
|
|
||
|
<v-btn
|
||
3 years ago
|
v-if="_isUIAllowed('rowComments')"
|
||
3 years ago
|
v-show="!toggleDrawer"
|
||
3 years ago
|
v-t="['c:row-expand:comment-toggle']"
|
||
4 years ago
|
class="comment-icon"
|
||
|
color="primary"
|
||
|
fab
|
||
|
@click="toggleDrawer = !toggleDrawer"
|
||
|
>
|
||
|
<v-icon>mdi-comment-multiple-outline</v-icon>
|
||
|
</v-btn>
|
||
|
</v-card>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
2 years ago
|
import dayjs from 'dayjs';
|
||
|
import { AuditOperationSubTypes, AuditOperationTypes, isSystemColumn, isVirtualCol, UITypes } from 'nocodb-sdk';
|
||
|
import form from '../mixins/form';
|
||
|
import HeaderCell from '~/components/project/spreadsheet/components/HeaderCell';
|
||
|
import EditableCell from '~/components/project/spreadsheet/components/EditableCell';
|
||
|
import colors from '@/mixins/colors';
|
||
|
import VirtualCell from '~/components/project/spreadsheet/components/VirtualCell';
|
||
|
import VirtualHeaderCell from '~/components/project/spreadsheet/components/VirtualHeaderCell';
|
||
|
import getPlainText from '~/components/project/spreadsheet/helpers/getPlainText';
|
||
3 years ago
|
|
||
2 years ago
|
const relativeTime = require('dayjs/plugin/relativeTime');
|
||
|
const utc = require('dayjs/plugin/utc');
|
||
|
dayjs.extend(utc);
|
||
|
dayjs.extend(relativeTime);
|
||
4 years ago
|
export default {
|
||
3 years ago
|
name: 'ExpandedForm',
|
||
3 years ago
|
components: {
|
||
|
VirtualHeaderCell,
|
||
|
VirtualCell,
|
||
|
EditableCell,
|
||
2 years ago
|
HeaderCell,
|
||
3 years ago
|
},
|
||
3 years ago
|
mixins: [colors, form],
|
||
4 years ago
|
props: {
|
||
3 years ago
|
showFields: Object,
|
||
3 years ago
|
showNextPrev: {
|
||
|
type: Boolean,
|
||
2 years ago
|
default: false,
|
||
3 years ago
|
},
|
||
4 years ago
|
breadcrumbs: {
|
||
|
type: Array,
|
||
3 years ago
|
default() {
|
||
2 years ago
|
return [];
|
||
|
},
|
||
4 years ago
|
},
|
||
4 years ago
|
dbAlias: String,
|
||
|
value: Object,
|
||
|
table: String,
|
||
|
primaryValueColumn: String,
|
||
3 years ago
|
// hasMany: [Object, Array],
|
||
|
// belongsTo: [Object, Array],
|
||
4 years ago
|
isNew: Boolean,
|
||
4 years ago
|
oldRow: Object,
|
||
4 years ago
|
iconColor: {
|
||
|
type: String,
|
||
2 years ago
|
default: 'primary',
|
||
4 years ago
|
},
|
||
|
availableColumns: [Object, Array],
|
||
3 years ago
|
queryParams: Object,
|
||
3 years ago
|
meta: Object,
|
||
3 years ago
|
presetValues: Object,
|
||
2 years ago
|
isLocked: Boolean,
|
||
4 years ago
|
},
|
||
|
data: () => ({
|
||
3 years ago
|
isVirtualCol,
|
||
|
UITypes,
|
||
4 years ago
|
showborder: false,
|
||
|
loadingLogs: true,
|
||
|
toggleDrawer: false,
|
||
|
logs: null,
|
||
3 years ago
|
active: '',
|
||
4 years ago
|
localState: {},
|
||
|
changedColumns: {},
|
||
|
comment: null,
|
||
3 years ago
|
showSystemFields: false,
|
||
2 years ago
|
commentsOnly: false,
|
||
4 years ago
|
}),
|
||
3 years ago
|
computed: {
|
||
3 years ago
|
primaryKey() {
|
||
3 years ago
|
return this.isNew
|
||
3 years ago
|
? ''
|
||
3 years ago
|
: this.meta.columns
|
||
2 years ago
|
.filter(c => c.pk)
|
||
|
.map(c => this.localState[c.title])
|
||
|
.join('___');
|
||
3 years ago
|
},
|
||
3 years ago
|
edited() {
|
||
2 years ago
|
return !!Object.keys(this.changedColumns).length;
|
||
3 years ago
|
},
|
||
3 years ago
|
fields() {
|
||
2 years ago
|
let fields;
|
||
3 years ago
|
if (this.availableColumns) {
|
||
2 years ago
|
fields = this.availableColumns;
|
||
3 years ago
|
} else if (this.showSystemFields) {
|
||
2 years ago
|
fields = this.meta.columns || [];
|
||
3 years ago
|
} else {
|
||
2 years ago
|
fields = this.meta.columns.filter(c => !isSystemColumn(c)) || [];
|
||
3 years ago
|
}
|
||
2 years ago
|
return this.isNew
|
||
|
? fields.filter(f => ![UITypes.Formula, UITypes.Rollup, UITypes.Lookup].includes(f.uidt))
|
||
|
: fields;
|
||
3 years ago
|
},
|
||
3 years ago
|
isChanged() {
|
||
2 years ago
|
return Object.values(this.changedColumns).some(Boolean);
|
||
3 years ago
|
},
|
||
3 years ago
|
localBreadcrumbs() {
|
||
3 years ago
|
return [
|
||
|
...this.breadcrumbs,
|
||
2 years ago
|
`${this.meta ? this.meta.title : this.table} ${this.primaryValue() ? `(${this.primaryValue()})` : ''}`,
|
||
|
];
|
||
|
},
|
||
4 years ago
|
},
|
||
|
watch: {
|
||
3 years ago
|
value(obj) {
|
||
2 years ago
|
this.localState = { ...obj };
|
||
4 years ago
|
if (!this.isNew && this.toggleDrawer) {
|
||
2 years ago
|
this.getAuditsAndComments();
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
isNew(n) {
|
||
4 years ago
|
if (!n && this.toggleDrawer) {
|
||
2 years ago
|
this.getAuditsAndComments();
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
meta() {
|
||
4 years ago
|
if (!this.isNew && this.toggleDrawer) {
|
||
2 years ago
|
this.getAuditsAndComments();
|
||
4 years ago
|
}
|
||
|
},
|
||
3 years ago
|
toggleDrawer(td) {
|
||
4 years ago
|
if (td) {
|
||
2 years ago
|
this.getAuditsAndComments();
|
||
4 years ago
|
}
|
||
2 years ago
|
},
|
||
3 years ago
|
},
|
||
3 years ago
|
created() {
|
||
2 years ago
|
this.localState = { ...this.value };
|
||
3 years ago
|
if (!this.isNew && this.toggleDrawer) {
|
||
2 years ago
|
this.getAuditsAndComments();
|
||
3 years ago
|
}
|
||
4 years ago
|
},
|
||
|
methods: {
|
||
3 years ago
|
updateCol(_row, _cn, pid) {
|
||
2 years ago
|
this.$set(this.localState, _cn, pid);
|
||
|
this.$set(this.changedColumns, _cn, true);
|
||
4 years ago
|
},
|
||
3 years ago
|
isYou(email) {
|
||
2 years ago
|
return this.$store.state.users.user && this.$store.state.users.user.email === email;
|
||
4 years ago
|
},
|
||
3 years ago
|
async getAuditsAndComments() {
|
||
2 years ago
|
this.loadingLogs = true;
|
||
3 years ago
|
|
||
3 years ago
|
const data = await this.$api.utils.commentList({
|
||
|
row_id: this.meta.columns
|
||
3 years ago
|
.filter(c => c.pk)
|
||
|
.map(c => this.localState[c.title])
|
||
|
.join('___'),
|
||
3 years ago
|
fk_model_id: this.meta.id,
|
||
2 years ago
|
comments_only: this.commentsOnly,
|
||
|
});
|
||
3 years ago
|
|
||
2 years ago
|
this.logs = data.reverse();
|
||
|
this.loadingLogs = false;
|
||
3 years ago
|
|
||
|
this.$nextTick(() => {
|
||
2 years ago
|
if (this.$refs.commentsList && this.$refs.commentsList.$el && this.$refs.commentsList.$el.firstElementChild) {
|
||
|
this.$refs.commentsList.$el.scrollTop = this.$refs.commentsList.$el.firstElementChild.offsetHeight;
|
||
3 years ago
|
}
|
||
2 years ago
|
});
|
||
4 years ago
|
},
|
||
3 years ago
|
async save() {
|
||
4 years ago
|
try {
|
||
3 years ago
|
const id = this.meta.columns
|
||
3 years ago
|
.filter(c => c.pk)
|
||
|
.map(c => this.localState[c.title])
|
||
2 years ago
|
.join('___');
|
||
4 years ago
|
|
||
3 years ago
|
if (this.presetValues) {
|
||
|
// cater presetValues
|
||
|
for (const k in this.presetValues) {
|
||
2 years ago
|
this.$set(this.changedColumns, k, true);
|
||
3 years ago
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
const updatedObj = Object.keys(this.changedColumns).reduce((obj, col) => {
|
||
|
obj[col] = this.localState[col];
|
||
|
return obj;
|
||
|
}, {});
|
||
4 years ago
|
|
||
4 years ago
|
if (this.isNew) {
|
||
2 years ago
|
const data = await this.$api.dbTableRow.create('noco', this.projectName, this.meta.title, updatedObj);
|
||
|
this.localState = { ...this.localState, ...data };
|
||
4 years ago
|
|
||
|
// save hasmany and manytomany relations from local state
|
||
|
if (this.$refs.virtual && Array.isArray(this.$refs.virtual)) {
|
||
|
for (const vcell of this.$refs.virtual) {
|
||
3 years ago
|
if (vcell.save) {
|
||
2 years ago
|
await vcell.save(this.localState);
|
||
3 years ago
|
}
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
await this.reload();
|
||
3 years ago
|
} else if (Object.keys(updatedObj).length) {
|
||
3 years ago
|
if (!id) {
|
||
2 years ago
|
return this.$toast.info("Update not allowed for table which doesn't have primary Key").goAway(3000);
|
||
3 years ago
|
}
|
||
2 years ago
|
await this.$api.dbTableRow.update('noco', this.projectName, this.meta.title, id, updatedObj);
|
||
3 years ago
|
for (const key of Object.keys(updatedObj)) {
|
||
|
// audit
|
||
3 years ago
|
this.$api.utils
|
||
|
.auditRowUpdate(id, {
|
||
|
fk_model_id: this.meta.id,
|
||
|
column_name: key,
|
||
|
row_id: id,
|
||
3 years ago
|
value: getPlainText(updatedObj[key]),
|
||
2 years ago
|
prev_value: getPlainText(this.oldRow[key]),
|
||
3 years ago
|
})
|
||
2 years ago
|
.then(() => {});
|
||
3 years ago
|
}
|
||
4 years ago
|
} else {
|
||
2 years ago
|
return this.$toast.info('No columns to update').goAway(3000);
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
this.$emit('update:oldRow', { ...this.localState });
|
||
|
this.changedColumns = {};
|
||
|
this.$emit('input', this.localState);
|
||
|
this.$emit('update:isNew', false);
|
||
4 years ago
|
|
||
3 years ago
|
this.$toast
|
||
3 years ago
|
.success(`${this.primaryValue() || 'Row'} updated successfully.`, {
|
||
2 years ago
|
position: 'bottom-right',
|
||
3 years ago
|
})
|
||
2 years ago
|
.goAway(3000);
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error(`Failed to update row : ${e.message}`).goAway(3000);
|
||
4 years ago
|
}
|
||
2 years ago
|
this.$e('a:row-expand:add');
|
||
4 years ago
|
},
|
||
3 years ago
|
async reload() {
|
||
3 years ago
|
const id = this.meta.columns
|
||
3 years ago
|
.filter(c => c.pk)
|
||
|
.map(c => this.localState[c.title])
|
||
2 years ago
|
.join('___');
|
||
|
this.$set(this, 'changedColumns', {});
|
||
|
this.localState = await this.$api.dbTableRow.read('noco', this.projectName, this.meta.title, id, {
|
||
|
query: this.queryParams || {},
|
||
|
});
|
||
4 years ago
|
},
|
||
3 years ago
|
calculateDiff(date) {
|
||
2 years ago
|
return dayjs.utc(date).fromNow();
|
||
4 years ago
|
},
|
||
3 years ago
|
async saveComment() {
|
||
4 years ago
|
try {
|
||
3 years ago
|
await this.$api.utils.commentRow({
|
||
|
fk_model_id: this.meta.id,
|
||
3 years ago
|
row_id: this.meta.columns
|
||
3 years ago
|
.filter(c => c.pk)
|
||
|
.map(c => this.localState[c.title])
|
||
|
.join('___'),
|
||
2 years ago
|
description: this.comment,
|
||
|
});
|
||
3 years ago
|
|
||
2 years ago
|
this.comment = '';
|
||
|
this.$toast.success('Comment added successfully').goAway(3000);
|
||
|
this.$emit('commented');
|
||
|
await this.getAuditsAndComments();
|
||
4 years ago
|
} catch (e) {
|
||
2 years ago
|
this.$toast.error(e.message).goAway(3000);
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
2 years ago
|
this.$e('a:row-expand:comment');
|
||
3 years ago
|
},
|
||
|
primaryValue() {
|
||
|
if (this.localState) {
|
||
2 years ago
|
const value = this.localState[this.primaryValueColumn];
|
||
|
const col = this.meta.columns.find(c => c.title == this.primaryValueColumn);
|
||
3 years ago
|
if (!col) {
|
||
2 years ago
|
return;
|
||
3 years ago
|
}
|
||
2 years ago
|
const uidt = col.uidt;
|
||
3 years ago
|
if (uidt == UITypes.Date) {
|
||
2 years ago
|
return (/^\d+$/.test(value) ? dayjs(+value) : dayjs(value)).format('YYYY-MM-DD');
|
||
3 years ago
|
} else if (uidt == UITypes.DateTime) {
|
||
2 years ago
|
return (/^\d+$/.test(value) ? dayjs(+value) : dayjs(value)).format('YYYY-MM-DD HH:mm');
|
||
3 years ago
|
} else if (uidt == UITypes.Time) {
|
||
2 years ago
|
let dateTime = dayjs(value);
|
||
3 years ago
|
if (!dateTime.isValid()) {
|
||
2 years ago
|
dateTime = dayjs(value, 'HH:mm:ss');
|
||
3 years ago
|
}
|
||
|
if (!dateTime.isValid()) {
|
||
2 years ago
|
dateTime = dayjs(`1999-01-01 ${value}`);
|
||
3 years ago
|
}
|
||
|
if (!dateTime.isValid()) {
|
||
2 years ago
|
return value;
|
||
3 years ago
|
}
|
||
2 years ago
|
return dateTime.format('HH:mm:ss');
|
||
3 years ago
|
}
|
||
2 years ago
|
return value;
|
||
3 years ago
|
}
|
||
2 years ago
|
},
|
||
|
},
|
||
|
};
|
||
4 years ago
|
</script>
|
||
|
|
||
|
<style scoped lang="scss">
|
||
|
.row-col > label {
|
||
|
color: grey;
|
||
|
font-weight: 700;
|
||
|
}
|
||
|
|
||
3 years ago
|
.row-col:focus > label,
|
||
|
.active-row > label {
|
||
4 years ago
|
color: var(--v-primary-base);
|
||
|
}
|
||
|
|
||
3 years ago
|
.title.text-center {
|
||
|
white-space: nowrap;
|
||
|
overflow: hidden;
|
||
|
text-overflow: ellipsis;
|
||
|
}
|
||
|
|
||
4 years ago
|
::v-deep {
|
||
4 years ago
|
.v-breadcrumbs__item:nth-child(odd) {
|
||
3 years ago
|
font-size: 0.72rem;
|
||
4 years ago
|
color: grey;
|
||
|
}
|
||
|
|
||
|
.v-breadcrumbs li:nth-child(even) {
|
||
|
padding: 0 6px;
|
||
3 years ago
|
font-size: 0.72rem;
|
||
4 years ago
|
color: var(--v-textColor-base);
|
||
|
}
|
||
|
|
||
4 years ago
|
position: relative;
|
||
|
|
||
|
.comment-icon {
|
||
|
position: absolute;
|
||
|
right: 60px;
|
||
|
bottom: 60px;
|
||
|
}
|
||
|
|
||
4 years ago
|
/* todo: refactor */
|
||
4 years ago
|
.row-col {
|
||
|
& > div > input,
|
||
3 years ago
|
//& > div div > input,
|
||
4 years ago
|
& > div > .xc-input > input,
|
||
3 years ago
|
& > div > .xc-input > div > input,
|
||
4 years ago
|
& > div > select,
|
||
|
& > div > .xc-input > select,
|
||
3 years ago
|
& > div textarea:not(.inputarea) {
|
||
4 years ago
|
border: 1px solid #7f828b33;
|
||
|
padding: 1px 5px;
|
||
3 years ago
|
font-size: 0.8rem;
|
||
4 years ago
|
border-radius: 4px;
|
||
|
min-height: 44px;
|
||
|
|
||
|
&:focus {
|
||
|
border: 1px solid var(--v-primary-base);
|
||
|
}
|
||
|
|
||
|
&:hover:not(:focus) {
|
||
|
box-shadow: 0 0 2px dimgrey;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
&.v-card {
|
||
|
&.theme--dark .v-card__text {
|
||
|
background: #363636;
|
||
|
|
||
|
.row-col {
|
||
4 years ago
|
//& > div div > input,
|
||
4 years ago
|
& > div > input,
|
||
|
& > div > .xc-input > input,
|
||
3 years ago
|
& > div > .xc-input > div > input,
|
||
4 years ago
|
& > div > select,
|
||
|
& > div > .xc-input > select,
|
||
3 years ago
|
& > div textarea:not(.inputarea) {
|
||
4 years ago
|
background: #1e1e1e;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
&.theme--light .v-card__text {
|
||
|
background-color: #f1f1f1 !important;
|
||
|
|
||
|
.row-col {
|
||
|
& > div > input,
|
||
3 years ago
|
//& > div div > input,
|
||
4 years ago
|
& > div > .xc-input > input,
|
||
3 years ago
|
& > div > .xc-input > div > input,
|
||
4 years ago
|
& > div > select,
|
||
|
& > div > .xc-input > select,
|
||
3 years ago
|
& > div textarea:not(.inputarea) {
|
||
4 years ago
|
background: white;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
h5 {
|
||
|
color: var(--v-textColor-base);
|
||
|
}
|
||
|
|
||
|
.form-container {
|
||
|
max-height: calc(100vh - 200px);
|
||
|
min-height: 200px;
|
||
|
overflow: auto;
|
||
|
}
|
||
|
|
||
3 years ago
|
.time,
|
||
|
.edited-text {
|
||
|
font-size: 0.65rem;
|
||
4 years ago
|
color: grey;
|
||
|
}
|
||
|
|
||
|
.comment-box.focus {
|
||
|
border: 1px solid #4185f4;
|
||
|
}
|
||
4 years ago
|
|
||
|
.required > div > label + * {
|
||
|
border: 1px solid red;
|
||
4 years ago
|
border-radius: 4px;
|
||
4 years ago
|
//min-height: 42px;
|
||
|
//display: flex;
|
||
|
//align-items: center;
|
||
|
//justify-content: flex-end;
|
||
4 years ago
|
background: var(--v-backgroundColorDefault-base);
|
||
|
}
|
||
3 years ago
|
|
||
2 years ago
|
.header {
|
||
|
display: flex;
|
||
|
align-items: center;
|
||
|
}
|
||
3 years ago
|
.nc-chip {
|
||
|
padding: 8px;
|
||
3 years ago
|
border-radius: 8px;
|
||
|
}
|
||
2 years ago
|
|
||
4 years ago
|
</style>
|
||
|
<!--
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
3 years ago
|
* @author Ayush Sahu <aztrexdx@gmail.com>
|
||
4 years ago
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
-->
|