Skip to content

Commit d9097c5

Browse files
committed
Add popover to the search result (tags list and full file name)
1 parent e72bf21 commit d9097c5

File tree

7 files changed

+53
-5
lines changed

7 files changed

+53
-5
lines changed

public/assets/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/assets/app.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/scripts/ui/filesSearch.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ export default (function () {
8080

8181
$(fileSearchResultWrapper).empty();
8282
$(fileSearchResultWrapper).append(searchResultsList);
83+
ui.widgets.popover.init();
84+
8385
bootstrap_notifications.notify("Found " + resultsCount + " matching file/s", 'success');
8486

8587

@@ -95,17 +97,33 @@ export default (function () {
9597
let ul = $('<ul>');
9698

9799
$.each(data, (index, result) => {
100+
let tagsJson = result['tags'];
101+
let arrayOfTags = JSON.parse(tagsJson);
102+
let tagsList = '';
98103
let module = result['module'];
99104
let filename = result['filename'];
100105
let filePath = result['fullFilePath'];
101106
let directoryPath = result['directoryPath'];
102107
let shortFilename = filename;
103108
let shortLen = 16;
104109

110+
// build list of tags
111+
$.each(arrayOfTags, (idx, tag) => {
112+
113+
tagsList += tag;
114+
115+
if( idx < ( arrayOfTags.length - 1 ) ){
116+
tagsList += ', ';
117+
}
118+
119+
});
120+
121+
// build shortname
105122
if( filename.length > shortLen ) {
106123
shortFilename = filename.substr(0, shortLen) + '...';
107124
}
108125

126+
// build download form
109127
let form = $('<form>');
110128
$(form).attr('method', "POST");
111129
$(form).attr('action', "/download/file");
@@ -145,6 +163,24 @@ export default (function () {
145163
$(link).append(moduleIcon);
146164
$(link).append(name);
147165

166+
//add popover to link
167+
$(link).attr('data-trigger', "hover");
168+
169+
$(link).attr('data-html', "true");
170+
$(link).attr('data-toggle-popover', 'true');
171+
172+
$(link).attr(
173+
'data-content',
174+
`<p style='display: flex;'>
175+
<span style='font-weight: bold; '>
176+
Tags:&nbsp;
177+
</span>
178+
<span style='word-break: break-all;'>` + tagsList + `</span>
179+
</p>`
180+
);
181+
$(link).attr('title', filename);
182+
183+
// combine list elements
148184
let li = $('<li>');
149185
$(li).append(link);
150186
$(li).append(form);

src/assets/scripts/ui/widgets.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default (function () {
3333
this.callModalOnWidgetPlusIcon();
3434
this.addMonthlyPaymentSummaryToAccordinHeader();
3535
this.removeFolderOnFolderRemovalIconClick();
36+
this.popover.init();
3637

3738
$(document).ready(function(){
3839
ui.widgets.fixAccordions();
@@ -258,6 +259,11 @@ export default (function () {
258259
});
259260

260261
}
262+
},
263+
popover: {
264+
init: function(){
265+
$('[data-toggle-popover="true"]').popover();
266+
}
261267
}
262268

263269
};

src/scss/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
@import 'app.css';
2020
@import 'libs/customization-for-liblaries/fontawesome';
21+
@import 'libs/customization-for-liblaries/popover.scss';
2122

2223
/* My-scsses */
2324

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.popover-header {
2+
font-size: 12px;
3+
}
4+
5+
.popover-body {
6+
font-size: 13px;
7+
}

templates/page-elements/components/topbar/components/search.twig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
</a>
66
</li>
77
<li class="search-input">
8-
{# TODO: prevent overwriting the styles by selectizejs #}
98
<input class="form-control tags" type="text" data-value="" placeholder="Search for files by tags..." id="filesSearchByTags">
109
<div id="searchResultListWrapper">
11-
1210
</div>
1311
</li>

0 commit comments

Comments
 (0)