Skip to content

Commit a9b323d

Browse files
feat: Add copy action to row
...changing the action button to a 3-dot menu AI-assistant: Claude Code v2.1.101 (Claude Sonnet 4.6) Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent 5d9d082 commit a9b323d

6 files changed

Lines changed: 50 additions & 11 deletions

File tree

src/modules/main/partials/TableView.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
@delete-column="deleteColumn"
2525
@create-row="createRow"
2626
@edit-row="editRow"
27+
@copy-row="copyRow"
2728
@delete-selected-rows="deleteSelectedRows">
2829
<template #actions>
2930
<slot name="actions" />
@@ -130,6 +131,9 @@ export default {
130131
editRow(rowId) {
131132
emit('tables:row:edit', { row: this.rows.find(r => r.id === rowId), columns: this.columns, isView: this.isView, element: this.element })
132133
},
134+
copyRow(rowId) {
135+
emit('tables:row:copy', { row: this.rows.find(r => r.id === rowId), columns: this.columns, isView: this.isView, elementId: this.element.id })
136+
},
133137
deleteSelectedRows(rows) {
134138
emit('tables:row:delete', { rows, isView: this.isView, elementId: this.element.id })
135139
},

src/modules/modals/CreateRow.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ export default {
7676
type: Number,
7777
default: null,
7878
},
79+
prefillData: {
80+
type: Array,
81+
default: null,
82+
},
7983
},
8084
data() {
8185
return {
@@ -99,6 +103,13 @@ export default {
99103
watch: {
100104
showModal() {
101105
if (this.showModal) {
106+
if (this.prefillData) {
107+
const prefilled = {}
108+
this.prefillData.forEach(item => {
109+
prefilled[item.columnId] = item.value
110+
})
111+
this.row = prefilled
112+
}
102113
this.$nextTick(() => {
103114
this.$el.querySelector('input')?.focus()
104115
})

src/modules/modals/Modals.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<CreateRow :columns="columnsForRow?.columns"
1717
:is-view="columnsForRow?.isView"
1818
:element-id="columnsForRow?.elementId"
19+
:prefill-data="columnsForRow?.prefillData ?? null"
1920
:show-modal="columnsForRow !== null"
2021
@close="columnsForRow = null" />
2122
<EditRow :columns="editRow?.columns"
@@ -147,6 +148,7 @@ export default {
147148
148149
// rows
149150
subscribe('tables:row:create', columnsInfo => { this.columnsForRow = columnsInfo })
151+
subscribe('tables:row:copy', rowInfo => { this.columnsForRow = { columns: rowInfo.columns, isView: rowInfo.isView, elementId: rowInfo.elementId, prefillData: rowInfo.row?.data } })
150152
subscribe('tables:row:edit', rowInfo => { this.editRow = rowInfo })
151153
subscribe('tables:row:delete', tableInfo => {
152154
this.rowsToDelete = tableInfo
@@ -169,6 +171,7 @@ export default {
169171
unsubscribe('tables:column:edit', columnInfo => { this.columnToEdit = columnInfo })
170172
unsubscribe('tables:column:delete', columnInfo => { this.columnToDelete = columnInfo })
171173
unsubscribe('tables:row:create', columnsInfo => { this.columnsForRow = columnsInfo })
174+
unsubscribe('tables:row:copy', rowInfo => { this.columnsForRow = { columns: rowInfo.columns, isView: rowInfo.isView, elementId: rowInfo.elementId, prefillData: rowInfo.row?.data } })
172175
unsubscribe('tables:row:edit', rowInfo => { this.editRow = rowInfo })
173176
unsubscribe('tables:row:delete', tableInfo => {
174177
this.rowsToDelete = tableInfo

src/shared/components/ncTable/NcTable.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ deselect-all-rows -> unselect all rows, e.g. after deleting selected rows
5555
:rows="rows" :is-view="isView" :element-id="elementId" :view-setting.sync="localViewSetting"
5656
:config="config" @create-row="$emit('create-row')"
5757
@edit-row="rowId => $emit('edit-row', rowId)"
58+
@copy-row="rowId => $emit('copy-row', rowId)"
5859
@create-column="$emit('create-column')"
5960
@edit-column="col => $emit('edit-column', col)"
6061
@delete-column="col => $emit('delete-column', col)"

src/shared/components/ncTable/partials/TableRow.vue

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,36 @@
2323
:is-view="isView"
2424
:can-edit="config.canEditRows" />
2525
</td>
26-
<td v-if="config.showActions" :class="{sticky: config.showActions}">
27-
<NcButton v-if="config.canEditRows || config.canDeleteRows" type="primary" :aria-label="t('tables', 'Edit row')" data-cy="editRowBtn" @click="$emit('edit-row', row.id)">
28-
<template #icon>
29-
<Fullscreen :size="20" />
30-
</template>
31-
</NcButton>
26+
<td v-if="config.showActions && (config.canEditRows || config.canDeleteRows || config.canCreateRows)"
27+
:class="{sticky: config.showActions}">
28+
<NcActions data-cy="rowActionMenu">
29+
<NcActionButton v-if="config.canEditRows || config.canDeleteRows"
30+
data-cy="editRowBtn"
31+
:close-after-click="true"
32+
@click="$emit('edit-row', row.id)">
33+
<template #icon>
34+
<Pencil :size="20" />
35+
</template>
36+
{{ t('tables', 'Edit row') }}
37+
</NcActionButton>
38+
<NcActionButton v-if="config.canCreateRows"
39+
data-cy="copyRowBtn"
40+
:close-after-click="true"
41+
@click="$emit('copy-row', row.id)">
42+
<template #icon>
43+
<ContentCopy :size="20" />
44+
</template>
45+
{{ t('tables', 'Copy row') }}
46+
</NcActionButton>
47+
</NcActions>
3248
</td>
3349
</tr>
3450
</template>
3551

3652
<script>
37-
import { NcCheckboxRadioSwitch, NcButton } from '@nextcloud/vue'
38-
import Fullscreen from 'vue-material-design-icons/Fullscreen.vue'
53+
import { NcCheckboxRadioSwitch, NcActions, NcActionButton } from '@nextcloud/vue'
54+
import ContentCopy from 'vue-material-design-icons/ContentCopy.vue'
55+
import Pencil from 'vue-material-design-icons/PencilOutline.vue'
3956
import TableCellHtml from './TableCellHtml.vue'
4057
import TableCellProgress from './TableCellProgress.vue'
4158
import TableCellLink from './TableCellLink.vue'
@@ -64,8 +81,10 @@ export default {
6481
TableCellLink,
6582
TableCellProgress,
6683
TableCellHtml,
67-
NcButton,
68-
Fullscreen,
84+
NcActions,
85+
NcActionButton,
86+
ContentCopy,
87+
Pencil,
6988
NcCheckboxRadioSwitch,
7089
TableCellDateTime,
7190
TableCellTextLine,

src/shared/components/ncTable/sections/CustomTable.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
:element-id="elementId"
3939
:is-view="isView"
4040
@update-row-selection="updateRowSelection"
41-
@edit-row="rowId => $emit('edit-row', rowId)" />
41+
@edit-row="rowId => $emit('edit-row', rowId)"
42+
@copy-row="rowId => $emit('copy-row', rowId)" />
4243
</transition-group>
4344
</table>
4445
<div v-if="totalPages > 1" class="pagination-footer" :class="{'large-width': !appNavCollapsed || isMobile}">

0 commit comments

Comments
 (0)