rails_profile 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +20 -0
  4. data/Rakefile +32 -0
  5. data/app/controllers/profiled/admin/address_organs_controller.rb +27 -0
  6. data/app/controllers/profiled/admin/addresses_controller.rb +48 -0
  7. data/app/controllers/profiled/admin/base_controller.rb +4 -0
  8. data/app/controllers/profiled/admin/profiles_controller.rb +42 -0
  9. data/app/controllers/profiled/areas_controller.rb +42 -0
  10. data/app/controllers/profiled/base_controller.rb +4 -0
  11. data/app/controllers/profiled/me/base_controller.rb +9 -0
  12. data/app/controllers/profiled/me/profiles_controller.rb +43 -0
  13. data/app/controllers/profiled/my/address_users_controller.rb +27 -0
  14. data/app/controllers/profiled/my/addresses_controller.rb +102 -0
  15. data/app/controllers/profiled/my/base_controller.rb +4 -0
  16. data/app/controllers/profiled/my/profiles_controller.rb +67 -0
  17. data/app/controllers/profiled/panel/areas_controller.rb +27 -0
  18. data/app/controllers/profiled/panel/base_controller.rb +4 -0
  19. data/app/models/concerns/qq_map_helper.rb +80 -0
  20. data/app/models/profiled/address.rb +8 -0
  21. data/app/models/profiled/address_organ.rb +5 -0
  22. data/app/models/profiled/address_user.rb +5 -0
  23. data/app/models/profiled/application_record.rb +5 -0
  24. data/app/models/profiled/area.rb +6 -0
  25. data/app/models/profiled/ext/organ.rb +11 -0
  26. data/app/models/profiled/ext/user.rb +17 -0
  27. data/app/models/profiled/model/account.rb +17 -0
  28. data/app/models/profiled/model/address.rb +33 -0
  29. data/app/models/profiled/model/address_organ.rb +23 -0
  30. data/app/models/profiled/model/address_user.rb +29 -0
  31. data/app/models/profiled/model/area.rb +120 -0
  32. data/app/models/profiled/model/profile.rb +43 -0
  33. data/app/models/profiled/profile.rb +5 -0
  34. data/app/models/profiled.rb +11 -0
  35. data/app/views/admin/_profile_nav.html.erb +10 -0
  36. data/app/views/me/_profile_nav.html.erb +4 -0
  37. data/app/views/my/_profile_nav.html.erb +5 -0
  38. data/app/views/panel/_profile_nav.html.erb +10 -0
  39. data/app/views/profiled/admin/base/_nav.html.erb +4 -0
  40. data/app/views/profiled/admin/profiles/_edit_form.html.erb +5 -0
  41. data/app/views/profiled/admin/profiles/_filter_form.html.erb +9 -0
  42. data/app/views/profiled/admin/profiles/_form.html.erb +6 -0
  43. data/app/views/profiled/admin/profiles/_index_tbody.html.erb +6 -0
  44. data/app/views/profiled/admin/profiles/_index_thead.html.erb +7 -0
  45. data/app/views/profiled/admin/profiles/_new_form.html.erb +5 -0
  46. data/app/views/profiled/admin/profiles/_profile.json.jbuilder +2 -0
  47. data/app/views/profiled/admin/profiles/_show_table.html.erb +24 -0
  48. data/app/views/profiled/admin/profiles/index.html.erb +5 -0
  49. data/app/views/profiled/admin/profiles/qrcode.json.jbuilder +1 -0
  50. data/app/views/profiled/areas/_index.html.erb +26 -0
  51. data/app/views/profiled/areas/follow.turbo_stream.erb +11 -0
  52. data/app/views/profiled/areas/index.json.jbuilder +2 -0
  53. data/app/views/profiled/areas/index.turbo_stream+phone.erb +1 -0
  54. data/app/views/profiled/me/profiles/_edit_form.html.erb +4 -0
  55. data/app/views/profiled/me/profiles/_form.html.erb +5 -0
  56. data/app/views/profiled/me/profiles/_profile.json.jbuilder +14 -0
  57. data/app/views/profiled/me/profiles/_show_table.html.erb +20 -0
  58. data/app/views/profiled/me/profiles/show.json.jbuilder +1 -0
  59. data/app/views/profiled/my/address_users/create.turbo_stream.erb +3 -0
  60. data/app/views/profiled/my/addresses/_filter_form.html.erb +9 -0
  61. data/app/views/profiled/my/addresses/_form.html+phone.erb +15 -0
  62. data/app/views/profiled/my/addresses/_form.html.erb +4 -0
  63. data/app/views/profiled/my/addresses/_index/_address.html.erb +20 -0
  64. data/app/views/profiled/my/addresses/_index_tbody.html.erb +4 -0
  65. data/app/views/profiled/my/addresses/_index_thead.html.erb +5 -0
  66. data/app/views/profiled/my/addresses/_list/_address.html.erb +18 -0
  67. data/app/views/profiled/my/addresses/_new_form.html+phone.erb +12 -0
  68. data/app/views/profiled/my/addresses/_new_form.html.erb +4 -0
  69. data/app/views/profiled/my/addresses/_outer_select.html+phone.erb +14 -0
  70. data/app/views/profiled/my/addresses/_outer_select.html.erb +17 -0
  71. data/app/views/profiled/my/addresses/_select.html.erb +10 -0
  72. data/app/views/profiled/my/addresses/_show_table.html+phone.erb +25 -0
  73. data/app/views/profiled/my/addresses/_show_table.html.erb +12 -0
  74. data/app/views/profiled/my/addresses/_wechat_form.html.erb +36 -0
  75. data/app/views/profiled/my/addresses/create.turbo_stream.erb +5 -0
  76. data/app/views/profiled/my/addresses/fork.turbo_stream.erb +3 -0
  77. data/app/views/profiled/my/addresses/index.html+phone.erb +26 -0
  78. data/app/views/profiled/my/addresses/index.html.erb +7 -0
  79. data/app/views/profiled/my/addresses/list.html+phone.erb +41 -0
  80. data/app/views/profiled/my/addresses/select.turbo_stream.erb +1 -0
  81. data/app/views/profiled/my/addresses/show.html+phone.erb +26 -0
  82. data/app/views/profiled/my/addresses/update.turbo_stream.erb +7 -0
  83. data/app/views/profiled/my/addresses/wechat.turbo_stream.erb +3 -0
  84. data/app/views/profiled/my/profiles/_edit_form.html+phone.erb +15 -0
  85. data/app/views/profiled/my/profiles/_edit_form.html.erb +4 -0
  86. data/app/views/profiled/my/profiles/_form.html.erb +6 -0
  87. data/app/views/profiled/my/profiles/_profile.json.jbuilder +1 -0
  88. data/app/views/profiled/my/profiles/_show_table.html+phone.erb +24 -0
  89. data/app/views/profiled/my/profiles/_show_table.html.erb +20 -0
  90. data/app/views/profiled/my/profiles/index.html+phone.erb +3 -0
  91. data/app/views/profiled/my/profiles/index.html.erb +31 -0
  92. data/app/views/profiled/my/profiles/index.json.jbuilder +1 -0
  93. data/app/views/profiled/my/profiles/show.html+phone.erb +8 -0
  94. data/app/views/profiled/my/profiles/show.html.erb +1 -0
  95. data/app/views/profiled/my/profiles/show.json.jbuilder +1 -0
  96. data/app/views/profiled/panel/addresses/_address.html.erb +24 -0
  97. data/app/views/profiled/panel/addresses/_edit_form.html.erb +4 -0
  98. data/app/views/profiled/panel/addresses/_form.html.erb +22 -0
  99. data/app/views/profiled/panel/addresses/_index_tbody.html.erb +16 -0
  100. data/app/views/profiled/panel/addresses/_index_thead.html.erb +5 -0
  101. data/app/views/profiled/panel/addresses/_new_form.html.erb +4 -0
  102. data/app/views/profiled/panel/addresses/index.html.erb +5 -0
  103. data/app/views/profiled/panel/areas/_filter_form.html.erb +9 -0
  104. data/app/views/profiled/panel/areas/_form.html.erb +5 -0
  105. data/app/views/profiled/panel/areas/_index_tbody.html.erb +17 -0
  106. data/app/views/profiled/panel/areas/_index_thead.html.erb +8 -0
  107. data/app/views/profiled/panel/areas/_show_table.html.erb +8 -0
  108. data/app/views/profiled/panel/areas/index.html.erb +5 -0
  109. data/app/views/profiled/panel/base/_nav.html.erb +3 -0
  110. data/config/locales/en.controller.yml +30 -0
  111. data/config/locales/en.enum.yml +15 -0
  112. data/config/locales/zh.attributes.yml +28 -0
  113. data/config/locales/zh.controller.yml +38 -0
  114. data/config/locales/zh.enum.yml +10 -0
  115. data/config/routes.rb +45 -0
  116. data/lib/rails_profile/config.rb +11 -0
  117. data/lib/rails_profile/engine.rb +21 -0
  118. data/lib/rails_profile.rb +2 -0
  119. 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,5 @@
1
+ module Profiled
2
+ class Profile < ApplicationRecord
3
+ include Model::Profile
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ module Profiled
2
+
3
+ def self.use_relative_model_naming?
4
+ true
5
+ end
6
+
7
+ def self.table_name_prefix
8
+ 'profiled_'
9
+ end
10
+
11
+ 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,4 @@
1
+ <span class="menu-label"><%= t('profiled.me.title') %></span>
2
+ <div class="menu-list">
3
+ <%= link_to t('profiled.me.profiles.show.title'), me_profile_path, class: active_helper(controllers: ['profiles'], active: 'is-active') %>
4
+ </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,4 @@
1
+ <aside class="menu is-light" style="height: 100%">
2
+ <%= render 'org_nav' if defined? RailsOrg %>
3
+ <%= render 'profile_nav' %>
4
+ </aside>
@@ -0,0 +1,5 @@
1
+ <%= form_with model: @profile, url: { action: 'create' } do |f| %>
2
+ <%= render 'error_messages', target: @profile %>
3
+ <%= render partial: 'form', locals: { f: f } %>
4
+ <%= f.submit %>
5
+ <% end %>
@@ -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,6 @@
1
+ <td><%= model.real_name %></td>
2
+ <td><%= model.nick_name %></td>
3
+ <td><%= model.gender %></td>
4
+ <td><%= model.birthday_type %></td>
5
+ <td><%= model.birthday %></td>
6
+ <td><%= model.extra %></td>
@@ -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,5 @@
1
+ <%= form_with model: @profile, url: { action: 'create' } do |f| %>
2
+ <%= render 'error_messages', target: @profile %>
3
+ <%= render partial: 'form', locals: { f: f } %>
4
+ <%= f.submit %>
5
+ <% end %>
@@ -0,0 +1,2 @@
1
+ json.extract! profile, :id, :real_name, :nick_name, :age, :birthday_type, :birthday, :address, :extra, :avatar_url
2
+ json.account profile.account, :id, :identity, :qrcode_url
@@ -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,5 @@
1
+ <%= render layout: 'index_table', locals: { cache_key: Profiled::Profile.column_names.hash } do %>
2
+ <%= render partial: 'index_tbody', layout: 'index_tr', collection: @profiles, as: :model %>
3
+ <% end %>
4
+
5
+ <%= paginate @profiles %>
@@ -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,2 @@
1
+ json.list Area.list
2
+ json.timestamp Area.timestamp
@@ -0,0 +1 @@
1
+ <%= turbo_stream.replace 'area_select', partial: 'index' %>
@@ -0,0 +1,4 @@
1
+ <%= form_with model: @profile, url: { action: 'update' } do |f| %>
2
+ <%= render partial: 'form', locals: { f: f } %>
3
+ <%= f.submit %>
4
+ <% end %>
@@ -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,14 @@
1
+ json.extract!(
2
+ profile,
3
+ :id,
4
+ :real_name,
5
+ :nick_name,
6
+ :age,
7
+ :birthday_type,
8
+ :birthday,
9
+ :address,
10
+ :organ_id,
11
+ :user_id,
12
+ :identity,
13
+ :extra
14
+ )
@@ -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,3 @@
1
+ <%= turbo_stream.append 'body' do %>
2
+ <div data-controller="visit" data-visit-url-value="<%= url_for(controller: 'wait/my/rallies') %>"></div>
3
+ <% end %>
@@ -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,4 @@
1
+ <%= f.text_field :contact %>
2
+ <%= f.text_field :tel %>
3
+ <%= render partial: 'outer_select', locals: { f: f, outer: 'area', node: @address.area } %>
4
+ <%= 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,4 @@
1
+ <td><%= model.contact %></td>
2
+ <td><%= model.tel %></td>
3
+ <td><%= model.area.full_name %></td>
4
+ <td><%= model.detail %></td>
@@ -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>