OSDN Git Service

fix story editor v0.1.12
authorhylom <hylom@users.osdn.me>
Mon, 3 Jun 2019 10:27:45 +0000 (10:27 +0000)
committerhylom <hylom@users.osdn.me>
Mon, 3 Jun 2019 10:27:45 +0000 (10:27 +0000)
src/newslash_web/lib/Newslash/Web/Controller/API/Story.pm
src/newslash_web/public/js/article-editor.js
src/newslash_web/templates/common/article/editor.html.tt2

index 6ee83d0..4c1280f 100644 (file)
@@ -204,9 +204,9 @@ sub post {
 
     # post action
     my ($sid, $stoid);
-    if ($item->{stoid}) {
+    if ($item->{stoid} || $item->{id}) {
         # update story
-        $params->{stoid} = $item->{stoid};
+        $params->{stoid} = $item->{stoid} || $item->{id};
         ($sid, $stoid) = $stories->update(user => $user, %$params);
     }
     else {
index 793e000..c09c240 100644 (file)
@@ -24,7 +24,7 @@ articleEditor.init = function init () {
         email: "",
         tags_string: "",
         related_urls: "",
-        display: "1",
+        display: 1,
         posttype: 1,
         formatter: "modern",
         id: "",
@@ -157,7 +157,7 @@ articleEditor.init = function init () {
     }
 
     if (this.contentType == "story") {
-      newslash.previewStory(postData).then(
+      newslash.admin.previewStory(postData).then(
         (resp) => { // success
           this.message = "";
           this.previewTitle = resp.item.title;
@@ -260,17 +260,17 @@ articleEditor.init = function init () {
     // story post
     if (this.contentType == "story") {
       postData.csrf_token = this.csrfToken;
-      newslash.postStory(postData).then(
+      newslash.admin.postStory(postData).then(
         (resp) => { // success
           this.message = "";
-          var id = resp.id;
+          var id = resp.sid;
           var type = resp.type;
           var url = '/' + type + '/' + id;
           
           // check if new post
           if (!postData.id) {
             this.createdUrl = url;
-            this.item.subid = id;
+            this.item.sid = id;
           }
           this.message = "";
           this.mode = "posted";
@@ -367,6 +367,8 @@ articleEditor.init = function init () {
           _loadStoryFromSubmission.call(this);
         } else if (this.sourceType == "journal") {
           _loadStoryFromJournal.call(this);
+        } else if (this.sourceType == "story") {
+          _loadStory.call(this);
         } else {
           // create new story
           _createNewStory.call(this);
@@ -422,6 +424,7 @@ articleEditor.init = function init () {
   }
 
   function _prepareStory(item) {
+    item.content_type = 'story';
     for (var k in this.editor) {
       if (item[k] !== undefined) {
         this.editor[k] = item[k];
@@ -447,7 +450,7 @@ articleEditor.init = function init () {
   }
 
   function _loadStory() {
-    newslash.admin.getStory(this.contentId).then(
+    newslash.admin.getStory(this.sourceId).then(
       resp => {
         _prepareStory.call(this, resp.item);
       },
index 3340d80..ed4b2f9 100644 (file)
@@ -1,11 +1,11 @@
 <div class="content-editor-wrap">
   <div class="alert alert-info post-done" v-if="mode == 'posted' && isUpdate">
     投稿を更新しました。
-    <span v-if="item.content_type == 'story'"><a href="#" @click="leavePreview">[再編集]</a></span>
+    <span v-if="contentType == 'story'"><a href="#" @click="leavePreview">[再編集]</a></span>
   </div>
   <div class="alert alert-info post-done" v-else-if="mode == 'posted'">
     投稿を行いました。URL:<A :href="createdUrl" v-text="createdUrl"></a>
-    <span v-if="item.content_type == 'story'"><a href="#" @click="leavePreview">[再編集]</a></span>
+    <span v-if="contentType == 'story'"><a href="#" @click="leavePreview">[再編集]</a></span>
   </div>
   <div class="alert alert-info post-error-message" v-show="message">
     <div v-if="message == 'duplicated_post'">エラー:すでに同じ内容が投稿されています</div>
@@ -24,7 +24,7 @@
       </label>
     </p>
 
-    <div v-if="item.content_type == 'story'">
+    <div v-if="contentType == 'story'">
       <p>
         <label>日時(JST):
           <input type="datetime-local" name="createtime"
@@ -44,7 +44,7 @@
       </p>
     </div>
 
-    <p v-if="item.content_type == 'story'">
+    <p v-if="contentType == 'story'">
       <label>部門名:
         <input type="text" name="dept" v-model="editor.dept" placeholder="部門名" />
       </label>
       </label>
     </p>
 
-    <p v-if="item.content_type == 'story'">
+    <p v-if="contentType == 'story'">
       <label>続きの本文:
         <textarea name="bodytext" v-model="editor.body_text"
                   placeholder="続きの本文をここに記述してください" ></textarea>
       </label>
     </p>
 
-    <p v-if="item.content_type == 'submission'">
+    <p v-if="contentType == 'submission'">
       <label>URL(本文がない場合は必須):
         <input type="text" name="url" v-model="editor.url" placeholder="重要なURLを1つ(任意)" />
       </label>
     </p>
 
-    <p v-if="item.content_type == 'submission'">
+    <p v-if="contentType == 'submission'">
       <label>投稿者のメールアドレス/URL(任意):
         <input type="text" name="email" v-model="editor.email"
                placeholder="メールアドレスかURL" />
@@ -94,7 +94,7 @@
 
     </div><!-- .tag-editor -->
     
-    <div v-if="item.content_type == 'story'">
+    <div v-if="contentType == 'story'">
       <label>関連ストーリー:
         <div class="related-stories">
           <ul v-for="rel in item.related">
       </label>
     </div>
 
-    <div v-if="item.content_type == 'story'">
+    <div v-if="contentType == 'story'">
       <p>
         <label>メディアURL:
           <input type="text" name="mediaurl" v-model="editor.mediaurl" placeholder="URL" />
       </p>
     </div>
 
-    <div v-if="item.content_type == 'story' || item.content_type == 'journal'">
+    <div v-if="contentType == 'story' || contentType == 'journal'">
       <p>
         <label>コメント設定:
           <select name="comment_status" v-model="editor.comment_status">
         </label>
       </p>
 
-      <p class="checkbox" v-if="item.content_type == 'story'">
+      <p class="checkbox" v-if="contentType == 'story'">
         <label>
           <input type="checkbox" name="display" v-model="editor.display" value="1" checked="checked"/>
           管理者や編集者以外にも表示
       </p>
     </div>
 
-    <div v-if="item.content_type == 'journal' && item.formatter == 'legacy'">
+    <div v-if="contentType == 'journal' && item.formatter == 'legacy'">
       <p>
         <label>投稿形式:
           <select name="posttype" v-model="editor.posttype">
       </p>
     </div>
 
-    <p class="checkbox" v-show="!item.id && item.content_type == 'journal'">
+    <p class="checkbox" v-show="!item.id && contentType == 'journal'">
       <label>
         <input type="checkbox" name="submissioncopy" v-model="editor.submissioncopy" value="0" />
         日記のコピーをタレコミとして投稿する