Merge branch 'master' of https://github.com/openclassify/openclassify into m_alibaba

This commit is contained in:
Muammer Top 2021-02-09 16:14:23 +03:00
commit 659feb6869
7 changed files with 54 additions and 46 deletions

View File

@ -0,0 +1,3 @@
select[name=filter_user] + .select2 {
min-width: 20rem;
}

View File

@ -41,11 +41,6 @@
.select2-container--default .select2-selection--single .select2-selection__arrow {
top: unset;
}
select[name=filter_User] + .select2 {
min-width: 20rem;
}
.navbar-collapse {
padding-left: 15px !important;
}

View File

@ -0,0 +1,25 @@
$(document).ready(function () {
// User filter
$("select[name=filter_user]").select2({
placeholder: $('select[name=filter_user] option:first-child').text(),
ajax: {
url: '/api/profile/query-users',
dataType: 'json',
processResults: function (data) {
let formattedData = [];
Object.keys(data).forEach(function (id) {
formattedData.push({
'id': id,
'text': data[id]
})
});
return {
results: formattedData
}
}
}
});
});

View File

@ -145,29 +145,6 @@ $(document).ready(function () {
filter.checkUser();
});
// User filter
$("select[name=filter_User]").select2({
placeholder: $('select[name=filter_User] option:first-child').text(),
ajax: {
url: '/api/profile/query-users',
dataType: 'json',
processResults: function (data) {
let formattedData = [];
Object.keys(data).forEach(function (id) {
formattedData.push({
'id': id,
'text': data[id]
})
})
return {
results: formattedData
}
}
}
});
// Country filter
$("select[name=filter_country]").select2({
placeholder: $('select[name=filter_country] option:first-child').text()

View File

@ -89,7 +89,11 @@ class AdvTableBuilder extends TableBuilder
*/
protected $assets = [
'scripts.js' => [
'visiosoft.module.advs::js/admin/advanced.js'
'visiosoft.module.advs::js/admin/advanced.js',
'visiosoft.module.advs::js/admin/filter-user.js',
],
'styles.css' => [
'visiosoft.module.advs::css/admin/filter-user.css',
],
];

View File

@ -40,7 +40,7 @@ class AdvTableFilters
'query' => CategoryFilterQuery::class,
'options' => $categories,
],
'User' => [
'user' => [
'exact' => true,
'filter' => 'select',
'query' => UserFilterQuery::class,

View File

@ -13,7 +13,9 @@ $('.filter-country-btn').on('click', function () {
countries = callback;
resetValue('country', true, false)
$.each(countries, function (index, value) {
$('.filter-location-modal .countries').append(item('country', value.id, value.name, value.abv.toLowerCase()));
$('.filter-location-modal .countries').append(
item('country', value.id, value.name, value.abv ? value.abv.toLowerCase() : '')
);
});
if (countries == "")
$('.filter-location-modal .countries').html(null_msg);
@ -245,22 +247,24 @@ function locationCrud(params, url, type, beforeSend, callback) {
function item(field_name, id, value, abv = '') {
var selected = defaultCountry === id ? "checked" : "";
if (field_name === 'country') {
return '<li class="px-2" data-id="' + id + '">\n' +
' <label class="w-100">\n' +
' <input' +
' type="checkbox" data-field="' + field_name + '" data-id="' + id + '" '+ selected +'>\n' +
' <span class="flag ml-1 flag-' + abv + '">\n' +
' </span>\n' +
' <small>' + value + '</small>\n' +
' </label>\n' +
' </li>';
return `
<li class="px-2" data-id="${id}">
<label class="w-100">
<input type="checkbox" data-field="${field_name}" data-id="${id}" ${selected}>
<span class="flag ml-1 flag-${abv}"></span>
<small>${value}</small>
</label>
</li>
`;
} else {
return '<li class="px-2" data-id="' + id + '">\n' +
' <label class="w-100">\n' +
' <input type="checkbox" data-field="' + field_name + '" data-id="' + id + '">\n' +
' <small>' + value + '</small>\n' +
' </label>\n' +
' </li>';
return `
<li class="px-2" data-id="${id}">
<label class="w-100">
<input type="checkbox" data-field="${field_name}" data-id="${id}">
<small>${value}</small>
</label>
</li>
`;
}
}