inactive feeds: use client dialog

This commit is contained in:
Andrew Dolgov 2021-02-13 21:41:38 +03:00
parent 17413078a7
commit 8464c619e4
2 changed files with 78 additions and 83 deletions

View File

@ -1485,56 +1485,14 @@ class Pref_Feeds extends Handler_Protected {
ORDER BY last_article"); ORDER BY last_article");
$sth->execute([$_SESSION['uid']]); $sth->execute([$_SESSION['uid']]);
print "<div dojoType='fox.Toolbar'>"; $rv = [];
print "<div dojoType='fox.form.DropDownButton'>".
"<span>" . __('Select')."</span>";
print "<div dojoType='dijit.Menu' style='display: none'>";
print "<div onclick=\"Tables.select('inactive-feeds-list', true)\"
dojoType='dijit.MenuItem'>".__('All')."</div>";
print "<div onclick=\"Tables.select('inactive-feeds-list', false)\"
dojoType='dijit.MenuItem'>".__('None')."</div>";
print "</div></div>";
print "</div>"; #toolbar
print "<div class='panel panel-scrollable'>"; while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
print "<table width='100%' id='inactive-feeds-list'>"; $row['last_article'] = TimeHelper::make_local_datetime($row['last_article'], false);
array_push($rv, $row);
$lnum = 1;
while ($line = $sth->fetch()) {
$feed_id = $line["id"];
print "<tr data-row-id='$feed_id'>";
print "<td width='5%' align='center'><input
onclick='Tables.onRowChecked(this);' dojoType='dijit.form.CheckBox'
type='checkbox'></td>";
print "<td>";
print "<a href='#' ".
"title=\"".__("Click to edit feed")."\" ".
"onclick=\"CommonDialogs.editFeed(".$line["id"].")\">".
htmlspecialchars($line["title"])."</a>";
print "</td><td class='text-muted' align='right'>";
print TimeHelper::make_local_datetime($line['last_article'], false);
print "</td>";
print "</tr>";
++$lnum;
} }
print "</table>"; print json_encode($rv);
print "</div>";
print "<footer>
<button style='float : left' class='alt-danger' dojoType='dijit.form.Button' onclick='App.dialogOf(this).removeSelected()'>"
.__('Unsubscribe from selected feeds')."</button>
<button dojoType='dijit.form.Button' class='alt-primary' type='submit'>"
.__('Close this window')."</button>
</footer>";
} }
function feedsWithErrors() { function feedsWithErrors() {

View File

@ -1,5 +1,5 @@
/* eslint-disable prefer-rest-params */ /* eslint-disable prefer-rest-params */
/* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhrPost, fox, App */ /* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhrPost, xhrJson, fox, App */
define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_base/array", "dojo/cookie"], define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_base/array", "dojo/cookie"],
function (declare, domConstruct, checkBoxTree, array, cookie) { function (declare, domConstruct, checkBoxTree, array, cookie) {
@ -409,6 +409,8 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
dialog.show(); dialog.show();
}, },
showInactiveFeeds: function() { showInactiveFeeds: function() {
xhrJson("backend.php", {op: 'pref-feeds', method: 'inactivefeeds'}, function (reply) {
const dialog = new fox.SingleUseDialog({ const dialog = new fox.SingleUseDialog({
id: "inactiveFeedsDlg", id: "inactiveFeedsDlg",
title: __("Feeds without recent updates"), title: __("Feeds without recent updates"),
@ -441,18 +443,53 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
alert(__("No feeds selected.")); alert(__("No feeds selected."));
} }
}, },
content: __("Loading, please wait...") content: `
}); <div dojoType='fox.Toolbar'>
<div dojoType='fox.form.DropDownButton'>
<span>${__('Select')}</span>
<div dojoType='dijit.Menu' style='display: none'>
<div onclick="Tables.select('inactive-feeds-list', true)"
dojoType='dijit.MenuItem'>${__('All')}</div>
<div onclick="Tables.select('inactive-feeds-list', false)"
dojoType='dijit.MenuItem'>${__('None')}</div>
</div>
</div>
</div>
const tmph = dojo.connect(dialog, 'onShow', function () { <div class='panel panel-scrollable'>
dojo.disconnect(tmph); <table width='100%' id='inactive-feeds-list'>
${reply.map((row) => `<tr data-row-id='${row.id}'>
<td width='5%' align='center'>
<input onclick='Tables.onRowChecked(this)' dojoType='dijit.form.CheckBox' type='checkbox'>
</td>
<td>
<a href='#' "title="${__("Click to edit feed")}" onclick="CommonDialogs.editFeed(${row.id})">
${App.escapeHtml(row.title)}
</a>
</td>
<td class='text-muted' align='right'>
${row.last_article}
</td>
</tr>
`).join("")}
</table>
</div>
xhrPost("backend.php", {op: "pref-feeds", method: "inactivefeeds"}, (transport) => { <footer>
dialog.attr('content', transport.responseText); <button style='float : left' class='alt-danger' dojoType='dijit.form.Button' onclick='App.dialogOf(this).removeSelected()'>
}) ${__('Unsubscribe from selected feeds')}
</button>
<button dojoType='dijit.form.Button' class='alt-primary' type='submit'>
${__('Close this window')}
</button>
</footer>
`
}); });
dialog.show(); dialog.show();
});
} }
}); });
}); });