CC-5450 : Refactor Media Management (Classes/DB) in Airtime
starting working on proper visibility of advanced search fields.
This commit is contained in:
parent
54de9d47c3
commit
71f9ce1942
|
@ -54,7 +54,6 @@ class Application_Service_MediaService
|
||||||
"title" => _("Scheduled"),
|
"title" => _("Scheduled"),
|
||||||
"width" => "90px",
|
"width" => "90px",
|
||||||
"class" => "library_is_scheduled",
|
"class" => "library_is_scheduled",
|
||||||
"searchable" => false,
|
|
||||||
"advancedSearch" => array(
|
"advancedSearch" => array(
|
||||||
"type" => "checkbox"
|
"type" => "checkbox"
|
||||||
)
|
)
|
||||||
|
@ -64,7 +63,6 @@ class Application_Service_MediaService
|
||||||
"title" => _("Playlist"),
|
"title" => _("Playlist"),
|
||||||
"width" => "90px",
|
"width" => "90px",
|
||||||
"class" => "library_is_playlist",
|
"class" => "library_is_playlist",
|
||||||
"searchable" => false,
|
|
||||||
"advancedSearch" => array(
|
"advancedSearch" => array(
|
||||||
"type" => "checkbox"
|
"type" => "checkbox"
|
||||||
)
|
)
|
||||||
|
@ -102,7 +100,6 @@ class Application_Service_MediaService
|
||||||
"width" => "80px",
|
"width" => "80px",
|
||||||
"class" => "library_bitrate",
|
"class" => "library_bitrate",
|
||||||
"visible" => false,
|
"visible" => false,
|
||||||
"searchable" => false,
|
|
||||||
"advancedSearch" => array(
|
"advancedSearch" => array(
|
||||||
"type" => "number-range"
|
"type" => "number-range"
|
||||||
)
|
)
|
||||||
|
@ -113,7 +110,6 @@ class Application_Service_MediaService
|
||||||
"width" => "50px",
|
"width" => "50px",
|
||||||
"class" => "library_bpm",
|
"class" => "library_bpm",
|
||||||
"visible" => false,
|
"visible" => false,
|
||||||
"searchable" => false,
|
|
||||||
"advancedSearch" => array(
|
"advancedSearch" => array(
|
||||||
"type" => "number-range"
|
"type" => "number-range"
|
||||||
)
|
)
|
||||||
|
@ -226,7 +222,6 @@ class Application_Service_MediaService
|
||||||
"width" => "125px",
|
"width" => "125px",
|
||||||
"class" => "library_modified_time",
|
"class" => "library_modified_time",
|
||||||
"visible" => false,
|
"visible" => false,
|
||||||
"searchable" => false,
|
|
||||||
"advancedSearch" => array(
|
"advancedSearch" => array(
|
||||||
"type" => "date-range"
|
"type" => "date-range"
|
||||||
)
|
)
|
||||||
|
@ -237,7 +232,6 @@ class Application_Service_MediaService
|
||||||
"width" => "125px",
|
"width" => "125px",
|
||||||
"class" => "library_modified_time",
|
"class" => "library_modified_time",
|
||||||
"visible" => false,
|
"visible" => false,
|
||||||
"searchable" => false,
|
|
||||||
"advancedSearch" => array(
|
"advancedSearch" => array(
|
||||||
"type" => "date-range"
|
"type" => "date-range"
|
||||||
)
|
)
|
||||||
|
@ -288,7 +282,6 @@ class Application_Service_MediaService
|
||||||
"width" => "80px",
|
"width" => "80px",
|
||||||
"class" => "library_replay_gain",
|
"class" => "library_replay_gain",
|
||||||
"visible" => false,
|
"visible" => false,
|
||||||
"searchable" => false,
|
|
||||||
"advancedSearch" => array(
|
"advancedSearch" => array(
|
||||||
"type" => "number-range"
|
"type" => "number-range"
|
||||||
)
|
)
|
||||||
|
@ -299,7 +292,6 @@ class Application_Service_MediaService
|
||||||
"width" => "80px",
|
"width" => "80px",
|
||||||
"class" => "library_sr",
|
"class" => "library_sr",
|
||||||
"visible" => false,
|
"visible" => false,
|
||||||
"searchable" => false,
|
|
||||||
"advancedSearch" => array(
|
"advancedSearch" => array(
|
||||||
"type" => "number-range"
|
"type" => "number-range"
|
||||||
)
|
)
|
||||||
|
@ -310,7 +302,6 @@ class Application_Service_MediaService
|
||||||
"width" => "65px",
|
"width" => "65px",
|
||||||
"class" => "library_track",
|
"class" => "library_track",
|
||||||
"visible" => false,
|
"visible" => false,
|
||||||
"searchable" => false,
|
|
||||||
"advancedSearch" => array(
|
"advancedSearch" => array(
|
||||||
"type" => "number-range"
|
"type" => "number-range"
|
||||||
)
|
)
|
||||||
|
@ -321,7 +312,6 @@ class Application_Service_MediaService
|
||||||
"width" => "125px",
|
"width" => "125px",
|
||||||
"class" => "library_upload_time",
|
"class" => "library_upload_time",
|
||||||
"visible" => false,
|
"visible" => false,
|
||||||
"searchable" => false,
|
|
||||||
"advancedSearch" => array(
|
"advancedSearch" => array(
|
||||||
"type" => "date-range"
|
"type" => "date-range"
|
||||||
)
|
)
|
||||||
|
|
|
@ -108,23 +108,66 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
template =
|
template =
|
||||||
"<div id='advanced_search_col_<%= index %>' class='control-group' <%= style %>>" +
|
"<div id='advanced_search_col_<%= index %>' class='control-group' <%= style %>>" +
|
||||||
"<label class='control-label'><%= title %></label>" +
|
"<label class='control-label'><%= title %></label>" +
|
||||||
"<div id='adv-search-<%= id %>' class='controls'></div>" +
|
"<div id='<%= id %>' class='controls'></div>" +
|
||||||
"</div>";
|
"</div>";
|
||||||
|
|
||||||
template = _.template(template);
|
template = _.template(template);
|
||||||
$el = $(template(config));
|
$el = $(template({
|
||||||
|
index: config.index,
|
||||||
|
style: display,
|
||||||
|
title: config.title,
|
||||||
|
id: config.id
|
||||||
|
}));
|
||||||
|
|
||||||
return $el;
|
return $el;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUpAdvancedSearch(columns) {
|
function setUpAdvancedSearch(columns, type) {
|
||||||
|
var i, len,
|
||||||
|
selector = "#advanced_search_"+type,
|
||||||
|
$div = $(selector),
|
||||||
|
col, tmp,
|
||||||
|
searchFields = [];
|
||||||
|
|
||||||
|
for (i = 0, len = columns.length; i < len; i++) {
|
||||||
|
|
||||||
|
col = columns[i];
|
||||||
|
|
||||||
|
if (col.bSearchable) {
|
||||||
|
tmp = createAdvancedSearchField({
|
||||||
|
index: i,
|
||||||
|
display: col.bVisible,
|
||||||
|
title: col.sTitle,
|
||||||
|
id: "adv-search-"+ col.mDataProp
|
||||||
|
});
|
||||||
|
|
||||||
|
searchFields.push(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//http://www.bennadel.com/blog/2281-jQuery-Appends-Multiple-Elements-Using-Efficient-Document-Fragments.htm
|
||||||
|
$div.append(searchFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setAdvancedSearchColumnDisplay(colNum, display) {
|
||||||
|
var selector = "#advanced_search_col_" + colNum,
|
||||||
|
$column = $(selector);
|
||||||
|
|
||||||
|
if (display) {
|
||||||
|
$column.show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$column.hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createDatatable(config) {
|
function createDatatable(config) {
|
||||||
|
|
||||||
var key = "datatables-"+config.type+"-aoColumns",
|
var key = "datatables-"+config.type+"-aoColumns",
|
||||||
columns = JSON.parse(localStorage.getItem(key));
|
columns = JSON.parse(localStorage.getItem(key)),
|
||||||
|
abVisible,
|
||||||
|
i, len;
|
||||||
|
|
||||||
|
setUpAdvancedSearch(columns, config.type);
|
||||||
|
|
||||||
var table = $("#"+config.type + "_table").dataTable({
|
var table = $("#"+config.type + "_table").dataTable({
|
||||||
"aoColumns": columns,
|
"aoColumns": columns,
|
||||||
|
@ -132,17 +175,17 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
"bServerSide": true,
|
"bServerSide": true,
|
||||||
"sAjaxSource": baseUrl+"media/"+config.type+"-feed",
|
"sAjaxSource": baseUrl+"media/"+config.type+"-feed",
|
||||||
"sAjaxDataProp": "media",
|
"sAjaxDataProp": "media",
|
||||||
"fnServerData": function ( sSource, aoData, fnCallback ) {
|
"fnServerData": function (sSource, aoData, fnCallback) {
|
||||||
|
|
||||||
aoData.push( { name: "format", value: "json"} );
|
aoData.push({ name: "format", value: "json"});
|
||||||
|
|
||||||
$.ajax( {
|
$.ajax({
|
||||||
"dataType": 'json',
|
"dataType": 'json',
|
||||||
"type": "POST",
|
"type": "POST",
|
||||||
"url": sSource,
|
"url": sSource,
|
||||||
"data": aoData,
|
"data": aoData,
|
||||||
"success": fnCallback
|
"success": fnCallback
|
||||||
} );
|
});
|
||||||
},
|
},
|
||||||
//save the tables based on tableId
|
//save the tables based on tableId
|
||||||
"bStateSave": true,
|
"bStateSave": true,
|
||||||
|
@ -194,6 +237,10 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//abVisible indices belong to the original column order.
|
||||||
|
//use to fix up advanced search.
|
||||||
|
abVisible = oData.abVisCols;
|
||||||
|
|
||||||
oData.iEnd = parseInt(oData.iEnd, 10);
|
oData.iEnd = parseInt(oData.iEnd, 10);
|
||||||
oData.iLength = parseInt(oData.iLength, 10);
|
oData.iLength = parseInt(oData.iLength, 10);
|
||||||
oData.iStart = parseInt(oData.iStart, 10);
|
oData.iStart = parseInt(oData.iStart, 10);
|
||||||
|
@ -216,10 +263,8 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
"fnStateChange": function ( iColumn, bVisible ) {
|
"fnStateChange": function ( iColumn, bVisible ) {
|
||||||
var c = table.fnSettings().aoColumns,
|
var c = table.fnSettings().aoColumns,
|
||||||
origIndex = c[iColumn]._ColReorder_iOrigCol;
|
origIndex = c[iColumn]._ColReorder_iOrigCol;
|
||||||
col = columns[origIndex];
|
|
||||||
|
setAdvancedSearchColumnDisplay(origIndex, bVisible);
|
||||||
console.log(col);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -232,6 +277,12 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//fnStateLoadParams will have already run.
|
||||||
|
//fix up advanced search from saved settings.
|
||||||
|
for (i = 0, len = abVisible.length; i < len; i++) {
|
||||||
|
setAdvancedSearchColumnDisplay(i, abVisible[i]);
|
||||||
|
}
|
||||||
|
|
||||||
table.fnSetFilteringDelay(350);
|
table.fnSetFilteringDelay(350);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,6 +537,12 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$library.on("click", "legend", function() {
|
||||||
|
var $fs = $(this).parents("fieldset");
|
||||||
|
|
||||||
|
$fs.toggleClass("closed");
|
||||||
|
});
|
||||||
|
|
||||||
$library.on("click", "#lib_new_webstream", function(e) {
|
$library.on("click", "#lib_new_webstream", function(e) {
|
||||||
var url = baseUrl+"webstream/new/format/json";
|
var url = baseUrl+"webstream/new/format/json";
|
||||||
|
|
||||||
|
@ -566,6 +623,7 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
$('#editmdsave').click();
|
$('#editmdsave').click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
//end of events fo the edit metadata dialog.
|
//end of events fo the edit metadata dialog.
|
||||||
|
|
||||||
// begin context menu initialization.
|
// begin context menu initialization.
|
||||||
|
|
Loading…
Reference in New Issue