1414 :value =" getCellValue(col)" />
1515 </td >
1616 <td v-if =" config.showActions" :class =" {sticky: config.showActions}" >
17- <NcButton v-if =" config .canEditRows || config .canDeleteRows " type="primary " :aria-label =" t (' tables' , ' Edit row' )" data-cy="editRowBtn" @click =" $emit (' edit-row' , row .id )" >
17+ <NcButton v-if =" config .canEditRows || config .canDeleteRows " type="secondary " :aria-label =" t (' tables' , ' Edit row' )" data-cy="editRowBtn" @click =" $emit (' edit-row' , row .id )" >
1818 <template #icon >
1919 <Pencil :size =" 20 " />
2020 </template >
2121 </NcButton >
22+ <NcActions v-if =" config .canDeleteRows || config .canCreateRows " >
23+ <NcActionButton v-if =" config .canDeleteRows "
24+ :close-after-click =" true "
25+ @click =" handleDeleteRow " >
26+ <template #icon >
27+ <Delete :size =" 20 " />
28+ </template >
29+ {{ t('tables', 'Delete row') }}
30+ </NcActionButton >
31+ <NcActionButton v-if =" config .canCreateRows "
32+ :close-after-click =" true "
33+ @click =" handleCloneRow " >
34+ <template #icon >
35+ <ContentCopy :size =" 20 " />
36+ </template >
37+ {{ t('tables', 'Duplicate row') }}
38+ </NcActionButton >
39+ </NcActions >
2240 </td >
2341 </tr >
2442</template >
2543
2644<script >
27- import { NcCheckboxRadioSwitch , NcButton } from ' @nextcloud/vue'
45+ import { mapActions } from ' pinia'
46+ import { useDataStore } from ' ../../../../store/data.js'
47+ import { NcCheckboxRadioSwitch , NcButton , NcActions , NcActionButton } from ' @nextcloud/vue'
2848import Pencil from ' vue-material-design-icons/Pencil.vue'
49+ import ContentCopy from ' vue-material-design-icons/ContentCopy.vue'
50+ import Delete from ' vue-material-design-icons/Delete.vue'
2951import TableCellHtml from ' ./TableCellHtml.vue'
3052import TableCellProgress from ' ./TableCellProgress.vue'
3153import TableCellLink from ' ./TableCellLink.vue'
@@ -40,6 +62,7 @@ import TableCellTextRich from './TableCellEditor.vue'
4062import TableCellUsergroup from ' ./TableCellUsergroup.vue'
4163import { ColumnTypes } from ' ./../mixins/columnHandler.js'
4264import { translate as t } from ' @nextcloud/l10n'
65+ import { showError } from ' @nextcloud/dialogs'
4366import {
4467 TYPE_META_ID , TYPE_META_CREATED_BY , TYPE_META_CREATED_AT , TYPE_META_UPDATED_BY , TYPE_META_UPDATED_AT ,
4568} from ' ../../../../shared/constants.js'
@@ -55,13 +78,17 @@ export default {
5578 TableCellHtml,
5679 NcButton,
5780 Pencil,
81+ ContentCopy,
82+ Delete,
5883 NcCheckboxRadioSwitch,
5984 TableCellDateTime,
6085 TableCellTextLine,
6186 TableCellSelection,
6287 TableCellMultiSelection,
6388 TableCellTextRich,
6489 TableCellUsergroup,
90+ NcActions,
91+ NcActionButton,
6592 },
6693
6794 props: {
@@ -85,6 +112,14 @@ export default {
85112 type: Object ,
86113 default: null ,
87114 },
115+ elementId: {
116+ type: Number ,
117+ default: null ,
118+ },
119+ isView: {
120+ type: Boolean ,
121+ default: false ,
122+ },
88123 },
89124 computed: {
90125 getSelection: {
@@ -165,6 +200,31 @@ export default {
165200 return text
166201 }
167202 },
203+ ... mapActions (useDataStore, [' removeRow' , ' insertNewRow' ]),
204+ async handleDeleteRow () {
205+ const res = await this .removeRow ({
206+ rowId: this .row .id ,
207+ isView: this .isView ,
208+ elementId: this .elementId ,
209+ })
210+ if (! res) {
211+ showError (t (' tables' , ' Could not delete row.' ))
212+ }
213+ },
214+ async handleCloneRow () {
215+ const data = this .row .data .reduce ((acc , curr ) => {
216+ acc[curr .columnId ] = curr .value
217+ return acc
218+ }, {})
219+ const res = await this .insertNewRow ({
220+ viewId: this .isView ? this .elementId : null ,
221+ tableId: this .isView ? null : this .elementId ,
222+ data,
223+ })
224+ if (! res) {
225+ showError (t (' tables' , ' Could not clone row.' ))
226+ }
227+ },
168228 },
169229}
170230< / script>
0 commit comments