User form

This commit is contained in:
Martin Lensment 2014-09-30 12:28:16 +03:00
parent 14f9304c6d
commit 0e7e83134c
11 changed files with 252 additions and 6 deletions

View file

@ -0,0 +1,56 @@
= form_for([:admin, @user]) do |f|
- if @user.errors.any?
- @user.errors.each do |attr, err|
= err
%br
- if @user.errors.any?
%hr
.row
.col-md-6
.form-group
= f.label :username
= f.text_field(:username, class: 'form-control')
.form-group
= f.label :password
= f.text_field(:password, class: 'form-control')
.form-group
= f.label :identity_code
= f.text_field(:identity_code, class: 'form-control')
.col-md-6.text-left
.form-group
= f.label :email
= f.text_field(:email, class: 'form-control')
.form-group
.form-group.has-feedback.js-typeahead-container
= f.label :registrar_typeahead
= f.text_field(:registrar_typeahead, class: 'form-control js-registrar-typeahead', placeholder: t('shared.registrar'), autocomplete: 'off')
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
%span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove
= f.hidden_field(:registrar_id, class: 'js-registrar-id')
.form-group
.checkbox
%label{for: 'user_admin'}
= f.check_box(:admin, class: 'js-admin')
= t('shared.admin')
%hr
.row
.col-md-12.text-right
= button_tag(t('shared.save'), class: 'btn btn-primary')
:javascript
Autocomplete.bindAdminRegistrarSearch();
toggleRegistrar();
$('#user_admin').click(function() {
toggleRegistrar();
});
function toggleRegistrar() {
if($('.js-admin').is(':checked')) {
$('.js-registrar-typeahead, .js-registrar-id').attr('disabled', true);
} else {
$('.js-registrar-typeahead, .js-registrar-id').attr('disabled', false);
}
}

View file

@ -0,0 +1,9 @@
.row
.col-sm-6
%h2.text-center-xs
= "#{t('shared.edit_user')}"
.col-sm-6
%h2.text-right.text-center-xs
= link_to(t('shared.back_to_user'), [:admin, @user], class: 'btn btn-default')
%hr
= render 'form'

View file

@ -0,0 +1,34 @@
.row
.col-sm-6
%h2.text-center-xs= t('shared.users')
.col-sm-6
%h2.text-right.text-center-xs
= link_to(t('shared.create_new_user'), new_admin_user_path, class: 'btn btn-primary')
%hr
.row
.col-md-12
.table-responsive
%table.table.table-hover.table-bordered.table-condensed
%thead
%tr
%th{class: 'col-xs-2'}
= sort_link(@q, 'username')
%th{class: 'col-xs-2'}
= sort_link(@q, 'email', t('shared.email'))
%th{class: 'col-xs-2'}
= sort_link(@q, 'identity_code', t('shared.identity_code'))
%th{class: 'col-xs-2'}
= sort_link(@q, 'admin', t('shared.admin'))
%th{class: 'col-xs-2'}
= sort_link(@q, 'registrar', t('shared.registrar'))
%tbody
- @users.each do |x|
%tr
%td= link_to(x, [:admin, x])
%td= x.email
%td= x.identity_code
%td= x.admin
%td= x.registrar
.row
.col-md-12
= paginate @users

View file

@ -0,0 +1,3 @@
%h2= t('shared.create_new_user')
%hr
= render 'form'

View file

@ -0,0 +1,46 @@
.row
.col-sm-6
%h2.text-center-xs
= "#{t('shared.user_details')}"
.col-sm-6
%h2.text-right.text-center-xs
= link_to(t('shared.edit'), edit_admin_user_path(@user), class: 'btn btn-primary')
= link_to(t('shared.delete'), admin_user_path(@user), method: :delete, data: { confirm: t('shared.are_you_sure') }, class: 'btn btn-danger')
%hr
- if @user.errors.any?
- @user.errors.each do |attr, err|
= err
%br
- if @user.errors.any?
%hr
.row
.col-md-6
.panel.panel-default
.panel-heading
%h3.panel-title= t('shared.general')
.panel-body
%dl.dl-horizontal
%dt= t('shared.username')
%dd= @user.username
%dt= t('shared.password')
%dd= @user.password
%dt= t('shared.identity_code')
%dd= @user.identity_code
.col-md-6
.panel.panel-default
.panel-heading
%h3.panel-title= t('shared.address')
.panel-body
%dl.dl-horizontal
%dt= t('shared.email')
%dd= @user.email
%dt= t('shared.registrar')
%dd= @user.registrar
%dt= t('shared.admin')
%dd= @user.admin