summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/markdown/field.vue
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-11-02 16:44:40 +0000
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-11-02 16:44:40 +0000
commita153f006ff274ba0caac720ce9d16949291d0b40 (patch)
tree43c20fa9236a777c86bdc2b7a9b9bcc1f7b550c9 /app/assets/javascripts/vue_shared/components/markdown/field.vue
parenta1c390653cf651378aadfc74d60833628ec2c47c (diff)
downloadgitlab-ce-a153f006ff274ba0caac720ce9d16949291d0b40.tar.gz
Separate preview and write tabs into seperate events
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/markdown/field.vue')
-rw-r--r--app/assets/javascripts/vue_shared/components/markdown/field.vue23
1 files changed, 13 insertions, 10 deletions
diff --git a/app/assets/javascripts/vue_shared/components/markdown/field.vue b/app/assets/javascripts/vue_shared/components/markdown/field.vue
index 62c4e014e73..7fa97eb1c46 100644
--- a/app/assets/javascripts/vue_shared/components/markdown/field.vue
+++ b/app/assets/javascripts/vue_shared/components/markdown/field.vue
@@ -45,10 +45,10 @@
},
},
methods: {
- toggleMarkdownPreview(isPreview) {
- if (isPreview === this.previewMarkdown) return;
+ showPreviewTab() {
+ if (this.previewMarkdown) return;
- this.previewMarkdown = isPreview;
+ this.previewMarkdown = true;
/*
Can't use `$refs` as the component is technically in the parent component
@@ -56,20 +56,22 @@
*/
const text = this.$slots.textarea[0].elm.value;
- if (!this.previewMarkdown) {
- this.markdownPreview = '';
- } else if (text) {
+ if (text) {
this.markdownPreviewLoading = true;
this.$http.post(this.markdownPreviewPath, { text })
.then(resp => resp.json())
- .then((data) => {
- this.renderMarkdown(data);
- })
+ .then(data => this.renderMarkdown(data))
.catch(() => new Flash('Error loading markdown preview'));
} else {
this.renderMarkdown();
}
},
+
+ showWriteTab() {
+ this.markdownPreview = '';
+ this.previewMarkdown = false;
+ },
+
renderMarkdown(data = {}) {
this.markdownPreviewLoading = false;
this.markdownPreview = data.body || 'Nothing to preview.';
@@ -106,7 +108,8 @@
ref="gl-form">
<markdown-header
:preview-markdown="previewMarkdown"
- @toggle-markdown="toggleMarkdownPreview" />
+ @preview-markdown="showPreviewTab"
+ @write-markdown="showWriteTab" />
<div
class="md-write-holder"
v-show="!previewMarkdown">