diff options
| author | Xinhui | 2017-05-22 11:14:47 +0200 | 
|---|---|---|
| committer | Xinhui | 2017-05-22 11:14:47 +0200 | 
| commit | 23608f5793ddf255ca616aa6eeabf88fe66b6ca2 (patch) | |
| tree | b632a099f814ecf10df6048fb08bad9e50333f43 | |
| parent | c05cca218b943e154d46f535f21834255439556d (diff) | |
| download | chouette-core-23608f5793ddf255ca616aa6eeabf88fe66b6ca2.tar.bz2 | |
Edit autocomplete time_tables json format
Refs #3429
| -rw-r--r-- | app/assets/javascripts/select2.coffee | 2 | ||||
| -rw-r--r-- | app/models/chouette/time_table.rb | 4 | ||||
| -rw-r--r-- | app/views/autocomplete_time_tables/index.rabl | 9 | ||||
| -rw-r--r-- | app/views/time_table_combinations/_form.html.slim | 2 | 
4 files changed, 12 insertions, 5 deletions
| diff --git a/app/assets/javascripts/select2.coffee b/app/assets/javascripts/select2.coffee index 07efac6d1..af3dc6d75 100644 --- a/app/assets/javascripts/select2.coffee +++ b/app/assets/javascripts/select2.coffee @@ -4,7 +4,7 @@ bind_select2 = (el, cfg = {}) ->      theme: 'bootstrap'      language: 'fr'      placeholder: target.data('select2ed-placeholder') -    allowClear: true +    allowClear: false    target.select2 $.extend({}, default_cfg, cfg) diff --git a/app/models/chouette/time_table.rb b/app/models/chouette/time_table.rb index 7cbc4fe8b..6fba5bab6 100644 --- a/app/models/chouette/time_table.rb +++ b/app/models/chouette/time_table.rb @@ -282,6 +282,10 @@ class Chouette::TimeTable < Chouette::TridentActiveRecord      [bounding_min, bounding_max].compact    end +  def display_day_types +    %w(monday tuesday wednesday thursday friday saturday sunday).select{ |d| self.send(d) }.map{ |d| self.human_attribute_name(d).first(2)}.join('') +  end +    def day_by_mask(flag)      int_day_types & flag == flag    end diff --git a/app/views/autocomplete_time_tables/index.rabl b/app/views/autocomplete_time_tables/index.rabl index f52429e9d..c6c993d16 100644 --- a/app/views/autocomplete_time_tables/index.rabl +++ b/app/views/autocomplete_time_tables/index.rabl @@ -1,11 +1,14 @@  collection @time_tables, :object_root => false  node do |time_table| -  { :id => time_table.id, :comment => time_table.comment, :objectid => time_table.objectid, +  { +    :id => time_table.id, :comment => time_table.comment, :objectid => time_table.objectid,      :time_table_bounding => time_table.presenter.time_table_bounding,      :composition_info => time_table.presenter.composition_info,      :tags => time_table.tags.join(','), -    :text => "#{time_table.objectid.parts.try(:third)} - #{time_table.comment}", -    :day_types => %w(monday tuesday wednesday thursday friday saturday sunday).select{ |d| time_table.send(d) }.map{ |d| time_table.human_attribute_name(d).first(2)}.join('')} +    :text => "#{time_table.comment} - #{time_table.display_day_types} - #{time_table.objectid.parts.try(:third)}", +    :color => time_table.color, +    :day_types => time_table.display_day_types +  }  end diff --git a/app/views/time_table_combinations/_form.html.slim b/app/views/time_table_combinations/_form.html.slim index 1cda41597..6051bfffa 100644 --- a/app/views/time_table_combinations/_form.html.slim +++ b/app/views/time_table_combinations/_form.html.slim @@ -5,7 +5,7 @@ h1 = @time_table.comment        = form.input :combined_type, as: :select, collection: ['time_table', 'calendar']        = form.input :operation, as: :select, collection: TimeTableCombination.operations -      = form.input :time_table_id, as: :select, input_html: {class: 'tt_combination_target', data: { select2_ajax: 'true', term: 'comment_cont', url: referential_autocomplete_time_tables_path(@referential, format: :json)}}, disabled: @combination.combined_type != 'time_table', wrapper_html: {class: @combination.combined_type != 'time_table' ? 'hidden' : ''} +      = form.input :time_table_id, as: :select, input_html: {class: 'tt_combination_target', data: { select2_ajax: 'true', term: 'comment_or_objectid_cont', url: referential_autocomplete_time_tables_path(@referential, format: :json)}}, disabled: @combination.combined_type != 'time_table', wrapper_html: {class: @combination.combined_type != 'time_table' ? 'hidden' : ''}        = form.input :calendar_id, as: :select, input_html: { class: 'tt_combination_target', data: { select2_ajax: 'true', term: 'name_cont', url: autocomplete_calendars_path}}, disabled: @combination.combined_type != 'calendar', wrapper_html: {class: @combination.combined_type != 'calendar' ? 'hidden' : ''} | 
