diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/admin/dashboard.coffee | 5 | ||||
-rw-r--r-- | app/controllers/admin/games_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/games_controller.rb | 2 | ||||
-rw-r--r-- | app/views/admin/games/_form.html.haml | 10 |
4 files changed, 16 insertions, 3 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/ |
4 | dash_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 @@ | |||
1 | class GamesController < ApplicationController | 1 | class 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 |