Permalink
Browse files

Fix playlist drag-and-drop

  • Loading branch information...
mnutt committed Aug 31, 2009
1 parent d1e552a commit 9787f94531ead2928813d817fd4605bd225ea07b
@@ -21,26 +21,9 @@ def destroy
def update
@collection = Limewire::Collection.find(params[:id])
- @collection.reorder(params[:sha1s]) if params[:sha1s]
+ @collection.update_items(params[:sha1s].split(',')) if params[:sha1s]
@collection.name = params[:name] if params[:name]
@collection.save
render :json => {:response => 200}
end
-
- def add_items
- @collection = Limewire::Collection.find(params[:id])
- params[:sha1s].each do |sha1|
- @collection.add sha1
- end
- render :json => {:response => 200}
- end
-
- def remove_items
- @collection = Limewire::Collection.find(params[:id])
- params[:sha1s].each do |sha1|
- @collection.remove sha1
- end
-
- render :json => {:response => 200}
- end
end
View
@@ -6,7 +6,7 @@
map.resources :library, :member => {:thumbnail => :get}
map.thumb "/library/:id/thumbnail/:s", :controller => 'library', :action => 'thumbnail'
- map.resources :collections, :member => {:add_items => :post, :remove_items => :post}
+ map.resources :collections
map.resources :searches
map.resources :downloads
map.resources :search
@@ -371,7 +371,7 @@ SC.Playlist.prototype = {
tracks = "0";
}
- $.post("/collectionss/" + this.id ,{"_method":"PUT","playlist[tracks]":tracks,"playlist[version]":this.version},function(dataJS) {
+ $.post("/collections/" + this.id ,{"_method":"PUT","sha1s":tracks,"playlist[version]":this.version},function(dataJS) {
var data = eval('(' + dataJS + ')');
if(data.response == 200) {
self.version++;
@@ -32,6 +32,14 @@ def add(sha1, position=nil)
end
end
+ def update_items(sha1s)
+ self.clear
+ sha1s.each do |sha1|
+ item = Library.find_by_sha1(sha1)
+ @raw_collection.add(item)
+ end
+ end
+
def id
@raw_collection.get_id
end

0 comments on commit 9787f94

Please sign in to comment.