also delete feeds when their parent folder is being deleted

This commit is contained in:
Bernhard Posselt 2014-09-13 04:43:37 +02:00
Родитель 5f43cd596f
Коммит 1cb7d9ad1f
5 изменённых файлов: 23 добавлений и 2 удалений

Просмотреть файл

@ -583,6 +583,7 @@ app.controller('NavigationController',
self._deletedFeedsBackup[folder.name] || [];
self._deletedFeedsBackup[folder.name].push(feed);
FeedResource.delete(feed.url);
self.reversiblyDeleteFeed(feed);
});
FolderResource.reversiblyDelete(folder.id);
@ -593,10 +594,14 @@ app.controller('NavigationController',
var deletedFeeds = this._deletedFeedsBackup[folder.name];
if (deletedFeeds !== undefined) {
deletedFeeds.forEach(function (feed) {
self.undoDeleteFeed(feed);
});
FeedResource.receive(deletedFeeds);
}
FolderResource.undoDelete(folder.id);
delete this._deletedFeedsBackup[folder.name];
};
this.deleteFolder = function (folder) {

2
js/build/app.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -256,6 +256,7 @@ function ($route, FEED_TYPE, FeedResource, FolderResource, ItemResource,
self._deletedFeedsBackup[folder.name] || [];
self._deletedFeedsBackup[folder.name].push(feed);
FeedResource.delete(feed.url);
self.reversiblyDeleteFeed(feed);
});
FolderResource.reversiblyDelete(folder.id);
@ -266,10 +267,14 @@ function ($route, FEED_TYPE, FeedResource, FolderResource, ItemResource,
var deletedFeeds = this._deletedFeedsBackup[folder.name];
if (deletedFeeds !== undefined) {
deletedFeeds.forEach(function (feed) {
self.undoDeleteFeed(feed);
});
FeedResource.receive(deletedFeeds);
}
FolderResource.undoDelete(folder.id);
delete this._deletedFeedsBackup[folder.name];
};
this.deleteFolder = function (folder) {

Просмотреть файл

@ -771,9 +771,11 @@ describe('NavigationController', function () {
it('should reversibly delete a folder', inject(function (
$controller, FolderResource, FeedResource) {
FolderResource.reversiblyDelete = jasmine.createSpy('reversiblyDelete');
FeedResource.reversiblyDelete = jasmine.createSpy('reversiblyDelete');
var ctrl = $controller('NavigationController', {
FolderResource: FolderResource,
FeedResource: FeedResource
});
var folder = {
@ -785,6 +787,8 @@ describe('NavigationController', function () {
ctrl.reversiblyDeleteFolder(folder);
expect(FolderResource.reversiblyDelete).toHaveBeenCalledWith(3);
expect(FeedResource.reversiblyDelete).toHaveBeenCalledWith(1);
expect(FeedResource.reversiblyDelete).toHaveBeenCalledWith(3);
expect(folder.deleted).toBe(true);
expect(FeedResource.size(2)).toBe(1);
expect(ctrl._deletedFeedsBackup.test.length).toBe(2);
@ -794,6 +798,7 @@ describe('NavigationController', function () {
it('should undo delete a folder', inject(function (
$controller, FolderResource, FeedResource) {
FolderResource.undoDelete = jasmine.createSpy('undoDelete');
FeedResource.undoDelete = jasmine.createSpy('undoDelete');
var ctrl = $controller('NavigationController', {
FolderResource: FolderResource,
@ -815,8 +820,13 @@ describe('NavigationController', function () {
ctrl.undoDeleteFolder(folder);
expect(FolderResource.undoDelete).toHaveBeenCalledWith(3);
expect(FeedResource.undoDelete).toHaveBeenCalledWith(1);
expect(FeedResource.undoDelete).toHaveBeenCalledWith(3);
expect(folder.deleted).toBe(false);
expect(feed1.deleted).toBe(false);
expect(feed2.deleted).toBe(false);
expect(FeedResource.size()).toBe(3);
expect(ctrl._deletedFeedsBackup.test).toBe(undefined);
}));

Просмотреть файл

@ -10,7 +10,8 @@
|| Navigation.isFolderActive(folder.id)
|| Navigation.subFeedActive(folder.id)
|| !folder.id
|| folder.getsFeed"
|| folder.getsFeed
|| !Navigation.hasFeeds(folder.id)"
class="folder with-counter with-menu"
data-id="{{ folder.id }}"
news-droppable>