renderToolbar: support empty data i.e. dashboard feed

This commit is contained in:
Andrew Dolgov 2021-02-15 07:46:24 +03:00
parent a2e688fcb2
commit 9f31381bb6
2 changed files with 46 additions and 42 deletions

View File

@ -141,7 +141,7 @@ class Feeds extends Handler_Protected {
$reply['toolbar'] = [
'site_url' => $feed_site_url,
'title' => truncate_string(strip_tags($feed_title), 30),
'title' => strip_tags($feed_title),
'error' => $last_error,
'last_updated' => $last_updated,
'plugin_menu_items' => $plugin_menu_items,

View File

@ -572,49 +572,53 @@ const Headlines = {
const search_query = Feeds._search_query ? Feeds._search_query.query : "";
const target = dijit.byId('toolbar-headlines');
target.attr('innerHTML',
`
<span class='left'>
<a href="#" title="${__("Show as feed")}"
onclick='CommonDialogs.generatedFeed("${headlines.id}", ${headlines.is_cat}, "${App.escapeHtml(search_query)}")'>
<i class='icon-syndicate material-icons'>rss_feed</i>
</a>
${tb.site_url ?
`<a class="feed_title" target="_blank" href="${App.escapeHtml(tb.site_url)}" title="${tb.last_updated}">${tb.title}</a>` :
`<span class="feed_title">${tb.title}</span>`}
${search_query ?
`
<span class='cancel_search'>(<a href='#' onclick='Feeds.cancelSearch()'>${__("Cancel search")}</a>)</span>
` : ''}
${tb.error ? `<i title="${App.escapeHtml(tb.error)}" class='material-icons icon-error'>error</i>` : ''}
<span id='feed_current_unread' style='display: none'></span>
</span>
<span class='right'>
<span id='selected_prompt'></span>
<div dojoType='fox.form.DropDownButton' title='"${__('Select articles')}'>
<span>${__("Select...")}</span>
<div dojoType='dijit.Menu' style='display: none;'>
<div dojoType='dijit.MenuItem' onclick='Headlines.select("all")'>${__('All')}</div>
<div dojoType='dijit.MenuItem' onclick='Headlines.select("unread")'>${__('Unread')}</div>
<div dojoType='dijit.MenuItem' onclick='Headlines.select("invert")'>${__('Invert')}</div>
<div dojoType='dijit.MenuItem' onclick='Headlines.select("none")'>${__('None')}</div>
<div dojoType='dijit.MenuSeparator'></div>
<div dojoType='dijit.MenuItem' onclick='Headlines.selectionToggleUnread()'>${__('Toggle unread')}</div>
<div dojoType='dijit.MenuItem' onclick='Headlines.selectionToggleMarked()'>${__('Toggle starred')}</div>
<div dojoType='dijit.MenuItem' onclick='Headlines.selectionTogglePublished()'>${__('Toggle published')}</div>
<div dojoType='dijit.MenuSeparator'></div>
<div dojoType='dijit.MenuItem' onclick='Headlines.catchupSelection()'>${__('Mark as read')}</div>
<div dojoType='dijit.MenuItem' onclick='Article.selectionSetScore()'>${__('Set score')}</div>
${tb.plugin_menu_items}
${headlines.id === 0 && !headlines.is_cat ?
if (tb && typeof tb == 'object') {
target.attr('innerHTML',
`
<span class='left'>
<a href="#" title="${__("Show as feed")}"
onclick='CommonDialogs.generatedFeed("${headlines.id}", ${headlines.is_cat}, "${App.escapeHtml(search_query)}")'>
<i class='icon-syndicate material-icons'>rss_feed</i>
</a>
${tb.site_url ?
`<a class="feed_title" target="_blank" href="${App.escapeHtml(tb.site_url)}" title="${tb.last_updated}">${tb.title}</a>` :
`<span class="feed_title">${tb.title}</span>`}
${search_query ?
`
<div dojoType='dijit.MenuSeparator'></div>
<div dojoType='dijit.MenuItem' class='text-error' onclick='Headlines.deleteSelection()'>${__('Delete permanently')}</div>
<span class='cancel_search'>(<a href='#' onclick='Feeds.cancelSearch()'>${__("Cancel search")}</a>)</span>
` : ''}
</div>
${tb.plugin_buttons}
</span>
`);
${tb.error ? `<i title="${App.escapeHtml(tb.error)}" class='material-icons icon-error'>error</i>` : ''}
<span id='feed_current_unread' style='display: none'></span>
</span>
<span class='right'>
<span id='selected_prompt'></span>
<div dojoType='fox.form.DropDownButton' title='"${__('Select articles')}'>
<span>${__("Select...")}</span>
<div dojoType='dijit.Menu' style='display: none;'>
<div dojoType='dijit.MenuItem' onclick='Headlines.select("all")'>${__('All')}</div>
<div dojoType='dijit.MenuItem' onclick='Headlines.select("unread")'>${__('Unread')}</div>
<div dojoType='dijit.MenuItem' onclick='Headlines.select("invert")'>${__('Invert')}</div>
<div dojoType='dijit.MenuItem' onclick='Headlines.select("none")'>${__('None')}</div>
<div dojoType='dijit.MenuSeparator'></div>
<div dojoType='dijit.MenuItem' onclick='Headlines.selectionToggleUnread()'>${__('Toggle unread')}</div>
<div dojoType='dijit.MenuItem' onclick='Headlines.selectionToggleMarked()'>${__('Toggle starred')}</div>
<div dojoType='dijit.MenuItem' onclick='Headlines.selectionTogglePublished()'>${__('Toggle published')}</div>
<div dojoType='dijit.MenuSeparator'></div>
<div dojoType='dijit.MenuItem' onclick='Headlines.catchupSelection()'>${__('Mark as read')}</div>
<div dojoType='dijit.MenuItem' onclick='Article.selectionSetScore()'>${__('Set score')}</div>
${tb.plugin_menu_items}
${headlines.id === 0 && !headlines.is_cat ?
`
<div dojoType='dijit.MenuSeparator'></div>
<div dojoType='dijit.MenuItem' class='text-error' onclick='Headlines.deleteSelection()'>${__('Delete permanently')}</div>
` : ''}
</div>
${tb.plugin_buttons}
</span>
`);
} else {
target.attr('innerHTML', '');
}
dojo.parser.parse(target.domNode);
},