mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-03-05 23:17:00 -05:00
improved: 'My Labels' field be searchable (#6753)
* datalist-labels * Update main.js
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
}
|
||||
?>
|
||||
|
||||
<datalist id="datalist-labels"></datalist>
|
||||
|
||||
<template id="share_article_template">
|
||||
<?php $this->renderHelper('index/normal/entry_share_menu'); ?>
|
||||
<a class="dropdown-close" href="#close">❌</a>
|
||||
|
||||
@@ -16,6 +16,8 @@ $useKeepUnreadImportant = !FreshRSS_Context::isImportant() && !FreshRSS_Context:
|
||||
$today = @strtotime('today');
|
||||
?>
|
||||
|
||||
<datalist id="datalist-labels"></datalist>
|
||||
|
||||
<template id="share_article_template">
|
||||
<?php $this->renderHelper('index/normal/entry_share_menu'); ?>
|
||||
<a class="dropdown-close" href="#close">❌</a>
|
||||
|
||||
@@ -1393,6 +1393,7 @@ function loadDynamicTags(div) {
|
||||
const input_newTag = document.createElement('input');
|
||||
input_newTag.setAttribute('type', 'text');
|
||||
input_newTag.setAttribute('name', 'newTag');
|
||||
input_newTag.setAttribute('list', 'datalist-labels');
|
||||
input_newTag.addEventListener('keydown', function (ev) { if (ev.key.toUpperCase() == 'ENTER') { this.parentNode.previousSibling.click(); } });
|
||||
|
||||
const button_btn = document.createElement('button');
|
||||
@@ -1416,6 +1417,7 @@ function loadDynamicTags(div) {
|
||||
}
|
||||
|
||||
let html = '';
|
||||
let datalist = '';
|
||||
if (json && json.length) {
|
||||
let nbLabelsChecked = 0;
|
||||
for (let i = 0; i < json.length; i++) {
|
||||
@@ -1432,12 +1434,16 @@ function loadDynamicTags(div) {
|
||||
'name="t_' + tag.id + '"type="checkbox" ' +
|
||||
(context.anonymous ? 'disabled="disabled" ' : '') +
|
||||
(tag.checked ? 'checked="checked" ' : '') + '/> ' + tag.name + '</label></li>';
|
||||
datalist += '<option value="' + tag.name + '"></option>';
|
||||
}
|
||||
if (context.anonymous && nbLabelsChecked === 0) {
|
||||
html += '<li class="item"><span class="emptyLabels">' + context.i18n.labels_empty + '</span></li>';
|
||||
}
|
||||
}
|
||||
div.querySelector('.dropdown-menu').insertAdjacentHTML('beforeend', html);
|
||||
const datalistLabels = document.getElementById('datalist-labels');
|
||||
datalistLabels.innerHTML = ''; // clear before add the (updated) labels list
|
||||
datalistLabels.insertAdjacentHTML('beforeend', datalist);
|
||||
};
|
||||
req.send();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user