From 63fa8d299a9835c787f25a25c94ed610ce705b52 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 7 Apr 2021 16:44:18 -0400 Subject: [PATCH] Include 'move to...' action in loaded draft posts Ref T401 --- static/js/posts.js | 9 ++++++++- templates/user/articles.tmpl | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/static/js/posts.js b/static/js/posts.js index ef3143d..e96aa79 100644 --- a/static/js/posts.js +++ b/static/js/posts.js @@ -181,6 +181,13 @@ var localPosts = function() { undoDelete: UndoDelete, }; }(); +var movePostHTML = function(postID) { + let $tmpl = document.getElementById('move-tmpl'); + if ($tmpl === null) { + return ""; + } + return $tmpl.innerHTML.replace(/POST_ID/g, postID); +} var createPostEl = function(post, owned) { var $post = document.createElement('div'); var title = (post.title || post.id); @@ -194,7 +201,7 @@ var createPostEl = function(post, owned) { posted = getFormattedDate(new Date(post.created)) } var hasDraft = H.exists('draft' + post.id); - $post.innerHTML += '

' + posted + ' edit' + (hasDraft ? 'ed' : '') + ' delete

'; + $post.innerHTML += '

' + posted + ' edit' + (hasDraft ? 'ed' : '') + ' delete '+movePostHTML(post.id)+'

'; if (post.error) { $post.innerHTML += '

Sync error: ' + post.error + '

'; diff --git a/templates/user/articles.tmpl b/templates/user/articles.tmpl index 0eccc9e..92f9c40 100644 --- a/templates/user/articles.tmpl +++ b/templates/user/articles.tmpl @@ -5,6 +5,9 @@ font-style: italic; color: #666; } + #move-tmpl { + display: none; + }
@@ -61,6 +64,25 @@
+{{ if .Collections }} +
+ {{if gt (len .Collections) 1}} +
+ + + +
+ {{else}} + {{range .Collections}} + move to {{.DisplayTitle}} + {{end}} + {{end}} +
+{{ end }} +