1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 17:59:21 +02:00

added the ability to split tags, inverse of the tag merge functionality

This commit is contained in:
John Moore 2014-09-07 18:49:35 -05:00
parent a87a343ca0
commit 13736a9bfe
3 changed files with 115 additions and 41 deletions

View file

@ -66,7 +66,7 @@ function showPlaylistDialog(e, item_type, item_ids) {
$(this).dialog("destroy");
}
});
$("#playlistdialog").dialog("option", "position", [e.clientX + 10, e.clientY]);
$("#playlistdialog").dialog("open");
closeplaylist = 0;
@ -120,7 +120,7 @@ function showBroadcastsDialog(e) {
$(this).dialog("destroy");
}
});
$("#broadcastsdialog").dialog("option", "position", [e.clientX - 180, e.clientY]);
$("#broadcastsdialog").dialog("open");
closebroadcasts = 0;
@ -153,17 +153,19 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
parent.refreshRowPrefix = refresh_row_prefix;
parent.editType = edit_type;
parent.editId = edit_id;
// Convert choices string ("tag0,tag1,tag2,...") to choices array
parent.editTagChoices = new Array();
if (tag_choices == undefined && tag_choices != '') {
// Load tag map
$.ajax(jsAjaxServer + '/ajax.server.php?page=tag&action=get_tag_map', { success: function(data) {
tag_choices = $(data).find('content').text();
if (tag_choices != '') {
showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_row_prefix);
}
}, type: 'post', dataType: 'xml' });
$.ajax(jsAjaxServer + '/ajax.server.php?page=tag&action=get_tag_map', {
success: function(data) {
tag_choices = $(data).find('content').text();
if (tag_choices != '') {
showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_row_prefix);
}
}, type: 'post', dataType: 'xml'
});
return;
}
var splitted = tag_choices.split(',');
@ -171,16 +173,16 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
for (i = 0; i < splitted.length; ++i) {
parent.editTagChoices.push($.trim(splitted[i]));
}
parent.dialog_buttons = {};
this.dialog_buttons[jsSaveTitle] = function() {
this.dialog_buttons[jsSaveTitle] = function () {
$.ajax({
url : parent.saveUrl,
type : 'POST',
data : $(parent.editFormId).serializeArray(),
success : function(resp){
url: parent.saveUrl,
type: 'POST',
data: $(parent.editFormId).serializeArray(),
success: function (resp) {
$("#editdialog").dialog("close");
if (parent.refreshRowPrefix != '') {
var new_id = $.trim(resp.lastChild.textContent);
@ -188,7 +190,7 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
if (new_id == '') {
new_id = parent.editId;
}
var url = jsAjaxServer + '/edit.server.php?action=refresh_updated&type=' + parent.editType + '&id=' + new_id;
// Reload only table
$('#' + parent.refreshRowPrefix + parent.editId).load(url, function() {
@ -204,15 +206,15 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
loadContentPage(reloadp);
}
},
error : function(resp){
error: function(resp) {
$("#editdialog").dialog("close");
}
});
});
}
this.dialog_buttons[jsCancelTitle] = function() {
$("#editdialog").dialog("close");
}
$(parent.editDialogId).dialog({
title: edit_title,
modal: true,
@ -224,7 +226,7 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
open: function () {
$(this).load(parent.contentUrl, function() {
$(this).dialog('option', 'position', 'center');
if ($('#edit_tags').length > 0) {
$("#edit_tags").tagit({
allowSpaces: true,
@ -233,10 +235,16 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
availableTags: parent.editTagChoices
});
}
if ($('#select_tags').length > 0) {
$.each(parent.editTagChoices, function(i, tagtext) {
$("#select_tags").append(new Option(tagtext, tagtext));
if ($('#merge_tag').length > 0) {
$.each(parent.editTagChoices, function (i, tagtext) {
$("#merge_tag").append(new Option(tagtext, tagtext));
});
}
if ($('#split_tag').length > 0) {
$.each(parent.editTagChoices, function (i, tagtext) {
$("#split_tag").append(new Option(tagtext, tagtext));
});
}
});
@ -247,7 +255,7 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_ro
},
buttons: dialog_buttons
});
$("#editdialog").dialog("open");
}
@ -267,7 +275,7 @@ function check_inline_song_edit(type, song) {
/*********************/
$(document).ready(function () {
var eles = $("tbody[id^='sortableplaylist_']");
if (eles != null) {
var len = eles.length;
@ -288,7 +296,7 @@ function submitNewItemsOrder(itemId, tableid, rowPrefix, updateUrl, refreshActio
var table = document.getElementById(tableid);
var rowLength = table.rows.length;
var finalOrder = '';
for (var i = 0; i < rowLength; ++i) {
var row = table.rows[i];
if (row.id != '') {
@ -296,16 +304,16 @@ function submitNewItemsOrder(itemId, tableid, rowPrefix, updateUrl, refreshActio
finalOrder += songid + ";"
}
}
if (finalOrder != '') {
$.ajax({
url : updateUrl,
type : 'GET',
data : 'order=' + finalOrder,
success : function(resp){
url: updateUrl,
type: 'GET',
data: 'order=' + finalOrder,
success: function (resp) {
var url = jsAjaxServer + '/refresh_reordered.server.php?action=' + parent.refreshAction + '&id=' + parent.itemId;
// Reload only table
$('#reordered_list_' + parent.itemId).load(url, function() {
$('#reordered_list_' + parent.itemId).load(url, function () {
$('#sortableplaylist_' + parent.itemId).sortable({
axis: 'y',
delay: 200
@ -324,6 +332,6 @@ function getPagePlaySettings() {
settings += '&subtitle=' + stg_subtitle.value;
}
}
return settings;
}
}