-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #2202 improve set up google wallet
- Loading branch information
1 parent
f17c557
commit 48f39f9
Showing
8 changed files
with
159 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
module Spree | ||
module Admin | ||
module GoogleWalletsHelper | ||
# override | ||
def preference_fields(object, form) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength | ||
return unless object.respond_to?(:preferences) | ||
|
||
fields = object.preferences.keys.map do |key| | ||
next unless object.has_preference?(key) | ||
|
||
next if key == :response | ||
next if key == :verified_at | ||
|
||
if key == :background_color | ||
content_tag(:div, class: 'form-group', id: [object.class.to_s.parameterize, 'preference', key].join('-')) do | ||
form.label("preferred_#{key}", Spree.t(key), class: 'mb-2') + | ||
content_tag(:div, class: 'd-flex') do | ||
preference_field_for(form, "preferred_#{key}", type: object.preference_type(key), class: 'form-control mr-2') + | ||
content_tag(:div, '', class: 'color-preview', | ||
style: "background-color: #{object.preferred_background_color}; | ||
height: 40px; width: 50px; margin-left: 10px; | ||
border-radius: 5px; border: 1px solid #ccc;" | ||
) | ||
end | ||
end | ||
|
||
elsif object.preference_type(key).to_sym == :boolean | ||
content_tag(:div, preference_field_for(form, "preferred_#{key}", type: object.preference_type(key)) + | ||
form.label("preferred_#{key}", Spree.t(key), class: 'form-check-label'), | ||
class: 'form-group form-check', id: [object.class.to_s.parameterize, 'preference', key].join('-') | ||
) | ||
|
||
elsif %i[start_date end_date].include?(key) | ||
content_tag(:div, class: 'form-group', id: "#{object.class.to_s.parameterize}-preference-#{key}") do | ||
form.label("preferred_#{key}", Spree.t(key), class: 'mb-2') + | ||
content_tag(:div, class: 'input-group datePickerTo', data: { | ||
wrap: 'true', 'alt-input': 'true', 'min-date': object.preferred_start_date, 'enable-time': 'true' | ||
} | ||
) do | ||
form.text_field("preferred_#{key}", value: object.send("preferred_#{key}"), class: 'form-control shadow-none', 'data-input' => '') | ||
end | ||
end | ||
|
||
else | ||
content_tag(:div, form.label("preferred_#{key}", Spree.t(key)) + | ||
preference_field_for(form, "preferred_#{key}", type: object.preference_type(key)), | ||
class: 'form-group', id: [object.class.to_s.parameterize, 'preference', key].join('-') | ||
) | ||
end | ||
end | ||
safe_join(fields) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
<%= render partial: 'spree/admin/shared/product_tabs', locals: { current: :google_wallet } %> | ||
|
||
<div class="my-2 mx-1"> | ||
<%= button_to Spree.t(:create), create_google_wallet_class_admin_product_google_wallet_path(@product, @object.id), method: :post, class: 'btn bg-success text-white my-1' %> | ||
<%= button_to Spree.t(:update), update_google_wallet_class_admin_product_google_wallet_path(@product, @object), method: :patch, class: 'btn bg-success text-white my-1' %> | ||
<small class="form-text text-muted"> | ||
<%= raw I18n.t('google_wallet.note') %> | ||
</small> | ||
</div> | ||
|
||
<div data-hook="admin_product_google_wallet_edit_form_header"> | ||
<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @object } %> | ||
<div class="card card-body mb-3"> | ||
<div data-hook="active" class="form-group"> | ||
<strong><%= Spree.t(:verified) %></strong> | ||
<%= active_badge(@object.verified?) %> | ||
</div> | ||
|
||
<div data-hook="admin_product_google_wallet_edit_form"> | ||
<%= form_with model: @object, url: { action: 'update' } do |f| %> | ||
<%= render partial: 'form', locals: { f: f } %> | ||
<div data-hook="admin_product_google_wallet_form_buttons"> | ||
<%= render partial: 'spree/admin/shared/edit_resource_links' %> | ||
<% if @object.verified_at.present? %> | ||
<div data-hook="verified-at" class="form-group"> | ||
<p><%= Spree.t(:verified_at) %>: <%= @object.verified_at %></p> | ||
</div> | ||
<% end %> | ||
|
||
<%= button_to Spree.t('verify_with_google_wallet'), | ||
verify_with_google_admin_product_google_wallet_path(@product, @object), | ||
method: :post, | ||
class: 'btn btn-outline-primary my-1', | ||
disabled: @object.verified? %> | ||
|
||
<% end %> | ||
<small class="form-text text-muted"> | ||
<%= raw I18n.t('google_wallet.note') %> | ||
</small> | ||
</div> | ||
|
||
|
||
<div data-hook="admin_product_google_wallet_edit_form_header"> | ||
<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @object } %> | ||
<div data-hook="admin_product_google_wallet_edit_form"> | ||
<%= form_with model: @object, url: { action: 'update' } do |f| %> | ||
<%= render partial: 'form', locals: { f: f } %> | ||
<div data-hook="admin_product_google_wallet_form_buttons"> | ||
<%= render partial: 'spree/admin/shared/edit_resource_links' %> | ||
</div> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters