summaryrefslogtreecommitdiff
path: root/app/views/projects/merge_requests/_new_compare.html.haml
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/projects/merge_requests/_new_compare.html.haml')
-rw-r--r--app/views/projects/merge_requests/_new_compare.html.haml116
1 files changed, 64 insertions, 52 deletions
diff --git a/app/views/projects/merge_requests/_new_compare.html.haml b/app/views/projects/merge_requests/_new_compare.html.haml
index 01dc7519bee..7d7c487e970 100644
--- a/app/views/projects/merge_requests/_new_compare.html.haml
+++ b/app/views/projects/merge_requests/_new_compare.html.haml
@@ -5,33 +5,74 @@
.hide.alert.alert-danger.mr-compare-errors
.merge-request-branches.row
.col-md-6
- .panel.panel-default
+ .panel.panel-default.panel-new-merge-request
.panel-heading
- %strong Source branch
- .panel-body
- = f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project select2 span3', disabled: @merge_request.persisted?, required: true })
-  
- = f.select(:source_branch, @merge_request.source_branches, { include_blank: true }, { class: 'source_branch select2 span2', required: true, data: { placeholder: "Select source branch" } })
+ Source branch
+ .panel-body.clearfix
+ .merge-request-select.dropdown
+ = f.hidden_field :source_project_id
+ = dropdown_toggle @merge_request.source_project_path, { toggle: "dropdown", field_name: "#{f.object_name}[source_project_id]", disabled: @merge_request.persisted? }, { toggle_class: "js-compare-dropdown js-source-project" }
+ .dropdown-menu.dropdown-menu-selectable.dropdown-source-project
+ = dropdown_title("Select source project")
+ = dropdown_filter("Search projects")
+ = dropdown_content do
+ - is_active = f.object.source_project_id == @merge_request.source_project.id
+ %ul
+ %li
+ %a{ href: "#", class: "#{("is-active" if is_active)}", data: { id: @merge_request.source_project.id } }
+ = @merge_request.source_project_path
+ .merge-request-select.dropdown
+ = f.hidden_field :source_branch
+ = dropdown_toggle "Select source branch", { toggle: "dropdown", field_name: "#{f.object_name}[source_branch]" }, { toggle_class: "js-compare-dropdown js-source-branch" }
+ .dropdown-menu.dropdown-menu-selectable.dropdown-source-branch
+ = dropdown_title("Select source branch")
+ = dropdown_filter("Search branches")
+ = dropdown_content do
+ %ul
+ - @merge_request.source_branches.each do |branch|
+ %li
+ %a{ href: "#", class: "#{("is-active" if f.object.source_branch == branch)}", data: { id: branch } }
+ = branch
.panel-footer
- .mr_source_commit
+ = icon('spinner spin', class: 'js-source-loading')
+ %ul.list-unstyled.mr_source_commit
.col-md-6
- .panel.panel-default
+ .panel.panel-default.panel-new-merge-request
.panel-heading
- %strong Target branch
- .panel-body
+ Target branch
+ .panel-body.clearfix
- projects = @project.forked_from_project.nil? ? [@project] : [@project, @project.forked_from_project]
- = f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace', f.object.target_project_id), {}, { class: 'target_project select2 span3', disabled: @merge_request.persisted?, required: true })
-  
- = f.select(:target_branch, @merge_request.target_branches, { include_blank: true }, { class: 'target_branch select2 span2', required: true, data: { placeholder: "Select target branch" } })
+ .merge-request-select.dropdown
+ = f.hidden_field :target_project_id
+ = dropdown_toggle f.object.target_project.path_with_namespace, { toggle: "dropdown", field_name: "#{f.object_name}[target_project_id]", disabled: @merge_request.persisted? }, { toggle_class: "js-compare-dropdown js-target-project" }
+ .dropdown-menu.dropdown-menu-selectable.dropdown-target-project
+ = dropdown_title("Select target project")
+ = dropdown_filter("Search projects")
+ = dropdown_content do
+ %ul
+ - projects.each do |project|
+ %li
+ %a{ href: "#", class: "#{("is-active" if f.object.target_project_id == project.id)}", data: { id: project.id } }
+ = project.path_with_namespace
+ .merge-request-select.dropdown
+ = f.hidden_field :target_branch
+ = dropdown_toggle f.object.target_branch, { toggle: "dropdown", field_name: "#{f.object_name}[target_branch]" }, { toggle_class: "js-compare-dropdown js-target-branch" }
+ .dropdown-menu.dropdown-menu-selectable.dropdown-target-branch.js-target-branch-dropdown
+ = dropdown_title("Select target branch")
+ = dropdown_filter("Search branches")
+ = dropdown_content do
+ %ul
+ - @merge_request.target_branches.each do |branch|
+ %li
+ %a{ href: "#", class: "#{("is-active" if f.object.target_branch == branch)}", data: { id: branch } }
+ = branch
.panel-footer
- .mr_target_commit
+ = icon('spinner spin', class: "js-target-loading")
+ %ul.list-unstyled.mr_target_commit
- if @merge_request.errors.any?
- .alert.alert-danger
- - @merge_request.errors.full_messages.each do |msg|
- %div= msg
-
+ = form_errors(@merge_request)
- elsif @merge_request.source_branch.present? && @merge_request.target_branch.present?
.light-well.append-bottom-default
.center
@@ -45,40 +86,11 @@
and
%span.label-branch #{@merge_request.target_branch}
are the same.
-
-
- .form-actions
- = f.submit 'Compare branches and continue', class: "btn btn-new mr-compare-btn"
-
-:javascript
- var source_branch = $("#merge_request_source_branch")
- , target_branch = $("#merge_request_target_branch")
- , target_project = $("#merge_request_target_project_id");
-
- $.get("#{branch_from_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}", {ref: source_branch.val() });
- $.get("#{branch_to_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}", {target_project_id: target_project.val(),ref: target_branch.val() });
-
- target_project.on("change", function() {
- $.get("#{update_branches_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}", {target_project_id: $(this).val() });
- });
- source_branch.on("change", function() {
- $.get("#{branch_from_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}", {ref: $(this).val() });
- $(".mr-compare-errors").fadeOut();
- $(".mr-compare-btn").enable();
- });
- target_branch.on("change", function() {
- $.get("#{branch_to_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}", {target_project_id: target_project.val(),ref: $(this).val() });
- $(".mr-compare-errors").fadeOut();
- $(".mr-compare-btn").enable();
- });
-
+ = f.submit 'Compare branches and continue', class: "btn btn-new mr-compare-btn"
:javascript
- $(".merge-request-form").on('submit', function () {
- if ($("#merge_request_source_branch").val() === "" || $('#merge_request_target_branch').val() === "") {
- $(".mr-compare-errors").html("You must select source and target branch to proceed");
- $(".mr-compare-errors").fadeIn();
- event.preventDefault();
- return;
- }
+ new Compare({
+ targetProjectUrl: "#{update_branches_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}",
+ sourceBranchUrl: "#{branch_from_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}",
+ targetBranchUrl: "#{branch_to_namespace_project_merge_requests_path(@source_project.namespace, @source_project)}"
});