Make collection titles searchable in table

This commit is contained in:
JonnyWong16 2020-10-01 19:43:10 -07:00
parent 72215a9f44
commit 0ba755e463
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 9 additions and 4 deletions

View file

@ -40,7 +40,7 @@ playlists_table_options = {
"createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== '') {
var type = MEDIA_TYPE_HEADERS[rowData['playlistType']] || '';
if (rowData['leafCount'] == 1) {
if (rowData['leafCount'] === 1) {
type = type.slice(0, -1);
}
$(td).html(cellData + ' ' + type);

View file

@ -581,7 +581,9 @@ def process_json_kwargs(json_kwargs):
return params
def process_datatable_rows(rows, json_data, default_sort, sort_keys=None):
def process_datatable_rows(rows, json_data, default_sort, search_cols=None, sort_keys=None):
if search_cols is None:
search_cols = []
if sort_keys is None:
sort_keys = {}
@ -592,7 +594,7 @@ def process_datatable_rows(rows, json_data, default_sort, sort_keys=None):
# Search results
search_value = json_data['search']['value'].lower()
if search_value:
searchable_columns = [d['data'] for d in json_data['columns'] if d['searchable']]
searchable_columns = [d['data'] for d in json_data['columns'] if d['searchable']] + search_cols
for row in rows:
for k, v in row.items():
if k in sort_keys:

View file

@ -201,6 +201,8 @@ def get_collections_list(section_id=None, **kwargs):
# Get datatables JSON data
json_data = helpers.process_json_kwargs(json_kwargs=kwargs['json_data'])
search_cols = ['title']
sort_keys = {
'collectionMode': {
-1: 'Library Default',
@ -215,7 +217,8 @@ def get_collections_list(section_id=None, **kwargs):
}
results = helpers.process_datatable_rows(
collections, json_data, default_sort='titleSort', sort_keys=sort_keys)
collections, json_data, default_sort='titleSort',
search_cols=search_cols, sort_keys=sort_keys)
data = {
'recordsFiltered': results['filtered_count'],