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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Added universal progress bar component (#12879)
Damian Legawiec745381af4192
diff --git a/admin/app/helpers/spree/admin/base_helper.rb b/admin/app/helpers/spree/admin/base_helper.rbindex 2aedd2ec84..0094bdd678 100644--- a/admin/app/helpers/spree/admin/base_helper.rb+++ b/admin/app/helpers/spree/admin/base_helper.rb@@ -281,6 +281,23 @@ module Spreeendend+ # renders a progress bar component+ # @param options [Hash] the options for the component+ # @param value [Integer] the value of the progress bar+ # @option options [Integer] :min the minimum value of the progress bar+ # @option options [Integer] :max the maximum value of the progress bar+ # @return [String] the component+ def progress_bar_component(value, options = {})+ min = options[:min] || 0+ max = options[:max] || 100+ percentage = (value.to_f / max * 100).round++ content_tag(:div, class: 'progress') do+ content_tag(:div, { class: 'progress-bar', role: 'progressbar', style: "width: #{percentage}%", aria: { valuenow: value, valuemin: min, valuemax: max } }) do+ end+ end+ end+# returns the allowed file types for upload, according to the active storage configuration# @return [Array<String>] the allowed file types for upload, eg. ['image/png', 'image/jpeg', 'image/gif', 'image/webp']def allowed_file_types_for_uploaddiff --git a/admin/app/views/spree/admin/dashboard/_setup_progress.html.erb b/admin/app/views/spree/admin/dashboard/_setup_progress.html.erbindex 7dc5caa273..0e88abd99c 100644--- a/admin/app/views/spree/admin/dashboard/_setup_progress.html.erb+++ b/admin/app/views/spree/admin/dashboard/_setup_progress.html.erb@@ -12,8 +12,7 @@</span></span></div>- <div class="progress">- <div class="progress-bar bg-success" style="width: <%= current_store.setup_percentage %>%" role="progressbar" aria-valuenow="<%= current_store.setup_percentage %>" aria-valuemin="0" aria-valuemax="100"></div>- </div>++ <%= progress_bar_component(current_store.setup_percentage) %></div></div>\ No newline at end of filediff --git a/admin/app/views/spree/admin/promotions/_sidebar.html.erb b/admin/app/views/spree/admin/promotions/_sidebar.html.erbindex 4efac2ad93..f17f01d732 100644--- a/admin/app/views/spree/admin/promotions/_sidebar.html.erb+++ b/admin/app/views/spree/admin/promotions/_sidebar.html.erb@@ -2,7 +2,6 @@<% coupon_codes_count = @promotion.coupon_codes.count %><% if coupon_codes_count.positive? %><% used_coupon_codes_count = @promotion.coupon_codes.used.count %>- <% remaining_coupon_codes_count = coupon_codes_count - used_coupon_codes_count %><div class="card mb-4"><div class="card-header d-flex justify-content-between">@@ -12,9 +11,7 @@<%= link_to_with_icon 'eye', Spree.t(:view), spree.admin_promotion_coupon_codes_path(@promotion), class: 'btn btn-sm btn-light' %></div><div class="card-body">- <div class="progress">- <div class="progress-bar" role="progressbar" style="width: <%= (used_coupon_codes_count.to_f / coupon_codes_count * 100).round %>%" aria-valuenow="<%= used_coupon_codes_count %>" aria-valuemin="0" aria-valuemax="<%= coupon_codes_count %>"></div>- </div>+ <%= progress_bar_component(used_coupon_codes_count, max: coupon_codes_count) %></div><div class="card-footer d-flex justify-content-between"><span class="badge badge-light">