From de794a48b0453b4db2c29bead4b0535614e1bd2a Mon Sep 17 00:00:00 2001 From: wvengen Date: Fri, 3 Apr 2015 17:02:55 +0200 Subject: [PATCH] Reorder roles and add icons --- README.md | 1 + app/assets/images/role-admin.png | Bin 0 -> 761 bytes app/assets/images/role-article_meta.png | Bin 0 -> 757 bytes app/assets/images/role-finance.png | Bin 0 -> 883 bytes app/assets/images/role-orders.png | Bin 0 -> 275 bytes app/assets/images/role-suppliers.png | Bin 0 -> 823 bytes app/helpers/application_helper.rb | 35 +++++++++++---------- app/views/admin/users/_users.html.haml | 2 +- app/views/admin/workgroups/_form.html.haml | 4 +-- 9 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 app/assets/images/role-admin.png create mode 100644 app/assets/images/role-article_meta.png create mode 100644 app/assets/images/role-finance.png create mode 100644 app/assets/images/role-orders.png create mode 100644 app/assets/images/role-suppliers.png diff --git a/README.md b/README.md index ad4febe6..cf544c7b 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,4 @@ License 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. diff --git a/app/assets/images/role-admin.png b/app/assets/images/role-admin.png new file mode 100644 index 0000000000000000000000000000000000000000..445c2634fb34db4c6694eab1898f6973814ae805 GIT binary patch literal 761 zcmVi_syO6zW2TNa_4~qANSsK&i}jT-2XW| zkaE(4A*{g&MzIbn@c8`-x&)K>0e_=fpugiNUdOy{13!%;_^(CKX8IRCz?@Ek594~` z@D`5YV{F4~A_ZG8flqN7|0Z@P@o+oAE4Ywz@KYA3ucZAGcu%CG=Hrug0KAkl+=toi z80TbA{YU<2$8anMU_T!E9{^N41yIG$A_a3x+CPaMrl+7Q05!dh<07ALV>|=)Mi%fh zoH4Tqy8>`d=g;s@{Ms#mF+oJ{|P38_K8b!!iJBb#Pc*;a~xPor&E=@kINvD*KuI{tZp~OfxF3 z3Re6L--}oA1?FdV{i1o*&OV>`9a68OOBtw^H!x*pE>le_zbb~AMshye-_b013ScZ- zdrC|`Q(`u}Bu1_(7UgU=sHbfp@mmpmQWX^4R95By91vtvM)sKAxDKhe@ZJo3{^qtc zb2L{JQ0?GZyrSUQWReD`;tIYIb(3HJ2TO~by(q@0)aX0xRv$`V74%%eVllYh!l?#e zZsykaw)hzYxg2TWsF6-)HpA+TYgYn(akl;f7L)-{lOjFdKhxXQ3<>d(L>ZjD1(Th z;O%WhVW5jBfrx@ZqJ^TV$SC3DWpu9ku=nZw=gj|{^FP!4H!S#{wbx$1@A`lgFmtp4K2iMktIEW@ zg@G9J)kuZvFeb&{78CyyW6F(=78~3ps>#-FZ@G0trCUhe{R~vuEyeCR08n7Qf z2_;w}wA9}e_xE)}_w+8jj``BdmNpK>wKtQ_FNEz;NZc&!-!mAD0KK?_r}zaQV*xJ2 zHODYM1HhLtzPI4mm=Ny57QCi-toCD1eBOpz@%eYWBb4i0^mPb7%1Wapp=S~v#1DlU zHsEsf-NDMlq8~67`*0WMg{HDMk#t=x0G}IL(^jFDFJp$V_3E%X&L0=L-baaqOVN|a z@pCNz?Ii%u@Hckj8{w5+z&KpRL7}4+-cD!A`p2~ZTuVuiW{acnGDFY(ayBt5z{89H zckzBqa419k8(9IeTp$WIfQuPpCu9Y#iU^4B%7_0Ox7}XvzU#do2Jngw{G* z;)9r53jpDEGFkvftB9upOc46|{}t~N4zQX5V7kx&M=IWfg&D*NM|fe)kTDHsM<9Mr zxI4_mcZUBZOWIDwyT$1=x|f8VQMh7PvOXM$;O{Bk3$s|SDt}Pwu@*=0hfv>c;mAIT nO?b29?Hv$q#nno6x*+}>Vnf&9yg?Q{00000NkvXXu0mjfvHD}x literal 0 HcmV?d00001 diff --git a/app/assets/images/role-finance.png b/app/assets/images/role-finance.png new file mode 100644 index 0000000000000000000000000000000000000000..05722a8ec0257a8c9d3f3b23c88381f26529b1d1 GIT binary patch literal 883 zcmV-(1C0EMP)GpL}43JS77hOC6_s=eft&7{-AS|6S{Go#1vd<)jY`Oe<^|KDr<_u6Yyjh%v9 z(Sx_~0k&WxUc%j&RT0(*n~x8%55o<3Ke{ooS>R*vW`m$(`BuzmhQK>bfEWG~PA&s} zNd@4AKUs!ASA_)LFGJvp3JE+@hQKszt^j-&&M!mYX0+hFCcwYP9Nb=pz+G64BXASG zJPhDp@d!@9_1IK~z)VqiHsSRA){1+R*hfifD?UXZR^oCTiKFo-hH_3RdsysfFJ48b zLsz%iN#vKD`$-ZnZAO=< zg4~7Ig!m?i$gQgfoPcYw7CXjSXb@i~`}Uf-XJ9ez5uttzE5xapBk~WI;fq{rQ7!m2 z__2YV)ca;kA1i!mlW{2?H1fo(#6`uR$4da$`X0>7wYu>Ke$MapW4C9dT7*U{Y!bZi z--Tw5#X#MEKj3v-EmAQP-{1wJgQQCNnrfTY7d?hjYy{~#j}JMngRbW!{3$!-V!3*CVIwa z#qmB~+#%hWhWp_aQI%F0EuKbvyXX3%uM!2Q3(Lj>Ihgeb#dhZJbMb)C#m+jwAt9n(k*=vi0}qKD zUtESji+CjL7vi`w7p=9)Mu%{ckv+lsGT?>H5G_=()7^L%Pl(Vi5j$Rn=S4R&R5Sh! z6}G*&+nmCzO4QlJB~D`ya>v`U!!zun_1t+u Z=>_mEWpj^w&4T~{002ovPDHLkV1g|&bK?L2 literal 0 HcmV?d00001 diff --git a/app/assets/images/role-suppliers.png b/app/assets/images/role-suppliers.png new file mode 100644 index 0000000000000000000000000000000000000000..550b77b50468af5e4189c4cf3bfa790484137fed GIT binary patch literal 823 zcmV-71IYY|P)FiK(bXMuvSXLM@VMMw`$U=e%~kymOoT-nT!T#XZmYpZ~e%KF@ic%k*&@ ze!)R(K%-@?foE|jWA5l8@3e3Y{>DbEO`#DiPa8?!T0DbE+*Fr%1N$)C;yVYsa3bx4 z^cC2QA273y0&d4R&MaA*hqFukL--vJ)=|JGc%=gGd3@8W_$8vnmsj9kfaAEbmjbrn ziyrtN7^kB5!)fDfYx}VsYp@MJ>EcMv62E_@zXM{zaI#f%bOKNe)n<9J(4 z#Ujs^%-s>U;(%!VW?V7ds;597mf*$Ac>uSR1rFdfF+!iydDAq+0BYj0w5AwHjSjpa zF&ifFYHFUWa=V!2OG=1mi1zOg`(VE`?pWq($1pyJ zqgd6pxGWcURuFE-PJD%{+Wf090Y7J@1lF*IDRZt6 zH{_AjJOvkGuhl~88fQ$+n^HWi|5%M@gON%AIX^cb&D66C%)mB zcxDx^;+OCzK2`o#tyT=+ZZWnGrG1#bfvIWb_y@S7zij<0tGWOH002ovPDHLkV1l(Y Bm#P2& literal 0 HcmV?d00001 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 07fd4187..8b8cd618 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -18,7 +18,7 @@ module ApplicationHelper def format_datetime_timespec(time, format) I18n.l(time, :format => format) unless (time.nil? || format.nil?) end - + # Creates ajax-controlled-links for pagination def pagination_links_remote(collection, options = {}) per_page = options[:per_page] || @per_page @@ -26,7 +26,7 @@ module ApplicationHelper params = params.merge({:per_page => per_page}) paginate collection, :params => params, :remote => true end - + # Link-collection for per_page-options when using the pagination-plugin def items_per_page(options = {}) per_page_options = options[:per_page_options] || [20, 50, 100, 500] @@ -98,20 +98,20 @@ module ApplicationHelper end s end - + # Generates a link to the top of the website def link_to_top link_to '#' do content_tag :i, nil, class: 'icon-arrow-up icon-large' end end - + # Returns the weekday. 0 is sunday, 1 is monday and so on def weekday(dayNumber) weekdays = I18n.t('date.day_names') return weekdays[dayNumber] end - + # to set a title for both the h1-tag and the title in the header def title(page_title, show_title = true) content_for(:title) { page_title.to_s } @@ -135,7 +135,7 @@ module ApplicationHelper options[:alt] ||= icons[name][:alt] options[:title] ||= icons[name][:title] options.merge!({:size => '16x16',:border => "0"}) - + image_tag icons[name][:file], options end @@ -149,21 +149,22 @@ module ApplicationHelper link_to(text, options[:url], remote_options.merge(options)) end - def format_roles(record) - roles = [] - roles << I18n.t('helpers.application.role_admin') if record.role_admin? - roles << I18n.t('helpers.application.role_finance') if record.role_finance? - roles << I18n.t('helpers.application.role_suppliers') if record.role_suppliers? - roles << I18n.t('helpers.application.role_article_meta') if record.role_article_meta? - roles << I18n.t('helpers.application.role_orders') if record.role_orders? - roles.join(', ') + def format_roles(record, icon=false) + roles = %w(suppliers article_meta orders finance admin) + roles.select! {|role| record.send "role_#{role}?"} + names = Hash[roles.map{|r| [r, I18n.t("helpers.application.role_#{r}")]}] + if icon + roles.map{|r| image_tag("role-#{r}.png", size: '22x22', border: 0, alt: names[r], title: names[r])}.join(' ').html_safe + else + roles.map{|r| names[r]}.join(', ') + end end def link_to_gmaps(address) link_to h(address), "http://maps.google.com/?q=#{h(address)}", :title => I18n.t('helpers.application.show_google_maps'), :target => "_blank" end - + # Returns flash messages html. # # Use this instead of twitter-bootstrap's +bootstrap_flash+ method for safety, until @@ -183,7 +184,7 @@ module ApplicationHelper end flash_messages.join("\n").html_safe end - + # render base errors in a form after failed validation # http://railsapps.github.io/twitter-bootstrap-rails.html def base_errors resource @@ -244,5 +245,5 @@ module ApplicationHelper stylesheet_link_tag foodcoop_css_path, media: 'all' end end - + end diff --git a/app/views/admin/users/_users.html.haml b/app/views/admin/users/_users.html.haml index 412ef932..9a4ba433 100644 --- a/app/views/admin/users/_users.html.haml +++ b/app/views/admin/users/_users.html.haml @@ -18,7 +18,7 @@ - if FoodsoftConfig[:use_nick] %td= user.name %td= user.email - %td= format_roles(user) + %td= format_roles(user, true) %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.delete'), [:admin, user], :data => {:confirm => t('admin.confirm', name: user.name)}, diff --git a/app/views/admin/workgroups/_form.html.haml b/app/views/admin/workgroups/_form.html.haml index 02427f35..3832e380 100644 --- a/app/views/admin/workgroups/_form.html.haml +++ b/app/views/admin/workgroups/_form.html.haml @@ -2,11 +2,11 @@ = simple_form_for [:admin, @workgroup] do |f| - captured = capture do %h4= t 'admin.access_to' - = f.input :role_admin - = f.input :role_finance = f.input :role_suppliers = f.input :role_article_meta = f.input :role_orders + = f.input :role_finance + = f.input :role_admin = render 'shared/group_form_fields', :f => f, captured: captured .form-actions = f.button :submit