Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

#13 login page converted from erb to slim #669

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
23 changes: 0 additions & 23 deletions app/views/sessions/new.html.erb

This file was deleted.

14 changes: 14 additions & 0 deletions app/views/sessions/new.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.login_page
= form_tag sessions_path, :class => 'default-form' do
= error_messages_for :session
.login_panel
h3= t("login.details")
p
= label_tag "user_name", t("login.username")
= text_field_tag "user_name"
p
= label_tag "password", t('login.password.label')
= password_field_tag "password"
.btn_panel
= submit_button t("buttons.login")
= link_to t("login.password.reset"), :controller => "password_recovery_requests", :action => "new"
25 changes: 0 additions & 25 deletions app/views/users/_devices.html.erb

This file was deleted.

17 changes: 17 additions & 0 deletions app/views/users/_devices.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
fieldset
h3 Devices
table.devices
thead
tr
th IMEI
th Blacklisted?
tbody
- devices.each do |device|
tr id="device-imei-#{device.imei}"
td
= device.imei
td
= hidden_field_tag "user[devices][][imei]", device.imei
= hidden_field_tag "user[devices][][user_name]", device.user_name
= check_box_tag "user[devices][][blacklisted]", true, device.blacklisted?, :class => "blacklisted-checkbox-#{device.imei}"

110 changes: 0 additions & 110 deletions app/views/users/_editable_user.html.erb

This file was deleted.

81 changes: 81 additions & 0 deletions app/views/users/_editable_user.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
script charset="utf-8" type="text/javascript"
| function confirmBlacklisted() {
| $(".devices :checkbox").each(function () {
| if (this.checked && !this.defaultChecked)
| return confirm(I18n.t("devices.message.disable"));
| });
| return true;
| }

| function confirmDisable() {
| var checkbox = $("#user_disabled")[0];
| if (checkbox.checked && !checkbox.defaultChecked) {
| return confirm(I18n.t("users.messages.disable"));
| }
| return true;
| }

| $(document).ready(function () {
| $("form").submit(function () {
| return (confirmDisable() && confirmBlacklisted());
| });
| });
- if flash[:verify]
.flash
p.notice= flash[:verify]
= form_for editable_user, :html => {:class => ''} do |f|
= f.error_messages :header_tag => :h3
- trying_to_edit_ourself = editing_ourself?(editable_user)
.mandate_panel
span *
= t("mandatory_field")
.clearfix
fieldset
p
= f.label :full_name, t("user.full_name"), :class=>'key'
= f.text_field :full_name, :autocomplete => "off"
| *
p
= f.label :user_name, t("login.username"), :class=>'key'
= f.text_field :user_name, :disabled => !editable_user.new_record?, :autocomplete => "off"
| *
span.footnote= t("user.no_blank")
p
= f.label :password, t('login.password.label'), :class=>'key'
= f.password_field :password, :autocomplete => "off"
| *
p
= f.label :password_confirmation,t("login.password.re_enter"), :class=>'key'
= f.password_field :password_confirmation, :autocomplete => "off"
| *
- if !trying_to_edit_ourself
p
label.key= t("roles.label")
- @roles.each do |role|
= f.check_box :role_ids, {:id => "user_#{role.name}", :name => "user[role_ids][]"}, role.id, ""
= f.label role.name
p
= f.label :phone, t("phone"), :class=>'key'
= f.text_field :phone
p
= f.label :email, t("email"), :class=>'key'
= f.text_field :email
p
= f.label :organisation, t("organisation"), :class=>'key'
= f.text_field :organisation
| *
p
= f.label :position, t("position"), :class=>'key'
= f.text_field :position
p
= f.label :location, t("location"), :class=>'key'
= f.text_field :location
- if !trying_to_edit_ourself && can?(:disable, @user)
p
= f.label :disabled, t("user.disabled"), :class=>'key'
= f.check_box :disabled, {}, "true", "false"
= f.hidden_field :verified, :value => true
.btn_panel
/! TODO: After we got the user object in the session replace the DB query with User object
= cancel_button(users_path)
= submit_button(editable_user.new_record? ? t("user.create") : (params[:verify] ? t('user.verify') : t('user.update')))
21 changes: 0 additions & 21 deletions app/views/users/_mobile_login_history.html.erb

This file was deleted.

12 changes: 12 additions & 0 deletions app/views/users/_mobile_login_history.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.device-information
h3= I18n.t("device.information")
table
tr
th= I18n.t("device.timestamp")
th= I18n.t("imei")
th= I18n.t("device.mobile_number")
- @user.mobile_login_history.reverse.each do |event|
tr
td= event[:timestamp].in_time_zone(@user.time_zone)
td= event[:imei]
td= event[:mobile_number]
23 changes: 0 additions & 23 deletions app/views/users/_user.html.erb

This file was deleted.

15 changes: 15 additions & 0 deletions app/views/users/_user.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
tr id="user-row-#{user.user_name}"
td.full_name= h user.full_name
td.user-name= h user.user_name
- if can?(:disable, user)
td.user-status
= render :partial => 'user_disabled_checkbox', :locals => {:user => user}
- if can? :show, User
td= link_to t("users.actions.show"), user
- if can? :edit, User
td= link_to t("buttons.edit"), edit_user_path(user)
- if can? :destroy, User
td
- if current_user_name != user.user_name
= link_to t("user.actions.delete"), user, method: :delete, data: { confirm: t("user.messages.confirmation") }

7 changes: 0 additions & 7 deletions app/views/users/_user_disabled_checkbox.html.erb

This file was deleted.

6 changes: 6 additions & 0 deletions app/views/users/_user_disabled_checkbox.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- if current_user_name != user.user_name
| <input type="checkbox" class="user-disabled-status"
| #{user.disabled ? "checked='checked'" : ""}

- else
= h t("enabled")
16 changes: 0 additions & 16 deletions app/views/users/_users_header.html.erb

This file was deleted.

11 changes: 11 additions & 0 deletions app/views/users/_users_header.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tr
th= t("user.full_name")
th= t("login.username")
- if can?(:disable, User)
th= t("user.disabled")
- if can? :show, User
th
- if can? :edit, User
th
- if can? :destroy, User
th
Loading