Commit d88aafcb authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'select2' of /home/git/repositories/gitlab/gitlabhq

parents 12dbd0a4 04ad19dc
......@@ -144,7 +144,6 @@ gem "therubyracer"
gem 'turbolinks'
gem 'jquery-turbolinks'
gem 'chosen-rails', "1.0.1"
gem 'select2-rails'
gem 'jquery-atwho-rails', "~> 0.3.3"
gem "jquery-rails", "2.1.3"
......
......@@ -71,12 +71,6 @@ GEM
celluloid (0.15.2)
timers (~> 1.1.0)
charlock_holmes (0.6.9.4)
chosen-rails (1.0.1)
coffee-rails (>= 3.2)
compass-rails (>= 1.0)
railties (>= 3.0)
sass-rails (>= 3.2)
chunky_png (1.2.9)
cliver (0.2.2)
code_analyzer (0.4.3)
sexp_processor
......@@ -92,12 +86,6 @@ GEM
coffee-script-source (1.6.3)
colored (1.2)
colorize (0.5.8)
compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
compass-rails (1.1.1)
compass (>= 0.12.2)
connection_pool (1.2.0)
coveralls (0.7.0)
multi_json (~> 1.3)
......@@ -161,7 +149,6 @@ GEM
dotenv (>= 0.7)
thor (>= 0.13.6)
formatador (0.2.4)
fssm (0.2.10)
gemoji (1.3.1)
gherkin-ruby (0.3.1)
racc
......@@ -572,7 +559,6 @@ DEPENDENCIES
bootstrap-sass (~> 3.0)
capybara
carrierwave
chosen-rails (= 1.0.1)
coffee-rails
colored
coveralls
......
......@@ -19,7 +19,6 @@
//= require jquery.turbolinks
//= require bootstrap
//= require modernizr
//= require chosen-jquery
//= require select2
//= require raphael
//= require g.raphael-min
......
......@@ -29,12 +29,10 @@
$('#filter_issue_search').val($('#issue_search').val())
initSelects: ->
$("#update_status").chosen()
$("#update_assignee_id").chosen()
$("#update_milestone_id").chosen()
$("#label_name").chosen()
$("#assignee_id").chosen()
$("#milestone_id").chosen()
$("select#update_status").select2()
$("select#update_assignee_id").select2()
$("select#update_milestone_id").select2()
$("select#label_name").select2()
$("#milestone_id, #assignee_id, #label_name").on "change", ->
$(this).closest("form").submit()
......
......@@ -67,8 +67,8 @@ $ ->
$('.appear-data').fadeIn()
e.preventDefault()
# Initialize chosen selects
$('select.chosen').chosen()
# Initialize select2 selects
$('select.select2').select2(width: 'resolve', dropdownAutoWidth: true)
# Initialize tooltips
$('.has_tooltip').tooltip()
......@@ -126,12 +126,6 @@ $ ->
$(@).remove()
(($) ->
_chosen = $.fn.chosen
$.fn.extend chosen: (options) ->
default_options = search_contains: "true"
$.extend default_options, options
_chosen.apply @, [default_options]
# Disable an element and add the 'disabled' Bootstrap class
$.fn.extend disable: ->
$(@).attr('disabled', 'disabled').addClass('disabled')
......
......@@ -2,8 +2,8 @@
# * Filter merge requests
#
@merge_requestsPage = ->
$('#assignee_id').chosen()
$('#milestone_id').chosen()
$('#assignee_id').select2()
$('#milestone_id').select2()
$('#milestone_id, #assignee_id').on 'change', ->
$(this).closest('form').submit()
......
......@@ -4,7 +4,6 @@
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require jquery.ui.gitlab
*= require jquery.atwho
*= require chosen
*= require select2
*= require_self
*/
......
/** Chosen.js selectbox style override **/
.chosen-container {
min-width: 100px;
/** Select2 selectbox style override **/
.chosen-single {
height: 26px;
background: #EEE !important;
border: 1px solid #DDD !important;
@include box-shadow(none !important);
@include border-radius(4px !important);
}
.select2-container {
.select2-choice {
background: #FFF;
border-color: #BBB;
.chosen-results li.highlighted {
background: #29b;
.select2-arrow {
background: #FFF;
}
.chosen-drop {
margin-top: 10px;
border: 1px solid #DDD !important;
@include border-radius(4px !important);
}
.chosen-search input {
border: 1px solid #CCC !important;
@include box-shadow(none !important);
}
}
/** Select2 styling **/
.select2-container .select2-choice {
@include bg-light-gray-gradient;
}
.select2-container .select2-choice div {
border: none;
background: none;
}
.select2-drop {
padding-top: 8px;
}
.select2-no-results, .select2-searching {
padding: 7px;
color: #666;
}
.chosen-container .chosen-single div b {
background-position-y: 0px !important;
}
.chosen-container .chosen-drop .chosen-search input {
background-position-y: -24px !important;
}
.chosen-compact {
max-width: 170px !important;
.select2-drop-active {
border: 1px solid #BBB;
margin-top: 4px;
}
select {
&.chosen {
&.select2 {
width: 100px;
}
&.chosen-sm {
&.select2-sm {
width: 100px;
}
}
@media (min-width: $screen-sm-min) {
select {
&.chosen {
&.select2 {
width: 150px;
}
&.chosen-sm {
&.select2-sm {
width: 120px;
}
}
......@@ -81,10 +40,10 @@ select {
/* Medium devices (desktops, 992px and up) */
@media (min-width: $screen-md-min) {
select {
&.chosen {
&.select2 {
width: 170px;
}
&.chosen-sm {
&.select2-sm {
width: 140px;
}
}
......@@ -93,11 +52,17 @@ select {
/* Large devices (large desktops, 1200px and up) */
@media (min-width: $screen-lg-min) {
select {
&.chosen {
&.select2 {
width: 200px;
}
&.chosen-sm {
&.select2-sm {
width: 150px;
}
}
}
/** Branch/tag selector **/
.project-refs-form .select2-container {
margin-right: 10px;
}
......@@ -77,8 +77,8 @@ input.check_all_issues {
@media (min-width: 800px) { .issues_filters select { width: 160px; } }
@media (min-width: 1200px) { .issues_filters select { width: 220px; } }
@media (min-width: 800px) { .issues_bulk_update .chosen-container { min-width: 120px; } }
@media (min-width: 1200px) { .issues_bulk_update .chosen-container { min-width: 160px; } }
@media (min-width: 800px) { .issues_bulk_update .select2-container { min-width: 120px; } }
@media (min-width: 1200px) { .issues_bulk_update .select2-container { min-width: 160px; } }
.issues-holder {
.issues_filters {
......@@ -105,7 +105,7 @@ input.check_all_issues {
}
.issues_bulk_update {
.chosen-container {
.select2-container {
text-shadow: none;
}
}
......
......@@ -95,7 +95,7 @@
font-weight: normal !important;
}
.chosen-container .chosen-single {
.select2-container .select2-single {
span {
font-weight: bold;
color: #555;
......
......@@ -230,43 +230,10 @@ ul.nav.nav-projects-tabs {
}
}
.transfer-project .chosen-container {
.transfer-project .select2-container {
min-width: 200px;
}
/** Branch/tag selector **/
.project-refs-form {
margin: 0;
span {
background:none !important;
position:static !important;
width:auto !important;
height:auto !important;
}
}
.project-refs-form .chosen-container {
position: relative;
top: 0;
left: 0;
margin-right: 10px;
.chosen-single span {
font-weight: bold;
color: #555;
}
&.chosen-container-active {
.chosen-drop {
min-width: 400px;
}
.chosen-results {
max-height: 400px;
}
}
}
.deploy-project-label {
margin: 1px;
}
......@@ -57,7 +57,7 @@
%div
= users_select_tag(:user_ids, multiple: true)
%div.prepend-top-10
= select_tag :group_access, options_for_select(UsersGroup.group_access_roles), class: "project-access-select chosen"
= select_tag :group_access, options_for_select(UsersGroup.group_access_roles), class: "project-access-select select2"
%hr
= submit_tag 'Add users into group', class: "btn btn-create"
.ui-box
......
......@@ -12,7 +12,7 @@
%p 2. Set access level for them
.form-group
= f.label :group_access, "Group Access", class: 'control-label'
.col-sm-10= select_tag :group_access, options_for_select(UsersGroup.group_access_roles, @users_group.group_access), class: "project-access-select chosen"
.col-sm-10= select_tag :group_access, options_for_select(UsersGroup.group_access_roles, @users_group.group_access), class: "project-access-select select2"
.form-actions
= f.submit 'Add users into group', class: "btn btn-create"
......@@ -26,7 +26,7 @@
- if @project.repository.exists? && @project.repository.branch_names.any?
.form-group
= f.label :default_branch, "Default Branch", class: 'control-label'
.col-sm-10= f.select(:default_branch, @repository.branch_names, {}, {class: 'chosen select-wide'})
.col-sm-10= f.select(:default_branch, @repository.branch_names, {}, {class: 'select2 select-wide'})
= render "visibility_level", f: f, visibility_level: @project.visibility_level, can_change_visibility_level: can?(current_user, :change_visibility_level, @project)
......@@ -145,7 +145,7 @@
%span Namespace
.col-sm-10
.form-group
= f.select :namespace_id, namespaces_options(@project.namespace_id), { prompt: 'Choose a project namespace' }, { class: 'chosen' }
= f.select :namespace_id, namespaces_options(@project.namespace_id), { prompt: 'Choose a project namespace' }, { class: 'select2' }
%ul
%li Be careful. Changing the project's namespace can have unintended side effects.
%li You can only transfer the project to namespaces you manage.
......
......@@ -24,7 +24,7 @@
%i.icon-user
Assign to
.col-sm-10
= f.select(:assignee_id, assignee_options(@issue), { include_blank: "Select a user" }, {class: 'chosen'})
= f.select(:assignee_id, assignee_options(@issue), { include_blank: "Select a user" }, {class: 'select2'})
 
= link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link'
.form-group
......@@ -32,7 +32,7 @@
= f.label :milestone_id, class: 'control-label' do
%i.icon-time
Milestone
.col-sm-10= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'chosen'})
.col-sm-10= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'select2'})
.form-group
= f.label :label_list, class: 'control-label' do
......@@ -87,6 +87,6 @@
});
$('.assign-to-me-link').on('click', function(e){
$('#issue_assignee_id').val("#{current_user.id}").trigger("chosen:updated");
$('#issue_assignee_id').val("#{current_user.id}").trigger("change");
e.preventDefault();
});
......@@ -6,7 +6,7 @@
- if can?(current_user, :modify_issue, @issue)
= link_to profile_path(issue.assignee) do
= image_tag(avatar_icon(issue.assignee.email), class: 'avatar avatar-inline s16 assignee') if issue.assignee
= f.select(:assignee_id, assignee_options(@issue), { include_blank: "Assign to user (none):" }, {class: 'chosen'})
= f.select(:assignee_id, assignee_options(@issue), { include_blank: "Assign to user (none):" }, {class: 'select2'})
- elsif issue.assignee
= link_to_member(@project, @issue.assignee)
......@@ -17,7 +17,7 @@
%cite.cgray Attached to milestone
- if can?(current_user, :modify_issue, @issue)
= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone (none):" }, {class: 'chosen chosen-compact'})
= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone (none):" }, {class: 'select2 select2-compact'})
= hidden_field_tag :issue_context
= f.submit class: 'btn'
......
......@@ -5,7 +5,7 @@
- elsif params[:issue_context]
$('.issue-box .context').html("#{escape_javascript(render partial: 'issue_context', locals: { issue: @issue })}");
$('.issue-box .context').effect('highlight');
$('.chosen').chosen();
$('.select2').select2();
$('.edit-issue.inline-update input[type="submit"]').hide();
- if @issue.milestone
$('.milestone-nav-link').replaceWith("<span class='milestone-nav-link'>| <span class='light'>Milestone</span> #{escape_javascript(link_to @issue.milestone.title, project_milestone_path(@issue.project, @issue.milestone))}</span>")
......
......@@ -10,10 +10,10 @@
.col-md-5
.clearfix
.pull-left
= f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project chosen span3', disabled: @merge_request.persisted? })
= f.select(:source_project_id, [[@merge_request.source_project_path,@merge_request.source_project.id]] , {}, { class: 'source_project select2 span3', disabled: @merge_request.persisted? })
.pull-left
&nbsp;
= f.select(:source_branch, @merge_request.source_project.repository.branch_names, { include_blank: "Select branch" }, {class: 'source_branch chosen span2'})
= f.select(:source_branch, @merge_request.source_project.repository.branch_names, { include_blank: "Select branch" }, {class: 'source_branch select2 span2'})
.mr_source_commit.prepend-top-10
.col-md-2
.merge-request-angle
......@@ -22,10 +22,10 @@
.clearfix
.pull-left
- 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'), {}, { class: 'target_project chosen span3', disabled: @merge_request.persisted? })
= f.select(:target_project_id, options_from_collection_for_select(projects, 'id', 'path_with_namespace'), {}, { class: 'target_project select2 span3', disabled: @merge_request.persisted? })
.pull-left
&nbsp;
= f.select(:target_branch, @target_branches, { include_blank: "Select branch" }, {class: 'target_branch chosen span2'})
= f.select(:target_branch, @target_branches, { include_blank: "Select branch" }, {class: 'target_branch select2 span2'})
.mr_target_commit.prepend-top-10
%hr
......@@ -47,7 +47,7 @@
%i.icon-user
Assign to
.col-sm-10
= f.select(:assignee_id, assignee_options(@merge_request), { include_blank: "Select a user" }, {class: 'chosen'})
= f.select(:assignee_id, assignee_options(@merge_request), { include_blank: "Select a user" }, {class: 'select2'})
&nbsp;
= link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link'
.form-group
......@@ -55,7 +55,7 @@
= f.label :milestone_id, class: 'control-label' do
%i.icon-time
Milestone
.col-sm-10= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'chosen'})
.col-sm-10= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2'})
.form-actions
......@@ -90,6 +90,6 @@
$.get("#{branch_to_project_merge_requests_path(@source_project)}", {target_project_id: target_project.val(),ref: $(this).val() });
});
$('.assign-to-me-link').on('click', function(e){
$('#merge_request_assignee_id').val("#{current_user.id}").trigger("chosen:updated");
$('#merge_request_assignee_id').val("#{current_user.id}").trigger("select2:updated");
e.preventDefault();
});
:plain
$(".target_branch").html("#{escape_javascript(options_for_select(@target_branches))}");
$(".target_branch").trigger("chosen:updated");
$(".target_branch").trigger("select2:updated");
$(".mr_target_commit").html("");
$(".target_branch").trigger("change");
......@@ -27,7 +27,7 @@
= f.label :namespace_id, class: 'control-label' do
%span Namespace
.col-sm-10
= f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'chosen', tabindex: 2}
= f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'select2', tabindex: 2}
.form-group
.col-sm-2
......
......@@ -22,7 +22,7 @@
.entry.clearfix
= f.label :name, "Branch"
.col-md-3
= f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: "Select branch"}, {class: "chosen span3"})
= f.select(:name, @project.open_branches.map { |br| [br.name, br.name] } , {include_blank: "Select branch"}, {class: "select2 span3"})
&nbsp;
= f.submit 'Protect', class: "btn-create btn"
- unless @branches.empty?
......
......@@ -14,7 +14,7 @@
.col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true
.form-group
= f.label "Lifetime"
.col-sm-10= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'}
.col-sm-10= f.select :expires_at, lifetime_select_options, {}, {class: 'select2 span2'}
.form-group
.file-editor
= f.label :file_name, "File"
......
......@@ -17,7 +17,7 @@
%p 2. Set access level for them
.form-group
= f.label :project_access, "Project Access", class: 'control-label'
.col-sm-10= select_tag :project_access, options_for_select(Gitlab::Access.options, @user_project_relation.project_access), class: "project-access-select chosen"
.col-sm-10= select_tag :project_access, options_for_select(Gitlab::Access.options, @user_project_relation.project_access), class: "project-access-select select2"
.form-actions
= f.submit 'Add users', class: "btn btn-create"
......
......@@ -6,7 +6,7 @@
= form_tag apply_import_project_team_members_path(@project), method: 'post', class: 'form-horizontal' do
.form-group
= label_tag :source_project_id, "Project", class: 'control-label'
.col-sm-10= select_tag(:source_project_id, options_from_collection_for_select(current_user.authorized_projects, :id, :name_with_namespace), prompt: "Select project", class: "chosen lg", required: true)
.col-sm-10= select_tag(:source_project_id, options_from_collection_for_select(current_user.authorized_projects, :id, :name_with_namespace), prompt: "Select project", class: "select2 lg", required: true)
.form-actions
= submit_tag 'Import project members', class: "btn btn-create"
......
= form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form" do
= select_tag "ref", grouped_options_refs, class: "project-refs-select chosen chosen-sm"
= select_tag "ref", grouped_options_refs, class: "project-refs-select select2 select2-sm"
= hidden_field_tag :destination, destination
- if defined?(path)
= hidden_field_tag :path, path
......
......@@ -3,7 +3,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
include SharedProject
include SharedNote
include SharedPaths
include ChosenHelper
include Select2Helper
step 'I am a member of project "Shop"' do
@project = Project.find_by_name "Shop"
......@@ -42,14 +42,14 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
end
step 'I fill out a "Merge Request On Forked Project" merge request' do
chosen @forked_project.id, from: "#merge_request_source_project_id"
chosen @project.id, from: "#merge_request_target_project_id"
select2 @forked_project.id, from: "#merge_request_source_project_id"
select2 @project.id, from: "#merge_request_target_project_id"
find(:select, "merge_request_source_project_id", {}).value.should == @forked_project.id.to_s
find(:select, "merge_request_target_project_id", {}).value.should == @project.id.to_s
chosen "master", from: "#merge_request_source_branch"
chosen "stable", from: "#merge_request_target_branch"
select2 "master", from: "#merge_request_source_branch"
select2 "stable", from: "#merge_request_target_branch"
find(:select, "merge_request_source_branch", {}).value.should == 'master'
find(:select, "merge_request_target_branch", {}).value.should == 'stable'
......
......@@ -15,11 +15,11 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
end
And 'page should select "master" in select box' do
page.should have_selector '.chosen-single span', text: "master"
page.should have_selector '.select2-chosen', text: "master"
end
And 'page should select "v2.1.0" in select box' do
page.should have_selector '.chosen-single span', text: "v2.1.0"
page.should have_selector '.select2-chosen', text: "v2.1.0"
end
And 'page should have "master" on graph' do
......@@ -56,11 +56,11 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
end
And 'page should select "stable" in select box' do
page.should have_selector '.chosen-single span', text: "stable"
page.should have_selector '.select2-chosen', text: "stable"
end
And 'page should select "v2.1.0" in select box' do
page.should have_selector '.chosen-single span', text: "v2.1.0"
page.should have_selector '.select2-chosen', text: "v2.1.0"
end
And 'page should have "stable" on graph' do
......
......@@ -15,7 +15,7 @@ require 'spinach/capybara'
require 'sidekiq/testing/inline'
%w(valid_commit big_commits select2_helper chosen_helper test_env).each do |f|
%w(valid_commit big_commits select2_helper test_env).each do |f|
require Rails.root.join('spec', 'support', f)
end
......
# Chosen programmatic helper
# It allows you to select value from chosen select
#
# Params
# value - real value of selected item
# opts - options containing css selector
#
# Usage:
#
# chosen(2, from: '#user_ids')
#
module ChosenHelper
def chosen(value, options={})
raise "Must pass a hash containing 'from'" if not options.is_a?(Hash) or not options.has_key?(:from)
selector = options[:from]
page.execute_script("$('#{selector}').val('#{value}').trigger('chosen:updated');")
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment