Просмотр исходного кода

Fix inconsistency between reply and replying in variable names

sbkwgh 8 лет назад
Родитель
Сommit
889710a7ac
3 измененных файлов с 35 добавлено и 25 удалено
  1. 9 3
      src/components/InputEditor.vue
  2. 20 16
      src/components/routes/Thread.vue
  3. 6 6
      src/store/modules/thread.js

+ 9 - 3
src/components/InputEditor.vue

@@ -7,7 +7,7 @@
 			"input_editor--hidden": !visible
 		}'
 	>
-		<div class='input_editor__replying' v-if='replying'>Replying to <strong>{{replying}}</strong></div>
+		<div class='input_editor__reply_username' v-if='replyUsername'>Replying to <strong>{{replyUsername}}</strong></div>
 		<div class='input_editor__close input_editor__format_button' @click='closeEditor'>&times;</div>
 		<tab-view :tabs='["Editor", "Preview"]' :name='name' small-tabs='true'>
 			<template slot='Editor'>
@@ -72,7 +72,7 @@
 
 	export default {
 		name: 'InputEditor',
-		props: ['name', 'float', 'replying'],
+		props: ['name', 'float', 'replyUsername'],
 		components: {
 			ModalWindow,
 			FancyInput,
@@ -126,6 +126,12 @@
 					name: this.name,
 					value: false
 				});
+				this.$store.commit({
+					type: 'setEditor',
+					name: this.name,
+					value: ''
+				});
+				this.$emit('close')
 			},
 			setEditor (value) {
 				this.$store.commit({
@@ -232,7 +238,7 @@
 			top: 0.5rem;
 		}
 
-		@at-root #{&}__replying {
+		@at-root #{&}__reply_username {
 			position: absolute;
 			width: 100%;
 			text-align: center;

+ 20 - 16
src/components/routes/Thread.vue

@@ -12,22 +12,22 @@
 			<div class='thread_header__thread_title' ref='title'>
 				{{thread}}
 			</div>
-			<button class='button thread_header__reply_button' @click='showEditor(true)'>Reply to thread</button>
+			<button class='button thread_header__reply_button' @click='replyThread'>Reply to thread</button>
 		</header>
-		<input-editor name='thread' float='true' :replying='replyingUsername' v-on:submit='addPost'></input-editor>
+		<input-editor name='thread' float='true' :replyUsername='replyUsername' v-on:close='clearReply' v-on:submit='addPost'></input-editor>
 		<div class='posts'>
 			<div class='post' v-for='post in posts'>
 				<div class='post__meta_data'>
 					<div class='post__avatar'>{{post.username[0]}}</div>
 					<div class='post__user'>{{post.username}}</div>
-					<span class='fa fa-long-arrow-right fa-fw' v-if='post.replyingUsername'></span>
-					<div class='post__reply' v-if='post.replyingUsername'>{{post.replyingUsername}}</div>
+					<span class='fa fa-long-arrow-right fa-fw' v-if='post.replyUsername'></span>
+					<div class='post__reply' v-if='post.replyUsername'>{{post.replyUsername}}</div>
 					<div class='post__date'>{{post.date | formatDate('time|date', ', ')}}</div>
 				</div>
 				<div class='post__content' v-html='post.content'></div>
 				<div class='post__actions'>
 					<div class='post__action post__share'>Share</div>
-					<div class='post__action post__reply' @click='reply("id", post.username)'>Reply</div>
+					<div class='post__action post__reply' @click='replyUser("id", post.username)'>Reply</div>
 				</div>
 			</div>
 		</div>
@@ -53,26 +53,30 @@
 			posts () {
 				return this.$store.state.thread.posts;
 			},
-			replyingUsername () {
-				return this.$store.state.thread.replying.username
+			replyUsername () {
+				return this.$store.state.thread.reply.username
 			}
 		},
 		methods: {
-			showEditor (clearReply) {
+			showEditor () {
 				this.$store.commit({
 					type: 'showEditor',
 					name: 'thread',
 					value: true
 				});
-				if(clearReply) {
-					this.$store.commit({
-						type: 'setReply',
-						username: '',
-						id: ''
-					});
-				}
 			},
-			reply (id, username) {
+			clearReply () {
+				this.$store.commit({
+					type: 'setReply',
+					username: '',
+					id: ''
+				});
+			},
+			replyThread () {
+				this.clearReply();
+				this.showEditor();
+			},
+			replyUser (id, username) {
 				this.$store.commit({
 					type: 'setReply',
 					username,

Разница между файлами не показана из-за своего большого размера
+ 6 - 6
src/store/modules/thread.js