added delete method for virtual items

This commit is contained in:
Luke Pulverenti 2013-10-18 17:12:05 -04:00
parent 7e34533cae
commit e674b68b00
4 changed files with 52 additions and 5 deletions

View File

@ -1163,6 +1163,20 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
}); });
}; };
self.deleteItem = function (itemId) {
if (!itemId) {
throw new Error("null itemId");
}
var url = self.getUrl("Items/" + itemId);
return self.ajax({
type: "DELETE",
url: url
});
};
self.updateItemImageIndex = function (itemId, itemType, itemName, imageType, imageIndex, newIndex) { self.updateItemImageIndex = function (itemId, itemType, itemName, imageType, imageIndex, newIndex) {
if (!imageType) { if (!imageType) {

View File

@ -32,12 +32,15 @@
</div> </div>
<button id="btnRefresh" type="button" data-icon="refresh" data-mini="true" data-theme="b" data-inline="true">Refresh</button> <button id="btnRefresh" type="button" data-icon="refresh" data-mini="true" data-theme="b" data-inline="true">Refresh</button>
<div id="fldRecursive" style="display: none; vertical-align: bottom;"> <div id="fldRecursive" style="display: none; vertical-align: bottom;">
<label for="chkRecursive">Refresh child items</label> <label for="chkRecursive">Refresh child items</label>
<input type="checkbox" id="chkRecursive" name="chkRecursive" data-mini="true" checked="checked" data-inline="true" /> <input type="checkbox" id="chkRecursive" name="chkRecursive" data-mini="true" checked="checked" data-inline="true" />
</div> </div>
<div id="fldDelete" style="vertical-align: bottom;"> <div style="display: inline-block;">
<button id="btnDelete" type="button" data-icon="delete" data-mini="true" data-theme="a" data-inline="true">Delete</button> <div id="fldDelete" style="vertical-align: bottom; display: none;">
<button id="btnDelete" type="button" data-icon="delete" data-mini="true" data-theme="a" data-inline="true">Delete</button>
</div>
</div> </div>
<div style="margin: .5em 0 1em;"> <div style="margin: .5em 0 1em;">
<div class="fieldDescription">A refresh will cause internet metadata to be re-downloaded (if enabled, and dependent on metadata settings).</div> <div class="fieldDescription">A refresh will cause internet metadata to be re-downloaded (if enabled, and dependent on metadata settings).</div>

View File

@ -350,17 +350,24 @@
} }
$('#btnRefresh', page).button('enable'); $('#btnRefresh', page).button('enable');
$('#btnDelete', page).button('enable');
$('#refreshLoading', page).hide(); $('#refreshLoading', page).hide();
currentItem = item; currentItem = item;
if (item.IsFolder) { if (item.IsFolder) {
$('#fldRecursive', page).css("display", "inline-block") $('#fldRecursive', page).css("display", "inline-block");
} else { } else {
$('#fldRecursive', page).hide(); $('#fldRecursive', page).hide();
} }
if (item.LocationType == "Virtual") {
$('#fldDelete', page).show();
} else {
$('#fldDelete', page).hide();
}
LibraryBrowser.renderName(item, $('.itemName', page), true); LibraryBrowser.renderName(item, $('.itemName', page), true);
updateTabs(page, item); updateTabs(page, item);
@ -1143,7 +1150,8 @@
$('#btnRefresh', this).on('click', function () { $('#btnRefresh', this).on('click', function () {
$(this).button('disable'); $('#btnDelete', page).button('disable');
$('#btnRefresh', page).button('disable');
$('#refreshLoading', page).show(); $('#refreshLoading', page).show();
@ -1180,6 +1188,28 @@
}); });
}); });
$('#btnDelete', this).on('click', function () {
Dashboard.confirm("Are you sure you wish to delete this item?", "Confirm Deletion", function (result) {
if (result) {
$('#btnDelete', page).button('disable');
$('#btnRefresh', page).button('disable');
$('#refreshLoading', page).show();
ApiClient.deleteItem(currentItem.Id).done(function () {
Dashboard.navigate('edititemmetadata.html?id=' + currentItem.ParentId);
});
}
});
});
$('.libraryTree', page).on('itemclicked', function (event, data) { $('.libraryTree', page).on('itemclicked', function (event, data) {
if (data.id != currentItem.Id) { if (data.id != currentItem.Id) {

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.179" targetFramework="net45" /> <package id="MediaBrowser.ApiClient.Javascript" version="3.0.180" targetFramework="net45" />
<package id="ServiceStack.Common" version="3.9.62" targetFramework="net45" /> <package id="ServiceStack.Common" version="3.9.62" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.62" targetFramework="net45" /> <package id="ServiceStack.Text" version="3.9.62" targetFramework="net45" />
</packages> </packages>