diff options
| author | jpl | 2017-04-10 18:34:15 +0200 | 
|---|---|---|
| committer | jpl | 2017-04-10 18:34:22 +0200 | 
| commit | f62876f66e1ded5347ac93954845357a58be6aa9 (patch) | |
| tree | 5b0832aacdc9613ae1a04662be4d47234bbbe81f | |
| parent | 46de3ff815baeb1d44e751b25df6594f26b77be4 (diff) | |
| download | chouette-core-f62876f66e1ded5347ac93954845357a58be6aa9.tar.bz2 | |
Refs #3092 #2909: adding color attribute, adding colorSelector component
| -rw-r--r-- | app/assets/javascripts/forms.coffee | 12 | ||||
| -rw-r--r-- | app/assets/stylesheets/components/_buttons.sass | 2 | ||||
| -rw-r--r-- | app/assets/stylesheets/components/_forms.sass | 33 | ||||
| -rw-r--r-- | app/controllers/time_tables_controller.rb | 2 | ||||
| -rw-r--r-- | app/models/chouette/time_table.rb | 1 | ||||
| -rw-r--r-- | app/views/time_tables/_form.html.slim | 15 | ||||
| -rw-r--r-- | app/views/time_tables/show.html.slim | 2 | ||||
| -rw-r--r-- | db/migrate/20170410134931_add_color_to_timetables.rb | 5 | ||||
| -rw-r--r-- | db/schema.rb | 3 | 
9 files changed, 67 insertions, 8 deletions
| diff --git a/app/assets/javascripts/forms.coffee b/app/assets/javascripts/forms.coffee index 9d884edcd..679f92a54 100644 --- a/app/assets/javascripts/forms.coffee +++ b/app/assets/javascripts/forms.coffee @@ -30,9 +30,21 @@ isEdge = !isIE && !!window.StyleMedia    if isIE || isEdge      $('.formSubmitr').off() +@colorSelector = -> +  $('.form-group .dropdown.color_selector').each -> +    selectedStatus = $(this).children('.dropdown-toggle').children('.fa-circle') + +    $(this).on 'click', "input[type='radio']", (e) -> +      selectedValue = e.currentTarget.value +      if selectedValue == '' +        $(selectedStatus).css('color', 'transparent') +      else +        $(selectedStatus).css('color', selectedValue) +  $(document).on 'ready page:load', togglableFilter  $(document).on 'ready page:load', submitMover  $(document).on 'ready page:load', switchInput +$(document).on 'ready page:load', colorSelector  if isIE || isEdge    $(document).on 'click', '.formSubmitr', (e)-> diff --git a/app/assets/stylesheets/components/_buttons.sass b/app/assets/stylesheets/components/_buttons.sass index f128512f5..07758d56c 100644 --- a/app/assets/stylesheets/components/_buttons.sass +++ b/app/assets/stylesheets/components/_buttons.sass @@ -5,7 +5,7 @@  .btn    font-weight: 700 -  .fa + span +  .fa + span:not(.caret)      padding-left: 0.5em    span + .fa      padding-left: 0.5em diff --git a/app/assets/stylesheets/components/_forms.sass b/app/assets/stylesheets/components/_forms.sass index f2c76c9c1..6d841d5d4 100644 --- a/app/assets/stylesheets/components/_forms.sass +++ b/app/assets/stylesheets/components/_forms.sass @@ -95,6 +95,39 @@ input          + [class*='col-sm-']            float: right +// Colors dropdown +.dropdown.color_selector +  .btn.btn-default +    &, &:hover, &:focus +      border: 1px solid #cccccc +      background-color: #fff +      font-weight: normal +      color: $darkgrey + +  .dropdown-menu +    position: absolute +    margin: 2px 0 0 0 +    min-width: 56px + +    > .radio +      position: relative +      padding: 3px 20px +      // cursor: pointer + +      &:hover, &:focus +        background-color: #f5f5f5 + +      > label +        padding: 0 + +        input.color_selector, input[type='radio'] +          position: absolute +          cursor: pointer +          z-index: 1 +          width: 100% +          margin: 0 +          opacity: 0 +  // Search bar  .search_bar    position: relative diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index c5aa7280a..2e03485f2 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -140,7 +140,7 @@ class TimeTablesController < ChouetteController        :object_version,        :creator_id,        :calendar_id, -      :version, :comment, +      :version, :comment, :color,        :int_day_types,        :monday,        :tuesday, diff --git a/app/models/chouette/time_table.rb b/app/models/chouette/time_table.rb index f018382fe..cc866c4dc 100644 --- a/app/models/chouette/time_table.rb +++ b/app/models/chouette/time_table.rb @@ -466,4 +466,3 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord      tt    end  end - diff --git a/app/views/time_tables/_form.html.slim b/app/views/time_tables/_form.html.slim index fdb735d12..91fb6e09c 100644 --- a/app/views/time_tables/_form.html.slim +++ b/app/views/time_tables/_form.html.slim @@ -3,10 +3,19 @@    .row      .col-lg-12        = form.input :comment, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.time_table.comment")} -      = form.input :tag_list, as: :tags +       +      .form-group +        = form.label @time_table.human_attribute_name(:color), required: false, class: 'control-label col-sm-4' +       +        .col-sm-8 +          .dropdown.color_selector +            button.btn.btn-default.dropdown-toggle type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" +              span.fa.fa-circle.mr-xs style="color:#{@time_table.color.nil? ? 'transparent' : @time_table.color}" +              span.caret -      / = form.input :version -      / = form.input :objectid, :required => !@time_table.new_record?, :input_html => { :title => t("formtastic.titles#{format_restriction_for_locales(@referential)}.time_table.objectid")} +            = form.input :color, as: :radio_buttons, label: false, collection: ["", "#9B9B9B", "#FFA070", "#C67300", "#7F551B", "#41CCE3", "#09B09C", "#3655D7",   "#6321A0", "#E796C6", "#DD2DAA"], input_html: {class: 'color_selector'}, label_method: lambda{|c| ("<span class='fa fa-circle' style='color:" + (c.empty? ? 'transparent' : c) + "'></span>").html_safe}, wrapper_html: { class: 'dropdown-menu', 'aria-labelledby': "dropdownMenu1"}, include_blank: true + +      = form.input :tag_list, as: :tags        .form-group          label.control-label.col-sm-4 diff --git a/app/views/time_tables/show.html.slim b/app/views/time_tables/show.html.slim index 0cfb49e80..d0a145f36 100644 --- a/app/views/time_tables/show.html.slim +++ b/app/views/time_tables/show.html.slim @@ -33,7 +33,7 @@              'Etiquettes' => @time_table.tag_list,              'Modèle de calendrier' => (@time_table.calendar ? link_to(@time_table.calendar.name, @time_table.calendar) : '-'),              "Journées d'application pour les périodes ci-dessous" => %w(monday tuesday wednesday thursday friday saturday sunday).collect{ |d| content_tag(:span, t("calendars.days.#{d}"), class: "label label-default #{@time_table.send(d) ? '' : 'disabled'}") }.join.html_safe, -            'Couleur associée' => '-' } +            'Couleur associée' => content_tag(:span, '', class: 'fa fa-circle', style: "color:#{@time_table.try(:color)}") }      .row        .col-lg-12.mb-sm diff --git a/db/migrate/20170410134931_add_color_to_timetables.rb b/db/migrate/20170410134931_add_color_to_timetables.rb new file mode 100644 index 000000000..c297bc537 --- /dev/null +++ b/db/migrate/20170410134931_add_color_to_timetables.rb @@ -0,0 +1,5 @@ +class AddColorToTimetables < ActiveRecord::Migration +  def change +    add_column :time_tables, :color, :string +  end +end diff --git a/db/schema.rb b/db/schema.rb index 24bcf199c..d67179e33 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: 20170404122930) do +ActiveRecord::Schema.define(version: 20170410134931) do    # These are extensions that must be enabled in order to support this database    enable_extension "plpgsql" @@ -722,6 +722,7 @@ ActiveRecord::Schema.define(version: 20170404122930) do      t.integer  "calendar_id",    limit: 8      t.datetime "created_at"      t.datetime "updated_at" +    t.string   "color"    end    add_index "time_tables", ["calendar_id"], :name => "index_time_tables_on_calendar_id" | 
