-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10321 from saraycp/inline-edit-user-profile
Allow inline edition for user profile page
- Loading branch information
Showing
10 changed files
with
144 additions
and
49 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
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
20 changes: 20 additions & 0 deletions
20
src/api/app/views/webui/user/user_profile_redesign/_basic_info.html.haml
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,20 @@ | ||
.basic-info{ class: feature_enabled?(:user_profile_redesign) ? 'in-place-editing' : '' } | ||
.row.mb-3.mb-md-0 | ||
.col-4.col-sm-2.col-md-12.text-center | ||
= image_tag_for(user, size: 200) | ||
.col-8.col-sm-10.col-md-12.pl-0.p-md-3 | ||
%h4#home-realname | ||
= user.realname | ||
%h5.text-muted#home-login | ||
= user.login | ||
|
||
- role_titles.each do |title| | ||
%span.badge.badge-secondary | ||
= title.upcase | ||
%p= render_as_markdown(user.biography) | ||
|
||
.mt-4 | ||
- if User.session | ||
= mail_to(user.email, title: "Send mail to #{user.name}", class: 'd-block') do | ||
%i.fas.fa-envelope.mr-1 | ||
= user.email |
28 changes: 28 additions & 0 deletions
28
src/api/app/views/webui/user/user_profile_redesign/_edit_account_form.html.haml
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,28 @@ | ||
- behind_proxy = account_edit_link.present? | ||
|
||
= form_for(displayed_user, url: user_path(displayed_user), method: :patch, remote: true) do |f| | ||
= f.hidden_field(:login, id: 'user') | ||
|
||
.mb-3.text-center= image_tag_for(displayed_user, size: 200) | ||
.form-group | ||
= f.text_field(:realname, readonly: behind_proxy, placeholder: 'Name', class: 'form-control') | ||
.form-group | ||
= f.text_field(:login, readonly: true, class: 'form-control') | ||
.form-group | ||
- role_titles.each do |title| | ||
%span.badge.badge-secondary | ||
= title.upcase | ||
.form-group | ||
= f.text_area(:biography, rows: 6, placeholder: 'Biography', maxlength: User::MAX_BIOGRAPHY_LENGTH_ALLOWED, class: 'form-control') | ||
= f.label(:biography, class: 'd-block text-right') do | ||
%small.form-text Max. #{User::MAX_BIOGRAPHY_LENGTH_ALLOWED} characters. | ||
.form-group | ||
= f.text_field(:email, required: true, email: true, placeholder: 'Email', readonly: behind_proxy, class: 'form-control') | ||
.form-group | ||
- if behind_proxy | ||
%p | ||
You are behind a proxy. You can modify other data related to your profile by | ||
= link_to(' this link.', account_edit_link) | ||
.form-group.text-right | ||
= link_to 'Cancel', user_path(displayed_user), class: 'cancel btn btn-outline-danger px-4', remote: true | ||
= submit_tag('Update', class: 'btn btn-primary px-4') |
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 @@ | ||
$('#flash').empty(); | ||
$('.in-place-editing').animate({ | ||
opacity: 0.25 | ||
}, 400, function() { | ||
scrollToInPlace(); | ||
$('.in-place-editing').html("<%= escape_javascript(render(partial: 'webui/user/user_profile_redesign/edit_account_form', locals: { displayed_user: @displayed_user, role_titles: @role_titles, account_edit_link: @account_edit_link})) %>"); | ||
$('.in-place-editing').animate({ opacity: 1 }, 400, function() { | ||
$("form *[autofocus='autofocus']").focus(); | ||
}); | ||
}); |
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,8 @@ | ||
$('.in-place-editing').animate({ | ||
opacity: 0.25 | ||
}, 400, function() { | ||
scrollToInPlace(); | ||
$('.in-place-editing').html("<%= escape_javascript(render(partial: 'webui/user/user_profile_redesign/basic_info', locals: { user: @displayed_user, role_titles: @role_titles })) %>"); | ||
setCollapsible(); | ||
$('.in-place-editing').animate({ opacity: 1 }, 400); | ||
}); |
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 @@ | ||
resetFormValidation(); | ||
- if @displayed_user.errors.any? | ||
- @displayed_user.errors.messages.each do |field, messages| | ||
element = $("##{@displayed_user.class.name.underscore}_#{field}"); // Create strings like "user_email" | ||
setFormValidation(element, "#{messages.to_sentence}"); | ||
- else | ||
- locals = { user: @displayed_user, role_titles: @role_titles } | ||
:plain | ||
$('.in-place-editing').animate({ | ||
opacity: 0.25 | ||
}, 400, function() { | ||
scrollToInPlace(); | ||
$('.in-place-editing').html( | ||
"#{escape_javascript(render(partial: 'webui/user/user_profile_redesign/basic_info', locals: locals))}"); | ||
setCollapsible(); | ||
$('.in-place-editing').animate({ opacity: 1 }, 400, function() { | ||
$('#flash').html("#{escape_javascript(render(layout: false, partial: 'layouts/webui/flash', object: flash))}"); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -300,6 +300,7 @@ | |
end | ||
member do | ||
post 'change_password' | ||
get 'edit_account' | ||
end | ||
end | ||
|
||
|
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