From bcf6445d92f1a57dff0b97bd9309f40b70088448 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 13 Mar 2019 10:18:45 -0400 Subject: Added started/finished on dates to Game --- app/assets/javascripts/admin/dashboard.coffee | 5 +++++ app/controllers/admin/games_controller.rb | 2 +- app/controllers/games_controller.rb | 2 +- app/views/admin/games/_form.html.haml | 10 +++++++++- 4 files changed, 16 insertions(+), 3 deletions(-) (limited to 'app') 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 @@ # Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://coffeescript.org/ +dash_ready = -> + $(".datepicker").datepicker({"dateFormat": "yy-mm-dd"}) + +$(document).ready(dash_ready) +$(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 private def game_params - params.require(:game).permit(:title, :description, :status, :progress, :score) + params.require(:game).permit(:title, :description, :status, :progress, :score, :started_on, :finished_on) end 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 @@ class GamesController < ApplicationController def index - @games = Game.all + @games = Game.order(started_on: :desc) if params[:status] @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 @@ -16,8 +16,16 @@ .progress-field = f.label :progress = f.text_area :progress + .details-module + .started-field + = f.label :started_on + = f.text_field :started_on, class: "datepicker" + .details-module + .finished-field + = f.label :finished_on + = f.text_field :finished_on, class: "datepicker" .details-module .status-field - = f.select :status, options_for_select(Game.status.values) + = f.select :status, options_for_select(Game.status.values, f.object.status) = f.label :status .details-module= f.submit -- cgit 1.4.1