Skip to content
Snippets Groups Projects
Select Git revision
  • ag-test
  • rs-test
  • master default protected
  • test-me-pa
  • mksionek-master-patch-52381
  • new-branch-10
  • test-conflicts
  • test-suggestions
  • alejandro-test
  • patch-25
  • winh-test-image-doscussion
  • stg-lfs-image-test-2
  • stg-lfs-image-test
  • test42016
  • issue_42016
  • issue-32709
  • add-codeowners
  • ClemMakesApps-master-patch-62759
  • bvl-staging-test
  • bvl-merge-base-api
  • v9.2.0-rc6 protected
  • v9.2.0-rc5 protected
  • v9.2.0-rc4 protected
  • v9.2.0-rc3 protected
  • v9.1.4 protected
  • v9.2.0-rc2 protected
  • v9.2.0-rc1 protected
  • v9.1.3 protected
  • v8.17.6 protected
  • v9.0.7 protected
  • v9.1.2 protected
  • v9.1.1 protected
  • v9.2.0.pre protected
  • v9.1.0 protected
  • v9.1.0-rc7 protected
  • v9.1.0-rc6 protected
  • v9.0.6 protected
  • v9.1.0-rc5 protected
  • v9.1.0-rc4 protected
  • v9.1.0-rc3 protected
40 results

merge_request.js.coffee

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    merge_request.js.coffee 2.36 KiB
    #= require jquery.waitforimages
    #= require task_list
    
    #= require merge_request_tabs
    
    class @MergeRequest
      # Initialize MergeRequest behavior
      #
      # Options:
      #   action - String, current controller action
      #
      constructor: (@opts = {}) ->
        this.$el = $('.merge-request')
    
        this.$('.show-all-commits').on 'click', =>
          this.showAllCommits()
    
        @initTabs()
    
        # Prevent duplicate event bindings
        @disableTaskList()
        @initMRBtnListeners()
    
        if $("a.btn-close").length
          @initTaskList()
    
      # Local jQuery finder
      $: (selector) ->
        this.$el.find(selector)
    
      initTabs: ->
        if @opts.action != 'new'
          # `MergeRequests#new` has no tab-persisting or lazy-loading behavior
          new MergeRequestTabs(@opts)
        else
          # Show the first tab (Commits)
          $('.merge-request-tabs a[data-toggle="tab"]:first').tab('show')
    
      showAllCommits: ->
        this.$('.first-commits').remove()
        this.$('.all-commits').removeClass 'hide'
    
      initTaskList: ->
        $('.detail-page-description .js-task-list-container').taskList('enable')
        $(document).on 'tasklist:changed', '.detail-page-description .js-task-list-container', @updateTaskList
    
      initMRBtnListeners: ->
        _this = @
        $('a.btn-close, a.btn-reopen').on 'click', (e) ->
          $this = $(this)
          shouldSubmit = $this.hasClass('btn-comment')
          if shouldSubmit && $this.data('submitted')
            return
          if shouldSubmit
            if $this.hasClass('btn-comment-and-close') || $this.hasClass('btn-comment-and-reopen')
              e.preventDefault()
              e.stopImmediatePropagation()
              _this.submitNoteForm($this.closest('form'),$this)
    
    
      submitNoteForm: (form, $button) =>
        noteText = form.find("textarea.js-note-text").val()
        if noteText.trim().length > 0
          form.submit()
          $button.data('submitted',true)
          $button.trigger('click')
    
    
      disableTaskList: ->
        $('.detail-page-description .js-task-list-container').taskList('disable')