rails_profile 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +20 -0
- data/Rakefile +32 -0
- data/app/controllers/profiled/admin/address_organs_controller.rb +27 -0
- data/app/controllers/profiled/admin/addresses_controller.rb +48 -0
- data/app/controllers/profiled/admin/base_controller.rb +4 -0
- data/app/controllers/profiled/admin/profiles_controller.rb +42 -0
- data/app/controllers/profiled/areas_controller.rb +42 -0
- data/app/controllers/profiled/base_controller.rb +4 -0
- data/app/controllers/profiled/me/base_controller.rb +9 -0
- data/app/controllers/profiled/me/profiles_controller.rb +43 -0
- data/app/controllers/profiled/my/address_users_controller.rb +27 -0
- data/app/controllers/profiled/my/addresses_controller.rb +102 -0
- data/app/controllers/profiled/my/base_controller.rb +4 -0
- data/app/controllers/profiled/my/profiles_controller.rb +67 -0
- data/app/controllers/profiled/panel/areas_controller.rb +27 -0
- data/app/controllers/profiled/panel/base_controller.rb +4 -0
- data/app/models/concerns/qq_map_helper.rb +80 -0
- data/app/models/profiled/address.rb +8 -0
- data/app/models/profiled/address_organ.rb +5 -0
- data/app/models/profiled/address_user.rb +5 -0
- data/app/models/profiled/application_record.rb +5 -0
- data/app/models/profiled/area.rb +6 -0
- data/app/models/profiled/ext/organ.rb +11 -0
- data/app/models/profiled/ext/user.rb +17 -0
- data/app/models/profiled/model/account.rb +17 -0
- data/app/models/profiled/model/address.rb +33 -0
- data/app/models/profiled/model/address_organ.rb +23 -0
- data/app/models/profiled/model/address_user.rb +29 -0
- data/app/models/profiled/model/area.rb +120 -0
- data/app/models/profiled/model/profile.rb +43 -0
- data/app/models/profiled/profile.rb +5 -0
- data/app/models/profiled.rb +11 -0
- data/app/views/admin/_profile_nav.html.erb +10 -0
- data/app/views/me/_profile_nav.html.erb +4 -0
- data/app/views/my/_profile_nav.html.erb +5 -0
- data/app/views/panel/_profile_nav.html.erb +10 -0
- data/app/views/profiled/admin/base/_nav.html.erb +4 -0
- data/app/views/profiled/admin/profiles/_edit_form.html.erb +5 -0
- data/app/views/profiled/admin/profiles/_filter_form.html.erb +9 -0
- data/app/views/profiled/admin/profiles/_form.html.erb +6 -0
- data/app/views/profiled/admin/profiles/_index_tbody.html.erb +6 -0
- data/app/views/profiled/admin/profiles/_index_thead.html.erb +7 -0
- data/app/views/profiled/admin/profiles/_new_form.html.erb +5 -0
- data/app/views/profiled/admin/profiles/_profile.json.jbuilder +2 -0
- data/app/views/profiled/admin/profiles/_show_table.html.erb +24 -0
- data/app/views/profiled/admin/profiles/index.html.erb +5 -0
- data/app/views/profiled/admin/profiles/qrcode.json.jbuilder +1 -0
- data/app/views/profiled/areas/_index.html.erb +26 -0
- data/app/views/profiled/areas/follow.turbo_stream.erb +11 -0
- data/app/views/profiled/areas/index.json.jbuilder +2 -0
- data/app/views/profiled/areas/index.turbo_stream+phone.erb +1 -0
- data/app/views/profiled/me/profiles/_edit_form.html.erb +4 -0
- data/app/views/profiled/me/profiles/_form.html.erb +5 -0
- data/app/views/profiled/me/profiles/_profile.json.jbuilder +14 -0
- data/app/views/profiled/me/profiles/_show_table.html.erb +20 -0
- data/app/views/profiled/me/profiles/show.json.jbuilder +1 -0
- data/app/views/profiled/my/address_users/create.turbo_stream.erb +3 -0
- data/app/views/profiled/my/addresses/_filter_form.html.erb +9 -0
- data/app/views/profiled/my/addresses/_form.html+phone.erb +15 -0
- data/app/views/profiled/my/addresses/_form.html.erb +4 -0
- data/app/views/profiled/my/addresses/_index/_address.html.erb +20 -0
- data/app/views/profiled/my/addresses/_index_tbody.html.erb +4 -0
- data/app/views/profiled/my/addresses/_index_thead.html.erb +5 -0
- data/app/views/profiled/my/addresses/_list/_address.html.erb +18 -0
- data/app/views/profiled/my/addresses/_new_form.html+phone.erb +12 -0
- data/app/views/profiled/my/addresses/_new_form.html.erb +4 -0
- data/app/views/profiled/my/addresses/_outer_select.html+phone.erb +14 -0
- data/app/views/profiled/my/addresses/_outer_select.html.erb +17 -0
- data/app/views/profiled/my/addresses/_select.html.erb +10 -0
- data/app/views/profiled/my/addresses/_show_table.html+phone.erb +25 -0
- data/app/views/profiled/my/addresses/_show_table.html.erb +12 -0
- data/app/views/profiled/my/addresses/_wechat_form.html.erb +36 -0
- data/app/views/profiled/my/addresses/create.turbo_stream.erb +5 -0
- data/app/views/profiled/my/addresses/fork.turbo_stream.erb +3 -0
- data/app/views/profiled/my/addresses/index.html+phone.erb +26 -0
- data/app/views/profiled/my/addresses/index.html.erb +7 -0
- data/app/views/profiled/my/addresses/list.html+phone.erb +41 -0
- data/app/views/profiled/my/addresses/select.turbo_stream.erb +1 -0
- data/app/views/profiled/my/addresses/show.html+phone.erb +26 -0
- data/app/views/profiled/my/addresses/update.turbo_stream.erb +7 -0
- data/app/views/profiled/my/addresses/wechat.turbo_stream.erb +3 -0
- data/app/views/profiled/my/profiles/_edit_form.html+phone.erb +15 -0
- data/app/views/profiled/my/profiles/_edit_form.html.erb +4 -0
- data/app/views/profiled/my/profiles/_form.html.erb +6 -0
- data/app/views/profiled/my/profiles/_profile.json.jbuilder +1 -0
- data/app/views/profiled/my/profiles/_show_table.html+phone.erb +24 -0
- data/app/views/profiled/my/profiles/_show_table.html.erb +20 -0
- data/app/views/profiled/my/profiles/index.html+phone.erb +3 -0
- data/app/views/profiled/my/profiles/index.html.erb +31 -0
- data/app/views/profiled/my/profiles/index.json.jbuilder +1 -0
- data/app/views/profiled/my/profiles/show.html+phone.erb +8 -0
- data/app/views/profiled/my/profiles/show.html.erb +1 -0
- data/app/views/profiled/my/profiles/show.json.jbuilder +1 -0
- data/app/views/profiled/panel/addresses/_address.html.erb +24 -0
- data/app/views/profiled/panel/addresses/_edit_form.html.erb +4 -0
- data/app/views/profiled/panel/addresses/_form.html.erb +22 -0
- data/app/views/profiled/panel/addresses/_index_tbody.html.erb +16 -0
- data/app/views/profiled/panel/addresses/_index_thead.html.erb +5 -0
- data/app/views/profiled/panel/addresses/_new_form.html.erb +4 -0
- data/app/views/profiled/panel/addresses/index.html.erb +5 -0
- data/app/views/profiled/panel/areas/_filter_form.html.erb +9 -0
- data/app/views/profiled/panel/areas/_form.html.erb +5 -0
- data/app/views/profiled/panel/areas/_index_tbody.html.erb +17 -0
- data/app/views/profiled/panel/areas/_index_thead.html.erb +8 -0
- data/app/views/profiled/panel/areas/_show_table.html.erb +8 -0
- data/app/views/profiled/panel/areas/index.html.erb +5 -0
- data/app/views/profiled/panel/base/_nav.html.erb +3 -0
- data/config/locales/en.controller.yml +30 -0
- data/config/locales/en.enum.yml +15 -0
- data/config/locales/zh.attributes.yml +28 -0
- data/config/locales/zh.controller.yml +38 -0
- data/config/locales/zh.enum.yml +10 -0
- data/config/routes.rb +45 -0
- data/lib/rails_profile/config.rb +11 -0
- data/lib/rails_profile/engine.rb +21 -0
- data/lib/rails_profile.rb +2 -0
- metadata +174 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
module Profiled
|
2
|
+
module Ext::User
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
has_many :profiles, class_name: 'Profiled::Profile', inverse_of: :user
|
7
|
+
#has_many :proteges, through: :profiles
|
8
|
+
#has_many :maintains, through: :proteges, source: :maintains
|
9
|
+
|
10
|
+
has_many :address_users, class_name: 'Profiled::AddressUser', inverse_of: :user, dependent: :delete_all
|
11
|
+
has_many :addresses, class_name: 'Profiled::Address', through: :address_users
|
12
|
+
has_many :principal_address_users, -> { where(role: 'principal') }, class_name: 'Profiled::AddressUser', dependent: :delete_all
|
13
|
+
has_many :principal_addresses, class_name: 'Profiled::Address', through: :principal_address_users, source: :address
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Profiled
|
2
|
+
module Model::Account
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
has_many :profiles, foreign_key: :identity, primary_key: :identity
|
7
|
+
after_save :sync_to_profiles, if: -> { saved_change_to_identity? || saved_change_to_user_id? || saved_change_to_confirmed? }
|
8
|
+
end
|
9
|
+
|
10
|
+
def sync_to_profiles
|
11
|
+
if confirmed?
|
12
|
+
profiles.update_all(user_id: self.user_id)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Profiled
|
2
|
+
module Model::Address
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :name, :string
|
7
|
+
attribute :detail, :string
|
8
|
+
attribute :contact, :string
|
9
|
+
attribute :tel, :string
|
10
|
+
attribute :post_code, :string
|
11
|
+
attribute :source, :string
|
12
|
+
attribute :cached_key, :string
|
13
|
+
|
14
|
+
has_taxons :area
|
15
|
+
belongs_to :area, class_name: 'Profiled::Area'
|
16
|
+
|
17
|
+
has_many :address_users, inverse_of: :address, dependent: :delete_all
|
18
|
+
has_many :users, through: :address_users
|
19
|
+
has_many :address_organs, inverse_of: :address, dependent: :delete_all
|
20
|
+
|
21
|
+
before_validation :sync_cached_key
|
22
|
+
end
|
23
|
+
|
24
|
+
def sync_cached_key
|
25
|
+
self.cached_key = [area_id, detail, contact, tel].join(',')
|
26
|
+
end
|
27
|
+
|
28
|
+
def content
|
29
|
+
"#{area.full_name} #{detail}"
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Profiled
|
2
|
+
module Model::AddressOrgan
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :kind, :string
|
7
|
+
attribute :default, :boolean, default: false
|
8
|
+
|
9
|
+
belongs_to :organ, class_name: 'Org::Organ', inverse_of: :address_organs
|
10
|
+
|
11
|
+
belongs_to :address, inverse_of: :address_organs
|
12
|
+
|
13
|
+
has_many :shipments, as: :shipping
|
14
|
+
|
15
|
+
enum kind: {
|
16
|
+
transport: 'transport',
|
17
|
+
forwarder: 'forwarder',
|
18
|
+
invoice: 'invoice'
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Profiled
|
2
|
+
module Model::AddressUser
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :commission_ratio, :decimal, precision: 4, scale: 2, default: 0, comment: '佣金比例'
|
7
|
+
attribute :kind, :string
|
8
|
+
attribute :role, :string, default: 'ordinary'
|
9
|
+
|
10
|
+
belongs_to :address, inverse_of: :address_users
|
11
|
+
belongs_to :user, inverse_of: :address_users, class_name: 'Auth::User'
|
12
|
+
belongs_to :inviter, class_name: 'Auth::User', optional: true
|
13
|
+
|
14
|
+
has_many :shipments, as: :shipping
|
15
|
+
|
16
|
+
enum role: {
|
17
|
+
principal: 'principal',
|
18
|
+
ordinary: 'ordinary'
|
19
|
+
}
|
20
|
+
|
21
|
+
enum kind: {
|
22
|
+
transport: 'transport',
|
23
|
+
forwarder: 'forwarder',
|
24
|
+
invoice: 'invoice'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Profiled
|
3
|
+
module Model::Area
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
attribute :name, :string
|
8
|
+
attribute :full, :string
|
9
|
+
attribute :published, :boolean, default: true
|
10
|
+
attribute :popular, :boolean, default: false
|
11
|
+
attribute :names, :string, array: true
|
12
|
+
attribute :timezone, :string
|
13
|
+
attribute :locale, :string
|
14
|
+
attribute :code, :string
|
15
|
+
|
16
|
+
validates :name, presence: true
|
17
|
+
|
18
|
+
scope :popular, -> { where(popular: true) }
|
19
|
+
|
20
|
+
default_scope -> { where(published: true) }
|
21
|
+
|
22
|
+
after_save_commit :sync_names, if: -> { saved_change_to_name? || saved_change_to_parent_id? }
|
23
|
+
after_commit :sync_children_names
|
24
|
+
after_save_commit :update_timestamp, :delete_cache, on: [:create, :update]
|
25
|
+
end
|
26
|
+
|
27
|
+
def full_name
|
28
|
+
names.join(' / ')
|
29
|
+
end
|
30
|
+
|
31
|
+
# todo sync after destroy parent
|
32
|
+
def sync_names
|
33
|
+
self.names = self.self_and_ancestors.pluck(:name).reverse
|
34
|
+
self.save
|
35
|
+
end
|
36
|
+
|
37
|
+
def sync_children_names
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def tree_lists(value_name: 'id', label_name: 'name')
|
42
|
+
children.map do |child|
|
43
|
+
{
|
44
|
+
value_name => child.id,
|
45
|
+
label_name => child.name,
|
46
|
+
children: child.tree_lists(value_name: value_name, label_name: label_name)
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def delete_cache
|
53
|
+
['areas/popular', 'areas/all_nations'].each do |c|
|
54
|
+
Rails.cache.delete(c)
|
55
|
+
end
|
56
|
+
#Rails.cache.delete_matched 'areas/list/*'
|
57
|
+
end
|
58
|
+
|
59
|
+
def update_timestamp
|
60
|
+
t = self.updated_at.to_i
|
61
|
+
Rails.cache.write('areas/timestamp', t)
|
62
|
+
end
|
63
|
+
|
64
|
+
class_methods do
|
65
|
+
|
66
|
+
def rebuild_names
|
67
|
+
find_each do |area|
|
68
|
+
area.sync_names
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def timestamp
|
73
|
+
Rails.cache.fetch('areas/timestamp') do
|
74
|
+
order(updated_at: :desc).last.updated_at.to_i
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def list(value_name: 'id', label_name: 'name')
|
79
|
+
Rails.cache.fetch("areas/list/#{value_name}/#{label_name}") do
|
80
|
+
roots.map do |root|
|
81
|
+
{
|
82
|
+
value_name => root.id,
|
83
|
+
label_name => root.name,
|
84
|
+
children: root.tree_lists(value_name: value_name, label_name: label_name)
|
85
|
+
}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# names must be an instance of Enumerator, first is root, child is after root
|
91
|
+
def sure_find(names, parent = nil)
|
92
|
+
names = names.to_enum unless names.is_a? Enumerator
|
93
|
+
area = find_or_initialize_by(name: names.next)
|
94
|
+
if parent
|
95
|
+
area.parent = parent
|
96
|
+
end
|
97
|
+
area.save!
|
98
|
+
sure_find(names, area)
|
99
|
+
rescue StopIteration => e
|
100
|
+
parent
|
101
|
+
end
|
102
|
+
|
103
|
+
# names must be an instance of Enumerator, first is root, child is after root
|
104
|
+
def sure_find_full(names, parent = nil)
|
105
|
+
names = names.to_enum unless names.is_a? Enumerator
|
106
|
+
area = find_or_initialize_by(full: names.next)
|
107
|
+
if parent
|
108
|
+
area.parent = parent
|
109
|
+
end
|
110
|
+
area.save
|
111
|
+
sure_find_full(names, area)
|
112
|
+
rescue StopIteration => e
|
113
|
+
parent
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Profiled
|
3
|
+
module Model::Profile
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
attribute :birthday, :date
|
8
|
+
attribute :real_name, :string
|
9
|
+
attribute :nick_name, :string
|
10
|
+
attribute :identity, :string
|
11
|
+
attribute :extra, :json, default: {}
|
12
|
+
|
13
|
+
belongs_to :organ, class_name: 'Org::Organ', optional: true
|
14
|
+
belongs_to :account, class_name: 'Auth::Account', foreign_key: :identity, primary_key: :identity, optional: true
|
15
|
+
|
16
|
+
enum birthday_type: {
|
17
|
+
solar: 'solar',
|
18
|
+
lunar: 'lunar'
|
19
|
+
}, _default: 'solar'
|
20
|
+
|
21
|
+
enum gender: {
|
22
|
+
male: 'male',
|
23
|
+
female: 'female',
|
24
|
+
unknown: 'unknown'
|
25
|
+
}
|
26
|
+
|
27
|
+
has_one_attached :avatar
|
28
|
+
end
|
29
|
+
|
30
|
+
def age
|
31
|
+
return 0 unless self.birthday
|
32
|
+
r_hash = TimeHelper.exact_distance_time(self.birthday, Date.today)
|
33
|
+
r_hash[:year]
|
34
|
+
end
|
35
|
+
|
36
|
+
def age_str
|
37
|
+
return '未知' unless self.birthday
|
38
|
+
r_hash = TimeHelper.exact_distance_time(self.birthday, Date.today)
|
39
|
+
"#{r_hash[:year]}岁#{r_hash[:month]}月"
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="<%= active_helper(modules: 'profiled/admin', active: 'menu ex-accordion is-active', item: 'menu ex-accordion is-active') %>" data-controller="menu">
|
2
|
+
<%= content_tag :div, class: 'menu-list' do %>
|
3
|
+
<%= link_to t('profiled.admin.addresses.index.title'), { controller: 'profiled/admin/addresses' }, class: active_helper(controllers: 'addresses', active: 'is-active') -%>
|
4
|
+
<% end %>
|
5
|
+
<a class="menu-label" data-action="menu#toggle">
|
6
|
+
<i class="fa-solid fa-map-marker-alt fa-fw"></i>
|
7
|
+
<span><%= t('profiled.admin.title') %></span>
|
8
|
+
<i class="fa-solid dropdown"></i>
|
9
|
+
</a>
|
10
|
+
</div>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<span class="menu-label"><%= t('profiled.my.title') %></span>
|
2
|
+
<div class="menu-list">
|
3
|
+
<%= link_to t('profiled.my.profiles.index.title'), { controller: 'profiled/my/profiles', action: 'show' }, class: active_helper(controllers: ['profiles'], active: 'is-active') %>
|
4
|
+
<%= link_to t('profiled.my.addresses.index.title'), { controller: 'profiled/my/addresses' }, class: active_helper(controllers: ['addresses'], active: 'is-active') %>
|
5
|
+
</div>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="<%= active_helper(modules: 'profiled/panel', active: 'menu ex-accordion is-active', item: 'menu ex-accordion') %>" data-controller="menu">
|
2
|
+
<%= content_tag :div, class: 'menu-list' do %>
|
3
|
+
<%= link_to t('profiled.panel.areas.index.title'), { controller: 'profiled/panel/areas' }, class: active_helper(controllers: 'areas', active: 'is-active') -%>
|
4
|
+
<% end %>
|
5
|
+
<a class="menu-label" data-action="menu#toggle">
|
6
|
+
<i class="fa-solid fa-map-marker-alt fa-fw"></i>
|
7
|
+
<span><%= t('profiled.panel.title') %></span>
|
8
|
+
<i class="fa-solid dropdown"></i>
|
9
|
+
</a>
|
10
|
+
</div>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%= form_with theme: 'search', model: Profiled::Profile.new, url: { action: params[:action] } do |f| %>
|
2
|
+
<div class="field-body">
|
3
|
+
<%= f.text_field :name %>
|
4
|
+
<div class="field is-narrow">
|
5
|
+
<%= f.submit %>
|
6
|
+
<%= link_to t('.clear'), filter_params(except: [:name]), class: 'button is-light' %>
|
7
|
+
</div>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%= f.text_field :real_name %>
|
2
|
+
<%= f.text_field :nick_name %>
|
3
|
+
<%= f.file_field :avatar %>
|
4
|
+
<%= f.select :gender, options_for_select(Profiled::Profile.options_i18n(:gender), f.object.gender) %>
|
5
|
+
<%= f.select :birthday_type, options_for_select(Profiled::Profile.options_i18n(:birthday_type), f.object.birthday_type) %>
|
6
|
+
<%= f.date_field :birthday %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<th><%= Profiled::Profile.human_attribute_name(:real_name) %></th>
|
2
|
+
<th><%= Profiled::Profile.human_attribute_name(:nick_name) %></th>
|
3
|
+
<th><%= Profiled::Profile.human_attribute_name(:gender) %></th>
|
4
|
+
<th><%= Profiled::Profile.human_attribute_name(:birthday_type) %></th>
|
5
|
+
<th><%= Profiled::Profile.human_attribute_name(:birthday) %></th>
|
6
|
+
<th><%= Profiled::Profile.human_attribute_name(:extra) %></th>
|
7
|
+
<th></th>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<tr>
|
2
|
+
<td class="has-text-right"><%= Profiled::Profile.human_attribute_name(:real_name) %></td>
|
3
|
+
<td><%= @profile.real_name %></td>
|
4
|
+
</tr>
|
5
|
+
<tr>
|
6
|
+
<td class="has-text-right"><%= Profiled::Profile.human_attribute_name(:nick_name) %></td>
|
7
|
+
<td><%= @profile.nick_name %></td>
|
8
|
+
</tr>
|
9
|
+
<tr>
|
10
|
+
<td class="has-text-right"><%= Profiled::Profile.human_attribute_name(:gender) %></td>
|
11
|
+
<td><%= @profile.gender %></td>
|
12
|
+
</tr>
|
13
|
+
<tr>
|
14
|
+
<td class="has-text-right"><%= Profiled::Profile.human_attribute_name(:birthday_type) %></td>
|
15
|
+
<td><%= @profile.birthday_type %></td>
|
16
|
+
</tr>
|
17
|
+
<tr>
|
18
|
+
<td class="has-text-right"><%= Profiled::Profile.human_attribute_name(:birthday) %></td>
|
19
|
+
<td><%= @profile.birthday %></td>
|
20
|
+
</tr>
|
21
|
+
<tr>
|
22
|
+
<td class="has-text-right"><%= Profiled::Profile.human_attribute_name(:extra) %></td>
|
23
|
+
<td><%= @profile.extra %></td>
|
24
|
+
</tr>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.profile @profile, partial: 'profile', as: :profile
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<div data-controller="weui-dialog weui-picker" data-weui-dialog-target="dialog" data-weui-picker-url-value="<%= url_for(action: 'follow') %>" class="weui-half-screen-dialog weui-picker weui-animate-slide-up" id="area_select">
|
2
|
+
<div class="weui-half-screen-dialog__hd">
|
3
|
+
<div class="weui-half-screen-dialog__hd__side">
|
4
|
+
<button class="weui-icon-btn weui-icon-btn_close weui-picker__btn" data-action="weui-dialog#close">关闭</button>
|
5
|
+
</div>
|
6
|
+
<div class="weui-half-screen-dialog__hd__main">
|
7
|
+
<strong class="weui-half-screen-dialog__title">选择地区</strong>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<div class="weui-half-screen-dialog__bd">
|
11
|
+
<div class="weui-picker__bd">
|
12
|
+
<div class="weui-picker__group">
|
13
|
+
<div class="weui-picker__mask"></div>
|
14
|
+
<div class="weui-picker__indicator"></div>
|
15
|
+
<select class="weui-picker__content" style="transform: translateY(96px)">
|
16
|
+
<% @areas.each do |area| %>
|
17
|
+
<option class="weui-picker__item" data-action="click->weui-picker#getNext click->weui-picker#setValue" data-id="<%= area.id %>"><%= area.name %></option>
|
18
|
+
<% end %>
|
19
|
+
</select>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
<div class="weui-half-screen-dialog__ft">
|
24
|
+
<button class="weui-btn weui-btn_primary weui-picker__btn">确认</button>
|
25
|
+
</div>
|
26
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% if @areas.size > 0 %>
|
2
|
+
<div class="weui-picker__group">
|
3
|
+
<div class="weui-picker__mask"></div>
|
4
|
+
<div class="weui-picker__indicator"></div>
|
5
|
+
<select class="weui-picker__content">
|
6
|
+
<% @areas.each do |area| %>
|
7
|
+
<option class="weui-picker__item" data-action="click->weui-picker#getNext click->weui-picker#setValue" data-id="<%= area.id %>"><%= area.name %></option>
|
8
|
+
<% end %>
|
9
|
+
</select>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= turbo_stream.replace 'area_select', partial: 'index' %>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<%= f.text_field :real_name %>
|
2
|
+
<%= f.text_field :nick_name %>
|
3
|
+
<%= f.select :gender, options_for_select(Profile.options_i18n(:gender), @profile.gender) %>
|
4
|
+
<%= f.select :birthday_type, options_for_select(Profile.options_i18n(:birthday_type)) %>
|
5
|
+
<%= f.date_field :birthday %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<tr>
|
2
|
+
<td class="has-text-right"><%= Profile.human_attribute_name(:real_name) %></td>
|
3
|
+
<td><%= @profile.real_name %></td>
|
4
|
+
</tr>
|
5
|
+
<tr>
|
6
|
+
<td class="has-text-right"><%= Profile.human_attribute_name(:nick_name) %></td>
|
7
|
+
<td><%= @profile.nick_name %></td>
|
8
|
+
</tr>
|
9
|
+
<tr>
|
10
|
+
<td class="has-text-right"><%= Profile.human_attribute_name(:gender) %></td>
|
11
|
+
<td><%= @profile.gender_i18n %></td>
|
12
|
+
</tr>
|
13
|
+
<tr>
|
14
|
+
<td class="has-text-right"><%= Profile.human_attribute_name(:birthday_type) %></td>
|
15
|
+
<td><%= @profile.birthday_type_i18n %></td>
|
16
|
+
</tr>
|
17
|
+
<tr>
|
18
|
+
<td class="has-text-right"><%= Profile.human_attribute_name(:birthday) %></td>
|
19
|
+
<td><%= @profile.birthday %></td>
|
20
|
+
</tr>
|
@@ -0,0 +1 @@
|
|
1
|
+
json.profile @profile, partial: 'profile', as: :profile
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%= form_with theme: 'search', model: Profiled::Address.new do |f| %>
|
2
|
+
<div class="field-body">
|
3
|
+
<%= f.text_field :name %>
|
4
|
+
<div class="field is-narrow">
|
5
|
+
<%= f.submit %>
|
6
|
+
<%= link_to t('.clear'), filter_params(except: [:name]), class: 'button is-light' %>
|
7
|
+
</div>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= render 'error_messages', target: f.object %>
|
2
|
+
<%= f.text_field :contact %>
|
3
|
+
<%= f.text_field :tel %>
|
4
|
+
<div class="weui-cell weui-cell_active weui-cell_readonly">
|
5
|
+
<div class="weui-cell__hd">
|
6
|
+
<label class="weui-label"><%= Profiled::Address.human_attribute_name(:area_id) %></label>
|
7
|
+
</div>
|
8
|
+
<div class="weui-cell__bd is-flex" data-controller="weui-picker" data-weui-picker-id-value="address_area_id" data-weui-picker-url-value="<%= url_for(controller: '/profiled/areas', area_id: f.object.area_id) %>" data-action="click->weui-picker#getData">
|
9
|
+
<%= f.hidden_field :area_id %>
|
10
|
+
<% f.object.area.names.each do |name| %>
|
11
|
+
<%= text_field_tag :provinceName, name, class: 'weui-input', readonly: true %>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
<%= f.text_area :detail %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="weui-media-box weui-media-box_appmsg" data-controller="swipe" data-action="touchmove->swipe#move:passive touchstart->swipe#start:passive touchend->swipe#end:passive">
|
2
|
+
<div class="weui-media-box__bd is-flex is-flex-direction-column">
|
3
|
+
<h6 class="weui-media-box__title">
|
4
|
+
<span><%= model.contact %></span>
|
5
|
+
<span><%= model.tel %></span>
|
6
|
+
</h6>
|
7
|
+
<div class="weui-media-box__desc is-size-7">
|
8
|
+
<span><%= model.area.full_name %></span>
|
9
|
+
<span><%= model.detail %></span>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
<div class="weui-media-box__ft" data-swipe-target="open" style="width: 0">
|
13
|
+
<%= link_to({ action: 'edit', id: model.id }, class: 'weui-btn weui-btn_primary button_to') do %>
|
14
|
+
<i class="fa-light fa-pencil has-text-white"></i>
|
15
|
+
<% end %>
|
16
|
+
<%= button_to({ action: 'destroy', id: model.id }, method: :delete, data: { confirm: t('.confirm') }, form: { class: 'weui-btn weui-btn_danger button_to' }) do %>
|
17
|
+
<i class="fa-light fa-trash has-text-white"></i>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<th><%= Profiled::Address.human_attribute_name(:contact) %></th>
|
2
|
+
<th><%= Profiled::Address.human_attribute_name(:tel) %></th>
|
3
|
+
<th><%= Profiled::Address.human_attribute_name(:full_name) %></th>
|
4
|
+
<th><%= Profiled::Address.human_attribute_name(:detail) %></th>
|
5
|
+
<th></th>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<label class="weui-cell weui-cell_active weui-check__label">
|
2
|
+
<span class="weui-cell__bd is-flex is-flex-direction-column">
|
3
|
+
<span>
|
4
|
+
<span><%= model.contact %></span>
|
5
|
+
<span><%= model.tel %></span>
|
6
|
+
</span>
|
7
|
+
<span class="is-size-7">
|
8
|
+
<span><%= model.area.full_name %></span>
|
9
|
+
<span><%= model.detail %></span>
|
10
|
+
</span>
|
11
|
+
</span>
|
12
|
+
<span class="weui-cell__ft" data-controller="input">
|
13
|
+
<%= form_with theme: nil, scope: 'cart', url: { controller: 'trade/my/carts', action: 'update' }, method: :patch do |f| %>
|
14
|
+
<%= f.check_box :address_id, { checked: model.id == current_cart.address_id, class: 'weui-check', data: { action: 'input#form' } }, model.id, model.id %>
|
15
|
+
<span class="weui-icon-checked"></span>
|
16
|
+
<% end %>
|
17
|
+
</span>
|
18
|
+
</label>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div class="weui-panel">
|
2
|
+
<div class="weui-panel__hd">填写收货地址</div>
|
3
|
+
<div class="weui-panel__bd">
|
4
|
+
<%= form_with theme: 'weui', model: @address, url: { controller: 'profiled/my/addresses', action: 'create' }, class: 'weui-form pt-0' do |f| %>
|
5
|
+
<%= render partial: 'form', locals: { f: f } %>
|
6
|
+
<div class="weui-form__opr-area is-flex is-justify-content-center mb-0">
|
7
|
+
<%= f.submit '提交', wrap: { submit: nil } %>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
<div id="area_select"></div>
|