<commit_before>angular.module('doubtfire.helpdesk.modals.helpdesk-submit-ticket-modal', [])

.factory('HelpDeskSubmitTicketModal', ($modal) ->
  HelpDeskSubmitTicketModal = {}

  HelpDeskSubmitTicketModal.show = (user, projects) ->
    $modal.open
      templateUrl: 'helpdesk/modals/helpdesk-submit-ticket-modal/helpdesk-submit-ticket-modal.tpl.html'
      controller: 'HelpDeskSubmitTicketModal'
      resolve:
        user: -> user
        projects: -> projects

  HelpDeskSubmitTicketModal
)

.controller('HelpDeskSubmitTicketModal', ($scope, $modalInstance, alertService, analyticsService, currentUser, User, user, unitService, projects, HelpDeskTicket, auth) ->
  $scope.currentUser = currentUser
  $scope.projects = projects
  $scope.selectedProject = $scope.projects[0]
  $scope.unitSelected = (project) ->
    $scope.selectedProject = project
  $scope.getUnit = (unitId) ->
    unitService.getUnit unitId, false, false, (response) ->
      $scope.loadedUnit = response
  $scope.getUnit($scope.selectedProject.unit_id)
  $scope.selectedTask

  openNewTicket = ->
    HelpDeskTicket.create( {project_id: $scope.selectedProject.project_id,  description: $scope.description} ).$promise.then (
      (response) ->
        $modalInstance.close(response)
    ),
    (
      (response) ->
        if response.data.error?
          alertService.add("danger", "Error: " + response.data.error, 6000)
    )

  $scope.openTicket = ->
    openNewTicket()
)<commit_msg>NEW: Modal now saves task definition id to server<commit_after>angular.module('doubtfire.helpdesk.modals.helpdesk-submit-ticket-modal', [])

.factory('HelpDeskSubmitTicketModal', ($modal) ->
  HelpDeskSubmitTicketModal = {}

  HelpDeskSubmitTicketModal.show = (user, projects) ->
    $modal.open
      templateUrl: 'helpdesk/modals/helpdesk-submit-ticket-modal/helpdesk-submit-ticket-modal.tpl.html'
      controller: 'HelpDeskSubmitTicketModal'
      resolve:
        user: -> user
        projects: -> projects

  HelpDeskSubmitTicketModal
)

.controller('HelpDeskSubmitTicketModal', ($scope, $modalInstance, alertService, analyticsService, currentUser, User, user, unitService, projects, HelpDeskTicket, auth) ->
  $scope.currentUser = currentUser
  $scope.projects = projects
  $scope.selectedProject = $scope.projects[0]
  $scope.unitSelected = (project) ->
    $scope.selectedProject = project
  $scope.getUnit = (unitId) ->
    unitService.getUnit unitId, false, false, (response) ->
      $scope.loadedUnit = response
  $scope.getUnit($scope.selectedProject.unit_id)
  $scope.onSelectDefinition = (taskDef) ->
    $scope.selectedTaskDef = taskDef

  openNewTicket = ->
    dataToPost =
      project_id: $scope.selectedProject.project_id
      description: $scope.description
      task_definition_id: $scope.selectedTaskDef?.id
    HelpDeskTicket.create(dataToPost).$promise.then (
      (response) ->
        $modalInstance.close(response)
        alertService.add("success", "Ticket created successfully.", 2000)
    ),
    (
      (response) ->
        if response.data.error?
          alertService.add("danger", "Error: " + response.data.error, 6000)
    )

  $scope.openTicket = ->
    openNewTicket()
)
{'fraction_non_alphanumeric': 0.12951901917635963, 'fraction_numerical': 0.0044011317195850365, 'mean_word_length': 3.7777777777777777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1895420', 'n_tokens_mistral': 1015, 'n_tokens_neox': 988, 'n_words': 156}