add wip UI/backend stuff to filter feed tree
This commit is contained in:
parent
0b7d021f8e
commit
ff4248b09e
|
@ -39,12 +39,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
/**
|
/**
|
||||||
* @return array<int, array<string, bool|int|string>>
|
* @return array<int, array<string, bool|int|string>>
|
||||||
*/
|
*/
|
||||||
private function get_category_items(int $cat_id): array {
|
private function get_category_items(int $cat_id, string $search): array {
|
||||||
|
|
||||||
if (clean($_REQUEST['mode'] ?? 0) != 2)
|
|
||||||
$search = $_SESSION["prefs_feed_search"] ?? "";
|
|
||||||
else
|
|
||||||
$search = "";
|
|
||||||
|
|
||||||
// first one is set by API
|
// first one is set by API
|
||||||
$show_empty_cats = self::_param_to_bool($_REQUEST['force_show_empty'] ?? false) ||
|
$show_empty_cats = self::_param_to_bool($_REQUEST['force_show_empty'] ?? false) ||
|
||||||
|
@ -64,7 +59,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
'id' => 'CAT:' . $feed_category->id,
|
'id' => 'CAT:' . $feed_category->id,
|
||||||
'bare_id' => (int)$feed_category->id,
|
'bare_id' => (int)$feed_category->id,
|
||||||
'name' => $feed_category->title,
|
'name' => $feed_category->title,
|
||||||
'items' => $this->get_category_items($feed_category->id),
|
'items' => $this->get_category_items($feed_category->id, $search),
|
||||||
'checkbox' => false,
|
'checkbox' => false,
|
||||||
'type' => 'category',
|
'type' => 'category',
|
||||||
'unread' => -1,
|
'unread' => -1,
|
||||||
|
@ -121,7 +116,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
if (clean($_REQUEST['mode'] ?? 0) != 2)
|
if (clean($_REQUEST['mode'] ?? 0) != 2)
|
||||||
$search = $_SESSION["prefs_feed_search"] ?? "";
|
$search = $_SESSION["prefs_feed_search"] ?? "";
|
||||||
else
|
else
|
||||||
$search = "";
|
$search = $_REQUEST['search'] ?? '';
|
||||||
|
|
||||||
$root = array();
|
$root = array();
|
||||||
$root['id'] = 'root';
|
$root['id'] = 'root';
|
||||||
|
@ -226,7 +221,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
'bare_id' => (int) $feed_category->id,
|
'bare_id' => (int) $feed_category->id,
|
||||||
'auxcounter' => -1,
|
'auxcounter' => -1,
|
||||||
'name' => $feed_category->title,
|
'name' => $feed_category->title,
|
||||||
'items' => $this->get_category_items($feed_category->id),
|
'items' => $this->get_category_items($feed_category->id, $search),
|
||||||
'checkbox' => false,
|
'checkbox' => false,
|
||||||
'type' => 'category',
|
'type' => 'category',
|
||||||
'unread' => -1,
|
'unread' => -1,
|
||||||
|
|
|
@ -263,6 +263,7 @@
|
||||||
|
|
||||||
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcPrefs')"><?= __('Preferences...') ?></div>
|
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcPrefs')"><?= __('Preferences...') ?></div>
|
||||||
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcSearch')"><?= __('Search...') ?></div>
|
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcSearch')"><?= __('Search...') ?></div>
|
||||||
|
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcFilterFeeds')"><?= __('Search feeds...') ?></div>
|
||||||
<div dojoType="dijit.MenuItem" disabled="1"><?= __('Feed actions:') ?></div>
|
<div dojoType="dijit.MenuItem" disabled="1"><?= __('Feed actions:') ?></div>
|
||||||
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcAddFeed')"><?= __('Subscribe to feed...') ?></div>
|
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcAddFeed')"><?= __('Subscribe to feed...') ?></div>
|
||||||
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcEditFeed')"><?= __('Edit this feed...') ?></div>
|
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcEditFeed')"><?= __('Edit this feed...') ?></div>
|
||||||
|
|
|
@ -1270,6 +1270,9 @@ const App = {
|
||||||
case "qmcSearch":
|
case "qmcSearch":
|
||||||
Feeds.search();
|
Feeds.search();
|
||||||
break;
|
break;
|
||||||
|
case "qmcFilterFeeds":
|
||||||
|
Feeds.filter();
|
||||||
|
break;
|
||||||
case "qmcAddFeed":
|
case "qmcAddFeed":
|
||||||
CommonDialogs.subscribeToFeed();
|
CommonDialogs.subscribeToFeed();
|
||||||
break;
|
break;
|
||||||
|
|
55
js/Feeds.js
55
js/Feeds.js
|
@ -23,6 +23,7 @@ const Feeds = {
|
||||||
infscroll_in_progress: 0,
|
infscroll_in_progress: 0,
|
||||||
infscroll_disabled: 0,
|
infscroll_disabled: 0,
|
||||||
_infscroll_timeout: false,
|
_infscroll_timeout: false,
|
||||||
|
_filter_query: false, // TODO: figure out the UI for this
|
||||||
_search_query: false,
|
_search_query: false,
|
||||||
last_search_query: [],
|
last_search_query: [],
|
||||||
_viewfeed_wait_timeout: false,
|
_viewfeed_wait_timeout: false,
|
||||||
|
@ -154,6 +155,10 @@ const Feeds = {
|
||||||
toggle: function() {
|
toggle: function() {
|
||||||
Element.toggle("feeds-holder");
|
Element.toggle("feeds-holder");
|
||||||
},
|
},
|
||||||
|
cancelFilter: function() {
|
||||||
|
this._filter_query = "";
|
||||||
|
this.reload();
|
||||||
|
},
|
||||||
cancelSearch: function() {
|
cancelSearch: function() {
|
||||||
this._search_query = "";
|
this._search_query = "";
|
||||||
this.reloadCurrent();
|
this.reloadCurrent();
|
||||||
|
@ -178,8 +183,14 @@ const Feeds = {
|
||||||
dijit.byId("feedTree").destroyRecursive();
|
dijit.byId("feedTree").destroyRecursive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let query = {op: 'Pref_Feeds', method: 'getfeedtree', mode: 2};
|
||||||
|
|
||||||
|
if (this._filter_query) {
|
||||||
|
query = Object.assign(query, this._filter_query);
|
||||||
|
}
|
||||||
|
|
||||||
const store = new dojo.data.ItemFileWriteStore({
|
const store = new dojo.data.ItemFileWriteStore({
|
||||||
url: "backend.php?op=Pref_Feeds&method=getfeedtree&mode=2"
|
url: "backend.php?" + dojo.objectToQuery(query)
|
||||||
});
|
});
|
||||||
|
|
||||||
// noinspection JSUnresolvedFunction
|
// noinspection JSUnresolvedFunction
|
||||||
|
@ -682,6 +693,48 @@ const Feeds = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
filter: function() {
|
||||||
|
const dialog = new fox.SingleUseDialog({
|
||||||
|
content: `
|
||||||
|
<form onsubmit='return false'>
|
||||||
|
<section>
|
||||||
|
<fieldset>
|
||||||
|
<input dojoType='dijit.form.ValidationTextBox' id='filter_query'
|
||||||
|
style='font-size : 16px; width : 540px;'
|
||||||
|
placeHolder="${__("Show feeds matching...")}"
|
||||||
|
name='search' type='search' value=''>
|
||||||
|
</fieldset>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
${App.FormFields.submit_tag(App.FormFields.icon("search") + " " + __('Search'), {onclick: "App.dialogOf(this).execute()"})}
|
||||||
|
${App.FormFields.cancel_dialog_tag(__('Cancel'))}
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
`,
|
||||||
|
title: __("Search feeds"),
|
||||||
|
execute: function () {
|
||||||
|
if (this.validate()) {
|
||||||
|
Feeds._filter_query = this.attr('value');
|
||||||
|
|
||||||
|
this.hide();
|
||||||
|
Feeds.reload();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const tmph = dojo.connect(dialog, 'onShow', function () {
|
||||||
|
dojo.disconnect(tmph);
|
||||||
|
|
||||||
|
if (Feeds._filter_query && Feeds._filter_query.search) {
|
||||||
|
dijit.byId('filter_query')
|
||||||
|
.attr('value', Feeds._filter_query.search);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.show();
|
||||||
|
|
||||||
},
|
},
|
||||||
updateRandom: function() {
|
updateRandom: function() {
|
||||||
console.log("in update_random_feed");
|
console.log("in update_random_feed");
|
||||||
|
|
Loading…
Reference in New Issue