spree_address_format_i18n 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe05594137f4e266415994c41802623185b224482a10060db4ed94732c6fafbd
|
|
4
|
+
data.tar.gz: edb6bceca9d561083f43481be33570bbc83b774a1b3886b564d68553c102e47a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2194c8c9a7f3e6d587878ee2dbc5300f65bc48b4a7c71eaaad8c84659a059d3535df4768abd7684beb1cff83932731c5358cdaf5afe23451f47d10764da8e739
|
|
7
|
+
data.tar.gz: ac88ba2170c5467d3bfe93cbbdaa2b92e1fce50255eae6561cb96a37178ded5503b405c63ad1e85a52d14d7ddba7cbe29fd16696776fb59eb1de537f9e31e6f0
|
|
@@ -3,6 +3,42 @@ module Spree
|
|
|
3
3
|
# List of kana fields that should not be excluded even when `store.use_kana_fields` is false.
|
|
4
4
|
IGNORED_KANA_FIELDS = [ :company_kana ]
|
|
5
5
|
|
|
6
|
+
# @gem-override spree_core-5.3.6/app/helpers/spree/addresses_helper.rb#address_field
|
|
7
|
+
# @see https://github.com/be-agile/giga-repeat/issues/1397
|
|
8
|
+
# 本家を super で呼び、入力欄の直下にその欄のエラーを足し、placeholder を入力例にする
|
|
9
|
+
# (引数リストは本家のシグネチャに依存する)。本家はエラーをページ最上部の一覧にしか
|
|
10
|
+
# 出さないため、入力欄から遠くて気づかれない。
|
|
11
|
+
def address_field(form, method, address_id = 'b', required = false, text_field_attributes: {}, &handler)
|
|
12
|
+
label = I18n.t("activerecord.attributes.spree/address.#{method}")
|
|
13
|
+
field = super(form, method, address_id, required, text_field_attributes: text_field_attributes.merge(placeholder: address_placeholder(method, label)), &handler)
|
|
14
|
+
field + address_field_errors(form, method)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# @gem-override spree_core-5.3.6/app/helpers/spree/addresses_helper.rb#address_zipcode
|
|
18
|
+
# @see https://github.com/be-agile/giga-repeat/issues/1397
|
|
19
|
+
# placeholder を入力例にする以外は本家のまま。
|
|
20
|
+
def address_zipcode(form, country, address_id = 'b')
|
|
21
|
+
method_name = Spree.t(:zipcode)
|
|
22
|
+
form.label(:zipcode, method_name, id: address_id + '_zipcode_label', class: 'block text-xs text-neutral-600 mb-1') +
|
|
23
|
+
form.text_field(:zipcode,
|
|
24
|
+
class: 'text-input',
|
|
25
|
+
placeholder: address_placeholder(:zipcode, method_name),
|
|
26
|
+
required: country&.zipcode_required?,
|
|
27
|
+
data: { 'address-form-target': 'zipcode', address_autocomplete_target: 'zipcode' },
|
|
28
|
+
aria: { label: Spree.t(:zipcode) })
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# 入力例(spree.address_placeholders.*)が無いロケール・欄では、本家と同じくラベル名を使う。
|
|
32
|
+
def address_placeholder(method, label)
|
|
33
|
+
I18n.t("spree.address_placeholders.#{method}", default: label)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def address_field_errors(form, method)
|
|
37
|
+
safe_join(form.object.errors.full_messages_for(method).map do |message|
|
|
38
|
+
content_tag(:p, message, class: 'text-red-500 text-xs mt-1')
|
|
39
|
+
end)
|
|
40
|
+
end
|
|
41
|
+
|
|
6
42
|
def order_address_fields(store)
|
|
7
43
|
name_order = I18n.t('address_format_i18n.fields')
|
|
8
44
|
return Spree::Address::ADDRESS_FIELDS if name_order.blank?
|
|
@@ -27,7 +27,7 @@ module SpreeAddressFormatI18n
|
|
|
27
27
|
base.validates :firstname_kana, presence: true, if: -> { kana_presence_required.call(self, :firstname_kana) }
|
|
28
28
|
base.validates :firstname_kana, format: { with: /\A[\p{Katakana}\p{Blank}ー・]+\z/, allow_blank: true, message: :invalid_katakana }, if: -> { Spree::Store.current.use_kana_fields }
|
|
29
29
|
|
|
30
|
-
base.validates :company_kana, format: { with: /\A[\p{Katakana}\p{Blank}ー・]+\z
|
|
30
|
+
base.validates :company_kana, format: { with: /\A[\p{Katakana}\p{Blank}ー・]+\z/, message: :invalid_katakana }, if: -> { company_kana.present? }
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
|
data/config/locales/ja.yml
CHANGED
|
@@ -4,6 +4,19 @@ ja:
|
|
|
4
4
|
firstname_kana: メイ
|
|
5
5
|
fax: FAX
|
|
6
6
|
company_kana: カナ会社名
|
|
7
|
+
address_placeholders:
|
|
8
|
+
company: 例)株式会社山田商事
|
|
9
|
+
company_kana: 例)カブシキガイシャヤマダショウジ
|
|
10
|
+
lastname: 例)山田
|
|
11
|
+
firstname: 例)太郎
|
|
12
|
+
lastname_kana: 例)ヤマダ
|
|
13
|
+
firstname_kana: 例)タロウ
|
|
14
|
+
zipcode: 例)150-0001
|
|
15
|
+
city: 例)渋谷区
|
|
16
|
+
address1: 例)神宮前1-1-1
|
|
17
|
+
address2: 例)山田ビル3F
|
|
18
|
+
phone: 例)03-1234-5678
|
|
19
|
+
fax: 例)03-1234-5679
|
|
7
20
|
use_kana_fields: "住所にかなフィールドを使用する"
|
|
8
21
|
show_country_field: "住所に国フィールドを表示する"
|
|
9
22
|
address_field_settings: "住所フィールド設定"
|
|
@@ -25,3 +38,6 @@ ja:
|
|
|
25
38
|
firstname_kana: メイ
|
|
26
39
|
company_kana: カナ会社名
|
|
27
40
|
fax: FAX
|
|
41
|
+
errors:
|
|
42
|
+
messages:
|
|
43
|
+
invalid_katakana: は全角カタカナで入力してください(漢字・ひらがな・数字・記号は使えません)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_address_format_i18n
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- be agile Co., Ltd.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree
|