Skip to content

Commit

Permalink
sorting; cosmetics;
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils Bartels committed Dec 20, 2023
1 parent d3eee73 commit d8f3fd3
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/controllers/desks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DesksController < ApplicationController

# GET /desks
def index
@desks = Desk.includes(room: { floor: { location: :tenant } }).all.page(@page)
@desks = Desk.includes(room: { floor: { location: :tenant } }).order("name ASC").all.page(@page)
respond_to do |format|
format.html
format.json { render json: Desk.all }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/floors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class FloorsController < ApplicationController

# GET /floors
def index
@floors = Floor.includes(location: :tenant).all.page(@page)
@floors = Floor.includes(location: :tenant).order("name ASC").all.page(@page)
respond_to do |format|
format.html
format.json { render json: Floor.all }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class LocationsController < ApplicationController

# GET /locations
def index
@locations = Location.includes([:tenant]).all.page(@page)
@locations = Location.includes([:tenant]).order("name ASC").all.page(@page)
respond_to do |format|
format.html
format.json { render json: Location.all }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class RoomsController < ApplicationController

# GET /rooms
def index
@rooms = Room.includes(floor: { location: :tenant }).all.page(@page)
@rooms = Room.includes(floor: { location: :tenant }).order("name ASC").all.page(@page)
respond_to do |format|
format.html
format.json { render json: Room.all }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/tenants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TenantsController < ApplicationController

# GET /tenants
def index
@tenants = Tenant.all.page(@page)
@tenants = Tenant.order("name ASC").all.page(@page)
respond_to do |format|
format.html
format.json { render json: Tenant.all }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class UsersController < ApplicationController

# GET /users
def index
@users = User.includes([:tenant]).all.page(@page)
@users = User.includes([:tenant]).order("email ASC").all.page(@page)
respond_to do |format|
format.html
format.json { render json: User.all }
Expand Down
4 changes: 1 addition & 3 deletions app/models/desk.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Desk < ApplicationRecord
self.implicit_order_column = :created_at
self.implicit_order_column = :name

scope :limit_room, ->(room) { where("room_id = ?", room.id) }

Expand All @@ -13,6 +13,4 @@ class Desk < ApplicationRecord
belongs_to :room
has_many :limitations, as: :limitable
has_many :reservations, dependent: :destroy

encrypts :name
end
3 changes: 1 addition & 2 deletions app/models/floor.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Floor < ApplicationRecord
self.implicit_order_column = :created_at
self.implicit_order_column = :name

scope :limit_location, ->(location) { where("location_id = ?", location.id) }

Expand All @@ -14,6 +14,5 @@ class Floor < ApplicationRecord
has_many :rooms, dependent: :destroy
has_many :limitations, as: :limitable

encrypts :name
encrypts :level
end
3 changes: 1 addition & 2 deletions app/models/location.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Location < ApplicationRecord
self.implicit_order_column = :created_at
self.implicit_order_column = :name

scope :limit_tenant, ->(tenant) { where("tenant_id = ?", tenant.id) }

Expand All @@ -19,7 +19,6 @@ class Location < ApplicationRecord
has_many :floors, dependent: :destroy
has_many :limitations, as: :limitable

encrypts :name
encrypts :street
encrypts :house_number
encrypts :zip_code
Expand Down
4 changes: 1 addition & 3 deletions app/models/room.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Room < ApplicationRecord
self.implicit_order_column = :created_at
self.implicit_order_column = :name

scope :limit_floor, ->(floor) { where("floor_id = ?", floor.id) }

Expand All @@ -12,6 +12,4 @@ class Room < ApplicationRecord
belongs_to :floor
has_many :desks, dependent: :destroy
has_many :limitations, as: :limitable

encrypts :name
end
4 changes: 1 addition & 3 deletions app/models/tenant.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# frozen_string_literal: true

class Tenant < ApplicationRecord
self.implicit_order_column = :created_at
self.implicit_order_column = :name

validates :name, uniqueness: true

# associations
has_many :users, dependent: :destroy
has_many :locations, dependent: :destroy
has_many :limitations, as: :limitable

encrypts :name
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class User < ApplicationRecord
devise :database_authenticatable, :lockable,
:recoverable, :rememberable, :validatable

self.implicit_order_column = :created_at
self.implicit_order_column = :email

validates :email, uniqueness: true
validates :first_name, length: { in: 2..20 }
Expand Down
6 changes: 3 additions & 3 deletions app/views/desks/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
%table.table.table-striped.table-hover
%thead
%tr
%th Name
%th Tenant
%th Location
%th Floor
%th Room
%th Name
%th X
%th Y
%th Width
Expand All @@ -20,6 +20,8 @@
%tbody
- @desks.each do |desk|
%tr
%td
= desk.name
%td
= desk.room.floor.location.tenant.name
%td
Expand All @@ -28,8 +30,6 @@
= desk.room.floor.name
%td
= desk.room.name
%td
= desk.name
%td
= desk.pos_x
%td
Expand Down
6 changes: 3 additions & 3 deletions app/views/floors/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
%table.table.table-striped.table-hover
%thead
%tr
%th Name
%th Tenant
%th Location
%th Name
%th Level
%tbody
- @floors.each do |floor|
%tr
%td
= floor.name
%td
= floor.location.tenant.name
%td
= floor.location.name
%td
= floor.name
%td
= floor.level
%td
Expand Down
6 changes: 3 additions & 3 deletions app/views/locations/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
%table.table.table-striped.table-hover
%thead
%tr
%th Tenant
%th Name
%th Tenant
%th Street
%th House number
%th Zip
Expand All @@ -18,10 +18,10 @@
%tbody
- @locations.each do |location|
%tr
%td
= location.tenant.name
%td
= location.name
%td
= location.tenant.name
%td
= location.street
%td
Expand Down
6 changes: 3 additions & 3 deletions app/views/rooms/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
%table.table.table-striped.table-hover
%thead
%tr
%th Name
%th Tenant
%th Location
%th Floor
%th Name
%tbody
- @rooms.each do |room|
%tr
%td
= link_to "#{room.name}", room_path(room)
%td
= room.floor.location.tenant.name
%td
= room.floor.location.name
%td
= room.floor.name
%td
= link_to "#{room.name}", room_path(room)
%td
.d-flex.justify-content-end
- if @current_role == "admin"
Expand Down

0 comments on commit d8f3fd3

Please sign in to comment.