Reorder roles and add icons
This commit is contained in:
parent
07311aa032
commit
de794a48b0
9 changed files with 22 additions and 20 deletions
|
@ -37,3 +37,4 @@ License
|
||||||
|
|
||||||
GPL version 3 or later, please see [LICENSE](LICENSE.md) for the full text.
|
GPL version 3 or later, please see [LICENSE](LICENSE.md) for the full text.
|
||||||
|
|
||||||
|
Thanks to [Icons8](http://icons8.com/) for letting us use their icons.
|
||||||
|
|
BIN
app/assets/images/role-admin.png
Normal file
BIN
app/assets/images/role-admin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 761 B |
BIN
app/assets/images/role-article_meta.png
Normal file
BIN
app/assets/images/role-article_meta.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 757 B |
BIN
app/assets/images/role-finance.png
Normal file
BIN
app/assets/images/role-finance.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 883 B |
BIN
app/assets/images/role-orders.png
Normal file
BIN
app/assets/images/role-orders.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 275 B |
BIN
app/assets/images/role-suppliers.png
Normal file
BIN
app/assets/images/role-suppliers.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 823 B |
|
@ -18,7 +18,7 @@ module ApplicationHelper
|
||||||
def format_datetime_timespec(time, format)
|
def format_datetime_timespec(time, format)
|
||||||
I18n.l(time, :format => format) unless (time.nil? || format.nil?)
|
I18n.l(time, :format => format) unless (time.nil? || format.nil?)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates ajax-controlled-links for pagination
|
# Creates ajax-controlled-links for pagination
|
||||||
def pagination_links_remote(collection, options = {})
|
def pagination_links_remote(collection, options = {})
|
||||||
per_page = options[:per_page] || @per_page
|
per_page = options[:per_page] || @per_page
|
||||||
|
@ -26,7 +26,7 @@ module ApplicationHelper
|
||||||
params = params.merge({:per_page => per_page})
|
params = params.merge({:per_page => per_page})
|
||||||
paginate collection, :params => params, :remote => true
|
paginate collection, :params => params, :remote => true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Link-collection for per_page-options when using the pagination-plugin
|
# Link-collection for per_page-options when using the pagination-plugin
|
||||||
def items_per_page(options = {})
|
def items_per_page(options = {})
|
||||||
per_page_options = options[:per_page_options] || [20, 50, 100, 500]
|
per_page_options = options[:per_page_options] || [20, 50, 100, 500]
|
||||||
|
@ -98,20 +98,20 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generates a link to the top of the website
|
# Generates a link to the top of the website
|
||||||
def link_to_top
|
def link_to_top
|
||||||
link_to '#' do
|
link_to '#' do
|
||||||
content_tag :i, nil, class: 'icon-arrow-up icon-large'
|
content_tag :i, nil, class: 'icon-arrow-up icon-large'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the weekday. 0 is sunday, 1 is monday and so on
|
# Returns the weekday. 0 is sunday, 1 is monday and so on
|
||||||
def weekday(dayNumber)
|
def weekday(dayNumber)
|
||||||
weekdays = I18n.t('date.day_names')
|
weekdays = I18n.t('date.day_names')
|
||||||
return weekdays[dayNumber]
|
return weekdays[dayNumber]
|
||||||
end
|
end
|
||||||
|
|
||||||
# to set a title for both the h1-tag and the title in the header
|
# to set a title for both the h1-tag and the title in the header
|
||||||
def title(page_title, show_title = true)
|
def title(page_title, show_title = true)
|
||||||
content_for(:title) { page_title.to_s }
|
content_for(:title) { page_title.to_s }
|
||||||
|
@ -135,7 +135,7 @@ module ApplicationHelper
|
||||||
options[:alt] ||= icons[name][:alt]
|
options[:alt] ||= icons[name][:alt]
|
||||||
options[:title] ||= icons[name][:title]
|
options[:title] ||= icons[name][:title]
|
||||||
options.merge!({:size => '16x16',:border => "0"})
|
options.merge!({:size => '16x16',:border => "0"})
|
||||||
|
|
||||||
image_tag icons[name][:file], options
|
image_tag icons[name][:file], options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -149,21 +149,22 @@ module ApplicationHelper
|
||||||
link_to(text, options[:url], remote_options.merge(options))
|
link_to(text, options[:url], remote_options.merge(options))
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_roles(record)
|
def format_roles(record, icon=false)
|
||||||
roles = []
|
roles = %w(suppliers article_meta orders finance admin)
|
||||||
roles << I18n.t('helpers.application.role_admin') if record.role_admin?
|
roles.select! {|role| record.send "role_#{role}?"}
|
||||||
roles << I18n.t('helpers.application.role_finance') if record.role_finance?
|
names = Hash[roles.map{|r| [r, I18n.t("helpers.application.role_#{r}")]}]
|
||||||
roles << I18n.t('helpers.application.role_suppliers') if record.role_suppliers?
|
if icon
|
||||||
roles << I18n.t('helpers.application.role_article_meta') if record.role_article_meta?
|
roles.map{|r| image_tag("role-#{r}.png", size: '22x22', border: 0, alt: names[r], title: names[r])}.join(' ').html_safe
|
||||||
roles << I18n.t('helpers.application.role_orders') if record.role_orders?
|
else
|
||||||
roles.join(', ')
|
roles.map{|r| names[r]}.join(', ')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_gmaps(address)
|
def link_to_gmaps(address)
|
||||||
link_to h(address), "http://maps.google.com/?q=#{h(address)}", :title => I18n.t('helpers.application.show_google_maps'),
|
link_to h(address), "http://maps.google.com/?q=#{h(address)}", :title => I18n.t('helpers.application.show_google_maps'),
|
||||||
:target => "_blank"
|
:target => "_blank"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns flash messages html.
|
# Returns flash messages html.
|
||||||
#
|
#
|
||||||
# Use this instead of twitter-bootstrap's +bootstrap_flash+ method for safety, until
|
# Use this instead of twitter-bootstrap's +bootstrap_flash+ method for safety, until
|
||||||
|
@ -183,7 +184,7 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
flash_messages.join("\n").html_safe
|
flash_messages.join("\n").html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
# render base errors in a form after failed validation
|
# render base errors in a form after failed validation
|
||||||
# http://railsapps.github.io/twitter-bootstrap-rails.html
|
# http://railsapps.github.io/twitter-bootstrap-rails.html
|
||||||
def base_errors resource
|
def base_errors resource
|
||||||
|
@ -244,5 +245,5 @@ module ApplicationHelper
|
||||||
stylesheet_link_tag foodcoop_css_path, media: 'all'
|
stylesheet_link_tag foodcoop_css_path, media: 'all'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
- if FoodsoftConfig[:use_nick]
|
- if FoodsoftConfig[:use_nick]
|
||||||
%td= user.name
|
%td= user.name
|
||||||
%td= user.email
|
%td= user.email
|
||||||
%td= format_roles(user)
|
%td= format_roles(user, true)
|
||||||
%td= format_time(user.last_activity)
|
%td= format_time(user.last_activity)
|
||||||
%td= link_to t('ui.edit'), edit_admin_user_path(user), class: 'btn btn-mini'
|
%td= link_to t('ui.edit'), edit_admin_user_path(user), class: 'btn btn-mini'
|
||||||
%td= link_to t('ui.delete'), [:admin, user], :data => {:confirm => t('admin.confirm', name: user.name)},
|
%td= link_to t('ui.delete'), [:admin, user], :data => {:confirm => t('admin.confirm', name: user.name)},
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
= simple_form_for [:admin, @workgroup] do |f|
|
= simple_form_for [:admin, @workgroup] do |f|
|
||||||
- captured = capture do
|
- captured = capture do
|
||||||
%h4= t 'admin.access_to'
|
%h4= t 'admin.access_to'
|
||||||
= f.input :role_admin
|
|
||||||
= f.input :role_finance
|
|
||||||
= f.input :role_suppliers
|
= f.input :role_suppliers
|
||||||
= f.input :role_article_meta
|
= f.input :role_article_meta
|
||||||
= f.input :role_orders
|
= f.input :role_orders
|
||||||
|
= f.input :role_finance
|
||||||
|
= f.input :role_admin
|
||||||
= render 'shared/group_form_fields', :f => f, captured: captured
|
= render 'shared/group_form_fields', :f => f, captured: captured
|
||||||
.form-actions
|
.form-actions
|
||||||
= f.button :submit
|
= f.button :submit
|
||||||
|
|
Loading…
Reference in a new issue