Module: SuppliersHelper
- Defined in:
- app/helpers/suppliers_helper.rb
Instance Method Summary collapse
- #display_supplier_banner(supplier) ⇒ Object
-
#supplier_link(supplier, text: nil, path: nil) ⇒ String
Renders a supplier link or disabled text based on user permissions.
- #suppliers_tab_options(supplier) ⇒ Object
Instance Method Details
#display_supplier_banner(supplier) ⇒ Object
2 3 4 5 |
# File 'app/helpers/suppliers_helper.rb', line 2 def (supplier) supplier ||= @supplier render partial: '/suppliers/supplier_banner', locals: { supplier: supplier } end |
#supplier_link(supplier, text: nil, path: nil) ⇒ String
Renders a supplier link or disabled text based on user permissions.
Users without Supplier read access see a grayed, disabled link with a tooltip.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/suppliers_helper.rb', line 21 def supplier_link(supplier, text: nil, path: nil) return '' unless supplier link_text = text || supplier.full_name link_path = path || supplier_path(supplier) if can?(:read, Supplier) link_to(link_text, link_path) else content_tag(:span, link_text, class: 'text-muted', style: 'cursor: not-allowed;', data: { bs_toggle: 'tooltip', bs_placement: 'top' }, title: 'You do not have permission to view suppliers. Contact the Heatwave Team to request access.') end end |
#suppliers_tab_options(supplier) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/helpers/suppliers_helper.rb', line 38 def (supplier) { vouchers: { remote_href: search_and_show_searches_path( type: 'VoucherSearch', set_limit: 30, query_params: { supplier_id_eq: supplier.id }, selected_columns: %i[voucher_link state company_name category payment_method invoice_number invoice_date gl_date currency business_unit_name total open_amount due_date prority], sort_columns: ['priority','gl_date desc'], links: { "New Voucher" => new_voucher_path(supplier_id: supplier.id) } ) }, main: { remote_href: tab_main_supplier_path(supplier) }, addresses: { remote_href: tab_addresses_supplier_path(supplier), counter: @supplier.addresses.size }, contacts: { counter: supplier.contacts.active.size, remote_href: tab_contacts_supplier_path(supplier) }, activities: { counter: supplier.activities.open_activities.size, remote_href: supplier_activities_path(supplier, selected_activity: params[:selected_activity]) }, payments: { remote_href: tab_payments_supplier_path(supplier) }, orders: { counter: @purchase_orders.open_po.size, remote_href: tab_orders_supplier_path(supplier) }, receipts: { remote_href: tab_receipts_supplier_path(supplier) }, attachments: { counter: supplier.all_uploads.size, remote_href: supplier_uploads_path(supplier) } } end |