Commit a9ea06ed authored by Phil Hughes's avatar Phil Hughes

Fixed ruby style errors

parent f3afcb87
module DropdownsHelper module DropdownsHelper
def dropdown_tag(toggle_text, id: nil, toggle_class: nil, dropdown_class: nil, title: false, filter: false, placeholder: "", footer_content: false, data: {}, &block) def dropdown_tag(toggle_text, options: {}, &block)
content_tag :div, class: "dropdown" do content_tag :div, class: "dropdown" do
toggle_hash = data.merge({toggle: "dropdown"}) data_attr = { toggle: "dropdown" }
dropdown_output = "" if options.has_key?(:data)
dropdown_output += content_tag :button, class: "dropdown-menu-toggle #{toggle_class}", id: id, type: "button", data: toggle_hash do data_attr = options[:data].merge(data_attr)
end
dropdown_output = dropdown_toggle(toggle_text, data_attr, options)
dropdown_output << content_tag(:div, class: "dropdown-menu dropdown-select #{options[:dropdown_class] if options.has_key?(:dropdown_class)}") do
output = ""
if options.has_key?(:title)
output << dropdown_title(options[:title])
end
if options.has_key?(:filter)
output << dropdown_filter(options[:placeholder])
end
output << content_tag(:div, class: "dropdown-content") do
capture(&block) if block && !options.has_key?(:footer_content)
end
if block && options.has_key?(:footer_content)
output << content_tag(:div, class: "dropdown-footer") do
capture(&block)
end
end
output << dropdown_loading
output.html_safe
end
dropdown_output.html_safe
end
end
def dropdown_toggle(toggle_text, data_attr, options)
content_tag(:button, class: "dropdown-menu-toggle #{options[:toggle_class] if options.has_key?(:toggle_class)}", id: (options[:id] if options.has_key?(:id)), type: "button", data: data_attr) do
output = content_tag(:span, toggle_text, class: "dropdown-toggle-text") output = content_tag(:span, toggle_text, class: "dropdown-toggle-text")
output << icon('chevron-down') output << icon('chevron-down')
output.html_safe output.html_safe
end end
end
dropdown_output += content_tag :div, class: "dropdown-menu dropdown-select #{dropdown_class}" do def dropdown_title(title, back: false)
output = "" content_tag :div, class: "dropdown-title" do
title_output = ""
if title if back
output += content_tag :div, class: "dropdown-title" do title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-back", aria: { label: "Go back" }, type: "button") do
title_output = content_tag(:span, title) icon('arrow-left')
end
end
title_output << content_tag(:span, title)
title_output += content_tag :button, class: "dropdown-title-button dropdown-menu-close", aria: {label: "close"}, type: "button" do title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-close", aria: { label: "Close" }, type: "button") do
icon('times') icon('times')
end.html_safe end
title_output.html_safe
end end
end end
if filter def dropdown_filter(placeholder)
output += content_tag :div, class: "dropdown-input" do content_tag :div, class: "dropdown-input" do
filter_output = search_field_tag nil, nil, class: "dropdown-input-field", placeholder: placeholder filter_output = search_field_tag nil, nil, class: "dropdown-input-field", placeholder: placeholder
filter_output += icon('search') filter_output << icon('search')
filter_output.html_safe filter_output.html_safe
end end
end end
output += content_tag :div, class: "dropdown-content" do def dropdown_content(&block)
capture(&block) if block && !footer_content content_tag(:div, class: "dropdown-content") do
end if block
if block && footer_content
output += content_tag :div, class: "dropdown-footer" do
capture(&block) capture(&block)
end end
end end
output += content_tag :div, class: "dropdown-loading" do
icon('spinner spin')
end end
output.html_safe def dropdown_footer(&block)
content_tag(:div, class: "dropdown-footer") do
if block
capture(&block)
end
end
end end
dropdown_output.html_safe def dropdown_loading
content_tag :div, class: "dropdown-loading" do
icon('spinner spin')
end end
end end
end end
...@@ -409,8 +409,8 @@ ...@@ -409,8 +409,8 @@
= icon('spinner spin') = icon('spinner spin')
:javascript :javascript
$('#js-project-dropdown').glDropdown({ $('#js-project-dropdown').glDropdown({
data: function (callback) { data: function (term, callback) {
Api.projects("", "last_activity_at", function (data) { Api.projects(term, "last_activity_at", function (data) {
callback(data); callback(data);
}); });
}, },
...@@ -433,7 +433,7 @@ ...@@ -433,7 +433,7 @@
.example .example
%div %div
= dropdown_tag("Projects", title: "Go to project", filter: true, placeholder: "Filter projects") = dropdown_tag("Projects", options: { title: "Go to project", filter: true, placeholder: "Filter projects" })
%h2#panels Panels %h2#panels Panels
......
...@@ -9,20 +9,20 @@ ...@@ -9,20 +9,20 @@
.filter-item.inline .filter-item.inline
- if params[:author_id] - if params[:author_id]
= hidden_field_tag(:author_id, params[:author_id]) = hidden_field_tag(:author_id, params[:author_id])
= dropdown_tag("Author", toggle_class: "js-user-search js-filter-submit", title: "Filter by author", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable", = dropdown_tag("Author", options: { toggle_class: "js-user-search js-filter-submit", title: "Filter by author", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable",
placeholder: "Search authors", data: {any_user: "Any Author", first_user: true, current_user: true, project_id: @project.id, selected: params[:author_id], field_name: "author_id"}) placeholder: "Search authors", data: { any_user: "Any Author", first_user: true, current_user: true, project_id: @project.id, selected: params[:author_id], field_name: "author_id" } })
.filter-item.inline .filter-item.inline
- if params[:assignee_id] - if params[:assignee_id]
= hidden_field_tag(:assignee_id, params[:assignee_id]) = hidden_field_tag(:assignee_id, params[:assignee_id])
= dropdown_tag("Assignee", toggle_class: "js-user-search js-filter-submit", title: "Filter by assignee", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable", = dropdown_tag("Assignee", options: { toggle_class: "js-user-search js-filter-submit", title: "Filter by assignee", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable",
placeholder: "Search assignee", data: {any_user: "Any Author", first_user: true, null_user: true, current_user: true, project_id: @project.id, selected: params[:assignee_id], field_name: "assignee_id"}) placeholder: "Search assignee", data: { any_user: "Any Author", first_user: true, null_user: true, current_user: true, project_id: @project.id, selected: params[:assignee_id], field_name: "assignee_id" } })
.filter-item.inline.milestone-filter .filter-item.inline.milestone-filter
- if params[:milestone_title] - if params[:milestone_title]
= hidden_field_tag(:milestone_title, params[:milestone_title]) = hidden_field_tag(:milestone_title, params[:milestone_title])
= dropdown_tag("Milestone", title: "Filter by milestone", toggle_class: 'js-milestone-select js-filter-submit', filter: true, dropdown_class: "dropdown-menu-selectable", = dropdown_tag("Milestone", options: { title: "Filter by milestone", toggle_class: 'js-milestone-select js-filter-submit', filter: true, dropdown_class: "dropdown-menu-selectable",
placeholder: "Search milestones", footer_content: true, data: {show_no: true, show_any: true, field_name: "milestone_title", selected: params[:milestone_title], project_id: @project.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :js)}) do placeholder: "Search milestones", footer_content: true, data: { show_no: true, show_any: true, field_name: "milestone_title", selected: params[:milestone_title], project_id: @project.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :js) } }) do
%ul.dropdown-footer-list %ul.dropdown-footer-list
- if can? current_user, :admin_milestone, @project - if can? current_user, :admin_milestone, @project
%li %li
...@@ -45,16 +45,10 @@ ...@@ -45,16 +45,10 @@
= icon('chevron-down') = icon('chevron-down')
.dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable .dropdown-menu.dropdown-select.dropdown-menu-paging.dropdown-menu-labels.dropdown-menu-selectable
.dropdown-page-one .dropdown-page-one
.dropdown-title = dropdown_title("Filter by label")
%span = dropdown_filter("Search labels")
Filter by label = dropdown_content
%button.dropdown-title-button.dropdown-menu-close{type: "button", aria: {label: "close"}} = dropdown_footer do
= icon('times')
.dropdown-input
= search_field_tag nil, nil, class: "dropdown-input-field", placeholder: "Search labels"
= icon('search')
.dropdown-content
.dropdown-footer
%ul.dropdown-footer-list %ul.dropdown-footer-list
- if can? current_user, :admin_label, @project - if can? current_user, :admin_label, @project
%li %li
...@@ -68,14 +62,8 @@ ...@@ -68,14 +62,8 @@
View labels View labels
- if can? current_user, :admin_label, @project - if can? current_user, :admin_label, @project
.dropdown-page-two .dropdown-page-two
.dropdown-title = dropdown_title("Create new label", back: true)
%button.dropdown-title-button.dropdown-menu-back{aria: {label: "Go back"}} = dropdown_content do
= icon('arrow-left')
%span
Create new label
%button.dropdown-title-button.dropdown-menu-close{type: "button", aria: {label: "close"}}
= icon('times')
.dropdown-content
%input#new_label_color{type: "hidden"} %input#new_label_color{type: "hidden"}
%input#new_label_name.dropdown-input-field{type: "text", placeholder: "Name new label"} %input#new_label_name.dropdown-input-field{type: "text", placeholder: "Name new label"}
.dropdown-label-color-preview.js-dropdown-label-color-preview .dropdown-label-color-preview.js-dropdown-label-color-preview
...@@ -85,6 +73,7 @@ ...@@ -85,6 +73,7 @@
&nbsp &nbsp
%button.btn.btn-primary.js-new-label-btn{type: "button"} %button.btn.btn-primary.js-new-label-btn{type: "button"}
Create Create
= dropdown_loading
.dropdown-loading .dropdown-loading
= icon('spinner spin') = icon('spinner spin')
...@@ -95,18 +84,18 @@ ...@@ -95,18 +84,18 @@
.issues_bulk_update.hide .issues_bulk_update.hide
= form_tag bulk_update_namespace_project_issues_path(@project.namespace, @project), method: :post do = form_tag bulk_update_namespace_project_issues_path(@project.namespace, @project), method: :post do
.filter-item.inline .filter-item.inline
= dropdown_tag("Status", toggle_class: "js-issue-status", title: "Change status", dropdown_class: "dropdown-menu-selectable", data: {field_name: "update[state_event]"}) do = dropdown_tag("Status", options: { toggle_class: "js-issue-status", title: "Change status", dropdown_class: "dropdown-menu-selectable", data: { field_name: "update[state_event]" } } ) do
%ul %ul
%li %li
%a{href: "#", data: {id: "reopen"}} Open %a{href: "#", data: {id: "reopen"}} Open
%li %li
%a{href: "#", data: {id: "close"}} Closed %a{href: "#", data: {id: "close"}} Closed
.filter-item.inline .filter-item.inline
= dropdown_tag("Assignee", toggle_class: "js-user-search", title: "Assign to", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable", = dropdown_tag("Assignee", options: { toggle_class: "js-user-search", title: "Assign to", filter: true, dropdown_class: "dropdown-menu-user dropdown-menu-selectable",
placeholder: "Search authors", data: {first_user: true, current_user: true, project_id: @project.id, field_name: "update[assignee_id]"}) placeholder: "Search authors", data: { first_user: true, current_user: true, project_id: @project.id, field_name: "update[assignee_id]" } })
.filter-item.inline .filter-item.inline
= dropdown_tag("Milestone", title: "Assign milestone", toggle_class: 'js-milestone-select', filter: true, dropdown_class: "dropdown-menu-selectable", = dropdown_tag("Milestone", options: { title: "Assign milestone", toggle_class: 'js-milestone-select', filter: true, dropdown_class: "dropdown-menu-selectable",
placeholder: "Search milestones", data: {show_no: true, field_name: "update[milestone_id]", project_id: @project.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :js), use_id: true}) placeholder: "Search milestones", data: { show_no: true, field_name: "update[milestone_id]", project_id: @project.id, milestones: namespace_project_milestones_path(@project.namespace, @project, :js), use_id: true } })
= hidden_field_tag 'update[issues_ids]', [] = hidden_field_tag 'update[issues_ids]', []
= hidden_field_tag :state_event, params[:state_event] = hidden_field_tag :state_event, params[:state_event]
.filter-item.inline .filter-item.inline
......
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