From ba358cc7d597bc8f5c8b27fe4c041c9c61426b4c Mon Sep 17 00:00:00 2001 From: hylom Date: Fri, 31 May 2019 11:27:22 +0000 Subject: [PATCH] fix article-editor to work --- .../lib/Newslash/Web/Controller/Journal.pm | 13 +++++++++++ src/newslash_web/public/js/article-editor.js | 12 +++++------ .../templates/common/article/editor.html.tt2 | 8 +++++-- src/newslash_web/templates/common/single.html.tt2 | 2 +- src/newslash_web/templates/journal/create.html.tt2 | 25 +++++++++++----------- 5 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/newslash_web/lib/Newslash/Web/Controller/Journal.pm b/src/newslash_web/lib/Newslash/Web/Controller/Journal.pm index 33464292..d5e25106 100644 --- a/src/newslash_web/lib/Newslash/Web/Controller/Journal.pm +++ b/src/newslash_web/lib/Newslash/Web/Controller/Journal.pm @@ -55,6 +55,19 @@ sub single { $c->stats->add_event_counter("journal_view"); } +sub create { + my $c = shift; + my $page = { content_type => "journal", + type => "single", + id => 0, + journal_id => 0, + }; + + $c->render(page => $page, + use_captcha => 1, + ); +} + sub user_journals { my $c = shift; my $users = $c->model('users'); diff --git a/src/newslash_web/public/js/article-editor.js b/src/newslash_web/public/js/article-editor.js index 312d25ee..7726dd39 100644 --- a/src/newslash_web/public/js/article-editor.js +++ b/src/newslash_web/public/js/article-editor.js @@ -38,7 +38,7 @@ articleEditor.init = function init () { mode: "editing", primaryTopicIconURL: "", - cancelable: 0, + isUpdate: 0, }; return data; } @@ -48,10 +48,10 @@ articleEditor.init = function init () { type: Object, default: function () {return new Content();}, }, - contentType: { type: String }, - contentId: { type: String }, + contentType: { type: String, required: true }, + contentId: { type: Number, dafault: 0 }, sourceType: { type: String }, - sourceId: { type: String }, + sourceId: { type: Number, default: 0 }, csrfToken: { type: String }, }; @@ -110,7 +110,7 @@ articleEditor.init = function init () { this.item.title = _quoteTitle(this.editor.title); }, startEdit: function startEdit() { - _startEdit(this); + _startEdit.call(this); }, cancelEdit: function cancelEdit() { for (k in this.originalItem) { @@ -387,7 +387,7 @@ articleEditor.init = function init () { newslash.getJournal(this.contentId).then( resp => { // succeed var item = resp.journal; - this.cancelable = 1; + this.isUpdate = 1; this.editor.title = item.title; this.editor.intro_text = item.article; this.editor.tags_string = item.tags_string || ""; diff --git a/src/newslash_web/templates/common/article/editor.html.tt2 b/src/newslash_web/templates/common/article/editor.html.tt2 index aea4e914..3340d806 100644 --- a/src/newslash_web/templates/common/article/editor.html.tt2 +++ b/src/newslash_web/templates/common/article/editor.html.tt2 @@ -1,5 +1,9 @@
-
+
+ 投稿を更新しました。 + [再編集] +
+
投稿を行いました。URL: [再編集]
@@ -162,7 +166,7 @@
-
diff --git a/src/newslash_web/templates/common/single.html.tt2 b/src/newslash_web/templates/common/single.html.tt2 index 439b8f01..b5055856 100644 --- a/src/newslash_web/templates/common/single.html.tt2 +++ b/src/newslash_web/templates/common/single.html.tt2 @@ -28,7 +28,7 @@
[%- INCLUDE common/article/article hide_more_link=1 -%] - +
[%- IF page.type == "single" && page.content_type == "story" -%] diff --git a/src/newslash_web/templates/journal/create.html.tt2 b/src/newslash_web/templates/journal/create.html.tt2 index f2d307b3..fa24393e 100644 --- a/src/newslash_web/templates/journal/create.html.tt2 +++ b/src/newslash_web/templates/journal/create.html.tt2 @@ -1,21 +1,22 @@ -[% WRAPPER common/layout enable_sidebar=1 enable_vuejs=1%] -[% INCLUDE common/components/article_item type="journal" %] +[% WRAPPER common/layout %] -
-
-

日記の編集

-
- - [%#- INCLUDE common/journal/editor -%] +
+
+
+

日記の編集

+
+ [%- INCLUDE common/article/article hide_more_link=1 -%] + +
+ [%- INCLUDE common/sidebar -%]
-[%- INCLUDE common/sidebar -%] -[% helpers.load_js("editor.js") %] -[%# %] +[% INCLUDE common/components/article_editor %] [% END %] -- 2.11.0