-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2798 from jtapia/chore/store_credit_reasons
Store credit reasons
- Loading branch information
Showing
30 changed files
with
257 additions
and
85 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
backend/app/controllers/spree/admin/store_credit_reasons_controller.rb
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,8 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spree | ||
module Admin | ||
class StoreCreditReasonsController < ResourceController | ||
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
15 changes: 15 additions & 0 deletions
15
backend/app/views/spree/admin/store_credit_reasons/edit.html.erb
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,15 @@ | ||
<%= render 'spree/admin/shared/settings_checkout_tabs' %> | ||
|
||
<% admin_breadcrumb t('spree.settings') %> | ||
<% admin_breadcrumb t('spree.admin.tab.checkout') %> | ||
<% admin_breadcrumb link_to plural_resource_name(Spree::StoreCreditReason), spree.admin_store_credit_reasons_path %> | ||
<% admin_breadcrumb @object.name %> | ||
|
||
<%= render partial: 'spree/shared/error_messages', locals: { target: @object } %> | ||
|
||
<%= form_for [:admin, @object] do |f| %> | ||
<fieldset class='no-border-top' data-hook='edit_store_credit_reason'> | ||
<%= render partial: 'spree/admin/store_credit_reasons/shared/form', locals: { f: f } %> | ||
<%= render partial: 'spree/admin/shared/edit_resource_links' %> | ||
</fieldset> | ||
<% end %> |
56 changes: 56 additions & 0 deletions
56
backend/app/views/spree/admin/store_credit_reasons/index.html.erb
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,56 @@ | ||
<%= render 'spree/admin/shared/settings_checkout_tabs' %> | ||
|
||
<% admin_breadcrumb(t('spree.settings')) %> | ||
<% admin_breadcrumb(t('spree.admin.tab.checkout')) %> | ||
<% admin_breadcrumb(plural_resource_name(Spree::StoreCreditReason)) %> | ||
|
||
<% content_for :page_actions do %> | ||
<ul class='actions inline-menu'> | ||
<li> | ||
<%= link_to t('spree.new_adjustment_reason'), new_object_url, id: 'admin_new_named_type', class: 'btn btn-primary' %> | ||
</li> | ||
</ul> | ||
<% end %> | ||
|
||
<% if @collection.any? %> | ||
<table class='index' id='listing_store_credit_reasons'> | ||
<colgroup> | ||
<col style='width: 65%' /> | ||
<col style='width: 20%' /> | ||
<col style='width: 15%' /> | ||
</colgroup> | ||
<thead> | ||
<tr data-hook='store_credit_reasons_header'> | ||
<th><%= Spree::StoreCreditReason.human_attribute_name(:name) %></th> | ||
<th><%= Spree::StoreCreditReason.human_attribute_name(:state) %></th> | ||
<th class='actions'></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @collection.each do |store_credit_reason| %> | ||
<tr id='<%= spree_dom_id store_credit_reason %>' data-hook='store_credit_reason_row'> | ||
<td> | ||
<%= store_credit_reason.name %> | ||
</td> | ||
<td> | ||
<span class="pill pill-<%= store_credit_reason.active? ? 'active' : 'inactive' %>"> | ||
<%= t(store_credit_reason.active? ? :active : :inactive, scope: 'spree') %> | ||
</span> | ||
</td> | ||
<td class='actions'> | ||
<%= link_to_edit store_credit_reason, no_text: true %> | ||
<% if can?(:destroy, store_credit_reason) %> | ||
<%= link_to_delete store_credit_reason, no_text: true %> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
<% else %> | ||
<div class='no-objects-found'> | ||
<%= render 'spree/admin/shared/no_objects_found', | ||
resource: Spree::StoreCreditReason, | ||
new_resource_url: new_object_url %> | ||
</div> | ||
<% end %> |
18 changes: 18 additions & 0 deletions
18
backend/app/views/spree/admin/store_credit_reasons/new.html.erb
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,18 @@ | ||
<%= render 'spree/admin/shared/settings_checkout_tabs' %> | ||
|
||
<% admin_breadcrumb(t('spree.settings')) %> | ||
<% admin_breadcrumb(t('spree.admin.tab.checkout')) %> | ||
<% admin_breadcrumb(link_to plural_resource_name(Spree::StoreCreditReason), spree.admin_store_credit_reasons_path) %> | ||
<% admin_breadcrumb(t('spree.new_store_credit_reason')) %> | ||
|
||
<% content_for :page_actions do %> | ||
<% end %> | ||
|
||
<%= render partial: 'spree/shared/error_messages', locals: { target: @object } %> | ||
|
||
<%= form_for [:admin, @object] do |f| %> | ||
<fieldset class='no-border-top'> | ||
<%= render partial: 'spree/admin/store_credit_reasons/shared/form', locals: { f: f } %> | ||
<%= render partial: 'spree/admin/shared/new_resource_links' %> | ||
</fieldset> | ||
<% end %> |
15 changes: 15 additions & 0 deletions
15
backend/app/views/spree/admin/store_credit_reasons/shared/_form.html.erb
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,15 @@ | ||
<div data-hook='admin_named_type_form_fields' class='row'> | ||
<div class='col-3'> | ||
<%= f.field_container :name do %> | ||
<%= f.label :name, class: 'required' %><br /> | ||
<%= f.text_field :name, class: 'fullwidth' %> | ||
<% end %> | ||
|
||
<div class='checkbox'> | ||
<label> | ||
<%= f.check_box :active %> | ||
<%= t('spree.active') %> | ||
</label> | ||
</div> | ||
</div> | ||
</div> |
7 changes: 7 additions & 0 deletions
7
backend/app/views/spree/admin/store_credits/_store_credit_reason_field.html.erb
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,7 @@ | ||
<%= f.field_container :reason do %> | ||
<%= f.label :store_credit_reason, t('spree.reason'), class: 'required' %> | ||
<%= select_tag :store_credit_reason_id, options_from_collection_for_select(@store_credit_reasons, :id, :name), | ||
include_blank: t('spree.choose_reason'), class: 'custom-select fullwidth', | ||
placeholder: t('spree.admin.store_credits.select_amount_store_credit_reason') %> | ||
<%= f.error_message_on :store_credit_reason %> | ||
<% end %> |
7 changes: 0 additions & 7 deletions
7
backend/app/views/spree/admin/store_credits/_update_reason_field.html.erb
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class Spree::StoreCreditReason < Spree::Base | ||
include Spree::NamedType | ||
|
||
has_many :store_credit_events, inverse_of: :store_credit_reason | ||
|
||
validates :name, presence: true, uniqueness: { case_sensitive: false, allow_blank: true } | ||
|
||
scope :active, -> { where(active: true) } | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.