diff --git a/client/src/components/content-block-form/ContentsForm.vue b/client/src/components/content-block-form/ContentsForm.vue index c646c33e..4df224d3 100644 --- a/client/src/components/content-block-form/ContentsForm.vue +++ b/client/src/components/content-block-form/ContentsForm.vue @@ -39,6 +39,8 @@ v-on:video-change-url="changeVideoUrl" + @switch-to-document="switchToDocument" + v-on:assignment-change-title="changeAssignmentTitle" v-on:assignment-change-assignment="changeAssignmentAssignment" > @@ -200,10 +202,10 @@ this.localContentBlock.title = title; this.error = false; }, - changeType(index, type) { + changeType(index, type, value) { let el = { type: type, - value: {} + value: Object.assign({}, value) }; switch (type) { case 'text_block': @@ -234,9 +236,9 @@ case 'document_block': el = { ...el, - value: { + value: Object.assign({ url: '' - } + }, value) }; break; case 'image_url_block': @@ -262,6 +264,9 @@ }, setContentBlockType(checked, localContentBlock) { this.localContentBlock.isAssignment = checked; + }, + switchToDocument(index, value) { + this.changeType(index, 'document_block', value) } } } diff --git a/client/src/components/content-forms/DocumentForm.vue b/client/src/components/content-forms/DocumentForm.vue index a1d9629d..bc6fe4da 100644 --- a/client/src/components/content-forms/DocumentForm.vue +++ b/client/src/components/content-forms/DocumentForm.vue @@ -2,7 +2,7 @@
@@ -18,12 +18,20 @@ this.$emit('link-change-url', url, this.index) }); }, + computed: { - previewUrl: function () { + previewUrl() { if (this.value && this.value.url) { return this.value.url; } return null; + }, + previewLink() { + if (this.value && this.value.url) { + const parts = this.value.url.split('/'); + return parts[parts.length - 1] + } + return ''; } } } @@ -32,7 +40,12 @@