add option to delete item to files view

This commit is contained in:
j 2012-02-16 16:38:25 +05:30
parent 5d0003fa95
commit 6327889594
2 changed files with 77 additions and 0 deletions

View file

@ -0,0 +1,53 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict';
pandora.ui.deleteItemDialog = function(item) {
var
that = Ox.Dialog({
buttons: [
Ox.Button({
id: 'keep',
title: 'Keep ' + pandora.site.itemName.singular
}).bindEvent({
click: function() {
that.close();
}
}),
Ox.Button({
id: 'delete',
title: 'Delete ' + pandora.site.itemName.singular
}).bindEvent({
click: function() {
that.close();
pandora.api.remove({
id: item.id
}, function(result) {
Ox.Request.clearCache();
pandora.UI.set({item: ''});
});
}
})
],
content: Ox.Element()
.append(
$('<img>')
.attr({src: '/static/png/icon64.png'})
.css({position: 'absolute', left: '16px', top: '16px', width: '64px', height: '64px'})
)
.append(
$('<div>')
.css({position: 'absolute', left: '96px', top: '16px', width: '256px'})
.html('Are you sure you want to delete the '
+ pandora.site.itemName.singular
+ ' "'+ item.title + '"?<br><br>All data will be lost.')
),
height: 128,
keys: {enter: 'delete', escape: 'keep'},
removeOnClose: true,
title: 'Delete ' + pandora.site.itemName.singular,
width: 368
});
return that;
};

View file

@ -37,6 +37,20 @@ pandora.ui.filesView = function(options, self) {
})
.appendTo(self.$toolbar);
*/
self.$deleteButton = Ox.Button({
disabled: false,
title: 'Delete ' + pandora.site.itemName.singular,
width: 116
})
.css({
float: 'right',
margin: '4px'
})
.appendTo(self.$toolbar)
.bindEvent({
click: deleteItem
});
self.$ignoreButton = Ox.Button({
disabled: 'true',
title: 'Ignore Selected Files...'
@ -369,6 +383,7 @@ pandora.ui.filesView = function(options, self) {
.bindEvent({
click: moveFiles
});
self.$moviePanel = Ox.Element()
.append(self.$movieLabel)
@ -405,6 +420,15 @@ pandora.ui.filesView = function(options, self) {
orientation: 'horizontal'
});
function deleteItem(data) {
pandora.api.get({
id: pandora.user.ui.item,
keys: ['id', 'title']
},function(result) {
pandora.ui.deleteItemDialog(result.data).open();
});
}
function moveFiles(data) {
var data = {
ids: self.selected,