Sha256: dc01a036833c3c85f44be3870cbcf40e6f21564a13b74aed9af5b0d18d58a203
Contents?: true
Size: 1.63 KB
Versions: 4
Compression:
Stored size: 1.63 KB
Contents
TemplatesController = ($scope, $state, $cookieStore, Restangular, $stateParams, Alertify, ErrorsService) -> $scope.editorOptions = lineNumbers: true mode:'htmlmixed' autoCloseTags: true matchTags: bothTags: true extraKeys: "F11": (cm)-> cm.setOption("fullScreen", !cm.getOption("fullScreen")) "Esc": (cm)-> if cm.getOption("fullScreen") then cm.setOption("fullScreen", false) $scope.store = Restangular.all('templates') $scope.store.getList().then (templates)-> $scope.templates = templates Restangular.all('users').customGET('kms_user').then (current_user) -> $scope.currentUser = current_user $scope.currentUser.admin = $scope.currentUser.role == 'admin' if $stateParams.id $scope.store.get($stateParams.id).then (template)-> $scope.template = template else $scope.template = {} $scope.create = -> $scope.store.post($scope.template).then -> $state.go('templates') , (response)-> Alertify.error(ErrorsService.prepareErrorsString(response.data.errors)) $scope.update = ($event)-> $scope.template.put().then -> if $event.target.attributes['data-redirect'] $state.go('templates') ,(response)-> Alertify.error(ErrorsService.prepareErrorsString(response.data.errors)) $scope.destroy = (template)-> if(confirm('Вы уверены?')) template.remove().then -> $scope.templates = _.without($scope.templates, template) angular.module('KMS') .controller('TemplatesController', ['$scope', '$state', '$cookieStore', 'Restangular', '$stateParams', 'Alertify', 'ErrorsService', TemplatesController])
Version data entries
4 entries across 4 versions & 1 rubygems