• R/O
  • HTTP
  • SSH
  • HTTPS

newslash: Commit

newslash


Commit MetaInfo

Revisãobe3023e083ab27f15239e35976693a39a2ed0f12 (tree)
Hora2019-06-03 19:27:45
Autorhylom <hylom@user...>
Commiterhylom

Mensagem de Log

fix story editor

Mudança Sumário

Diff

--- a/src/newslash_web/lib/Newslash/Web/Controller/API/Story.pm
+++ b/src/newslash_web/lib/Newslash/Web/Controller/API/Story.pm
@@ -204,9 +204,9 @@ sub post {
204204
205205 # post action
206206 my ($sid, $stoid);
207- if ($item->{stoid}) {
207+ if ($item->{stoid} || $item->{id}) {
208208 # update story
209- $params->{stoid} = $item->{stoid};
209+ $params->{stoid} = $item->{stoid} || $item->{id};
210210 ($sid, $stoid) = $stories->update(user => $user, %$params);
211211 }
212212 else {
--- a/src/newslash_web/public/js/article-editor.js
+++ b/src/newslash_web/public/js/article-editor.js
@@ -24,7 +24,7 @@ articleEditor.init = function init () {
2424 email: "",
2525 tags_string: "",
2626 related_urls: "",
27- display: "1",
27+ display: 1,
2828 posttype: 1,
2929 formatter: "modern",
3030 id: "",
@@ -157,7 +157,7 @@ articleEditor.init = function init () {
157157 }
158158
159159 if (this.contentType == "story") {
160- newslash.previewStory(postData).then(
160+ newslash.admin.previewStory(postData).then(
161161 (resp) => { // success
162162 this.message = "";
163163 this.previewTitle = resp.item.title;
@@ -260,17 +260,17 @@ articleEditor.init = function init () {
260260 // story post
261261 if (this.contentType == "story") {
262262 postData.csrf_token = this.csrfToken;
263- newslash.postStory(postData).then(
263+ newslash.admin.postStory(postData).then(
264264 (resp) => { // success
265265 this.message = "";
266- var id = resp.id;
266+ var id = resp.sid;
267267 var type = resp.type;
268268 var url = '/' + type + '/' + id;
269269
270270 // check if new post
271271 if (!postData.id) {
272272 this.createdUrl = url;
273- this.item.subid = id;
273+ this.item.sid = id;
274274 }
275275 this.message = "";
276276 this.mode = "posted";
@@ -367,6 +367,8 @@ articleEditor.init = function init () {
367367 _loadStoryFromSubmission.call(this);
368368 } else if (this.sourceType == "journal") {
369369 _loadStoryFromJournal.call(this);
370+ } else if (this.sourceType == "story") {
371+ _loadStory.call(this);
370372 } else {
371373 // create new story
372374 _createNewStory.call(this);
@@ -422,6 +424,7 @@ articleEditor.init = function init () {
422424 }
423425
424426 function _prepareStory(item) {
427+ item.content_type = 'story';
425428 for (var k in this.editor) {
426429 if (item[k] !== undefined) {
427430 this.editor[k] = item[k];
@@ -447,7 +450,7 @@ articleEditor.init = function init () {
447450 }
448451
449452 function _loadStory() {
450- newslash.admin.getStory(this.contentId).then(
453+ newslash.admin.getStory(this.sourceId).then(
451454 resp => {
452455 _prepareStory.call(this, resp.item);
453456 },
--- a/src/newslash_web/templates/common/article/editor.html.tt2
+++ b/src/newslash_web/templates/common/article/editor.html.tt2
@@ -1,11 +1,11 @@
11 <div class="content-editor-wrap">
22 <div class="alert alert-info post-done" v-if="mode == 'posted' && isUpdate">
33 投稿を更新しました。
4- <span v-if="item.content_type == 'story'"><a href="#" @click="leavePreview">[再編集]</a></span>
4+ <span v-if="contentType == 'story'"><a href="#" @click="leavePreview">[再編集]</a></span>
55 </div>
66 <div class="alert alert-info post-done" v-else-if="mode == 'posted'">
77 投稿を行いました。URL:<A :href="createdUrl" v-text="createdUrl"></a>
8- <span v-if="item.content_type == 'story'"><a href="#" @click="leavePreview">[再編集]</a></span>
8+ <span v-if="contentType == 'story'"><a href="#" @click="leavePreview">[再編集]</a></span>
99 </div>
1010 <div class="alert alert-info post-error-message" v-show="message">
1111 <div v-if="message == 'duplicated_post'">エラー:すでに同じ内容が投稿されています</div>
@@ -24,7 +24,7 @@
2424 </label>
2525 </p>
2626
27- <div v-if="item.content_type == 'story'">
27+ <div v-if="contentType == 'story'">
2828 <p>
2929 <label>日時(JST):
3030 <input type="datetime-local" name="createtime"
@@ -44,7 +44,7 @@
4444 </p>
4545 </div>
4646
47- <p v-if="item.content_type == 'story'">
47+ <p v-if="contentType == 'story'">
4848 <label>部門名:
4949 <input type="text" name="dept" v-model="editor.dept" placeholder="部門名" />
5050 </label>
@@ -57,20 +57,20 @@
5757 </label>
5858 </p>
5959
60- <p v-if="item.content_type == 'story'">
60+ <p v-if="contentType == 'story'">
6161 <label>続きの本文:
6262 <textarea name="bodytext" v-model="editor.body_text"
6363 placeholder="続きの本文をここに記述してください" ></textarea>
6464 </label>
6565 </p>
6666
67- <p v-if="item.content_type == 'submission'">
67+ <p v-if="contentType == 'submission'">
6868 <label>URL(本文がない場合は必須):
6969 <input type="text" name="url" v-model="editor.url" placeholder="重要なURLを1つ(任意)" />
7070 </label>
7171 </p>
7272
73- <p v-if="item.content_type == 'submission'">
73+ <p v-if="contentType == 'submission'">
7474 <label>投稿者のメールアドレス/URL(任意):
7575 <input type="text" name="email" v-model="editor.email"
7676 placeholder="メールアドレスかURL" />
@@ -94,7 +94,7 @@
9494
9595 </div><!-- .tag-editor -->
9696
97- <div v-if="item.content_type == 'story'">
97+ <div v-if="contentType == 'story'">
9898 <label>関連ストーリー:
9999 <div class="related-stories">
100100 <ul v-for="rel in item.related">
@@ -106,7 +106,7 @@
106106 </label>
107107 </div>
108108
109- <div v-if="item.content_type == 'story'">
109+ <div v-if="contentType == 'story'">
110110 <p>
111111 <label>メディアURL:
112112 <input type="text" name="mediaurl" v-model="editor.mediaurl" placeholder="URL" />
@@ -121,7 +121,7 @@
121121 </p>
122122 </div>
123123
124- <div v-if="item.content_type == 'story' || item.content_type == 'journal'">
124+ <div v-if="contentType == 'story' || contentType == 'journal'">
125125 <p>
126126 <label>コメント設定:
127127 <select name="comment_status" v-model="editor.comment_status">
@@ -136,7 +136,7 @@
136136 </label>
137137 </p>
138138
139- <p class="checkbox" v-if="item.content_type == 'story'">
139+ <p class="checkbox" v-if="contentType == 'story'">
140140 <label>
141141 <input type="checkbox" name="display" v-model="editor.display" value="1" checked="checked"/>
142142 管理者や編集者以外にも表示
@@ -144,7 +144,7 @@
144144 </p>
145145 </div>
146146
147- <div v-if="item.content_type == 'journal' && item.formatter == 'legacy'">
147+ <div v-if="contentType == 'journal' && item.formatter == 'legacy'">
148148 <p>
149149 <label>投稿形式:
150150 <select name="posttype" v-model="editor.posttype">
@@ -157,7 +157,7 @@
157157 </p>
158158 </div>
159159
160- <p class="checkbox" v-show="!item.id && item.content_type == 'journal'">
160+ <p class="checkbox" v-show="!item.id && contentType == 'journal'">
161161 <label>
162162 <input type="checkbox" name="submissioncopy" v-model="editor.submissioncopy" value="0" />
163163 日記のコピーをタレコミとして投稿する
Show on old repository browser