Show an error message if deleting a data source that is used by a feed.
@@ -79,6 +79,7 @@ define(["angular", "feed-mgr/datasources/module-name"], function (angular, modul
* Deletes the current data source.
*/
self.onDelete = function () {
+ if (!angular.isArray(self.model.sourceForFeeds) || self.model.sourceForFeeds.length === 0) {
DatasourcesService.deleteById(self.model.id)
.then(function () {
$mdToast.show(
@@ -97,6 +98,16 @@ define(["angular", "feed-mgr/datasources/module-name"], function (angular, modul
.ok("Got it!")
);
});
+ } else {
+ $mdDialog.show(
+ $mdDialog.alert()
+ .clickOutsideToClose(true)
+ .title("Delete Failed")
+ .textContent("This data source is currently being used by " + self.model.sourceForFeeds.length + " feed(s).")
+ .ariaLabel("Failed to delete data source")
+ .ok("Got it!")
+ );
+ }
};
/**
