HistoryV2AddLabelModalController.coffee 768 B

12345678910111213141516171819202122232425262728
  1. define [
  2. "base",
  3. ], (App) ->
  4. App.controller "HistoryV2AddLabelModalController", ["$scope", "$modalInstance", "ide", ($scope, $modalInstance, ide) ->
  5. $scope.inputs =
  6. labelName: null
  7. $scope.state =
  8. inflight: false
  9. error: false
  10. $modalInstance.opened.then () ->
  11. $scope.$applyAsync () ->
  12. $scope.$broadcast "open"
  13. $scope.addLabelModalFormSubmit = () ->
  14. $scope.state.inflight = true
  15. ide.historyManager.labelCurrentVersion $scope.inputs.labelName
  16. .then (response) ->
  17. $scope.state.inflight = false
  18. $modalInstance.close()
  19. .catch (response) ->
  20. { data, status } = response
  21. $scope.state.inflight = false
  22. if status == 400
  23. $scope.state.error = { message: data }
  24. else
  25. $scope.state.error = true
  26. ]