forked from Archives/Athou_commafeed
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({
|
$scope.sub = FeedService.get({
|
||||||
id : $stateParams._id
|
id : $stateParams._id
|
||||||
|
}, function(data) {
|
||||||
|
if (!data.categoryId)
|
||||||
|
data.categoryId = 'all';
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.back = function() {
|
$scope.back = function() {
|
||||||
@@ -240,6 +243,12 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
|
|||||||
return parseInt($stateParams._id, 10) != $stateParams._id;
|
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() {
|
CategoryService.get(function() {
|
||||||
if ($scope.isMeta()) {
|
if ($scope.isMeta()) {
|
||||||
$scope.category = {
|
$scope.category = {
|
||||||
@@ -259,6 +268,8 @@ module.controller('CategoryDetailsCtrl', ['$scope', '$state', '$stateParams', 'F
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!$scope.category.parentId)
|
||||||
|
$scope.category.parentId = 'all';
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.back = function() {
|
$scope.back = function() {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<label class="control-label">Parent category</label>
|
<label class="control-label">Parent category</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<select name="category" class="input-block-level" ng-model="category.parentId"
|
<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>
|
</select>
|
||||||
<span class="help-block" ng-show="!form.category.$valid">Required</span>
|
<span class="help-block" ng-show="!form.category.$valid">Required</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user