forked from thesuss/shf-project
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into ruby-2.4.1#147050603
- Loading branch information
Showing
21 changed files
with
573 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
module PaginationUtility | ||
extend ActiveSupport::Concern | ||
|
||
# This constant is used to specify "all" items to be shown in a view that | ||
# uses the will_paginate gem for listing a collection. That has to be a number. | ||
# This particular number is used when the user selects "All" in the | ||
# items-per-page selection. | ||
ALL_ITEMS = 10_000.freeze | ||
|
||
DEFAULT_ITEMS_SELECTION = 10.freeze # Default items-per-page setting | ||
|
||
def process_pagination_params(entity) | ||
|
||
# This method is used in controller actions involved in pagination of | ||
# collection tables (e.g., companies, member_applications). | ||
|
||
# It is passed a string that indicates the type of paginated collection, | ||
# e.g. "company", "membership_application". | ||
|
||
# It returns: | ||
# 1) search params hash, for use with ransack gems "ransack" method, | ||
# 2) the user's last items-per-page selection (an integer or 'All'), | ||
# 3) the actual number of items-per-page to show in the table. | ||
|
||
# This method uses the session to store (and recover) search criteria | ||
# and per-page items selection. These need to be persisted across action | ||
# invocations in order to accommodate the multiple ways in which a | ||
# typical controller "index" action might be called. | ||
|
||
# For instance, the companies_controller "index" action is called when: | ||
# 1) loading the index page, | ||
# 2) moving to another pagination page in the companies listing table (XHR), | ||
# 3) sorting on one of the table columns, | ||
# 4) executing a companies search from the index page, and, | ||
# 5) changing per-page items count in the pagination table on that page (XHR). | ||
|
||
entity_items_selection = (entity + '_items_selection').to_sym | ||
entity_search_criteria = (entity + '_search_criteria').to_sym | ||
|
||
if params[:items_count] # << user has selected a per-page items count | ||
items_count = params[:items_count] | ||
items_selection = items_count == 'All' ? 'All' : items_count.to_i | ||
|
||
session[entity_items_selection] = items_selection | ||
|
||
search_criteria = JSON.parse(session[entity_search_criteria]) | ||
|
||
search_params = search_criteria ? | ||
ActionController::Parameters.new(search_criteria) : nil | ||
|
||
# Reset params hash so that sort_link works correctly in the view | ||
# (the sort links are built using, as one input, the controller params) | ||
params[:q] = search_params | ||
params.delete(:items_count) | ||
|
||
else | ||
items_selection = session[entity_items_selection] ? | ||
session[entity_items_selection] : DEFAULT_ITEMS_SELECTION | ||
|
||
session[entity_search_criteria] = params[:q].to_json | ||
|
||
search_params = params[:q] | ||
end | ||
|
||
items_per_page = items_selection == 'All' ? ALL_ITEMS : items_selection | ||
|
||
[ search_params, items_selection, items_per_page ] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.row.center-aligned-container | ||
|
||
.col-sm-8.col-sm-offset-2{ style: 'text-align: center;' } | ||
= will_paginate entities, | ||
renderer: BootstrapPagination::Rails, | ||
link_options: { 'data-remote': true, | ||
class: paginate_class } | ||
|
||
.col-sm-2{ style: 'text-align: right;' } | ||
-# override min-width from 'custom.css' - too wide | ||
= select_tag(:items_count, paginate_count_options(items_count), | ||
data: { remote: true, | ||
url: url }, | ||
style: 'min-width: 50px;', | ||
class: paginate_class ) | ||
|
||
%span.glyphicon.glyphicon-info-sign{ title: "#{t('items_per_page_tooltip')}", | ||
data: {toggle: 'tooltip'} } | ||
-# | ||
for background on will_paginate method args, see: | ||
https://gist.github.com/jeroenr/3142686, and | ||
https://github.com/bootstrap-ruby/will_paginate-bootstrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,36 @@ | ||
.index.company#companies | ||
%header.entry-header | ||
- unless current_user.try(:admin) | ||
%h1.entry-title= t('.title') | ||
- if current_user.try(:admin) | ||
%h1.entry-title= t('.admin_title') | ||
|
||
%header.entry-header | ||
- unless current_user.try(:admin) | ||
%h1.entry-title= t('.title') | ||
- if current_user.try(:admin) | ||
%h1.entry-title= t('.admin_title') | ||
.entry-content | ||
|
||
.entry-content | ||
.row | ||
= render 'map_companies', | ||
markers: location_and_markers_for(@all_visible_companies) | ||
|
||
.row | ||
= render 'map_companies', | ||
markers: location_and_markers_for(@all_visible_companies) | ||
|
||
- unless current_user.try(:admin) | ||
|
||
- unless current_user.try(:admin) | ||
.search-instructions | ||
%h3 | ||
#{t('.h_companies_listed_below')} | ||
%br | ||
#{t('.how_to_search')} | ||
|
||
.search-instructions | ||
%h3 | ||
#{t('.h_companies_listed_below')} | ||
%br | ||
#{t('.how_to_search')} | ||
%button.btn.hide-search-form.btn-success.btn-xs.pull-right{ id: 'toggle_search_form', | ||
href: '#company_search_form', | ||
style: 'color:black; text-transform:none;' } | ||
#{t('toggle.company_search_form.hide')} | ||
|
||
%button.btn.hide-search-form.btn-success.btn-xs.pull-right{ id: 'toggle_search_form', | ||
href: '#company_search_form', | ||
style: 'color:black; text-transform:none;' } | ||
#{t('toggle.company_search_form.hide')} | ||
.panel.panel-default.search-panel{ id: 'company_search_form' } | ||
|
||
.panel.panel-default.search-panel{ id: 'company_search_form' } | ||
= render 'search_form' | ||
|
||
= render 'search_form' | ||
|
||
|
||
- if @companies.empty? | ||
%strong | ||
#{t('.no_search_results')} | ||
- else | ||
= render partial: 'companies_list' | ||
- if @companies.empty? | ||
%strong | ||
#{t('.no_search_results')} | ||
- else | ||
= render partial: 'companies_list' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
lock '3.6.1' | ||
|
||
set :rbenv_type, :user | ||
set :rbenv_ruby, '2.3.1' | ||
set :rbenv_ruby, '2.4.0' | ||
|
||
set :application, 'shf' | ||
set :repo_url, '[email protected]:AgileVentures/shf-project.git' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.