OSDN Git Service

fix journal's comment settings to work
authorhylom <hylom@users.sourceforge.jp>
Wed, 4 Oct 2017 17:22:03 +0000 (02:22 +0900)
committerhylom <hylom@users.sourceforge.jp>
Wed, 4 Oct 2017 17:22:03 +0000 (02:22 +0900)
src/newslash_web/public/js/base.js
src/newslash_web/public/js/comment-tree.js
src/newslash_web/templates/common/comment/comment_header.html.tt2
src/newslash_web/templates/common/comment/comments.html.tt2
src/newslash_web/templates/common/components/comment_tree.html.tt2
src/newslash_web/templates/common/js_vars.html.tt2
src/newslash_web/templates/journal/journal.html.tt2

index f7e0931..bd807eb 100644 (file)
@@ -55,7 +55,7 @@ var Comment = function () {
   this.tweak = 0;
   this.badge_id = 0;
   this.comment = '';
-
+  this.create_time = '';
   this.author = '';
   this.children = [];
 };
index 5863e12..afa426d 100644 (file)
@@ -12,6 +12,7 @@ commentTree.init = function () {
       return {
         userConfig: userConfig || {},
         archived: page.archived || false,
+        commentAllowed: page.commentAllowed || false,
         savable: user.is_login || false,
         isConfigVisible: false,
       };
@@ -46,7 +47,8 @@ commentTree.init = function () {
     template: '#comment-tree-template',
     data: function () {
       return {
-        archived: page.archived,
+        commentAllowed: page.commentAllowed,
+        archived: page.archived || false,
         comments: [],
         rootID: 0,
       };
@@ -101,7 +103,8 @@ commentTree.init = function () {
         secToken: '',
 
         displayForce: false,
-        archived: page.archived,
+        commentAllowed: page.commentAllowed,
+        archived: page.archived || false,
 
         isFormVisible: false,
       };
@@ -116,6 +119,7 @@ commentTree.init = function () {
     },
     computed: {
       commentLocalTime: function () {
+        if (this.comment.create_time == "") return "";
         var dt = nsUtil.decodeMySQLDateTime(this.comment.create_time);
         return nsUtil.formatToLocalDateTime(dt);
       },
@@ -179,10 +183,10 @@ commentTree.init = function () {
         return count[0];
       },
       isModerateEnabled: function () {
-        return this.comment.cid && (user.is_admin || (user.is_moderator && !this.archived));
+        return this.comment.cid && (user.is_admin || (user.is_moderator && this.commentAllowed));
       },
       isReplyEnabled: function () {
-        return !this.archived && !this.comment.isPreview;
+        return this.commentAllowed && !this.comment.isPreview;
       },
       isSignatureVisible: function () {
         return !userConfig.hide_signature && this.comment.signature;
index abde023..eda0a1f 100644 (file)
@@ -2,11 +2,14 @@
   <div v-if="archived" class="alert alert-info">
     この議論は賞味期限が切れたので、アーカイブ化されています。 新たにコメントを付けることはできません。
   </div>
+  <div v-if="!commentAllowed" class="alert alert-info">
+    設定によりコメント投稿は許可されていません。
+  </div>
   <div class="form-inline">
     [%#
     <button type="button" class="btn btn-default form-control">コメント元ページを表示</button>
     %]
-    <button type="button" class="btn btn-default form-control" v-if="!archived">コメントを書く</button>
+    <button type="button" class="btn btn-default form-control" v-if="commentAllowed">コメントを書く</button>
     <select id="comment-filter" name="comment-filter" class="form-control" v-model="userConfig.show_threshold">
       <option value="-1">全コメントを表示</option>
       <option value="0">スコア0以上のコメントのみ表示</option>
index 20ca2ad..2102b07 100644 (file)
@@ -6,7 +6,7 @@
       <comment :comment="comment"></comment>
       <comment-node :parent="comment"></comment-node>
     </li>
-    <comment-form :reply="rootReply" v-if="!archived"></comment-form>
+    <comment-form :reply="rootReply" v-if="commentAllowed"></comment-form>
   </ol>
 </div>
 
index a6ac0f6..c2191be 100644 (file)
@@ -14,7 +14,7 @@
         </li>
       </ol>
     </div>
-    <comment-form v-if="!archived" :target="comments"></comment-form>
+    <comment-form v-if="commentAllowed" :target="comments"></comment-form>
   </div>
 </script>
 
index da249d4..f5d6c15 100644 (file)
@@ -25,6 +25,7 @@
   page.id =  [% journal.id %];
   page.archived = [% IF discussion.type == 'archived' %]1[% ELSE %]0[% END %];
   page.discussionID = [% IF journal.discussion_id; journal.discussion_id; ELSE; 0; END %];
+  page.commentAllowed = [% IF comment_allowed; comment_allowed; ELSE; 0; END %];
   [%- END -%]
 
   [%- IF comment && comment.content_type == "comment" -%]
@@ -35,6 +36,7 @@
   page.sid = '[% discussion.sid %]';
   page.archived = [% IF discussion.type == 'archived' %]1[% ELSE %]0[% END %];
   page.discussionID = [% discussion.id %];
+  page.commentAllowed = [% IF comment_allowed; comment_allowed; ELSE; 0; END %];
   [%- END -%]
 
   [%- IF story && story.content_type == "poll" -%]
@@ -42,6 +44,7 @@
   page.qid =  [% story.qid %];
   page.archived = [% IF discussion.type == 'archived' %]1[% ELSE %]0[% END %];
   page.discussionID = [% story.discussion %];
+  page.commentAllowed = [% IF comment_allowed; comment_allowed; ELSE; 0; END %];
   [%- END -%]
 
 </script>
index 74daa71..b5aa2fb 100644 (file)
     </div>
 
     [%- IF !journal.discussion_id -%]
-    <div class="alert alert-info clear">
-      この投稿に対するコメントは設定により無効にされています
+    <div class="alert alert-info">
+      この投稿に対するコメントは設定により無効にされています。
+    </div>
+    [%- ELSIF discussion.commentstatus == "disabled" -%]
+    <div class="alert alert-info">
+      この投稿に対するコメントは設定により無効にされています。
+    </div>
+    [%- ELSIF discussion.commentstatus == "logged_in" -%]
+    <div class="alert alert-info">
+      この投稿に対するコメントはログインユーザーにのみ許可されています。
     </div>
     [%- ELSIF !comment_allowed -%]
     <div class="alert alert-info clear">
-      この投稿に対するコメントは一部のユーザーのみに許可されています
+      この投稿に対するコメントは一部のユーザーのみに許可されています
     </div>
     [%- END -%]
 
@@ -26,7 +34,7 @@
 
 [%- INCLUDE common/sidebar mode="journal" -%]
 
-[% IF journal.discussion_id && comment_allowed %]
+[% IF journal.discussion_id %]
 <div id="comments">
   <comment-tree></comment-tree>
 </div>