Skip to content

Commit

Permalink
Fix: some UI bugs (edit previous submission & edit user page) (#30)
Browse files Browse the repository at this point in the history
* disable edit link in the  submissions table

* fix user edit action returning always password empty error
  • Loading branch information
syphax-bouazzouni authored Oct 21, 2023
1 parent e0af502 commit b5b53da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
16 changes: 5 additions & 11 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class UsersController < ApplicationController

before_action :unescape_id, only: [:edit, :show, :update]
before_action :verify_owner, only: [:edit, :show, :subscribe, :un_subscribe]
before_action :authorize_admin, only: [:index,:subscribe, :un_subscribe]
Expand Down Expand Up @@ -231,7 +231,7 @@ def validate(params)
end

if params[:username].nil? || params[:username].length < 1 || !params[:username].match(/^[a-zA-Z0-9]([._-](?![._-])|[a-zA-Z0-9]){3,18}[a-zA-Z0-9]$/)
errors << "Please provide a valid username, which should not be your email address or include any special characters"
errors << "please enter a valid username"
end
return errors
end
Expand All @@ -250,16 +250,10 @@ def validate_update(params)
if params[:username].nil? || params[:username].length < 1
errors << "Last name field is required"
end
if params[:orcidId] && ((!params[:orcidId].match(/^\d{4}+(-\d{4})+$/)) || (params[:orcidId].length != 19)) && !(params[:orcidId].nil? || params[:orcidId].length < 1)
errors << "Please enter a valid orcid id"
end


if params[:password].nil? || params[:password].empty?
errors << "Your Password can't be empty"
if params[:orcidId].present? && ((!params[:orcidId].match(/^\d{4}-\d{4}-\d{4}-\d{4}$/)) || (params[:orcidId].length != 19))
errors << "Please enter a valide orcide id"
end

if params[:password] && !params[:password].eql?(params[:password_confirmation])
if !params[:password].eql?(params[:password_confirmation])
errors << "Your Password and Password Confirmation do not match"
end

Expand Down
6 changes: 3 additions & 3 deletions app/views/submissions/_submissions.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
- if @ontology.admin?(session[:user])
%td
%div.d-flex
%a.btn.btn-sm.btn-link{:href => "/ontologies/#{@ontology.acronym}/submissions/#{sub.submissionId}/edit", 'data-turbo-frame':"_top"}
%span Edit
- unless index.zero?
-#%a.btn.btn-sm.btn-link{:href => "/ontologies/#{@ontology.acronym}/submissions/#{sub.submissionId}/edit", 'data-turbo-frame':"_top"}
-# %span Edit
- unless sub.submissionId.eql?(submission_readyId)
- alert_text = "Are you sure you want to delete submission <span style='color:red;font-weight:bold;'>" + sub.submissionId.to_s + "</span> for ontology <span style='color:red;font-weight:bold;'>" + @ontology.acronym + "</span>?<br/><b>This action CAN NOT be undone!!!</b>"
= button_to "Delete", "/admin/ontologies/#{@ontology.acronym}/submissions/#{sub.submissionId}?turbo_stream=true", method: :delete, class:'btn btn-sm btn-link', form: {data: { turbo: true, turbo_confirm: alert_text, turbo_frame: '_top'}}

Expand Down

0 comments on commit b5b53da

Please sign in to comment.