From: yomguy Date: Fri, 10 Feb 2012 15:05:28 +0000 (+0100) Subject: add edit popup for playlists, add delete warnings X-Git-Tag: 1.3.10~11 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=507bea5921e184caf8a3fd30c1071269d6d17e43;p=telemeta.git add edit popup for playlists, add delete warnings --- diff --git a/telemeta/htdocs/js/playlist.js b/telemeta/htdocs/js/playlist.js index c89f9222..6a3d1382 100644 --- a/telemeta/htdocs/js/playlist.js +++ b/telemeta/htdocs/js/playlist.js @@ -44,13 +44,20 @@ var playlistUtils = { playlists : [], addPlaylist: function(name, id){ - //this.playlists[name]=id; this.playlists.push({ 'name':name, 'id':id }); }, + addEditPlaylist: function(id, title, description){ + this.playlists.push({ + 'id': id, + 'title': title, + 'description': description, + }); + }, + showAdd: function(anchorElement){ var t = gettrans('title'); @@ -111,10 +118,47 @@ var playlistUtils = { }); }, -// TODO: add edit fonction + update : function(dictionary){ + json([dictionary],'telemeta.update_playlist',function(){ + window.location.reload(); + }); + }, + showEdit: function(anchorElement, id){ + + var t = gettrans('title'); + var d = gettrans('description'); + var dd = {}; + var playlist = this; + + var playlists = this.playlists; + for (var i=0; i< playlists.length; i++){ + if (playlists[i].id == id){ + dd[t] = playlists[i].title; + dd[d] = playlists[i].description; + } + } + + new PopupDiv({ + 'content':dd, + invoker:anchorElement, + showOk:true, + onOk:function(data){ + if(!data[t] && !data[d]){ + return; + } + //convert language + playlist.update({ + 'public_id': id, + 'title': data[t], + 'description': data[d], + }); + } + }).show(); + }, + /*shows the popup for adding a resource to a playlist*/ - showAddResourceToPlaylist: function(anchorElement,resourceType,objectId, optionalOkMessage){ + showAddResourceToPlaylist: function(anchorElement, resourceType, objectId, optionalOkMessage){ var ar = []; var playlists = this.playlists; for(var i=0; i< playlists.length; i++){ diff --git a/telemeta/templates/telemeta/lists.html b/telemeta/templates/telemeta/lists.html index 1b550534..f47df171 100644 --- a/telemeta/templates/telemeta/lists.html +++ b/telemeta/templates/telemeta/lists.html @@ -10,7 +10,13 @@ var p = playlistUtils; var a = jQuery('#_new_playlist'); a.unbind('click').click(function(){p.showAdd(a);return false;}); - }); + }); + + {% for playlist in playlists %} + playlistUtils.addEditPlaylist('{{playlist.playlist.public_id}}','{{ playlist.playlist.title }}','{{playlist.playlist.description}}'); + {% endfor %} + + {% endblock %} @@ -38,10 +44,11 @@ - {% if playlist.playlist.description %} @@ -94,7 +101,7 @@ {% endif %} {% endfor %} diff --git a/telemeta/views/base.py b/telemeta/views/base.py index 9d2ef361..5a6fd355 100644 --- a/telemeta/views/base.py +++ b/telemeta/views/base.py @@ -1271,7 +1271,7 @@ class PlaylistView(object): def update_playlist(request, playlist): if isinstance(playlist, dict): m = Playlist.objects.get(public_id=playlist['public_id']) - m.title = float(playlist['title']) + m.title = playlist['title'] m.description = playlist['description'] m.save() else:
{{ playlist.playlist.title }} + + {% trans "Edit" %} CSV Collections CSV Items - {% trans "Delete" %} + {% trans "Delete" %}
- +