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 { .select2-container--default .select2-selection--single .select2-selection__arrow {
top: unset; top: unset;
} }
select[name=filter_User] + .select2 {
min-width: 20rem;
}
.navbar-collapse { .navbar-collapse {
padding-left: 15px !important; 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(); 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 // Country filter
$("select[name=filter_country]").select2({ $("select[name=filter_country]").select2({
placeholder: $('select[name=filter_country] option:first-child').text() placeholder: $('select[name=filter_country] option:first-child').text()

View File

@ -89,7 +89,11 @@ class AdvTableBuilder extends TableBuilder
*/ */
protected $assets = [ protected $assets = [
'scripts.js' => [ '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, 'query' => CategoryFilterQuery::class,
'options' => $categories, 'options' => $categories,
], ],
'User' => [ 'user' => [
'exact' => true, 'exact' => true,
'filter' => 'select', 'filter' => 'select',
'query' => UserFilterQuery::class, 'query' => UserFilterQuery::class,

View File

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