Merge pull request #2960 from hennevogel/bugfix/forms
Bugfix some forms
This commit is contained in:
commit
95964267a0
9 changed files with 97 additions and 114 deletions
|
|
@ -26,14 +26,9 @@ class RegistrationsController < Devise::RegistrationsController
|
||||||
end
|
end
|
||||||
|
|
||||||
def account_update_params
|
def account_update_params
|
||||||
params.require(:user).permit(
|
user_attributes = [:email, :name, :password, :password_confirmation, :current_password, :email_public]
|
||||||
:email,
|
user_attributes << :is_admin if current_user.is_admin?
|
||||||
:password,
|
params.require(:user).permit(user_attributes)
|
||||||
:password_confirmation,
|
|
||||||
:current_password,
|
|
||||||
:username,
|
|
||||||
:email_public
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_captcha
|
def check_captcha
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class UsersController < ApplicationController
|
||||||
def search
|
def search
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.json do
|
format.json do
|
||||||
render json: { users: User.where('username like ?', "%#{params[:query]}%").select(:username, :id) }
|
render json: { users: User.active.where('username like ?', "%#{params[:query]}%").select(:username, :id) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -111,30 +111,6 @@ module ApplicationHelper
|
||||||
safe_join(event.speakers.map{ |speaker| link_to speaker.name, admin_user_path(speaker) }, ',')
|
safe_join(event.speakers.map{ |speaker| link_to speaker.name, admin_user_path(speaker) }, ',')
|
||||||
end
|
end
|
||||||
|
|
||||||
def speaker_selector_input(form)
|
|
||||||
user_selector_input(:speakers, form, '', true)
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_selector_input(field, form, hint = '', multiple = true)
|
|
||||||
users = User.where(is_disabled: false).pluck(:id, :name, :username, :email).map { |user| [user[0], user[1].blank? ? user[2] : user[1], user[2], user[3]] }.sort_by { |user| user[1].downcase }
|
|
||||||
form.input(
|
|
||||||
field,
|
|
||||||
as: :select,
|
|
||||||
include_blank: true,
|
|
||||||
label: field.to_s.titleize,
|
|
||||||
hint: hint,
|
|
||||||
collection: options_for_select(
|
|
||||||
users.map { |user| ["#{user[1]} (#{user[2]}) #{user[3]}", user[0]] },
|
|
||||||
(form.object.send(field)&.map(&:id) || form.object.send(field)&.id)
|
|
||||||
),
|
|
||||||
input_html: {
|
|
||||||
class: 'select-help-toggle',
|
|
||||||
multiple: multiple,
|
|
||||||
placeholder: (multiple ? 'Select users...' : 'Select a user...')
|
|
||||||
}
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def event_types_sentence(conference)
|
def event_types_sentence(conference)
|
||||||
conference.event_types.map { |et| et.title.pluralize }.to_sentence
|
conference.event_types.map { |et| et.title.pluralize }.to_sentence
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@
|
||||||
%abbr{title: 'This field is required'} *
|
%abbr{title: 'This field is required'} *
|
||||||
= f.text_field :website_url, class: 'form-control', required: true, placeholder: 'URL'
|
= f.text_field :website_url, class: 'form-control', required: true, placeholder: 'URL'
|
||||||
.form-group
|
.form-group
|
||||||
= f.text_field :responsible_ids, multiple: true, class: "form-control", id: "booth_responsibles", placeholder: "Responsibles"
|
= f.label :responsible_ids, 'Responsibles'
|
||||||
|
= f.select :responsible_ids, [], {}, { multiple: true, class: 'form-control', id: 'users_selectize', placeholder: 'Responsibles' }
|
||||||
%span.help-block
|
%span.help-block
|
||||||
The people responsible for the `t('booth')`. You can only select existing users.
|
The people responsible for the `t('booth')`. You can only select existing users.
|
||||||
.form-group
|
.form-group
|
||||||
|
|
@ -38,33 +39,5 @@
|
||||||
- else
|
- else
|
||||||
Update `(t'booth').capitalize` Request
|
Update `(t'booth').capitalize` Request
|
||||||
|
|
||||||
:javascript
|
= render partial: 'shared/user_selectize'
|
||||||
$(document).ready(function() {
|
|
||||||
$('#booth_responsibles').selectize({
|
|
||||||
persist: false,
|
|
||||||
create: false,
|
|
||||||
valueField: 'id',
|
|
||||||
labelField: 'username',
|
|
||||||
searchField: 'username',
|
|
||||||
load: function(query, callback) {
|
|
||||||
if (!query.length) return callback();
|
|
||||||
$.ajax({
|
|
||||||
url: "#{search_users_path}.json",
|
|
||||||
type: 'GET',
|
|
||||||
dataType: 'json',
|
|
||||||
data: {
|
|
||||||
query: query,
|
|
||||||
},
|
|
||||||
error: function(res) {
|
|
||||||
console.log("selectize error");
|
|
||||||
callback();
|
|
||||||
},
|
|
||||||
success: function(res) {
|
|
||||||
console.log("selectize success");
|
|
||||||
// console.log(res);
|
|
||||||
callback(res.users);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,22 @@
|
||||||
.row
|
.container
|
||||||
.col-md-12
|
.row
|
||||||
.well
|
.col-md-12
|
||||||
%h1
|
.well
|
||||||
Welcome to your new
|
%h1
|
||||||
= link_to('https://osem.io') do
|
Welcome to your new
|
||||||
Open Source Event Manager
|
= link_to('https://osem.io') do
|
||||||
installation!
|
Open Source Event Manager
|
||||||
%p
|
installation!
|
||||||
The first user to
|
%p
|
||||||
- if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
The first user to
|
||||||
= link_to(new_ichain_registration_path('user')) do
|
- if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
sign up
|
= link_to(new_ichain_registration_path('user')) do
|
||||||
- else
|
sign up
|
||||||
= link_to(new_registration_path('user')) do
|
- else
|
||||||
sign up
|
= link_to(new_registration_path('user')) do
|
||||||
will the be administrator of it.
|
sign up
|
||||||
%p
|
will the be administrator of it.
|
||||||
We hope you enjoy using OSEM, if you have any question don't hesitate to
|
%p
|
||||||
= link_to('https://osem.io/#contact') do
|
We hope you enjoy using OSEM, if you have any question don't hesitate to
|
||||||
contact us!
|
= link_to('https://osem.io/#contact') do
|
||||||
|
contact us!
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
.form-group
|
- unless @user.persisted?
|
||||||
= f.label :username
|
.form-group
|
||||||
%abbr{title: 'This field is required'} *
|
= f.label :username
|
||||||
= f.text_field :username, required: true, autocomplete: 'off', class: 'form-control', placeholder: 'Username'
|
%abbr{title: 'This field is required'} *
|
||||||
|
= f.text_field :username, required: true, autocomplete: 'off', class: 'form-control', placeholder: 'Username'
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :email
|
= f.label :email
|
||||||
%abbr{title: 'This field is required'} *
|
%abbr{title: 'This field is required'} *
|
||||||
|
|
@ -10,17 +11,17 @@
|
||||||
.checkbox
|
.checkbox
|
||||||
%label
|
%label
|
||||||
= f.check_box :email_public
|
= f.check_box :email_public
|
||||||
Check if you want your email address to appear publicly (e.g. on sessions, registration lists, etc.)
|
Do you want your email address to appear publicly
|
||||||
.form-group
|
%span.help-block
|
||||||
= f.label :name, 'Real Name'
|
For instance on sessions pages or registration lists.
|
||||||
= f.text_field :name, required: true, class: 'form-control', placeholder: 'Name'
|
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :password, 'Password'
|
= f.label :password, 'Password'
|
||||||
%abbr{title: 'This field is required'} *
|
- if !@user.persisted?
|
||||||
= f.password_field :password, required: true, class: 'form-control', placeholder: 'Password'
|
%abbr{title: 'This field is required'} *
|
||||||
|
= f.password_field :password, required: !@user.persisted?, class: 'form-control', placeholder: 'Password'
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :password_confirmation, 'Password Confirmation'
|
= f.label :password_confirmation, 'Password Confirmation'
|
||||||
= f.password_field :password_confirmation, required: true, class: 'form-control', placeholder: 'Password Confirmation'
|
= f.password_field :password_confirmation, required: !@user.persisted?, class: 'form-control', placeholder: 'Password Confirmation'
|
||||||
- if @user.persisted?
|
- if @user.persisted?
|
||||||
%p.text-muted
|
%p.text-muted
|
||||||
Leave blank if you don't want to change your password
|
Leave blank if you don't want to change your password
|
||||||
|
|
@ -32,16 +33,16 @@
|
||||||
is Admin?
|
is Admin?
|
||||||
%span.help-block
|
%span.help-block
|
||||||
An admin can create a new conference, manage users and make other users admins.
|
An admin can create a new conference, manage users and make other users admins.
|
||||||
- elsif @user.persisted?
|
- if @user.persisted?
|
||||||
%h4
|
%h4
|
||||||
Confirmation
|
Confirmation
|
||||||
%hr
|
%hr
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :password, "Current Password"
|
= f.label :password, "Current Password"
|
||||||
%abbr{title: 'This field is required'} *
|
%abbr{title: 'This field is required'} *
|
||||||
= f.password_field :current_password, autocomplete: 'off', class: 'form-control', placeholder: 'Password'
|
= f.password_field :current_password, required: true, autocomplete: 'off', class: 'form-control', placeholder: 'Password'
|
||||||
%p.text-muted
|
%p.text-muted
|
||||||
We need your current password to confirm password, email or username changes
|
We need your current password to confirm changes
|
||||||
- Feature.with(:recaptcha) do
|
- Feature.with(:recaptcha) do
|
||||||
.form-group
|
.form-group
|
||||||
= recaptcha_tags
|
= recaptcha_tags
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,24 @@
|
||||||
.form-group
|
.form-group
|
||||||
= f.label :subtitle
|
= f.label :subtitle
|
||||||
= f.text_field :subtitle, class: 'form-control'
|
= f.text_field :subtitle, class: 'form-control'
|
||||||
= # speaker_selector_input f
|
.form-group
|
||||||
|
= f.label :speaker_ids, 'Speakers'
|
||||||
|
- if f.object.speakers.any?
|
||||||
|
%p
|
||||||
|
Current:
|
||||||
|
= f.object.speakers.pluck(:username).join(', ')
|
||||||
|
= f.select :speaker_ids, [], {}, { multiple: true, class: "form-control", id: "users_selectize", placeholder: "Speakers" }
|
||||||
|
%span.help-block
|
||||||
|
The people responsible for the event, beside you. You can only select existing users.
|
||||||
- if @program.tracks.confirmed.cfp_active.any?
|
- if @program.tracks.confirmed.cfp_active.any?
|
||||||
= f.label :track_id, 'Track'
|
.form-group
|
||||||
= f.select :track_id, @program.tracks.confirmed.cfp_active.pluck(:name, :id), include_blank: '(Please select)'
|
= f.label :track_id, 'Track'
|
||||||
= f.label :event_type_id, 'Type'
|
= f.select :track_id, @program.tracks.confirmed.cfp_active.pluck(:name, :id), { include_blank: '(Please select)' }, { class: 'form-control' }
|
||||||
= f.select :event_type_id, event_type_select_options(@conference.program.event_types), { include_blank: false }, { class: 'select-help-toggle form-control' }
|
.form-group
|
||||||
|
= f.label :event_type_id, 'Type'
|
||||||
|
= f.select :event_type_id, event_type_select_options(@conference.program.event_types), { include_blank: false }, { class: 'select-help-toggle form-control' }
|
||||||
- if @program.languages.present?
|
- if @program.languages.present?
|
||||||
|
.form-group
|
||||||
= f.label :language
|
= f.label :language
|
||||||
= f.select :language, @languages, { include_blank: false}, { class: 'select-help-toggle form-control' }
|
= f.select :language, @languages, { include_blank: false}, { class: 'select-help-toggle form-control' }
|
||||||
- @conference.program.event_types.each do |event_type|
|
- @conference.program.event_types.each do |event_type|
|
||||||
|
|
@ -72,10 +83,5 @@
|
||||||
%p.text-right
|
%p.text-right
|
||||||
= f.submit 'Update Proposal', class: 'btn btn-success'
|
= f.submit 'Update Proposal', class: 'btn btn-success'
|
||||||
|
|
||||||
:javascript
|
= render partial: 'shared/user_selectize'
|
||||||
$(document).ready(function() {
|
|
||||||
$('#event_speaker_ids').selectize({
|
|
||||||
plugins: ['remove_button'],
|
|
||||||
maxItems: 5
|
|
||||||
} )
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,10 @@
|
||||||
words.
|
words.
|
||||||
= markdown_hint('[Tips to improve your presentations.](http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx)')
|
= markdown_hint('[Tips to improve your presentations.](http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx)')
|
||||||
- if @program.cfp.enable_registrations?
|
- if @program.cfp.enable_registrations?
|
||||||
.form-group
|
.checkbox
|
||||||
= f.label :require_registration, 'Require participants to register to your event'
|
%label
|
||||||
= f.check_box :require_registration, class: 'form-control'
|
= f.check_box :require_registration
|
||||||
|
Require participants to register to your event?
|
||||||
%p.text-right
|
%p.text-right
|
||||||
= link_to '#description', 'data-toggle' => 'collapse', id: 'description_link' do
|
= link_to '#description', 'data-toggle' => 'collapse', id: 'description_link' do
|
||||||
Do you require something special for your event?
|
Do you require something special for your event?
|
||||||
|
|
|
||||||
30
app/views/shared/_user_selectize.html.haml
Normal file
30
app/views/shared/_user_selectize.html.haml
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
:javascript
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#users_selectize').selectize({
|
||||||
|
persist: false,
|
||||||
|
create: false,
|
||||||
|
valueField: 'id',
|
||||||
|
labelField: 'username',
|
||||||
|
searchField: 'username',
|
||||||
|
load: function(query, callback) {
|
||||||
|
if (!query.length) return callback();
|
||||||
|
$.ajax({
|
||||||
|
url: "#{search_users_path}.json",
|
||||||
|
type: 'GET',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
query: query,
|
||||||
|
},
|
||||||
|
error: function(res) {
|
||||||
|
console.log("selectize error");
|
||||||
|
callback();
|
||||||
|
},
|
||||||
|
success: function(res) {
|
||||||
|
console.log("selectize success");
|
||||||
|
// console.log(res);
|
||||||
|
callback(res.users);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue