Skip to content

Commit

Permalink
Hide Duplicate Row button when max grid rows reached (#3006)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmcdade authored Dec 11, 2020
1 parent 9a54761 commit ee8c874
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions resources/js/components/fieldtypes/grid/Grid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
:meta="meta.existing"
:name="name"
:can-delete-rows="canDeleteRows"
:can-add-rows="canAddRows"
@updated="updated"
@meta-updated="updateRowMeta"
@removed="removed"
Expand Down
6 changes: 5 additions & 1 deletion resources/js/components/fieldtypes/grid/Row.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<td class="row-controls" v-if="!grid.isReadOnly">
<dropdown-list>
<dropdown-item :text="__('Duplicate Row')" @click="$emit('duplicate', index)" />
<dropdown-item :text="__('Duplicate Row')" @click="$emit('duplicate', index)" v-if="canAddRows" />
<dropdown-item v-if="canDelete" :text="__('Delete Row')" class="warning" @click="$emit('removed', index)" />
</dropdown-list>
</td>
Expand Down Expand Up @@ -74,6 +74,10 @@ export default {
type: Boolean,
default: true
},
canAddRows: {
type: Boolean,
default: true
},
},
inject: [
Expand Down
1 change: 1 addition & 0 deletions resources/js/components/fieldtypes/grid/Stacked.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
:name="name"
:error-key-prefix="errorKeyPrefix"
:can-delete="canDeleteRows"
:can-add-rows="canAddRows"
@updated="(row, value) => $emit('updated', row, value)"
@meta-updated="$emit('meta-updated', row._id, $event)"
@removed="(row) => $emit('removed', row)"
Expand Down
1 change: 1 addition & 0 deletions resources/js/components/fieldtypes/grid/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
:name="name"
:error-key-prefix="errorKeyPrefix"
:can-delete="canDeleteRows"
:can-add-rows="canAddRows"
@updated="(row, value) => $emit('updated', row, value)"
@meta-updated="$emit('meta-updated', row._id, $event)"
@duplicate="(row) => $emit('duplicate', row)"
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/fieldtypes/grid/View.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
export default {
props: ['fields', 'rows', 'meta', 'name', 'canDeleteRows'],
props: ['fields', 'rows', 'meta', 'name', 'canDeleteRows', 'canAddRows'],
inject: ['grid'],
Expand Down

0 comments on commit ee8c874

Please sign in to comment.