Module: DiscoApp::ApplicationHelper
- Defined in:
- app/helpers/disco_app/application_helper.rb
Instance Method Summary collapse
-
#link_to_modal(name, path, options = {}) ⇒ Object
Generate a link that will open its href in an embedded Shopify modal.
-
#link_to_shopify_admin(shop, name, admin_path, options = {}) ⇒ Object
Generates a link pointing to an object (such as an order or customer) inside the given shop’s Shopify admin.
Instance Method Details
#link_to_modal(name, path, options = {}) ⇒ Object
Generate a link that will open its href in an embedded Shopify modal.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/disco_app/application_helper.rb', line 15 def link_to_modal(name, path, = {}) = { src: path, title: .delete(:modal_title), width: .delete(:modal_width), height: .delete(:modal_height), buttons: .delete(:modal_buttons), } [:onclick] = "ShopifyApp.Modal.open(#{modal_options.to_json}); return false;" [:onclick].gsub!(/"function(.*?)"/, 'function\1') link_to(name, path, ) end |
#link_to_shopify_admin(shop, name, admin_path, options = {}) ⇒ Object
Generates a link pointing to an object (such as an order or customer) inside the given shop’s Shopify admin. This helper makes it easy to create links to objects within the admin that support both right-clicking and opening in a new tab as well as capturing a left click and redirecting to the relevant object using ‘ShopifyApp.redirect()`.
8 9 10 11 12 |
# File 'app/helpers/disco_app/application_helper.rb', line 8 def link_to_shopify_admin(shop, name, admin_path, = {}) [:onclick] = "ShopifyApp.redirect('#{admin_path}'); return false;" [:'data-no-turbolink'] = true link_to(name, "https://#{shop.shopify_domain}/admin/#{admin_path}", ) end |