mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
preselect All if no category is set, and prevent setting a parent category to itself
This commit is contained in:
@@ -176,6 +176,9 @@ module.controller('FeedDetailsCtrl', ['$scope', '$state', '$stateParams', 'FeedS
|
||||
|
||||
$scope.sub = FeedService.get({
|
||||
id : $stateParams._id
|
||||
}, function(data) {
|
||||
if (!data.categoryId)
|
||||
data.categoryId = 'all';
|
||||
});
|
||||
|
||||
$scope.back = function() {
|
||||
@@ -240,6 +243,12 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
|
||||
return parseInt($stateParams._id, 10) != $stateParams._id;
|
||||
};
|
||||
|
||||
$scope.filterCurrent = function(elem) {
|
||||
if (!$scope.category)
|
||||
return true;
|
||||
return elem.id != $scope.category.id;
|
||||
};
|
||||
|
||||
CategoryService.get(function() {
|
||||
if ($scope.isMeta()) {
|
||||
$scope.category = {
|
||||
@@ -259,6 +268,8 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$scope.category.parentId)
|
||||
$scope.category.parentId = 'all';
|
||||
});
|
||||
|
||||
$scope.back = function() {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<label class="control-label">Parent category</label>
|
||||
<div class="controls">
|
||||
<select name="category" class="input-block-level" ng-model="category.parentId"
|
||||
ng-options="cat.id as cat.name for cat in CategoryService.flatCategories">
|
||||
ng-options="cat.id as cat.name for cat in CategoryService.flatCategories | filter: filterCurrent">
|
||||
</select>
|
||||
<span class="help-block" ng-show="!form.category.$valid">Required</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user