Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

open source a batch of helpers

Damian Legawiec93219bee89f7
diff --git a/admin/app/helpers/spree/admin/onboarding_helper.rb b/admin/app/helpers/spree/admin/onboarding_helper.rb
new file mode 100644
index 0000000000..c7c2963112
--- /dev/null
+++ b/admin/app/helpers/spree/admin/onboarding_helper.rb
@@ -0,0 +1,18 @@
+module Spree
+ module Admin
+ module OnboardingHelper
+ def onboarding_check_circle(condition, pending: false)
+ if pending
+ return icon('exclamation-circle', height: height,
+ class: 'rounded-circle d-inline-flex align-items-center bg-warning text-primary p-1').html_safe
+ end
+
+ if condition == true
+ icon('check', class: 'rounded-circle d-inline-flex align-items-center bg-success text-success p-1', style: 'border: 3px solid #C6F6D5')
+ else
+ icon('check', class: 'rounded-circle d-inline-flex align-items-center border-dashed text-light p-1')
+ end.html_safe
+ end
+ end
+ end
+end
diff --git a/admin/app/helpers/spree/admin/reimbursement_type_helper.rb b/admin/app/helpers/spree/admin/reimbursement_type_helper.rb
new file mode 100644
index 0000000000..43ddab201f
--- /dev/null
+++ b/admin/app/helpers/spree/admin/reimbursement_type_helper.rb
@@ -0,0 +1,9 @@
+module Spree
+ module Admin
+ module ReimbursementTypeHelper
+ def reimbursement_type_name(reimbursement_type)
+ reimbursement_type.present? ? reimbursement_type.name.humanize : ''
+ end
+ end
+ end
+end
diff --git a/admin/app/helpers/spree/admin/webhooks_subscribers_helper.rb b/admin/app/helpers/spree/admin/webhooks_subscribers_helper.rb
new file mode 100644
index 0000000000..efb12d8b99
--- /dev/null
+++ b/admin/app/helpers/spree/admin/webhooks_subscribers_helper.rb
@@ -0,0 +1,31 @@
+module Spree
+ module Admin
+ module WebhooksSubscribersHelper
+ def event_checkbox_for(resource_name, form)
+ content_tag :div, class: 'col-xs-12 col-sm-6 col-md-4 col-lg-4 form-group' do
+ content_tag :div, class: 'custom-control custom-switch' do
+ (form.check_box resource_name, event_checkbox_opts(resource_name), true, nil) + ' ' +
+ form.label(resource_name, Spree.t("admin.webhooks_subscribers.#{resource_name.to_s.pluralize}"), class: 'custom-control-label')
+ end
+ end
+ end
+
+ def subscribe_to_all_events?
+ @webhooks_subscriber.new_record? || @webhooks_subscriber.subscriptions == ['*']
+ end
+
+ private
+
+ def event_checkbox_opts(resource_name)
+ {
+ class: 'events-checkbox custom-control-input',
+ checked: subscribed_to_resource?(resource_name)
+ }
+ end
+
+ def subscribed_to_resource?(resource_name)
+ @webhooks_subscriber.subscriptions&.any? { |event| event.include? "#{resource_name}." }
+ end
+ end
+ end
+end