Sha256: a6569a42c741bada7ca9c086296dd085bb5204d3e93595ced3e37bf9a0d32c88

Contents?: true

Size: 1013 Bytes

Versions: 2

Compression:

Stored size: 1013 Bytes

Contents

UsersController = ($scope, $state, $cookieStore, Restangular, $stateParams, Alertify, ErrorsService) ->
  $scope.store = Restangular.all('users')
  $scope.store.getList().then (users)->
    $scope.users = users

  if $stateParams.id
    $scope.store.get($stateParams.id).then (user)->
      $scope.user = user
  else
    $scope.user = {role: 'content_manager'}

  $scope.create = ->
    $scope.store.customPOST($scope.user, 'from_kms').then ->
      $state.go('users')
    , (response)->
      Alertify.error(ErrorsService.prepareErrorsString(response.data.errors))

  #$scope.update = ->
    #$scope.user.put().then ->
      #$state.go('users')
    #,->
      #console.log('bug')

  $scope.destroy = (user)->
    if(confirm('<%= I18n.t(:are_you_sure) %>'))
      user.remove().then ->
        $scope.users = _.without($scope.users, user)


angular.module('KMS')
    .controller('UsersController', ['$scope', '$state', '$cookieStore', 'Restangular', '$stateParams', 'Alertify', 'ErrorsService', UsersController])

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kms-1.0.1 app/assets/javascripts/kms/application/controllers/users_controller.coffee
kms-1.0.0 app/assets/javascripts/kms/application/controllers/users_controller.coffee