From 9586c72a17dabd907becebffc938add10c4a8626 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 20 Feb 2021 10:26:09 +0300 Subject: wip: feed editor client-side --- js/CommonDialogs.js | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 212 insertions(+), 7 deletions(-) (limited to 'js/CommonDialogs.js') diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index a75b36ed8..5477e9ecd 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -389,19 +389,20 @@ const CommonDialogs = { return false; }, - editFeed: function (feed) { - if (feed <= 0) + editFeed: function (feed_id) { + if (feed_id <= 0) return alert(__("You can't edit this kind of feed.")); - const query = {op: "pref-feeds", method: "editfeed", id: feed}; + const query = {op: "pref-feeds", method: "editfeed", id: feed_id}; console.log("editFeed", query); const dialog = new fox.SingleUseDialog({ id: "feedEditDlg", title: __("Edit Feed"), - unsubscribeFeed: function(feed_id, title) { - if (confirm(__("Unsubscribe from %s?").replace("%s", title))) { + feed_title: "", + unsubscribe: function() { + if (confirm(__("Unsubscribe from %s?").replace("%s", this.feed_title))) { dialog.hide(); CommonDialogs.unsubscribeFeed(feed_id); } @@ -430,8 +431,212 @@ const CommonDialogs = { const tmph = dojo.connect(dialog, 'onShow', function () { dojo.disconnect(tmph); - xhr.post("backend.php", {op: "pref-feeds", method: "editfeed", id: feed}, (reply) => { - dialog.attr('content', reply); + xhr.json("backend.php", {op: "pref-feeds", method: "editfeed", id: feed_id}, (reply) => { + const feed = reply.feed; + + // for unsub prompt + dialog.feed_title = feed.title; + + dialog.attr('content', + ` +
+
+ + ${App.FormFields.hidden_tag("id", feed_id)} + ${App.FormFields.hidden_tag("op", "pref-feeds")} + ${App.FormFields.hidden_tag("method", "editSave")} + +
+
+ +
+ +
+ + + + ${feed.last_error ? + `error + ` : ""} +
+ + ${reply.cats.enabled ? + ` +
+ + ${reply.cats.select} +
+ ` : ""} + +
+ + +
+ + ${reply.lang.enabled ? + ` +
+ + ${App.FormFields.select_tag("feed_language", feed.feed_language, reply.lang.all)} +
+ ` : ""} + +
+ +
+ + ${App.FormFields.select_hash("update_interval", feed.update_interval, reply.intervals.update)} +
+
+ + + ${App.FormFields.select_hash("purge_interval", + feed.purge_interval, + reply.intervals.purge, + reply.force_purge ? {disabled: 1} : {})} + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+ +
+ + $include_in_digest = $row["include_in_digest"]; + + if ($include_in_digest) { + $checked = "checked="1" + } else { + $checked = " + } + +
+ + + +
+ + $always_display_enclosures = $row["always_display_enclosures"]; + + if ($always_display_enclosures) { + $checked = "checked + } else { + $checked = " + } + +
+ + + +
+ + $hide_images = $row["hide_images"]; + + if ($hide_images) { + $checked = "checked="1" + } else { + $checked = " + } + +
+ + + +
+ + $cache_images = $row["cache_images"]; + + if ($cache_images) { + $checked = "checked="1" + } else { + $checked = " + } + +
+ + + +
+ + $mark_unread_on_update = $row["mark_unread_on_update"]; + + if ($mark_unread_on_update) { + $checked = "checked + } else { + $checked = " + } + +
+ + + +
+ +
+ +
+ + + +
+ + + ${App.FormFields.hidden_tag("op", "pref-feeds")} + ${App.FormFields.hidden_tag("feed_id", feed_id)} + ${App.FormFields.hidden_tag("method", "uploadIcon")} + ${App.FormFields.hidden_tag("csrf_token", App.getInitParam("csrf_token"))} + + ${App.FormFields.submit_tag(__("Replace"), {onclick: "return CommonDialogs.uploadFeedIcon()"})} + ${App.FormFields.submit_tag(__("Remove"), {class: "alt-danger", onclick: "return CommonDialogs.removeFeedIcon("+feed_id+")"})} +
+
+ +
+ ${reply.plugin_data} +
+ +
+ + + `); }) }); -- cgit v1.2.3