summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-18 16:22:57 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-18 16:22:57 +0200
commitb05a67f4e3fdf94477539d61bff6d74337d2ddef (patch)
tree93f5277312e9630ace82aa5f362d19cf58ce17ac
parent8a55636f8974d73c097a52721e2208cea727bc17 (diff)
downloadgitlab-ce-b05a67f4e3fdf94477539d61bff6d74337d2ddef.tar.gz
Split merge request coffee
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/assets/javascripts/merge_request.js.coffee103
-rw-r--r--app/assets/javascripts/merge_requests.js.coffee96
2 files changed, 103 insertions, 96 deletions
diff --git a/app/assets/javascripts/merge_request.js.coffee b/app/assets/javascripts/merge_request.js.coffee
new file mode 100644
index 00000000000..c0f83c93021
--- /dev/null
+++ b/app/assets/javascripts/merge_request.js.coffee
@@ -0,0 +1,103 @@
+class MergeRequest
+ constructor: (@opts) ->
+ @initContextWidget()
+ this.$el = $('.merge-request')
+ @diffs_loaded = if @opts.action == 'diffs' then true else false
+ @commits_loaded = false
+
+ this.activateTab(@opts.action)
+
+ this.bindEvents()
+
+ this.initMergeWidget()
+ this.$('.show-all-commits').on 'click', =>
+ this.showAllCommits()
+
+ modal = $('#modal_merge_info').modal(show: false)
+
+ disableButtonIfEmptyField '#merge_commit_message', '.accept_merge_request'
+
+
+ # Local jQuery finder
+ $: (selector) ->
+ this.$el.find(selector)
+
+ initContextWidget: ->
+ $('.edit-merge_request.inline-update input[type="submit"]').hide()
+ $(".issue-box .inline-update").on "change", "select", ->
+ $(this).submit()
+ $(".issue-box .inline-update").on "change", "#merge_request_assignee_id", ->
+ $(this).submit()
+
+ initMergeWidget: ->
+ this.showState( @opts.current_status )
+
+ if this.$('.automerge_widget').length and @opts.check_enable
+ $.get @opts.url_to_automerge_check, (data) =>
+ this.showState( data.merge_status )
+ , 'json'
+
+ if @opts.ci_enable
+ $.get @opts.url_to_ci_check, (data) =>
+ this.showCiState data.status
+ , 'json'
+
+ bindEvents: ->
+ this.$('.nav-tabs').on 'click', 'a', (event) =>
+ a = $(event.currentTarget)
+
+ href = a.attr('href')
+ History.replaceState {path: href}, document.title, href
+
+ event.preventDefault()
+
+ this.$('.nav-tabs').on 'click', 'li', (event) =>
+ this.activateTab($(event.currentTarget).data('action'))
+
+ this.$('.accept_merge_request').on 'click', ->
+ $('.automerge_widget.can_be_merged').hide()
+ $('.merge-in-progress').show()
+
+ activateTab: (action) ->
+ this.$('.nav-tabs li').removeClass 'active'
+ this.$('.tab-content').hide()
+ switch action
+ when 'diffs'
+ this.$('.nav-tabs .diffs-tab').addClass 'active'
+ this.loadDiff() unless @diffs_loaded
+ this.$('.diffs').show()
+ else
+ this.$('.nav-tabs .notes-tab').addClass 'active'
+ this.$('.notes').show()
+
+ showState: (state) ->
+ $('.automerge_widget').hide()
+ $('.automerge_widget.' + state).show()
+
+ showCiState: (state) ->
+ $('.ci_widget').hide()
+ $('.ci_widget.ci-' + state).show()
+
+ loadDiff: (event) ->
+ $.ajax
+ type: 'GET'
+ url: this.$('.nav-tabs .diffs-tab a').attr('href')
+ beforeSend: =>
+ this.$('.status').addClass 'loading'
+ complete: =>
+ @diffs_loaded = true
+ this.$('.status').removeClass 'loading'
+ success: (data) =>
+ this.$(".diffs").html(data.html)
+ dataType: 'json'
+
+ showAllCommits: ->
+ this.$('.first-commits').remove()
+ this.$('.all-commits').removeClass 'hide'
+
+ alreadyOrCannotBeMerged: ->
+ this.$('.automerge_widget').hide()
+ this.$('.merge-in-progress').hide()
+ this.$('.automerge_widget.already_cannot_be_merged').show()
+
+this.MergeRequest = MergeRequest
diff --git a/app/assets/javascripts/merge_requests.js.coffee b/app/assets/javascripts/merge_requests.js.coffee
index ff843c68d68..9201c84c5ed 100644
--- a/app/assets/javascripts/merge_requests.js.coffee
+++ b/app/assets/javascripts/merge_requests.js.coffee
@@ -6,99 +6,3 @@
$('#milestone_id').select2()
$('#milestone_id, #assignee_id').on 'change', ->
$(this).closest('form').submit()
-
-class MergeRequest
-
- constructor: (@opts) ->
- this.$el = $('.merge-request')
- @diffs_loaded = if @opts.action == 'diffs' then true else false
- @commits_loaded = false
-
- this.activateTab(@opts.action)
-
- this.bindEvents()
-
- this.initMergeWidget()
- this.$('.show-all-commits').on 'click', =>
- this.showAllCommits()
-
- modal = $('#modal_merge_info').modal(show: false)
-
- disableButtonIfEmptyField '#merge_commit_message', '.accept_merge_request'
-
- # Local jQuery finder
- $: (selector) ->
- this.$el.find(selector)
-
- initMergeWidget: ->
- this.showState( @opts.current_status )
-
- if this.$('.automerge_widget').length and @opts.check_enable
- $.get @opts.url_to_automerge_check, (data) =>
- this.showState( data.merge_status )
- , 'json'
-
- if @opts.ci_enable
- $.get @opts.url_to_ci_check, (data) =>
- this.showCiState data.status
- , 'json'
-
- bindEvents: ->
- this.$('.nav-tabs').on 'click', 'a', (event) =>
- a = $(event.currentTarget)
-
- href = a.attr('href')
- History.replaceState {path: href}, document.title, href
-
- event.preventDefault()
-
- this.$('.nav-tabs').on 'click', 'li', (event) =>
- this.activateTab($(event.currentTarget).data('action'))
-
- this.$('.accept_merge_request').on 'click', ->
- $('.automerge_widget.can_be_merged').hide()
- $('.merge-in-progress').show()
-
- activateTab: (action) ->
- this.$('.nav-tabs li').removeClass 'active'
- this.$('.tab-content').hide()
- switch action
- when 'diffs'
- this.$('.nav-tabs .diffs-tab').addClass 'active'
- this.loadDiff() unless @diffs_loaded
- this.$('.diffs').show()
- else
- this.$('.nav-tabs .notes-tab').addClass 'active'
- this.$('.notes').show()
-
- showState: (state) ->
- $('.automerge_widget').hide()
- $('.automerge_widget.' + state).show()
-
- showCiState: (state) ->
- $('.ci_widget').hide()
- $('.ci_widget.ci-' + state).show()
-
- loadDiff: (event) ->
- $.ajax
- type: 'GET'
- url: this.$('.nav-tabs .diffs-tab a').attr('href')
- beforeSend: =>
- this.$('.status').addClass 'loading'
- complete: =>
- @diffs_loaded = true
- this.$('.status').removeClass 'loading'
- success: (data) =>
- this.$(".diffs").html(data.html)
- dataType: 'json'
-
- showAllCommits: ->
- this.$('.first-commits').remove()
- this.$('.all-commits').removeClass 'hide'
-
- alreadyOrCannotBeMerged: ->
- this.$('.automerge_widget').hide()
- this.$('.merge-in-progress').hide()
- this.$('.automerge_widget.already_cannot_be_merged').show()
-
-this.MergeRequest = MergeRequest