spree_cm_commissioner 2.5.4 → 2.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d93944d0194c1c575eca6f946b9b616ba4772fba61151fbc9b605464d87cb46
4
- data.tar.gz: a0f1f687982be229cf5958a5f0ba0077eac693166dde8587c9a69df8bbf6caae
3
+ metadata.gz: d077884a4c72aea34ebabce75fcc9ad8c032d20eb6ee2cad7c753bb544d28b1c
4
+ data.tar.gz: d89d2c942374c0342b6fc5447220eee3d72773c0578afc0b45a08b390b51a624
5
5
  SHA512:
6
- metadata.gz: 978c11238f4ba63ff0e9e41444ca8d67046eab18d924996ad03dd4c64fe725285f225db7a9f8345220e60cb91b4147f915b8096eefc40c15453f2a090e115000
7
- data.tar.gz: 9256c928528ebd0911aa5c4083ce477821d5117cfa379d205f8667fcbca17bd5e5f2052839d67079bf5627a4a56747f0e45d4ccb236c97831c6de6bdf45fec81
6
+ metadata.gz: 41dbb774e8f9d97dee38db2e23ed4741f2888b73a41660c77c968bedb7c26d9de747587cc8779a3ac93e16ef88a11e0f1ce276bc562252776218218423d47538
7
+ data.tar.gz: e95ac81f757dcdabafd539957ad2945dda624348a72e06f2490e24fabfdc8bc5b53fdee24a62b66dd807349996152a2dad334ecea387cfe37c73c58707b58237
data/.env.example CHANGED
@@ -31,3 +31,12 @@ ORGANIZER_URL=http://127.0.0.1:4000/organizer
31
31
  # Use to sign & verify Distance object:
32
32
  # spree_cm_commissioner/distance.rb
33
33
  DISTANCE_SIGNING_KEY=hei********************VY
34
+
35
+ # Cache durations (in seconds) for different content types
36
+ # See: app/controllers/concerns/spree_cm_commissioner/content_cachable.rb
37
+ CACHE_CDN_MAX_AGE=86400 # CDN/server-side cache duration for all responses
38
+ CACHE_STATIC_MAX_AGE=86400 # Static content (countries, provinces, seat layouts, CMS pages) - 1 day
39
+ CACHE_SEMI_STATIC_MAX_AGE=3600 # Semi-static content (menus, homepage backgrounds, routes) - 1 hour
40
+ CACHE_MODERATE_MAX_AGE=1800 # Moderate freshness (products, events, vendors) - 30 minutes
41
+ CACHE_REALTIME_MAX_AGE=300 # High freshness (trips, trip search) - 5 minutes
42
+ CACHE_DEFAULT_MAX_AGE=300 # Default for unlisted controllers - 5 minutes
data/Gemfile.lock CHANGED
@@ -34,7 +34,7 @@ GIT
34
34
  PATH
35
35
  remote: .
36
36
  specs:
37
- spree_cm_commissioner (2.5.4)
37
+ spree_cm_commissioner (2.5.6)
38
38
  activerecord-multi-tenant
39
39
  activerecord_json_validator (~> 2.1, >= 2.1.3)
40
40
  aws-sdk-cloudfront
@@ -3,22 +3,22 @@ module Spree
3
3
  class InventoryItemsController < StockManagementsController
4
4
  before_action :load_parent
5
5
 
6
- # GET /products/:slug/inventory_items/prices?inventory_ids=1,2,3
6
+ # GET /products/:slug/inventory_items/prices?inventory_item_ids=1,2,3
7
7
  def prices
8
- inventory_ids = params[:inventory_ids].to_s.split(',').map(&:to_i)
9
- @inventory_items = @product.inventory_items.where(id: inventory_ids)
8
+ inventory_item_ids = params[:inventory_item_ids]
9
+ @inventory_items = @product.inventory_items.where(id: inventory_item_ids)
10
10
  end
11
11
 
12
- # GET /products/:slug/inventory_items/stocks?inventory_ids=1,2,3
12
+ # GET /products/:slug/inventory_items/stocks?inventory_item_ids=1,2,3
13
13
  def stocks
14
- inventory_ids = params[:inventory_ids].to_s.split(',').map(&:to_i)
15
- @inventory_items = @product.inventory_items.where(id: inventory_ids)
14
+ inventory_item_ids = params[:inventory_item_ids]
15
+ @inventory_items = @product.inventory_items.where(id: inventory_item_ids)
16
16
  end
17
17
 
18
18
  # PATCH /products/:slug/inventory_items/bulk_update_prices
19
19
  def bulk_update_prices # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
20
- inventory_ids = params[:inventory_ids].to_s.split(',').map(&:to_i)
21
- inventory_items = @product.inventory_items.where(id: inventory_ids)
20
+ inventory_item_ids = params[:inventory_item_ids]
21
+ inventory_items = @product.inventory_items.where(id: inventory_item_ids)
22
22
 
23
23
  inventory_items.each do |inventory_item|
24
24
  params[:prices]&.values&.each do |price_params|
@@ -38,8 +38,8 @@ module Spree
38
38
 
39
39
  # PATCH /products/:slug/inventory_items/bulk_update_stocks
40
40
  def bulk_update_stocks
41
- inventory_ids = params[:inventory_ids].to_s.split(',').map(&:to_i)
42
- inventory_items = @product.inventory_items.where(id: inventory_ids)
41
+ inventory_item_ids = params[:inventory_item_ids]
42
+ inventory_items = @product.inventory_items.where(id: inventory_item_ids)
43
43
  target_quantity = params[:quantity].to_i
44
44
 
45
45
  if target_quantity.zero?
@@ -58,6 +58,26 @@ module Spree
58
58
  flash[:success] = "Successfully updated stocks for #{inventory_items.count} items"
59
59
  redirect_back fallback_location: admin_product_stock_managements_path(@product)
60
60
  end
61
+
62
+ # PATCH /products/:slug/inventory_items/bulk_reset?inventory_item_ids=1,2,3
63
+ def bulk_reset
64
+ inventory_item_ids = params[:inventory_item_ids]
65
+ inventory_items = @product.inventory_items.where(id: inventory_item_ids)
66
+
67
+ errors = []
68
+ inventory_items.each do |inventory_item|
69
+ result = SpreeCmCommissioner::Stock::InventoryItemResetter.call(inventory_item: inventory_item)
70
+ errors << result.message unless result.success?
71
+ end
72
+
73
+ if errors.empty?
74
+ flash[:success] = "Successfully reset inventory items (#{inventory_items.count})"
75
+ else
76
+ flash[:error] = errors.join(', ')
77
+ end
78
+
79
+ redirect_back fallback_location: admin_product_stock_managements_path(@product)
80
+ end
61
81
  end
62
82
  end
63
83
  end
@@ -11,9 +11,7 @@
11
11
  <p class="mb-0 text-white position-relative"><%= @inventory_items.count %> items selected</p>
12
12
  </div>
13
13
 
14
- <%= form_with url: bulk_update_prices_admin_product_inventory_items_path(@product), method: :patch, local: true, html: { class: 'bulk-inventory-items-form' } do |form| %>
15
- <%= form.hidden_field :inventory_ids, value: params[:inventory_ids] %>
16
-
14
+ <%= form_with url: bulk_update_prices_admin_product_inventory_items_path(@product, inventory_item_ids: params[:inventory_item_ids]), method: :patch, local: true, html: { class: 'bulk-inventory-items-form' } do |form| %>
17
15
  <table class="table">
18
16
  <tbody>
19
17
  <% supported_currencies_for_all_stores.each do |currency| %>
@@ -11,9 +11,7 @@
11
11
  <p class="mb-0 text-white position-relative"><%= @inventory_items.count %> items selected</p>
12
12
  </div>
13
13
 
14
- <%= form_with url: bulk_update_stocks_admin_product_inventory_items_path(@product), method: :patch, local: true, html: { class: 'bulk-inventory-items-form' } do |form| %>
15
- <%= form.hidden_field :inventory_ids, value: params[:inventory_ids] %>
16
-
14
+ <%= form_with url: bulk_update_stocks_admin_product_inventory_items_path(@product, inventory_item_ids: params[:inventory_item_ids]), method: :patch, local: true, html: { class: 'bulk-inventory-items-form' } do |form| %>
17
15
  <div class="form-group">
18
16
  <%= form.label :quantity, "Available Quantity", class: 'form-label' %>
19
17
  <%= form.number_field :quantity,
@@ -2,22 +2,22 @@
2
2
  <div class="flex-wrap gap-3 mt-4 d-flex align-items-center justify-content-between">
3
3
  <%= form_with url: admin_product_stock_managements_path, method: :get, class: "d-flex flex-wrap align-items-center gap-2" do |f| %>
4
4
  <%= select_year(params[:year]&.to_i || @year, { start_year: 2025, end_year: @year + 3 }, { class: 'form-control', style: "width: auto;", name: "year", onchange: "this.form.submit()" }) %>
5
- <%= f.select :selected_variant_id,
5
+ <%= f.select :selected_variant_id,
6
6
  options_for_select([["All Variants", ""]] + @variants.map { |v| [v.options_text.presence || "N/A", v.id] }, params[:selected_variant_id]), {},
7
7
  { class: "form-control", style: "width: auto;", onchange: "this.form.submit()" } %>
8
8
  <% end %>
9
9
 
10
10
  <div id="bulkActionsBar" class="flex-wrap gap-2 align-items-center" style="display:none;">
