Skip to content

Commit b66917a

Browse files
committed
Hide the delete button if a section cant be deleted
1 parent af3f63d commit b66917a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

resources/js/components/blueprints/Section.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<button @click.prevent="toggleEditing" class="text-grey-60 hover:text-grey-100 mr-1">
2020
<svg-icon :name="isEditing ? 'shrink' : 'expand'" />
2121
</button>
22-
<button @click.prevent="$emit('deleted')" class="text-grey-60 hover:text-grey-100">
22+
<button @click.prevent="$emit('deleted')" class="text-grey-60 hover:text-grey-100" v-if="deletable">
2323
<svg-icon name="trash" />
2424
</button>
2525
</div>
@@ -69,6 +69,10 @@ export default {
6969
isSingle: {
7070
type: Boolean,
7171
default: false
72+
},
73+
deletable: {
74+
type: Boolean,
75+
default: true
7276
}
7377
},
7478

resources/js/components/blueprints/Sections.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
:key="section._id"
1111
:section="section"
1212
:is-single="singleSection"
13+
:deletable="isSectionDeletable(i)"
1314
@updated="updateSection(i, $event)"
1415
@deleted="deleteSection(i)"
1516
/>
@@ -181,6 +182,14 @@ export default {
181182
if (this.requireSection && this.sections.length === 0) {
182183
this.addSection();
183184
}
185+
},
186+
187+
isSectionDeletable(i) {
188+
if (this.sections.length > 1) return true;
189+
190+
if (i > 0) return true;
191+
192+
return !this.requireSection;
184193
}
185194
186195
}

0 commit comments

Comments
 (0)