Skip to content

Commit

Permalink
Delete Room
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackPearl96 committed Sep 3, 2019
1 parent 1cb612c commit 64c7850
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 7 deletions.
12 changes: 12 additions & 0 deletions app/assets/javascripts/manager/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ function previewImages() {
}

$(document).ready(function(){
$('#room_table').DataTable({
scrollY: 500,
"pageLength": 25,
});

$('#admin_table').DataTable({
scrollY: 500,
"pageLength": 25,
Expand All @@ -33,6 +38,13 @@ $(document).ready(function(){
]
});

$("#micropost_picture").bind("change", function(){
var size_in_megabytes = this.files(0).size/1024/1024;
if (size_in_megabytes > 5) {
alert("Maximum file size is 5MB. Please choose an other file!");
}
});

$('#member_table').DataTable({
scrollY: 500,
"pageLength": 25,
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/manager/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ td.action{
padding: 0;
}

td.action{
padding: 0;
}

.action{
padding: 0 10px 0 10px;
margin: 0 10px 0 10px;
Expand Down
13 changes: 12 additions & 1 deletion app/controllers/manager/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Manager
class RoomsController < BaseController
before_action :load_room, only: %i[edit update]
before_action :load_room, only: %i[edit update show destroy]

def index
@rooms = Room.sort_by_name
Expand All @@ -15,6 +15,8 @@ def new

def edit; end

def show; end

def create
@room = current_admin.rooms.build room_params
if @room.save
Expand All @@ -34,6 +36,15 @@ def update
end
end

def destroy
if @room.destroy
flash[:success] = t ".deleted_success"
else
flash[:danger] = t ".deleted_fail"
end
redirect_to manager_rooms_path
end

private

def room_params
Expand Down
4 changes: 3 additions & 1 deletion app/views/manager/rooms/_room.html.slim
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
tr
td
= room.name
= link_to room.name, manager_room_path(room)
td
= room.location.name
td
= room.type_room
td.action
= link_to t(".edit"), edit_manager_room_path(room),
class: "action btn btn-outline-info"
= link_to t(".delete"), manager_room_path(room), method: :delete,
data: {confirm: t(".sure") }, class: "action btn btn-outline-danger"
56 changes: 56 additions & 0 deletions app/views/manager/rooms/show.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.bs-example
ul.nav.nav-tabs
li.nav-item
= link_to "#home", class: "nav-link active", data:{toggle: "tab"} do
= t ".description"
li
= link_to "#menu1", class: "nav-link", data:{toggle: "tab"} do
= t ".room"
li
= link_to "#menu2", class: "nav-link", data:{toggle: "tab"} do
= t ".utility"
li
= link_to "#menu3", class: "nav-link", data:{toggle: "tab"} do
= t ".image"
.tab-content
#home.tab-pane.fade.show.active
h3 = @room.name
= @room.description
#menu1.tab-pane.fade
h3 = t ".room"
div.row
.col-md-3
= t ".guest"
.col-md-9
= @room.guest
div.row
.col-md-3
= t ".bed_room"
.col-md-9
= @room.bed_room
div.row
.col-md-3
= t ".bath_room"
.col-md-9
= @room.bath_room
div.row
.col-md-3
= t ".acreage"
.col-md-9
= @room.acreage
div.row
.col-md-3
= t ".address"
.col-md-9
= @room.address
div.row
.col-md-3
= t ".type_room"
.col-md-9
= @room.type_room
#menu2.tab-pane.fade
h3 = t ".utility"
#menu3.tab-pane.fade
h3 = t ".image"
- @room.room_images.each do |img|
= image_tag img.image.url, class: "image-detail"
5 changes: 0 additions & 5 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# frozen_string_literal: true

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# Do not eager load code on boot.
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ en:
update_success: Update Success!
update_fail: Update Failed
deleted_success: Deleted success
deleted_fail: Deleted fail
new:
create_room: Create Room
edit:
Expand Down

0 comments on commit 64c7850

Please sign in to comment.