forked from solidusio/solidus
-
Notifications
You must be signed in to change notification settings - Fork 3
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 solidusio#6034 from MadelineCollier/admin-user-sto…
…re-credit-invalidate [Admin][Users] Add new admin store credits invalidate flow
- Loading branch information
Showing
10 changed files
with
218 additions
and
22 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
admin/app/components/solidus_admin/users/store_credits/edit_validity/component.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,22 @@ | ||
<%= turbo_frame_tag :edit_validity_modal do %> | ||
<%= render component("ui/modal").new(title: t(".title")) do |modal| %> | ||
<%= form_for @store_credit, url: solidus_admin.invalidate_user_store_credit_path(@user, @store_credit), method: :put, html: { id: form_id } do |f| %> | ||
<div class="flex flex-col gap-6 pb-4"> | ||
<%= render component("ui/forms/field").select( | ||
f, | ||
:store_credit_reason_id, | ||
store_credit_reasons_select_options.html_safe, | ||
include_blank: t('spree.choose_reason'), | ||
html: { required: true } | ||
) %> | ||
</div> | ||
<% modal.with_actions do %> | ||
<form method="dialog"> | ||
<%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %> | ||
</form> | ||
<%= render component("ui/button").new(form: form_id, scheme: :danger, type: :submit, text: t('.submit')) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<%= render component("users/store_credits/show").new(user: @user, store_credit: @store_credit, events: @store_credit_events) %> |
19 changes: 19 additions & 0 deletions
19
admin/app/components/solidus_admin/users/store_credits/edit_validity/component.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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
class SolidusAdmin::Users::StoreCredits::EditValidity::Component < SolidusAdmin::BaseComponent | ||
def initialize(user:, store_credit:, events:, reasons:) | ||
@user = user | ||
@store_credit = store_credit | ||
@store_credit_events = events | ||
@store_credit_reasons = reasons | ||
end | ||
|
||
def form_id | ||
dom_id(@store_credit, "#{stimulus_id}_edit_validity_form") | ||
end | ||
|
||
def store_credit_reasons_select_options | ||
# Placeholder + Store Credit Reasons | ||
"<option value>#{t('.choose_reason')}</option>" + options_from_collection_for_select(@store_credit_reasons, :id, :name) | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
admin/app/components/solidus_admin/users/store_credits/edit_validity/component.yml
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,5 @@ | ||
en: | ||
title: Invalidate Store Credit | ||
cancel: Cancel | ||
submit: Invalidate | ||
choose_reason: Choose Reason For Invalidating |
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 |
---|---|---|
|
@@ -52,6 +52,7 @@ def turbo_frames | |
%w[ | ||
edit_amount_modal | ||
edit_memo_modal | ||
edit_validity_modal | ||
] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,8 @@ | |
put :update_amount | ||
get :edit_memo | ||
put :update_memo | ||
get :edit_validity | ||
put :invalidate | ||
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