From a32435b57786521719e25098d09cc881188849b9 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 13 Feb 2014 11:54:30 +0000 Subject: [PATCH] allow deleting own videos --- static/js/infoView.padma.js | 2 +- static/js/item.js | 4 +--- static/js/mediaView.js | 13 +++++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/static/js/infoView.padma.js b/static/js/infoView.padma.js index 5aea6c750..33e95a771 100644 --- a/static/js/infoView.padma.js +++ b/static/js/infoView.padma.js @@ -4,7 +4,7 @@ pandora.ui.infoView = function(data) { var ui = pandora.user.ui, canEdit = pandora.site.capabilities.canEditMetadata[pandora.user.level] || data.editable, - canRemove = pandora.site.capabilities.canRemoveItems[pandora.user.level], + canRemove = pandora.site.capabilities.canRemoveItems[pandora.user.level] || data.editable, css = { marginTop: '4px', textAlign: 'justify' diff --git a/static/js/item.js b/static/js/item.js index 54ca7830a..2e3663167 100644 --- a/static/js/item.js +++ b/static/js/item.js @@ -119,9 +119,7 @@ pandora.ui.item = function() { } else if (pandora.user.ui.itemView == 'media') { pandora.$ui.contentPanel.replaceElement(1, - pandora.$ui.item = pandora.ui.mediaView({ - id: result.data.id - }) + pandora.$ui.item = pandora.ui.mediaView(result.data) ); } else if (pandora.user.ui.itemView == 'frames' || pandora.user.ui.itemView == 'posters') { diff --git a/static/js/mediaView.js b/static/js/mediaView.js index 8a1627d1a..f5cbd37da 100644 --- a/static/js/mediaView.js +++ b/static/js/mediaView.js @@ -2,19 +2,20 @@ 'use strict'; -pandora.ui.mediaView = function(options, self) { +pandora.ui.mediaView = function(options) { - var self = self || {}, + var canRemove = pandora.site.capabilities.canRemoveItems[pandora.user.level] || options.editable, + self = {}, that = Ox.Element({}, self) .defaults({ id: '' }) - .options(options || {}); + .options({}); self.filesQuery = { conditions: [{ key: 'id', - value: self.options.id, + value: options.id, operator: '==' }] }; @@ -35,7 +36,7 @@ pandora.ui.mediaView = function(options, self) { }, {}, { - disabled: !pandora.site.capabilities.canRemoveItems[pandora.user.level], + disabled: !canRemove, id: 'delete', title: Ox._('Delete {0}...', [Ox._(pandora.site.itemName.singular)]) } @@ -527,7 +528,7 @@ pandora.ui.mediaView = function(options, self) { ); pandora.api.moveMedia(data, function(result) { if ( - pandora.user.ui.item == self.options.id + pandora.user.ui.item == options.id && pandora.user.ui.itemView == 'media' ) { Ox.Request.clearCache(); // fixme: remove