cobuild-angular-stack
Version:
Base stack angular sass jade gulp
83 lines (68 loc) • 2.42 kB
JavaScript
(function (module) {
'use strict';
module.controller('AdminCategoriesListController', CategoriesListController);
CategoriesListController.$inject = ['$scope', 'Category', 'Store', 'toastr', '$uibModal'];
function CategoriesListController($scope, Category, Store, toastr, $uibModal) {
$scope.categories = [];
$scope.stores = [];
$scope.refresh = function () {
$scope.categories = Category.find({
filter: {
order: 'name ASC'
}
});
$scope.stores = Store.find({
filter: {
order: 'name ASC'
}
});
};
$scope.addStore = function () {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'partials/admin.stores.create.html',
controller: 'AdminStoreCreateController'
});
modalInstance.result.then(function (newStore) {
$scope.stores = Store.find({
filter: {
order: 'name ASC'
}
});
});
};
$scope.removeStore = function (store) {
Store.removeById({id: store.id}, function () {
$scope.stores = Store.find({
filter: {
order: 'name ASC'
}
});
});
};
$scope.addCategory = function () {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'partials/admin.categories.create.html',
controller: 'AdminCategoryCreateController'
});
modalInstance.result.then(function (newStore) {
$scope.categories = Category.find({
filter: {
order: 'name ASC'
}
});
});
};
$scope.removeCategory = function (category) {
Category.removeById({id: category.id}, function () {
$scope.categories = Category.find({
filter: {
order: 'name ASC'
}
});
});
};
$scope.refresh();
}
})(angular.module('uniko.admin.categories'));