Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Searchbar for projects list and sitemaps list #151

Merged
merged 14 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,5 +381,11 @@
},
"sitemap_template_create_nav_button": {
"message": "Load news template"
},
"searchbar_placeholder_message_for_sitemaps": {
"message": "Search for sitemaps..."
},
"searchbar_placeholder_message_for_projects": {
"message": "Search for projects..."
}
}
6 changes: 6 additions & 0 deletions src/_locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -415,5 +415,11 @@
},
"sitemap_template_create_nav_button": {
"message": "Загрузить новостной шаблон"
},
"searchbar_placeholder_message_for_sitemaps": {
"message": "Поиск карт обхода..."
},
"searchbar_placeholder_message_for_projects": {
"message": "Поиск проектов..."
}
}
29 changes: 28 additions & 1 deletion src/devtools/panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ tbody tr {

.table-condensed tbody > tr > td {
padding: 1px 5px;
overflow-wrap: anywhere;
}
#projects .table-condensed {
width: 100%;
table-layout: fixed;
}
#sitemaps .table-condensed {
width: 100%;
}

body {
font-size: 12px;
}
Expand Down Expand Up @@ -182,3 +189,23 @@ select[size] {
font-style: normal;
font-weight: normal;
}
.searchbar {
margin: 5px;
width: 20em;
padding: 0.5em 1em;
border: 2px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
font-size: 1em;
color: #333;
transition: border-color 0.2s ease, box-shadow 0.2s ease;
&:focus {
border-color: #007bff;
box-shadow: 0 0 4px rgba(0, 123, 255, 0.4);
outline: none;
}
&::placeholder {
color: #888;
font-style: italic;
}
}
5 changes: 5 additions & 0 deletions src/devtools/views/ProjectList.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<div id="projects">
<input class="searchbar" id="searchbar" />
<table class="table table-bordered table-condensed table-hover">
<colgroup>
<col style="width: 30%" />
<col style="width: 70%" />
</colgroup>
<thead>
<tr>
<th data-i18n="projectlist_id"></th>
Expand Down
6 changes: 6 additions & 0 deletions src/devtools/views/SitemapList.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<div id="sitemaps">
<input class="searchbar" id="searchbar" />
<table class="table table-bordered table-condensed table-hover">
<colgroup>
<col style="width: 30%" />
<col style="max-width: 60%" />
<col style="width: auto" />
</colgroup>
<thead>
<tr>
<th data-i18n="sitemaplist_id"></th>
Expand Down
2 changes: 1 addition & 1 deletion src/devtools/views/SitemapListItem.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<tr>
<td class="id">{{_id}}</td>
<td>{{#startUrls}} {{.}}, {{/startUrls}}{{^startUrls}}{{urlPattern}}{{/startUrls}}</td>
<td>
<td class="actions">
<div class="actions-block">
<button
action="browse-sitemap-data"
Expand Down
31 changes: 30 additions & 1 deletion src/scripts/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,19 @@ export default class SitemapController {
});
$('#viewport').html($projectListPanel);
Translator.translatePage();

$('table').searcher({
inputSelector: '#searchbar',
toggle: (item, containsText) => {
$(item).unhighlight();
$(item).toggle(containsText);
$(item).highlight($('#searchbar').val());
},
});
$('#searchbar').attr(
'placeholder',
Translator.getTranslationByKey('searchbar_placeholder_message_for_projects')
);
}

getCurrentProjectId() {
Expand Down Expand Up @@ -872,8 +885,24 @@ export default class SitemapController {
$('#viewport').html($sitemapListPanel);
Translator.translatePage();
}
$('table').searcher({
inputSelector: '#searchbar',
textSelector: 'td:not(td.actions)',
toggle: (item, containsText) => {
$(item).unhighlight();
$(item).toggle(containsText);
$(item)
.find('td:not(.actions)')
.each(function () {
$(this).highlight($('#searchbar').val());
});
},
});
$('#searchbar').attr(
'placeholder',
Translator.getTranslationByKey('searchbar_placeholder_message_for_sitemaps')
);
}

getSitemapFromMetadataForm() {
const metadata = {};
const $form = $('#viewport form');
Expand Down