Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: some UI bugs (edit previous submission & edit user page) #30

Merged
merged 2 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading