spree_cm_commissioner 1.17.0.pre.pre4 → 1.17.0.pre.pre6

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: 27eaa71cfc36b120e800e8d027a0bac70c7896a47349b57334e9b311f1a8bfa4
4
- data.tar.gz: 3721c925d915dc0e02660abf2abefbc42e62e66ace288f9bc57c0d8adf23b335
3
+ metadata.gz: 22af33dbb7a3b02cec407695525b7745f8fee24b4b6fd60d5a18b85c5fd3566e
4
+ data.tar.gz: 4dc584a0641e4463531a66ef87d2b596b69dd41edd9d11c498fa80569b5aadae
5
5
  SHA512:
6
- metadata.gz: 764f2f2ea0a5894c6a0110264f497a2d879b23c58951c46cfcbae15bf752b9c63cd7401adb353981d1e4ef7c1e58d0991668397ffda4b7f9ab6431b5bad6403b
7
- data.tar.gz: 8030d23be060aa290f79ed06cb25cf0caa6250aa677b59b9f5410def6269a62f8d7948c3e030618c0906954a5a0e11e5b9fce1a690adc8872115c5ed4c545aa5
6
+ metadata.gz: f3486c5f18f49a85918ed8b6f78440955fbff5f86820b66327b36eb028ffb884517428ecf4a822301d73b91c3f0ce729f9285381c91ee58fce424f03efce9e41
7
+ data.tar.gz: a1c6454f5da6873e47cd7ffc4cda002a879ad764d72c925cb8d83dc0b645e5f34b3d0a19c80652b7666c8e4c968210f3e59c2b8e9fe458019f115cde5a18caa8
data/Gemfile.lock CHANGED
@@ -34,7 +34,7 @@ GIT
34
34
  PATH
35
35
  remote: .
36
36
  specs:
37
- spree_cm_commissioner (1.17.0.pre.pre4)
37
+ spree_cm_commissioner (1.17.0.pre.pre6)
38
38
  activerecord-multi-tenant
39
39
  activerecord_json_validator (~> 2.1, >= 2.1.3)
40
40
  aws-sdk-cloudfront
@@ -1,87 +1,65 @@
1
- function getAssetUrl(path) {
2
- if (!path) return '';
3
- if (path.startsWith('http') || path.startsWith('//') || path.startsWith('/')) {
4
- return path;
1
+ document.addEventListener('DOMContentLoaded', function () {
2
+ // Initialize Select2 for all tenant-payment-icon-select elements
3
+ if (window.$ && $.fn.select2) {
4
+ $('.tenant-payment-icon-select').each(function () {
5
+ $(this).select2({
6
+ width: '100%'
7
+ });
8
+ });
5
9
  }
6
- return '/assets/' + path;
7
- }
8
10
 
9
- function removeIcon(fieldId) {
10
- const field = document.getElementById(fieldId);
11
- const preview = document.getElementById('preview_' + fieldId);
12
- const removeBtn = document.getElementById('remove_' + fieldId);
11
+ // Handle icon selection change
12
+ document.querySelectorAll('.tenant-payment-icon-select').forEach(function (select) {
13
+ select.addEventListener('change', function (e) {
14
+ const field = e.target.name.match(/\[([^\]]*)\]$/)[1]; // Extract field name
15
+ const preview = document.getElementById(`icon-preview-${field}`);
16
+ const removeBtn = document.querySelector(`.remove-icon-btn[data-target="${field}"]`);
17
+ const iconPath = e.target.value;
13
18
 
14
- if (field) {
15
- field.value = '';
16
- }
17
- if (preview) {
18
- preview.src = '';
19
- preview.style.display = 'none';
20
- }
21
- if (removeBtn) {
22
- removeBtn.classList.add('hidden');
23
- }
19
+ if (!preview || !removeBtn) return;
24
20
 
25
- const $select = $(".select2-icon-picker[data-target-field='" + fieldId + "']");
26
- if ($select.length) {
27
- $select.val(null).trigger('change');
28
- }
29
- }
30
-
31
- function formatIconOption(icon) {
32
- if (!icon.id) return icon.text;
33
- return $(`<span>
34
- <img src="${getAssetUrl(icon.id)}" style="height:20px;width:auto;margin-right:5px;" />
35
- ${icon.text}
36
- </span>`);
37
- }
38
-
39
- function formatIconSelection(icon) {
40
- if (!icon.id) return icon.text;
41
- return $(`<span>
42
- <img src="${getAssetUrl(icon.id)}" style="height:20px;width:auto;margin-right:5px;" />
43
- ${icon.text}
44
- </span>`);
45
- }
21
+ if (!iconPath) {
22
+ preview.innerHTML = '<span class="no-icon-placeholder"></span>';
23
+ removeBtn.classList.add('hidden');
24
+ return;
25
+ }
46
26
 
47
- document.addEventListener("turbo:load", function () {
48
- $('.select2-icon-picker').each(function () {
49
- if ($(this).hasClass("select2-hidden-accessible")) {
50
- $(this).select2('destroy');
51
- }
27
+ // Fetch SVG for the selected icon
28
+ fetch(`/admin/vector_icons/svg?path=${encodeURIComponent(iconPath)}`)
29
+ .then((response) => {
30
+ if (!response.ok) throw new Error('Failed to fetch SVG');
31
+ return response.text();
32
+ })
33
+ .then((svg) => {
34
+ preview.innerHTML = svg;
35
+ removeBtn.classList.remove('hidden');
36
+ })
37
+ .catch((error) => {
38
+ console.error('Error fetching SVG:', error);
39
+ preview.innerHTML = '<span class="no-icon-placeholder">Error loading icon</span>';
40
+ });
41
+ });
52
42
  });
53
43
 
54
- $('.select2-icon-picker').select2({
55
- width: '100%',
56
- allowClear: true,
57
- placeholder: 'None',
58
- templateResult: formatIconOption,
59
- templateSelection: formatIconSelection
60
- });
44
+ document.addEventListener('click', function (e) {
45
+ if (!e.target.classList.contains('remove-icon-btn')) return;
61
46
 
62
- $('.select2-icon-picker').on('select2:select', function (e) {
63
- const selectedIcon = e.params.data.id;
64
- const fieldId = $(this).data('target-field');
65
- const previewId = $(this).data('target_preview');
66
- const removeBtnId = $(this).data('remove_btn');
47
+ const field = e.target.getAttribute('data-target');
48
+ const select = document.querySelector(`.tenant-payment-icon-select[name*="[${field}]"]`);
49
+ const preview = document.getElementById(`icon-preview-${field}`);
50
+ const removeBtn = e.target;
67
51
 
68
- const field = document.getElementById(fieldId);
69
- const preview = document.getElementById(previewId);
70
- const removeBtn = document.getElementById(removeBtnId);
52
+ if (!select || !preview || !removeBtn) return;
71
53
 
72
- if (field) {
73
- field.value = selectedIcon;
74
- }
75
- if (preview) {
76
- preview.src = getAssetUrl(selectedIcon);
77
- preview.style.display = selectedIcon ? 'inline' : 'none';
78
- }
79
- if (removeBtn) {
80
- if (selectedIcon) {
81
- removeBtn.classList.remove('hidden');
82
- } else {
83
- removeBtn.classList.add('hidden');
84
- }
54
+ // Clear the select input
55
+ select.value = '';
56
+
57
+ if (window.$ && $(select).hasClass('select2-hidden-accessible')) {
58
+ $(select).val('').trigger('change.select2');
59
+ } else {
60
+ select.dispatchEvent(new Event('change', { bubbles: true }));
85
61
  }
62
+ preview.innerHTML = '<span class="no-icon-placeholder"></span>';
63
+ removeBtn.classList.add('hidden');
86
64
  });
87
65
  });
@@ -1,14 +1,27 @@
1
1
  .payment-icon-preview {
2
- max-height: 60px;
3
- max-width: 120px;
4
- min-height: 60px;
5
- min-width: 120px;
2
+ width: 80px;
3
+ height: 80px;
6
4
  background: #f8f9fa;
7
5
  border: 1px dashed #ccc;
8
- display: inline-block;
9
- object-fit: contain;
6
+ display: inline-flex;
7
+ align-items: center;
8
+ justify-content: center;
10
9
  cursor: pointer;
11
- position: relative;
10
+ }
11
+
12
+ .payment-icon-preview svg {
13
+ width: 100%;
14
+ height: 100%;
15
+ object-fit: contain;
16
+ }
17
+
18
+
19
+ .no-icon-placeholder {
20
+ width: 40px;
21
+ height: 40px;
22
+ border: 1px dashed #ddd;
23
+ background: #f8f9fa;
24
+ display: inline-block;
12
25
  }
13
26
 
14
27
  .icon-preview-container {
@@ -44,4 +57,4 @@
44
57
 
45
58
  .remove-icon-btn.hidden {
46
59
  display: none;
47
- }
60
+ }
@@ -47,21 +47,22 @@
47
47
  <div class="col-12">
48
48
  <%= f.field_container :preferred_assetlinks do %>
49
49
  <%= f.label :preferred_assetlinks, raw(Spree.t(:assetlinks)) %>
50
- <%= f.text_area :preferred_assetlinks, class: 'form-control', rows: 5, placeholder: <<~JSON.strip
51
- example:
52
- [
53
- {
54
- "relation": ["delegate_permission/common.handle_all_urls"],
55
- "target": {
56
- "namespace": "android_app",
57
- "package_name": "com.yourapp.app",
58
- "sha256_cert_fingerprints": [
59
- "SHA256_CERTIFICATE_FINGERPRINT_HERE"
50
+ <%= f.text_area :preferred_assetlinks, class: 'form-control', rows: 5,
51
+ placeholder: <<~JSON.strip
52
+ example:
53
+ [
54
+ {
55
+ "relation": ["delegate_permission/common.handle_all_urls"],
56
+ "target": {
57
+ "namespace": "android_app",
58
+ "package_name": "com.yourapp.app",
59
+ "sha256_cert_fingerprints": [
60
+ "SHA256_CERTIFICATE_FINGERPRINT_HERE"
61
+ ]
62
+ }
63
+ }
60
64
  ]
61
- }
62
- }
63
- ]
64
- JSON
65
+ JSON
65
66
  %>
66
67
  <% if f.object.errors[:preferred_assetlinks].any? %>
67
68
  <div class="error text-danger"><%= f.object.errors[:preferred_assetlinks].join(', ') %></div>
@@ -73,25 +74,26 @@
73
74
  <div class="col-12">
74
75
  <%= f.field_container :preferred_apple_app_site_association do %>
75
76
  <%= f.label :preferred_apple_app_site_association, raw(Spree.t(:apple_app_site_association)) %>
76
- <%= f.text_area :preferred_apple_app_site_association, class: 'form-control', rows: 5, placeholder: <<~JSON.strip
77
- example:
78
- {
79
- "webcredentials": {
80
- "apps": [
81
- "TEAM_ID.com.yourapp.app"
82
- ]
83
- },
84
- "applinks": {
85
- "apps": [],
86
- "details": [
77
+ <%= f.text_area :preferred_apple_app_site_association, class: 'form-control', rows: 5,
78
+ placeholder: <<~JSON.strip
79
+ example:
87
80
  {
88
- "appID": "TEAM_ID.com.yourapp.app",
89
- "paths": ["*"]
81
+ "webcredentials": {
82
+ "apps": [
83
+ "TEAM_ID.com.yourapp.app"
84
+ ]
85
+ },
86
+ "applinks": {
87
+ "apps": [],
88
+ "details": [
89
+ {
90
+ "appID": "TEAM_ID.com.yourapp.app",
91
+ "paths": ["*"]
92
+ }
93
+ ]
94
+ }
90
95
  }
91
- ]
92
- }
93
- }
94
- JSON
96
+ JSON
95
97
  %>
96
98
  <% if f.object.errors[:preferred_apple_app_site_association].any? %>
97
99
  <div class="error text-danger"><%= f.object.errors[:preferred_apple_app_site_association].join(', ') %></div>
@@ -115,55 +117,45 @@
115
117
  </div>
116
118
 
117
119
  <div data-hook="admin_tenant_form_fields" class="row">
118
- <% [
119
- { field: :preferred_payment_checkout_image, label: :payment_checkout_image },
120
- { field: :preferred_payment_failed_image, label: :payment_failed_image },
121
- { field: :preferred_payment_success_image, label: :payment_success_image },
122
- { field: :preferred_payment_loader, label: :payment_loader }
123
- ].each do |config| %>
124
- <div class="col-6">
125
- <div class="card mb-3">
126
- <div class="card-body text-center">
127
- <%= f.field_container config[:field] do %>
128
- <%= f.label config[:field], raw(Spree.t(config[:label])), class: 'font-weight-bold' %>
120
+ <div class="col-12">
121
+ <div class="row gy-4">
122
+ <% payment_icon_fields = [
123
+ { field: :preferred_payment_checkout_image, label: Spree.t(:payment_checkout_image), target: 'checkout' },
124
+ { field: :preferred_payment_failed_image, label: Spree.t(:payment_failed_image), target: 'failed' },
125
+ { field: :preferred_payment_success_image, label: Spree.t(:payment_success_image), target: 'success' },
126
+ { field: :preferred_payment_loader, label: Spree.t(:payment_loader), target: 'loader' }
127
+ ] %>
128
+
129
+ <% payment_icon_fields.each do |icon| %>
130
+ <div class="col-md-3">
131
+ <%= f.field_container icon[:field] do %>
132
+ <div class="d-flex flex-column align-items-center text-center">
133
+ <label class="form-label fw-bold mb-2" for="tenant_<%= icon[:field] %>">
134
+ <%= icon[:label] %>
135
+ </label>
129
136
 
130
- <div class="mb-2">
131
- <div class="icon-preview-container">
132
- <% value = f.object.send(config[:field]) %>
133
- <% if value.present? %>
134
- <%= image_tag asset_path(value), alt: "#{Spree.t(config[:label])}", class: 'img-thumbnail bg-light border payment-icon-preview', id: "preview_#{config[:field]}" %>
135
- <% end %>
136
- <button
137
- type="button"
138
- class="remove-icon-btn <%= 'hidden' unless value.present? %>"
139
- id="remove_<%= config[:field] %>"
140
- title="Remove icon"
141
- onclick="removeIcon('<%= config[:field] %>')"
142
- >
143
- &times;
144
- </button>
137
+ <div class="icon-preview-container mb-2" id="icon-preview-container-<%= icon[:field] %>">
138
+ <span class="payment-icon-preview" id="icon-preview-<%= icon[:field] %>">
139
+ <% if f.object.send(icon[:field]).present? %>
140
+ <%= render_vector_icon(f.object.send(icon[:field])) %>
141
+ <% else %>
142
+ <span class="no-icon-placeholder"></span>
143
+ <% end %>
144
+ </span>
145
+ <span class="remove-icon-btn <%= 'hidden' unless f.object.send(icon[:field]).present? %>" data-target="<%= icon[:field] %>">&times;</span>
145
146
  </div>
146
147
  </div>
147
148
 
148
- <%= f.select config[:field],
149
- options_for_select(
150
- @vector_icons&.map { |icon| [icon.path, icon.path] },
151
- f.object.send(config[:field])
152
- ),
153
- { include_blank: 'None' },
154
- class: 'form-control select2-icon-picker',
155
- data: {
156
- target_field: config[:field],
157
- target_preview: "preview_#{config[:field]}",
158
- remove_btn: "remove_#{config[:field]}"
159
- } %>
160
-
161
- <% if f.object.errors[config[:field]].any? %>
162
- <div class="error text-danger"><%= f.object.errors[config[:field]].join(', ') %></div>
149
+ <%= f.collection_select icon[:field],
150
+ @vector_icons, :path, :path,
151
+ { include_blank: 'None' },
152
+ { class: 'select2 form-control tenant-payment-icon-select mt-2', data: { target: icon[:target] } } %>
153
+ <% if f.object.errors[icon[:field]].any? %>
154
+ <div class="text-danger small mt-1"><%= f.object.errors[icon[:field]].join(', ') %></div>
163
155
  <% end %>
164
156
  <% end %>
165
157
  </div>
166
- </div>
158
+ <% end %>
167
159
  </div>
168
- <% end %>
160
+ </div>
169
161
  </div>
@@ -1,5 +1,5 @@
1
1
  module SpreeCmCommissioner
2
- VERSION = '1.17.0-pre4'.freeze
2
+ VERSION = '1.17.0-pre6'.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: 1.17.0.pre.pre4
4
+ version: 1.17.0.pre.pre6
5
5
  platform: ruby
6
6
  authors:
7
7
  - You
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-02 00:00:00.000000000 Z
11
+ date: 2025-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree