mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
Merge pull request #134 from meilisearch/improve_httpui
add a button to display or show the facets
This commit is contained in:
commit
f2a786ecbf
@ -1,5 +1,6 @@
|
|||||||
var request = null;
|
var request = null;
|
||||||
var timeoutID = null;
|
var timeoutID = null;
|
||||||
|
var display_facets = false;
|
||||||
|
|
||||||
$('#query, #filters').on('input', function () {
|
$('#query, #filters').on('input', function () {
|
||||||
var query = $('#query').val();
|
var query = $('#query').val();
|
||||||
@ -18,7 +19,7 @@ $('#query, #filters').on('input', function () {
|
|||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
'query': query,
|
'query': query,
|
||||||
'filters': filters,
|
'filters': filters,
|
||||||
"facetDistribution": true,
|
"facetDistribution": display_facets,
|
||||||
}),
|
}),
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
success: function (data, textStatus, request) {
|
success: function (data, textStatus, request) {
|
||||||
@ -114,6 +115,22 @@ function selectedFacetsToArray(facets_obj) {
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('#display_facets').click(function() {
|
||||||
|
if (display_facets) {
|
||||||
|
display_facets = false;
|
||||||
|
$('#display_facets').html("Display facets")
|
||||||
|
$('#display_facets').removeClass("is-danger");
|
||||||
|
$('#display_facets').addClass("is-success");
|
||||||
|
$('#facets').hide();
|
||||||
|
} else {
|
||||||
|
display_facets = true;
|
||||||
|
$('#display_facets').html("Hide facets")
|
||||||
|
$('#display_facets').addClass("is-danger");
|
||||||
|
$('#display_facets').removeClass("is-success");
|
||||||
|
$('#facets').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Make the number of document a little bit prettier
|
// Make the number of document a little bit prettier
|
||||||
$('#docs-count').text(function(index, text) {
|
$('#docs-count').text(function(index, text) {
|
||||||
return parseInt(text).toLocaleString()
|
return parseInt(text).toLocaleString()
|
||||||
|
@ -10,11 +10,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#facets {
|
#facets {
|
||||||
|
display: none;
|
||||||
max-width: 900px;
|
max-width: 900px;
|
||||||
margin: 20px auto 0 auto;
|
margin: 20px auto 0 auto;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
max-height: 16em;
|
max-height: 16em;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
#display_facets {
|
||||||
|
margin: 20px auto 0 auto;
|
||||||
|
padding: 5px;
|
||||||
|
max-height: 16em;
|
||||||
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
#facets .tag:hover {
|
#facets .tag:hover {
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
<p class="heading">Number of Documents</p>
|
<p class="heading">Number of Documents</p>
|
||||||
<p class="title" id="docs-count">{{ docs_count }}</p>
|
<p class="title" id="docs-count">{{ docs_count }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
<button id="display_facets" class="button is-success">display facets</button>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user