about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2019-03-13 10:18:45 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2019-03-13 10:18:45 -0400
commitbcf6445d92f1a57dff0b97bd9309f40b70088448 (patch)
tree94d908f819d4e1360b37ea794b26fde4dde81944
parent837537b14b01a8c7504b786e1bbf7a350c21242a (diff)
downloadthoughts-bcf6445d92f1a57dff0b97bd9309f40b70088448.tar.gz
thoughts-bcf6445d92f1a57dff0b97bd9309f40b70088448.tar.bz2
thoughts-bcf6445d92f1a57dff0b97bd9309f40b70088448.zip
Added started/finished on dates to Game
-rw-r--r--app/assets/javascripts/admin/dashboard.coffee5
-rw-r--r--app/controllers/admin/games_controller.rb2
-rw-r--r--app/controllers/games_controller.rb2
-rw-r--r--app/views/admin/games/_form.html.haml10
-rw-r--r--db/migrate/20190313123149_add_start_and_end_dates_to_game.rb8
-rw-r--r--db/schema.rb4
6 files changed, 27 insertions, 4 deletions
diff --git a/app/assets/javascripts/admin/dashboard.coffee b/app/assets/javascripts/admin/dashboard.coffee index 24f83d1..4fa6cd8 100644 --- a/app/assets/javascripts/admin/dashboard.coffee +++ b/app/assets/javascripts/admin/dashboard.coffee
@@ -1,3 +1,8 @@
1# Place all the behaviors and hooks related to the matching controller here. 1# Place all the behaviors and hooks related to the matching controller here.
2# All this logic will automatically be available in application.js. 2# All this logic will automatically be available in application.js.
3# You can use CoffeeScript in this file: http://coffeescript.org/ 3# You can use CoffeeScript in this file: http://coffeescript.org/
4dash_ready = ->
5 $(".datepicker").datepicker({"dateFormat": "yy-mm-dd"})
6
7$(document).ready(dash_ready)
8$(document).on('turbolinks:load', dash_ready)
diff --git a/app/controllers/admin/games_controller.rb b/app/controllers/admin/games_controller.rb index 5bc6de9..ee5fe59 100644 --- a/app/controllers/admin/games_controller.rb +++ b/app/controllers/admin/games_controller.rb
@@ -46,7 +46,7 @@ class Admin::GamesController < Admin::AdminController
46 private 46 private
47 47
48 def game_params 48 def game_params
49 params.require(:game).permit(:title, :description, :status, :progress, :score) 49 params.require(:game).permit(:title, :description, :status, :progress, :score, :started_on, :finished_on)
50 end 50 end
51 51
52 def set_section 52 def set_section
diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 490e0b0..8ddcf24 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb
@@ -1,6 +1,6 @@
1class GamesController < ApplicationController 1class GamesController < ApplicationController
2 def index 2 def index
3 @games = Game.all 3 @games = Game.order(started_on: :desc)
4 4
5 if params[:status] 5 if params[:status]
6 @games = @games.where(status: params[:status]) 6 @games = @games.where(status: params[:status])
diff --git a/app/views/admin/games/_form.html.haml b/app/views/admin/games/_form.html.haml index 4b17664..ed0982e 100644 --- a/app/views/admin/games/_form.html.haml +++ b/app/views/admin/games/_form.html.haml
@@ -17,7 +17,15 @@
17 = f.label :progress 17 = f.label :progress
18 = f.text_area :progress 18 = f.text_area :progress
19 .details-module 19 .details-module
20 .started-field
21 = f.label :started_on
22 = f.text_field :started_on, class: "datepicker"
23 .details-module
24 .finished-field
25 = f.label :finished_on
26 = f.text_field :finished_on, class: "datepicker"
27 .details-module
20 .status-field 28 .status-field
21 = f.select :status, options_for_select(Game.status.values) 29 = f.select :status, options_for_select(Game.status.values, f.object.status)
22 = f.label :status 30 = f.label :status
23 .details-module= f.submit 31 .details-module= f.submit
diff --git a/db/migrate/20190313123149_add_start_and_end_dates_to_game.rb b/db/migrate/20190313123149_add_start_and_end_dates_to_game.rb new file mode 100644 index 0000000..7803344 --- /dev/null +++ b/db/migrate/20190313123149_add_start_and_end_dates_to_game.rb
@@ -0,0 +1,8 @@
1class AddStartAndEndDatesToGame < ActiveRecord::Migration[5.2]
2 def change
3 change_table :games do |c|
4 c.date :started_on
5 c.date :finished_on
6 end
7 end
8end
diff --git a/db/schema.rb b/db/schema.rb index c5c794f..0ae9b11 100644 --- a/db/schema.rb +++ b/db/schema.rb
@@ -10,7 +10,7 @@
10# 10#
11# It's strongly recommended that you check this file into your version control system. 11# It's strongly recommended that you check this file into your version control system.
12 12
13ActiveRecord::Schema.define(version: 2019_03_12_193154) do 13ActiveRecord::Schema.define(version: 2019_03_13_123149) do
14 14
15 create_table "audits", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", force: :cascade do |t| 15 create_table "audits", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", force: :cascade do |t|
16 t.integer "auditable_id" 16 t.integer "auditable_id"
@@ -65,6 +65,8 @@ ActiveRecord::Schema.define(version: 2019_03_12_193154) do
65 t.integer "score" 65 t.integer "score"
66 t.datetime "created_at", null: false 66 t.datetime "created_at", null: false
67 t.datetime "updated_at", null: false 67 t.datetime "updated_at", null: false
68 t.date "started_on"
69 t.date "finished_on"
68 end 70 end
69 71
70 create_table "links", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", force: :cascade do |t| 72 create_table "links", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", force: :cascade do |t|