Skip to content
Snippets Groups Projects
Commit 873ebefe authored by Ron Lucke's avatar Ron Lucke
Browse files

Biest #3468

Closes #3468

Merge request studip/studip!2467
parent 9dc0187b
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
containerClass="cw-container-accordion" containerClass="cw-container-accordion"
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
:editDataValid="editDataValid"
@showEdit="setShowEdit" @showEdit="setShowEdit"
@storeContainer="storeContainer" @storeContainer="storeContainer"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
...@@ -89,13 +90,17 @@ ...@@ -89,13 +90,17 @@
</template> </template>
<template v-slot:containerEditDialog> <template v-slot:containerEditDialog>
<form class="default cw-container-dialog-edit-form" @submit.prevent=""> <form class="default cw-container-dialog-edit-form" @submit.prevent="">
<fieldset v-for="(section, index) in currentContainer.attributes.payload.sections.filter(section => !section.locked)" :key="index"> <fieldset
v-for="(section, index) in currentContainer.attributes.payload.sections.filter(section => !section.locked)"
:key="index"
:class="{ invalid: !section.name && !section.icon }"
>
<label> <label>
{{ $gettext('Title')}} {{ $gettext('Titel')}}
<input type="text" v-model="section.name" /> <input type="text" v-model="section.name" />
</label> </label>
<label> <label>
{{ $gettext('Icon')}} {{ $gettext('Symbol')}}
<studip-select :options="icons" v-model="section.icon"> <studip-select :options="icons" v-model="section.icon">
<template #open-indicator="selectAttributes"> <template #open-indicator="selectAttributes">
<span v-bind="selectAttributes"><studip-icon shape="arr_1down" :size="10"/></span> <span v-bind="selectAttributes"><studip-icon shape="arr_1down" :size="10"/></span>
...@@ -166,6 +171,7 @@ export default { ...@@ -166,6 +171,7 @@ export default {
assistiveLive: '', assistiveLive: '',
showDeleteDialog: false, showDeleteDialog: false,
currentSection: null, currentSection: null,
editDataValid: true,
}; };
}, },
computed: { computed: {
...@@ -268,6 +274,7 @@ export default { ...@@ -268,6 +274,7 @@ export default {
async storeContainer() { async storeContainer() {
const timeout = setTimeout(() => this.processing = true, 800); const timeout = setTimeout(() => this.processing = true, 800);
this.currentContainer.attributes.payload.sections = this.currentContainer.attributes.payload.sections.filter(section => !section.locked); this.currentContainer.attributes.payload.sections = this.currentContainer.attributes.payload.sections.filter(section => !section.locked);
let validSections = true;
this.currentContainer.attributes.payload.sections.forEach(section => { this.currentContainer.attributes.payload.sections.forEach(section => {
section.blocks = section.blocks.map((block) => {return block.id;}); section.blocks = section.blocks.map((block) => {return block.id;});
delete section.locked; delete section.locked;
...@@ -418,6 +425,17 @@ export default { ...@@ -418,6 +425,17 @@ export default {
} }
}, },
deep: true deep: true
},
currentContainer: {
handler() {
this.editDataValid = true;
this.currentContainer.attributes.payload.sections.forEach(section => {
if (!section.icon && !section.name) {
this.editDataValid = false;
}
});
},
deep: true
} }
} }
}; };
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
closeClass="cancel" closeClass="cancel"
@close="closeEdit" @close="closeEdit"
@confirm="storeContainer" @confirm="storeContainer"
:confirmDisabled="!editDataValid"
height="430" height="430"
width="680" width="680"
> >
...@@ -147,6 +148,10 @@ export default { ...@@ -147,6 +148,10 @@ export default {
container: Object, container: Object,
canEdit: Boolean, canEdit: Boolean,
isTeacher: Boolean, isTeacher: Boolean,
editDataValid: {
type: Boolean,
default: true
},
}, },
data() { data() {
return { return {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
containerClass="cw-container-tabs" containerClass="cw-container-tabs"
:canEdit="canEdit" :canEdit="canEdit"
:isTeacher="isTeacher" :isTeacher="isTeacher"
:editDataValid="editDataValid"
@showEdit="setShowEdit" @showEdit="setShowEdit"
@storeContainer="storeContainer" @storeContainer="storeContainer"
@closeEdit="initCurrentData" @closeEdit="initCurrentData"
...@@ -88,13 +89,17 @@ ...@@ -88,13 +89,17 @@
</template> </template>
<template v-slot:containerEditDialog> <template v-slot:containerEditDialog>
<form class="default cw-container-dialog-edit-form" @submit.prevent=""> <form class="default cw-container-dialog-edit-form" @submit.prevent="">
<fieldset v-for="(section, index) in currentContainer.attributes.payload.sections.filter(section => !section.locked)" :key="index"> <fieldset
v-for="(section, index) in currentContainer.attributes.payload.sections.filter(section => !section.locked)"
:key="index"
:class="{ invalid: !section.name && !section.icon }"
>
<label> <label>
{{ $gettext('Title') }} {{ $gettext('Titel') }}
<input type="text" v-model="section.name" /> <input type="text" v-model="section.name" />
</label> </label>
<label> <label>
{{ $gettext('Icon') }} {{ $gettext('Symbol') }}
<studip-select :options="icons" v-model="section.icon"> <studip-select :options="icons" v-model="section.icon">
<template #open-indicator="selectAttributes"> <template #open-indicator="selectAttributes">
<span v-bind="selectAttributes"><studip-icon shape="arr_1down" :size="10"/></span> <span v-bind="selectAttributes"><studip-icon shape="arr_1down" :size="10"/></span>
...@@ -169,6 +174,7 @@ export default { ...@@ -169,6 +174,7 @@ export default {
assistiveLive: '', assistiveLive: '',
showDeleteDialog: false, showDeleteDialog: false,
currentSection: null, currentSection: null,
editDataValid: true,
}; };
}, },
computed: { computed: {
...@@ -414,6 +420,17 @@ export default { ...@@ -414,6 +420,17 @@ export default {
} }
}, },
deep: true deep: true
},
currentContainer: {
handler() {
this.editDataValid = true;
this.currentContainer.attributes.payload.sections.forEach(section => {
if (!section.icon && !section.name) {
this.editDataValid = false;
}
});
},
deep: true
} }
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment