diff options
| author | Ron Lucke <lucke@elan-ev.de> | 2025-01-17 14:15:09 +0000 |
|---|---|---|
| committer | Ron Lucke <lucke@elan-ev.de> | 2025-01-17 14:15:09 +0000 |
| commit | ddce12c92465e45f4456992990a5109c3c3f588e (patch) | |
| tree | a6abaadfda0020cd52f664b816d26f44bf2594a7 | |
| parent | d1824682f25474c7f551e37ca57f772933513e86 (diff) | |
Courseware: Beim Importieren wird zu jeder Seite ein leerer Abschnitt hinzugefügt
Closes #5139
Merge request studip/studip!3850
| -rw-r--r-- | lib/classes/JsonApi/Routes/Courseware/StructuralElementsCreate.php | 4 | ||||
| -rw-r--r-- | resources/vue/mixins/courseware/import.js | 1 | ||||
| -rw-r--r-- | resources/vue/store/courseware/courseware.module.js | 3 |
3 files changed, 6 insertions, 2 deletions
diff --git a/lib/classes/JsonApi/Routes/Courseware/StructuralElementsCreate.php b/lib/classes/JsonApi/Routes/Courseware/StructuralElementsCreate.php index 99481f5..082821b 100644 --- a/lib/classes/JsonApi/Routes/Courseware/StructuralElementsCreate.php +++ b/lib/classes/JsonApi/Routes/Courseware/StructuralElementsCreate.php @@ -100,6 +100,8 @@ class StructuralElementsCreate extends JsonApiController $struct->store(); $template = \Courseware\Template::find(self::arrayGet($json, 'data.templateId')); + $with_default_container = self::arrayGet($json, 'data.withDefaultContainer', true); + if ($template) { $structure = json_decode($template->structure, true); @@ -134,7 +136,7 @@ class StructuralElementsCreate extends JsonApiController $new_container['payload'] = $new_container->type->copyPayload($blockMap); $new_container->store(); } - } else { + } else if ($with_default_container) { $new_container = \Courseware\Container::build([ 'structural_element_id' => $struct->id, 'owner_id' => $user->id, diff --git a/resources/vue/mixins/courseware/import.js b/resources/vue/mixins/courseware/import.js index 3513891..7582587 100644 --- a/resources/vue/mixins/courseware/import.js +++ b/resources/vue/mixins/courseware/import.js @@ -172,6 +172,7 @@ export default { attributes: element[i].attributes, parentId: parent_id, currentId: parent_id, + withDefaultContainer: false }); new_element = this.lastCreatedElements; } catch { diff --git a/resources/vue/store/courseware/courseware.module.js b/resources/vue/store/courseware/courseware.module.js index 8aacdda..6ff9257 100644 --- a/resources/vue/store/courseware/courseware.module.js +++ b/resources/vue/store/courseware/courseware.module.js @@ -747,7 +747,7 @@ export const actions = { )).then(() => dispatch('courseware-structure/build', null, { root: true })); }, - async createStructuralElement({ dispatch }, { attributes, parentId, currentId }) { + async createStructuralElement({ dispatch }, { attributes, parentId, currentId, withDefaultContainer = true }) { const data = { attributes, relationships: { @@ -758,6 +758,7 @@ export const actions = { }, }, }, + withDefaultContainer: withDefaultContainer, }; await dispatch('courseware-structural-elements/create', data, { root: true }); |
