From 86d279498da5e383caba5a53ee9dde1b5bf39113 Mon Sep 17 00:00:00 2001 From: Chris Howlett Date: Sat, 12 Mar 2016 15:25:20 +0000 Subject: [PATCH] Update styling, mark edited journals For #128 --- app/assets/stylesheets/_colours.css.scss | 2 +- app/assets/stylesheets/_mixins.css.scss | 3 +++ app/assets/stylesheets/application.css.scss | 2 -- app/assets/stylesheets/games.css.scss | 2 +- app/controllers/journals_controller.rb | 2 +- app/models/player.rb | 2 +- app/views/games/_journals.html.slim | 22 ++++++++++--------- ...20160312145617_add_modified_to_journals.rb | 5 +++++ db/schema.rb | 3 ++- 9 files changed, 26 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20160312145617_add_modified_to_journals.rb diff --git a/app/assets/stylesheets/_colours.css.scss b/app/assets/stylesheets/_colours.css.scss index 0be81e3a..0f63d1cd 100644 --- a/app/assets/stylesheets/_colours.css.scss +++ b/app/assets/stylesheets/_colours.css.scss @@ -35,7 +35,7 @@ $play-treasure-colour: darken($treasure, 10%); $reaction-blue: #337; $buy-gold: $treasure * 0.75; -$p0col: #fcc; +$p0col: #fdb; $p1col: #ffd; $p2col: #cfc; $p3col: #dff; diff --git a/app/assets/stylesheets/_mixins.css.scss b/app/assets/stylesheets/_mixins.css.scss index d553b683..a6292468 100644 --- a/app/assets/stylesheets/_mixins.css.scss +++ b/app/assets/stylesheets/_mixins.css.scss @@ -3,6 +3,9 @@ $header-height: 230px; .lighter {font-weight: normal; color: #ccc;} +.bold {font-weight: bold;} +.red { color: red; } +.error { background-color: lighten(red, 25%); } @mixin when-smaller-than($breakpoint) { @if $breakpoint == small { diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 111a1641..49097022 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -7,8 +7,6 @@ @import "form-styles"; -.red { color: red; } - .design { border: 1px solid blue; } diff --git a/app/assets/stylesheets/games.css.scss b/app/assets/stylesheets/games.css.scss index 29bf1359..01c90534 100644 --- a/app/assets/stylesheets/games.css.scss +++ b/app/assets/stylesheets/games.css.scss @@ -33,7 +33,7 @@ } } - .bold, .current {font-weight: bold;} + .current {font-weight: bold;} &.ended.rowEven {background-color: #ffe0e0;} &.ended.rowOdd {background-color: #fbb;} diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index e74ad93d..c3662007 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -52,7 +52,7 @@ def update if params[:journal].andand[:event].andand.blank? @journal.destroy else - @journal.update(journal_params) + @journal.update(journal_params.merge({ modified: true })) end respond_to do |format| format.html { redirect_to play_game_path(@journal.game), status: :see_other } diff --git a/app/models/player.rb b/app/models/player.rb index e5b0e83e..316dec35 100644 --- a/app/models/player.rb +++ b/app/models/player.rb @@ -858,7 +858,7 @@ def draw_cards(num, reason = nil) else drawn_string << "#{cards_drawn.join(', ')}|#{cards_drawn.length} card#{cards_drawn.length == 1 ? '' : 's'}]" end -raise + game.add_history(:event => "#{name} drew #{drawn_string}#{reason}.", :css_class => "player#{seat} card_draw #{'shuffle' if (shuffle_point > 0 && shuffle_point < cards_drawn.length)}") end diff --git a/app/views/games/_journals.html.slim b/app/views/games/_journals.html.slim index bf37de0d..939f88f5 100644 --- a/app/views/games/_journals.html.slim +++ b/app/views/games/_journals.html.slim @@ -1,17 +1,19 @@ ul - @game.journals.each do |journal| - li.journal class=('red' if journal.errors.any?) + li.journal class=('error' if journal.errors.any?) + - if journal.modified + span.bold>[] (Edited) - if journal.player == @player && journal.order > @game.last_blocked_journal span.insert data-order=journal.order = best_in_place journal, :event, class: 'change_journal', other_fields: {game_id: @game.id}, html_attrs: {style: 'width: 100%', autocomplete: 'off'} - else span.immutable= journal.event - -if journal.errors.any? - ul.journal_errors - - journal.errors.full_messages.each do |msg| - li= msg - - journal.histories.each do |history| - - classes = history.css_class - - if @player && history.css_class =~ /\bplayer#{@player.seat}\b/ - - classes += ' self' - li class=classes = format_history(history, @player) \ No newline at end of file + -if journal.errors.any? + ul.journal_errors.error + - journal.errors.full_messages.each do |msg| + li= msg + - journal.histories.each do |history| + - classes = history.css_class + - if @player && history.css_class =~ /\bplayer#{@player.seat}\b/ + - classes += ' self' + li class=classes = format_history(history, @player) \ No newline at end of file diff --git a/db/migrate/20160312145617_add_modified_to_journals.rb b/db/migrate/20160312145617_add_modified_to_journals.rb new file mode 100644 index 00000000..d0bbb718 --- /dev/null +++ b/db/migrate/20160312145617_add_modified_to_journals.rb @@ -0,0 +1,5 @@ +class AddModifiedToJournals < ActiveRecord::Migration + def change + add_column :journals, :modified, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index c6178070..dd0b407d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160202160833) do +ActiveRecord::Schema.define(version: 20160312145617) do create_table "chats", force: true do |t| t.integer "game_id" @@ -37,6 +37,7 @@ t.text "event" t.datetime "created_at" t.integer "order" + t.boolean "modified", default: false end add_index "journals", ["game_id"], name: "index_journals_on_game_id"