file summary table now starting to work with templates.need to change query around to be configurable still.

This commit is contained in:
Naomi 2013-08-02 15:29:39 -04:00
parent b480a5ae18
commit c110b4b4df
10 changed files with 298 additions and 162 deletions

View file

@ -80,17 +80,13 @@ var AIRTIME = (function(AIRTIME) {
addField(name, type, false, false);
});
function createUpdateTemplate(template_id, isDefault) {
var createUrl = baseUrl+"Playouthistory/create-template/format/json";
var updateUrl = baseUrl+"Playouthistory/update-template/format/json";
var url;
function updateTemplate(template_id, isDefault) {
var url = baseUrl+"Playouthistory/update-template/format/json";
var data = {};
var $lis, $li;
var i, len;
var templateName;
url = (isNaN(parseInt(template_id, 10))) ? createUrl : updateUrl;
templateName = $("#template_name").val();
$lis = $templateList.children();
@ -108,24 +104,16 @@ var AIRTIME = (function(AIRTIME) {
$templateDiv.on("click", "#template_item_save", function(){
var template_id = $(this).data("template");
createUpdateTemplate(template_id, false);
updateTemplate(template_id, false);
});
$templateDiv.on("click", "#template_set_default", function(){
var template_id = $(this).data("template");
if (isNaN(parseInt(template_id, 10))) {
createUpdateTemplate(template_id, true);
}
else {
var url = baseUrl+"Playouthistory/set-item-template-default/format/json";
$.post(url, {id: template_id}, function(json) {
var x;
});
}
var template_id = $(this).data("template");
var url = baseUrl+"Playouthistory/set-template-default/format/json";
$.post(url, {id: template_id}, function(json) {
var x;
});
});
};

View file

@ -104,16 +104,11 @@ var AIRTIME = (function(AIRTIME) {
nRow.setAttribute('url-edit', editUrl);
};
var columns = JSON.parse(localStorage.getItem('datatables-historyfile-aoColumns'));
oTable = $historyTableDiv.dataTable( {
"aoColumns": [
{"sTitle": $.i18n._("Title"), "mDataProp": "title", "sClass": "his_title"}, /* Title */
{"sTitle": $.i18n._("Creator"), "mDataProp": "artist", "sClass": "his_artist"}, /* Creator */
{"sTitle": $.i18n._("Played"), "mDataProp": "played", "sClass": "his_artist"}, /* times played */
{"sTitle": $.i18n._("Length"), "mDataProp": "length", "sClass": "his_length library_length"}, /* Length */
{"sTitle": $.i18n._("Composer"), "mDataProp": "composer", "sClass": "his_composer"}, /* Composer */
{"sTitle": $.i18n._("Copyright"), "mDataProp": "copyright", "sClass": "his_copyright"} /* Copyright */
],
"aoColumns": columns,
"bProcessing": true,
"bServerSide": true,

View file

@ -9,8 +9,8 @@ var AIRTIME = (function(AIRTIME) {
function createItemLi(id, name, configured) {
var editUrl = baseUrl+"Playouthistory/configure-item-template/id/"+id;
var defaultUrl = baseUrl+"Playouthistory/set-item-template-default/format/json/id/"+id;
var editUrl = baseUrl+"Playouthistory/configure-template/id/"+id;
var defaultUrl = baseUrl+"Playouthistory/set-template-default/format/json/id/"+id;
var removeUrl = baseUrl+"Playouthistory/delete-template/format/json/id/"+id;
var itemConfigured =
@ -70,10 +70,11 @@ var AIRTIME = (function(AIRTIME) {
});
});
$historyTemplate.on("click", "#new_item_template", function() {
function createTemplate(type) {
var createUrl = baseUrl+"Playouthistory/create-template";
$.post(createUrl, {format: "json"}, function(json) {
$.post(createUrl, {format: "json", type: type}, function(json) {
if (json.error !== undefined) {
alert(json.error);
@ -82,8 +83,15 @@ var AIRTIME = (function(AIRTIME) {
window.location.href = json.url;
});
}
$historyTemplate.on("click", "#new_item_template", function() {
createTemplate("item");
});
$historyTemplate.on("click", "#new_file_template", function() {
createTemplate("file");
});
};
return AIRTIME;