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');
});
},
-// 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++){
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 %}
+
+
</script>
{% endblock %}
<table class="listing" style="width:100%;margin-top: 3em">
<tr>
<td style="border-bottom:1px solid #6A0307;color:#6A0307;font-size: 100%">{{ playlist.playlist.title }}</td>
- <td style="width:66ex; padding-right: 0; border-bottom:1px solid #6A0307; text-align:right">
+ <td style="width:86ex; padding-right: 0; border-bottom:1px solid #6A0307; text-align:right">
+ <a href="#" id="{{playlist.playlist.public_id}}" onclick="playlistUtils.showEdit(this, this.id); return false;" class="component_icon button icon_edit">{% trans "Edit" %}</a>
<a href="{% url telemeta-playlist-csv-export playlist.playlist.public_id 'collections' %}" class="component_icon button icon_csv">CSV Collections</a>
<a href="{% url telemeta-playlist-csv-export playlist.playlist.public_id 'items' %}" class="component_icon button icon_csv">CSV Items</a>
- <a href="#" id="{{playlist.playlist.public_id}}" onclick="playlistUtils.remove(this.id);return false;" class="component_icon button icon_cancel">{% trans "Delete" %}</a>
+ <a href="#" id="{{playlist.playlist.public_id}}" onclick="if(confirm(gettrans('delete the playlist permanently?'))){playlistUtils.remove(this.id);};return false;" class="component_icon button icon_cancel">{% trans "Delete" %}</a>
</td>
</tr>
{% if playlist.playlist.description %}
{% endif %}
</td>
<td style="vertical-align:middle">
- <a href="#" onclick="playlistUtils.removeResource('{{resource.public_id}}');return false;" class="component_icon button icon_cancel" style="padding: 4px 12px;"></a>
+ <a href="#" onclick="if(confirm(gettrans('delete the resource from the playlist permanently?'))){playlistUtils.removeResource('{{resource.public_id}}');};return false;" class="component_icon button icon_cancel" style="padding: 4px 12px;"></a>
</td>
</tr>
{% endfor %}
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: