-
-
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.
- Loading branch information
1 parent
2d5bda7
commit 9dc1797
Showing
12 changed files
with
276 additions
and
44 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
33 changes: 33 additions & 0 deletions
33
admin/app/components/solidus_admin/users/store_credits/edit_amount/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,33 @@ | ||
<%= render component("ui/modal").new(title: t(".title")) do |modal| %> | ||
<%= form_for @store_credit, url: solidus_admin.update_amount_user_store_credit_path(@user, @store_credit), method: :put, data: { turbo: false }, html: { id: form_id } do |f| %> | ||
<div class="flex flex-col gap-6 pb-4"> | ||
<%= render component("ui/forms/field").text_field(f, :amount, class: "required") %> | ||
<%= 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 } | ||
) %> | ||
<!-- Display error messages from :base --> | ||
<% if @store_credit.errors.any? %> | ||
<div class="alert alert-error"> | ||
<ul> | ||
<% @store_credit.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
<%= render component("ui/forms/field").text_field(f, :memo, class: "required") %> | ||
</div> | ||
<% modal.with_actions do %> | ||
<form method="dialog"> | ||
<%= render component("ui/button").new(scheme: :secondary, tag: :a, href: solidus_admin.user_store_credit_path(@user, @store_credit), text: t('.cancel')) %> | ||
</form> | ||
<%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %> | ||
<% 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_amount/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::EditAmount::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_store_credit_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_amount/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: Edit Store Credit | ||
cancel: Cancel | ||
submit: Update Store Credit | ||
choose_reason: Choose Reason For Changing Amount |
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
admin/app/components/solidus_admin/users/store_credits/show/component.js
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 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
export default class extends Controller { | ||
actionButtonClicked(event) { | ||
const url = new URL(event.params.url, "http://dummy.com") | ||
const params = new URLSearchParams(url.search) | ||
const frameId = params.get('_turbo_frame') | ||
const frame = frameId ? { frame: frameId } : {} | ||
// remove the custom _turbo_frame param from url search: | ||
params.delete('_turbo_frame') | ||
url.search = params.toString() | ||
|
||
window.Turbo.visit(url.pathname + url.search, frame) | ||
} | ||
} |
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,10 @@ | ||
en: | ||
solidus_admin: | ||
store_credits: | ||
title: "Store Credits" | ||
destroy: | ||
success: "Store credit was successfully removed." | ||
create: | ||
success: "Store credit was successfully created." | ||
update_amount: | ||
success: "Store credit was successfully updated." |
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
Oops, something went wrong.