diff --git a/client/cypress/integration/frontend/modules/custom-content-block.spec.js b/client/cypress/integration/frontend/modules/custom-content-block.spec.js
index 21bf98c8..d569de30 100644
--- a/client/cypress/integration/frontend/modules/custom-content-block.spec.js
+++ b/client/cypress/integration/frontend/modules/custom-content-block.spec.js
@@ -61,6 +61,14 @@ describe('Custom Content Block', () => {
cy.log('Opening More Menu');
cy.getByDataCy('more-options-link').click();
+ cy.log('Duplicating Content Block');
+ cy.getByDataCy('duplicate-content-block-link').click();
+
+ cy.get('.content-block').should('have.length', 2);
+
+ cy.log('Opening More Menu');
+ cy.getByDataCy('more-options-link').click();
+
// check if content block is still there
cy.log('Deleting Content Block');
cy.getByDataCy('delete-content-block-link').click();
diff --git a/client/src/components/ContentBlock.vue b/client/src/components/ContentBlock.vue
index 77cd254f..2fabf50b 100644
--- a/client/src/components/ContentBlock.vue
+++ b/client/src/components/ContentBlock.vue
@@ -11,14 +11,27 @@
>
-
+
+
+
+
-
+
contentBlock.id === id);
+ const contentBlocks = insertAtIndex(chapter.contentBlocks, index, contentBlock);
+ const data = {
+ chapter: {
+ ...chapter,
+ contentBlocks,
+ },
+ };
+ store.writeQuery({query, variables, data});
+ }
+ },
+ });
+
+ },
editContentBlock(contentBlock) {
const route = {
name: EDIT_CONTENT_BLOCK_PAGE,
diff --git a/client/src/graphql/gql/mutations/duplicateContentBlock.gql b/client/src/graphql/gql/mutations/duplicateContentBlock.gql
new file mode 100644
index 00000000..dbefec53
--- /dev/null
+++ b/client/src/graphql/gql/mutations/duplicateContentBlock.gql
@@ -0,0 +1,11 @@
+#import "../fragments/contentBlockInterfaceParts.gql"
+#import "../fragments/contentBlockParts.gql"
+
+mutation DuplicateContentBlock($input: DuplicateContentBlockInput!) {
+ duplicateContentBlock(input: $input) {
+ contentBlock {
+ ...ContentBlockInterfaceParts
+ ...ContentBlockParts
+ }
+ }
+}
diff --git a/server/books/managers.py b/server/books/managers.py
index 603ff304..305c8ddd 100644
--- a/server/books/managers.py
+++ b/server/books/managers.py
@@ -15,7 +15,7 @@ class ContentBlockManager(PageManager):
user_created=True,
owner=user,
contents=content_block.contents,
- title=content_block.title,
+ title=f'{content_block.title} (Kopie)',
type=content_block.type,
)
content_block.add_sibling(instance=new_content_block, pos='right')
diff --git a/server/schema.graphql b/server/schema.graphql
index 7a19e840..0cb896a5 100644
--- a/server/schema.graphql
+++ b/server/schema.graphql
@@ -478,6 +478,16 @@ type DjangoDebugSQL {
encoding: String
}
+input DuplicateContentBlockInput {
+ id: ID!
+ clientMutationId: String
+}
+
+type DuplicateContentBlockPayload {
+ contentBlock: ContentBlockNode
+ clientMutationId: String
+}
+
type DuplicateName {
reason: String
}
@@ -694,6 +704,7 @@ type Mutation {
mutateContentBlock(input: MutateContentBlockInput!): MutateContentBlockPayload
addContentBlock(input: AddContentBlockInput!): AddContentBlockPayload
deleteContentBlock(input: DeleteContentBlockInput!): DeleteContentBlockPayload
+ duplicateContentBlock(input: DuplicateContentBlockInput!): DuplicateContentBlockPayload
updateSolutionVisibility(input: UpdateSolutionVisibilityInput!): UpdateSolutionVisibilityPayload
updateLastModule(input: UpdateLastModuleInput!): UpdateLastModulePayload
updateLastTopic(input: UpdateLastTopicInput!): UpdateLastTopicPayload