mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat(UI): context option to copy cell or row value
This commit is contained in:
@ -12,6 +12,8 @@
|
|||||||
:selected-rows="selectedRows"
|
:selected-rows="selectedRows"
|
||||||
@show-delete-modal="showDeleteConfirmModal"
|
@show-delete-modal="showDeleteConfirmModal"
|
||||||
@set-null="setNull"
|
@set-null="setNull"
|
||||||
|
@copy-cell="copyCell"
|
||||||
|
@copy-row="copyRow"
|
||||||
@close-context="closeContext"
|
@close-context="closeContext"
|
||||||
/>
|
/>
|
||||||
<ul v-if="resultsWithRows.length > 1" class="tab tab-block result-tabs">
|
<ul v-if="resultsWithRows.length > 1" class="tab tab-block result-tabs">
|
||||||
@ -385,6 +387,22 @@ export default {
|
|||||||
};
|
};
|
||||||
this.$emit('update-field', params);
|
this.$emit('update-field', params);
|
||||||
},
|
},
|
||||||
|
copyCell () {
|
||||||
|
const row = this.localResults.find(row => this.selectedRows.includes(row._id));
|
||||||
|
const cellName = Object.keys(row).find(prop => [
|
||||||
|
this.selectedCell.field,
|
||||||
|
`${this.fields[0].table}.${this.selectedCell.field}`,
|
||||||
|
`${this.fields[0].tableAlias}.${this.selectedCell.field}`
|
||||||
|
].includes(prop));
|
||||||
|
const valueToCopy = row[cellName];
|
||||||
|
navigator.clipboard.writeText(valueToCopy);
|
||||||
|
},
|
||||||
|
copyRow () {
|
||||||
|
const row = this.localResults.find(row => this.selectedRows.includes(row._id));
|
||||||
|
const rowToCopy = JSON.parse(JSON.stringify(row));
|
||||||
|
delete rowToCopy._id;
|
||||||
|
navigator.clipboard.writeText(JSON.stringify(rowToCopy));
|
||||||
|
},
|
||||||
applyUpdate (params) {
|
applyUpdate (params) {
|
||||||
const { primary, id, field, table, content } = params;
|
const { primary, id, field, table, content } = params;
|
||||||
|
|
||||||
|
@ -3,6 +3,30 @@
|
|||||||
:context-event="contextEvent"
|
:context-event="contextEvent"
|
||||||
@close-context="closeContext"
|
@close-context="closeContext"
|
||||||
>
|
>
|
||||||
|
<div v-if="selectedRows.length === 1" class="context-element">
|
||||||
|
<span class="d-flex"><i class="mdi mdi-18px mdi-content-copy text-light pr-1" /> {{ $t('word.copy') }}</span>
|
||||||
|
<i class="mdi mdi-18px mdi-chevron-right text-light pl-1" />
|
||||||
|
<div class="context-submenu">
|
||||||
|
<div
|
||||||
|
v-if="selectedRows.length === 1"
|
||||||
|
class="context-element"
|
||||||
|
@click="copyCell"
|
||||||
|
>
|
||||||
|
<span class="d-flex">
|
||||||
|
<i class="mdi mdi-18px mdi-numeric-0 mdi-rotate-90 text-light pr-1" /> {{ $tc('word.cell', 1) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="selectedRows.length === 1"
|
||||||
|
class="context-element"
|
||||||
|
@click="copyRow"
|
||||||
|
>
|
||||||
|
<span class="d-flex">
|
||||||
|
<i class="mdi mdi-18px mdi-table-row text-light pr-1" /> {{ $tc('word.row', 1) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="selectedRows.length === 1"
|
v-if="selectedRows.length === 1"
|
||||||
class="context-element"
|
class="context-element"
|
||||||
@ -44,6 +68,14 @@ export default {
|
|||||||
setNull () {
|
setNull () {
|
||||||
this.$emit('set-null');
|
this.$emit('set-null');
|
||||||
this.closeContext();
|
this.closeContext();
|
||||||
|
},
|
||||||
|
copyCell () {
|
||||||
|
this.$emit('copy-cell');
|
||||||
|
this.closeContext();
|
||||||
|
},
|
||||||
|
copyRow () {
|
||||||
|
this.$emit('copy-row');
|
||||||
|
this.closeContext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -109,7 +109,9 @@ module.exports = {
|
|||||||
structure: 'Structure',
|
structure: 'Structure',
|
||||||
small: 'Small',
|
small: 'Small',
|
||||||
medium: 'Medium',
|
medium: 'Medium',
|
||||||
large: 'Large'
|
large: 'Large',
|
||||||
|
row: 'Row | Rows',
|
||||||
|
cell: 'Cell | Cells'
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
appWelcome: 'Welcome to Antares SQL Client!',
|
appWelcome: 'Welcome to Antares SQL Client!',
|
||||||
|
Reference in New Issue
Block a user