11
- <button class="btn btn-primary"
11
+ <button class="btn btn-primary"
12
12
  onclick="setModalUrl('prices')"
13
- data-toggle="modal"
13
+ data-toggle="modal"
14
14
  data-target="#inventoryItemModal">
15
15
  <%= svg_icon name: "money.svg", width: '18', height: '18' %>
16
16
  <span class="ml-1">Bulk Update Prices</span>
17
17
  </button>
18
- <button class="btn btn-success"
18
+ <button class="btn btn-success"
19
19
  onclick="setModalUrl('stocks')"
20
- data-toggle="modal"
20
+ data-toggle="modal"
21
21
  data-target="#inventoryItemModal">
22
22
  <%= svg_icon name: "box-seam.svg", width: '18', height: '18' %>
23
23
  <span class="ml-1">Bulk Update Stocks</span>
@@ -32,11 +32,11 @@
32
32
  .gap-2 {
33
33
  gap: 0.5rem;
34
34
  }
35
-
35
+
36
36
  .gap-3 {
37
37
  gap: 1rem;
38
38
  }
39
-
39
+
40
40
  .day-selected {
41
41
  background-color: #e3f2fd !important;
42
42
  border: 2px solid #2196F3 !important;
@@ -137,10 +137,15 @@
137
137
  }
138
138
 
139
139
  function setModalUrl(type) {
140
- const ids = Array.from(selectedInventoryIds).join(',');
141
- const url = type === 'prices'
142
- ? '<%= prices_admin_product_inventory_items_path(@product) %>?inventory_ids=' + ids
143
- : '<%= stocks_admin_product_inventory_items_path(@product) %>?inventory_ids=' + ids;
140
+ const params = new URLSearchParams();
141
+ Array.from(selectedInventoryIds).forEach(id =>
142
+ params.append('inventory_item_ids[]', id)
143
+ );
144
+
145
+ const url = type === 'prices'
146
+ ? `<%= prices_admin_product_inventory_items_path(@product) %>?${params.toString()}`
147
+ : `<%= stocks_admin_product_inventory_items_path(@product) %>?${params.toString()}`;
148
+
144
149
  let frame = document.getElementById('inventory_item');
145
150
  frame.innerHTML = `<div class="mt-2 spinner-border" role="status"></div>`;
146
151
  frame.setAttribute('src', url);
@@ -37,19 +37,6 @@
37
37
  </div>
38
38
  <% end if can?(:update, @product) && can?(:update, variant) %>
39
39
 
40
- <% if defined?(@reserved_stocks) %>
41
- <div>
42
- <%= svg_icon name: "cart-check.svg", width: '14', height: '14' %>
43
- <%= label_tag "reserved_stock#{variant.id}", "Reserved Stock: #{@reserved_stocks[variant.id] || 0}", class: "m-0" %>
44
- <%= link_to_with_icon('capture.svg', "Create Inventory Item", admin_product_inventory_items_path(@product.slug, variant_id: variant.id),
45
- method: :post,
46
- remote: false,
47
- class: 'icon_link btn btn-sm btn-outline-primary ml-2',
48
- no_text: true
49
- ) unless @inventory_items[variant.id].present? %>
50
- </div>
51
- <% end %>
52
-
53
40
  <% if variant.permanent_stock? %>
54
41
  <div>
55
42
  <span type="button" data-toggle="popover" data-trigger="hover" data-placement="right" data-content="This product stock will renew every day">
@@ -78,7 +65,7 @@
78
65
  <% end %>
79
66
  </span>
80
67
 
81
- <%= link_to_with_icon('arrow-counterclockwise.svg', "Reset Inventory Item", reset_admin_product_inventory_item_path(@product.slug, inventory_item.id),
68
+ <%= link_to_with_icon('arrow-counterclockwise.svg', "Reset Inventory Item", bulk_reset_admin_product_inventory_items_path(@product, inventory_item_ids: [inventory_item.id]),
82
69
  method: :patch,
83
70
  remote: false,
84
71
  class: 'icon_link btn btn-sm outline text-dark',
data/config/routes.rb CHANGED
@@ -155,6 +155,7 @@ Spree::Core::Engine.add_routes do
155
155
  get :stocks
156
156
  patch :bulk_update_prices
157
157
  patch :bulk_update_stocks
158
+ patch :bulk_reset
158
159
  end
159
160
  end
160
161
 
@@ -1,5 +1,5 @@
1
1
  module SpreeCmCommissioner
2
- VERSION = '2.5.4'.freeze
2
+ VERSION = '2.5.6'.freeze
3
3
 
4
4
  module_function
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_cm_commissioner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.4
4
+ version: 2.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - You
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-30 00:00:00.000000000 Z
11
+ date: 2026-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree