-
Notifications
You must be signed in to change notification settings - Fork 510
Expand file tree
/
Copy path_form.html.erb
More file actions
200 lines (178 loc) · 8.25 KB
/
Copy path_form.html.erb
File metadata and controls
200 lines (178 loc) · 8.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<%= form_with(model: person, url: settings_person_path, class: "contents") do |form| %>
<% if person.errors.any? %>
<div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-lg mt-3">
<h2><%= pluralize(person.errors.count, "error") %> prohibited this person from being saved:</h2>
<ul>
<% person.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="my-5">
<%= form.label :email %>
<%= form.text_field :email, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full dark:text-black" %>
</div>
<%= form.fields_for :personable_attributes, person.personable do |user_fields| %>
<%= user_fields.hidden_field :id %>
<div class="my-5">
<%= user_fields.label :first_name %>
<%= user_fields.text_field :first_name, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full dark:text-black" %>
</div>
<div class="my-5">
<%= user_fields.label :last_name %>
<%= user_fields.text_field :last_name, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full dark:text-black" %>
</div>
<!-- Profile Picture Upload -->
<div class="my-5" data-controller="profile-picture-upload">
<%= user_fields.label :profile_picture, "Profile Picture" %>
<div class="mt-2">
<div class="flex items-center space-x-4">
<!-- Current avatar display -->
<div data-profile-picture-upload-target="currentAvatar">
<%= render partial: "layouts/user_avatar", locals: { user: person.personable, size: 16, classes: "" } %>
</div>
<!-- Upload controls -->
<div class="flex-1">
<%= user_fields.file_field :profile_picture,
accept: "image/*",
class: "hidden",
data: {
profile_picture_upload_target: "fileInput",
action: "change->profile-picture-upload#previewImage"
} %>
<div class="flex space-x-2">
<%= button_tag "Choose Photo",
type: "button",
class: "inline-block font-medium bg-gray-100 dark:bg-gray-900 dark:text-white border border-gray-400 rounded-lg py-2 px-4 cursor-pointer text-sm",
data: { action: "profile-picture-upload#chooseFile" } %>
<% if person.personable.has_profile_picture? %>
<%= button_tag "Remove",
type: "button",
class: "inline-block font-medium bg-red-100 dark:bg-red-900 dark:text-white border border-red-400 rounded-lg py-2 px-4 cursor-pointer text-sm",
data: { action: "profile-picture-upload#removeImage" } %>
<% end %>
</div>
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
JPEG, PNG, GIF, or WebP. Max 5MB.
</p>
</div>
</div>
<!-- Preview area (hidden by default) -->
<div class="mt-4 hidden" data-profile-picture-upload-target="previewContainer">
<p class="text-sm text-gray-600 dark:text-gray-400 mb-2">Preview:</p>
<div class="flex items-center space-x-4">
<div class="rounded-full w-16 h-16 overflow-hidden border border-gray-200 dark:border-gray-600">
<img data-profile-picture-upload-target="previewImage"
class="w-full h-full object-cover"
alt="Profile picture preview">
</div>
<p class="text-sm text-gray-600 dark:text-gray-400">
This is how your profile picture will appear.
</p>
</div>
</div>
</div>
</div>
<% person.personable.credentials.type_is("PasswordCredential").each do |credential| %>
<%= user_fields.fields_for :credentials_attributes, credential, index: credential.id do |credential_fields| %>
<%= credential_fields.hidden_field :type, value: credential.type %>
<div class="my-5">
<%= credential_fields.label :password %>
<%= credential_fields.text_field :password, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full dark:text-black" %>
</div>
<% end %>
<% end %>
<div class="my-5" data-controller="transition" data-transition-toggle-class="hidden">
<%= user_fields.label :dark_mode, "Color Theme" %>
<div class="flex items-center justify-between outline-none pl-3 py-2 mt-2 w-full dark:text-black gap-1">
<%= user_fields.fields_for :preferences do |preferences_fields| %>
<% %w(dark light system).each do |value| %>
<div class="flex items-center gap-2">
<%= preferences_fields.radio_button :dark_mode, value, checked: Current.user.preferences[:dark_mode] == value %>
<%= user_fields.label :dark_mode, value.capitalize, class: "dark:text-gray-100", for: "person_personable_attributes_preferences_dark_mode_#{value}"%>
</div>
<% end %>
<% end %>
</div>
</div>
<% if Feature.google_tools? %>
<div class="my-5" data-controller="transition" data-transition-toggle-class="hidden">
<%= user_fields.label "Enable Tools for Assistants", "Enable Tools for Assistants" %>
<div class="flex items-center justify-between outline-none py-2 mt-2 w-full dark:text-black gap-1">
<div class="dark:text-gray-400 border-l-4 border-gray-100 dark:border-gray-600 pl-5 pr-1">
Gmail:<br>
Trouble? Try <%= link_to "Deleting connection", "https://myaccount.google.com/connections", target: "_blank", class: "underline" %>
</div>
<% if Current.user.gmail_credential %>
<div class="text-green-700 font-bold">Enabled</div>
<% else %>
<%= form.label :authorize_gmail, "Enable Gmail",
class: %|
inline-block font-medium
bg-gray-100 dark:bg-gray-900 dark:text-white
border border-gray-400
rounded-lg py-3 px-5
cursor-pointer
whitespace-nowrap
| %>
<% end %>
</div>
<div class="flex items-center justify-between outline-none py-2 mt-2 w-full dark:text-black gap-1">
<div class="dark:text-gray-400 border-l-4 border-gray-100 dark:border-gray-600 pl-5 pr-1">
Google Tasks:<br>
Trouble? Try <%= link_to "Deleting connection", "https://myaccount.google.com/connections", target: "_blank", class: "underline" %>
</div>
<% if Current.user.google_tasks_credential %>
<div class="text-green-700 font-bold">Enabled</div>
<% else %>
<%= form.label :authorize_google_tasks, "Enable Google Tasks",
class: %|
inline-block font-medium
bg-gray-100 dark:bg-gray-900 dark:text-white
border border-gray-400
rounded-lg py-3 px-5
cursor-pointer
whitespace-nowrap
| %>
<% end %>
</div>
</div>
<% end %>
<% end %>
<div class="inline">
<%= form.submit "Save",
class: %|
inline-block font-bold
bg-gray-200 dark:bg-gray-900
border border-gray-400
rounded-lg py-3 px-5
cursor-pointer
|,
data: { turbo_submits_with: "Saving..." }
%>
<%= link_to "Cancel", root_path, class: "float-right inline-block ml-5 py-3" %>
</div>
<% end # form %>
<%= button_to "Gmail",
"/auth/gmail",
id: "person_authorize_gmail",
method: :post,
data: {
turbo: false, # w/o this submits w/ ajax and the user won't see it
controller: "confirm",
confirm_text_value: "When you see the permission checkboxes, you need to Select All for this feature to work. Got it?"
},
class: "hidden"
%>
<%= button_to "Google Tasks",
"/auth/google_tasks",
id: "person_authorize_google_tasks",
method: :post,
data: {
turbo: false, # w/o this submits w/ ajax and the user won't see it
controller: "confirm",
confirm_text_value: "When you see the permission checkboxes, you need to Select All for this feature to work. Got it?"
},
class: "hidden"
%>