-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a store credit reasons Admin UI #2798
Merged
kennyadsl
merged 9 commits into
solidusio:master
from
jtapia:chore/store_credit_reasons
Jan 18, 2019
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ece326b
Add migration to create spree_store_credit_reasons table
172aa3c
Add store credit reason controller
0d01a17
Add store credit reason model
42981e9
Add store credit reason views
d7291cd
Add store credit routes and locales
7640076
Update store credit model to use store credit reason
5edcc43
Update store credit db seed
739c2c5
Update factories to use store credit reason
ad1ec79
Update tests to use store credit reason
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think
store_credit_reason
here is needed anymore