Skip to content

Commit

Permalink
Merge pull request #45 from kingscode/feature/can-delete-edit-per-line
Browse files Browse the repository at this point in the history
Feature/can delete edit per line
  • Loading branch information
ricardovanlaarhoven authored May 22, 2019
2 parents f992cdd + 9fa1806 commit 05ddc08
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,18 @@ example for crudActionsAfter slot:
canUpdate: {required: false, type: Boolean, default: true},
```
```
canUpdateResourceKey: {required: false, type: String, default: ''},
```
```
canAdd: {required: false, type: Boolean, default: true},
```
```
canDelete: {required: false, type: Boolean, default: true},
```
```
canDeleteResourceKey: {required: false, type: String, default: ''},
```
```
canSearch: {required: false, type: Boolean, default: false},
```
```
Expand Down
38 changes: 33 additions & 5 deletions src/VuetifyResource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
fab
slot="activator"
small
v-if="canUpdate === true && selected.length === 1"
v-if="canUpdateResources(selected) && selected.length === 1"
v-on:click="openUpdateHandler()"
>
<v-icon>$vuetify.icons.edit</v-icon>
Expand Down Expand Up @@ -113,7 +113,7 @@
fab
slot="activator"
small
v-if="canDelete === true && selected.length >= 1"
v-if="canDeleteResources(selected) && selected.length >= 1"
v-on:click="showDeleteConfirmation()"
>
<v-icon>$vuetify.icons.delete</v-icon>
Expand Down Expand Up @@ -166,7 +166,7 @@
></component>
</td>
<td class="crud-actions">
<v-tooltip left v-if="canUpdate === true">
<v-tooltip left v-if="canUpdateResources([props.item])">
<v-btn
color="green"
flat
Expand All @@ -178,7 +178,7 @@
</v-btn>
<span>{{ lang('update') }}</span>
</v-tooltip>
<v-tooltip left v-if="canDelete === true">
<v-tooltip left v-if="canDeleteResources([props.item])">
<v-btn
color="red"
flat
Expand Down Expand Up @@ -399,8 +399,10 @@
*/
tableContent: {required: true, type: Array},
canUpdate: {required: false, type: Boolean, default: true},
canUpdateResourceKey: {required: false, type: String, default: ''},
canAdd: {required: false, type: Boolean, default: true},
canDelete: {required: false, type: Boolean, default: true},
canDeleteResourceKey: {required: false, type: String, default: ''},
canSearch: {required: false, type: Boolean, default: false},
useCheckboxes: {required: false, type: Boolean, default: true},
showSpeedDail: {required: false, type: Boolean},
Expand Down Expand Up @@ -753,7 +755,33 @@
*/
onSelectedChange() {
this.$emit('input', this.selected);
}
},
canDeleteResources(selected) {
let canDelete = this.canDelete;
if (this.canDeleteResourceKey !== '') {
selected.forEach((resource) => {
if (resource[this.canDeleteResourceKey] === false) {
canDelete = false;
return;
}
});
}
return canDelete;
},
canUpdateResources(selected) {
let canUpdate = this.canUpdate;
if (this.canUpdateResourceKey !== '') {
selected.forEach((resource) => {
if (resource[this.canUpdateResourceKey] === false) {
canUpdate = false;
return;
}
});
}
return canUpdate;
},
},
};
</script>
Expand Down

0 comments on commit 05ddc08

Please sign in to comment.