summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdocs/CHANGELOG1
-rw-r--r--lib/class/song.class.php15
-rw-r--r--lib/javascript-base.js10
-rw-r--r--lib/ui.lib.php24
-rw-r--r--templates/show_edit_song_row.inc.php4
5 files changed, 49 insertions, 5 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index c2304789..0f8d16bc 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,7 @@
--------------------------------------------------------------------------
v.3.4-Beta1
+ - Added 'Add New...' option to Album on Song Edit (Thx picasso)
- Fixed multiple login check
- Fixed filters applying incorrectly to non-browse displays
- Fixed Flash Player issue when Playlist Method wasn't default
diff --git a/lib/class/song.class.php b/lib/class/song.class.php
index 61ee2b93..19c5c0cf 100644
--- a/lib/class/song.class.php
+++ b/lib/class/song.class.php
@@ -395,7 +395,7 @@ class Song {
foreach ($data as $key=>$value) {
switch ($key) {
case 'title':
- case 'album':
+ #case 'album':
case 'artist':
case 'genre':
case 'track':
@@ -407,6 +407,19 @@ class Song {
$updated = 1;
}
break;
+ case 'album':
+ if ($value != $this->$key) {
+ if ($value == -1) {
+ // Add new album based on album_name
+ $value = Catalog::check_album($data['album_name']);
+ }
+ if ($value) {
+ self::update_album($value, $this->id);
+ $this->$key = $value;
+ $updated = 1;
+ }
+ }
+ break;
default:
// Rien a faire
break;
diff --git a/lib/javascript-base.js b/lib/javascript-base.js
index 0e9296ba..a51f7323 100644
--- a/lib/javascript-base.js
+++ b/lib/javascript-base.js
@@ -76,3 +76,13 @@ function popup_art(url) {
newwindow=window.open(url, "ampache_art", "menubar=no,toolbar=no,location=no,directories=no");
if (window.focus) {newwindow.focus()}
}
+
+// In-line album editing helper function
+function checkAlbum(song) {
+ if ($('album_select_'+song).options[$('album_select_'+song).selectedIndex].value == -1) {
+ $('album_select_song_'+song).innerHTML = '<input type="textbox" name="album_name" value="New Album" />';
+ } else {
+ $('album_select_song_'+song).innerHTML = '';
+ }
+}
+
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index e932aaae..aa28af36 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -613,9 +613,22 @@ function show_playlist_import() {
* This displays a select of every album that we've got in Ampache, (it can be hella long) it's used
* by the Edit page, it takes a $name and a $album_id
*/
-function show_album_select($name='album',$album_id=0) {
-
- echo "<select name=\"$name\">\n";
+function show_album_select($name='album',$album_id=0,$allow_add=0,$song_id=0) {
+ // Probably superfluous code to ensure we never generate two album_select
+ // elements with the same ID on the same page.
+ static $id_inc;
+ static $keys;
+ if (!isset($keys)) $keys = array();
+ if (!isset($id_inc)) $id_inc = 1;
+ else $id_inc++;
+ $key = "album_select_$song_id";
+ if (!empty($keys[$key])) $key = "album_select_$name";
+ if (!empty($keys[$key])) $key = "album_select_x$id_inc";
+ if (!empty($keys[$key])) $key = "album_select_{$name}_x{$id_inc}";
+ $keys[$key] = true;
+
+ // Added ID field so we can easily observe this element
+ echo "<select name=\"$name\" id=\"$key\">\n";
$sql = "SELECT `id`, `name`, `prefix` FROM `album` ORDER BY `name`";
$db_results = Dba::query($sql);
@@ -631,6 +644,11 @@ function show_album_select($name='album',$album_id=0) {
} // end while
+ if ($allow_add) {
+ // Append additional option to the end with value=-1
+ echo "\t<option value=\"-1\">Add New...</option>\n";
+ }
+
echo "</select>\n";
} // show_album_select
diff --git a/templates/show_edit_song_row.inc.php b/templates/show_edit_song_row.inc.php
index e3d1a89e..dcd41750 100644
--- a/templates/show_edit_song_row.inc.php
+++ b/templates/show_edit_song_row.inc.php
@@ -29,7 +29,9 @@
<?php show_artist_select('artist',$song->artist); ?>
</td>
<td>
- <?php show_album_select('album',$song->album); ?>
+ <?php show_album_select('album',$song->album,true,$song->id); ?>
+ <div id="album_select_song_<?php echo $song->id ?>"></div>
+<?php echo Ajax::observe('album_select_'.$song->id,'change','checkAlbum('.$song->id.')'); ?>
</td>
<td>
<?php show_genre_select('genre',$song->genre); ?>