From 6e9b078adb6bc17633967eb75500b0a8dce65215 Mon Sep 17 00:00:00 2001 From: Marc Florisson Date: Sat, 20 Sep 2014 00:00:52 +0200 Subject: change time table lists look --- app/assets/stylesheets/main/time_tables.css.scss | 32 ++++++----- .../stylesheets/main/vehicle_journeys.css.scss | 67 +++++++++++++++------- app/helpers/time_tables_helper.rb | 11 ++-- app/views/time_tables/_cell_info.html.erb | 14 +++++ app/views/time_tables/_cell_title.html.erb | 10 ++++ app/views/time_tables/_time_table.html.erb | 15 +---- app/views/vehicle_journeys/_time_table.html.erb | 12 +--- 7 files changed, 101 insertions(+), 60 deletions(-) create mode 100644 app/views/time_tables/_cell_info.html.erb create mode 100644 app/views/time_tables/_cell_title.html.erb (limited to 'app') diff --git a/app/assets/stylesheets/main/time_tables.css.scss b/app/assets/stylesheets/main/time_tables.css.scss index 0989b5745..10a8ca161 100644 --- a/app/assets/stylesheets/main/time_tables.css.scss +++ b/app/assets/stylesheets/main/time_tables.css.scss @@ -8,8 +8,14 @@ .time_tables { margin-top: 20px; } - + .time_table { + span.included_day_type { + font-weight: bolder; + color: black; + } + span.excluded_day_type { + } .state-code { width: 25px; @@ -28,7 +34,7 @@ width: 25px; height: 25px; } - + .validity_regular { background-color: #86B41D; width: 25px; @@ -42,12 +48,12 @@ #workspace.time_tables.show { .modal-body{overflow-y: visible;} - + .typeahead.dropdown-menu { z-index: 100001; - } + } - .day_type { + .day_type { border-style:solid; border-width:1px; } @@ -91,7 +97,7 @@ background-color: #86B41D; } } -} +} #workspace.time_tables.edit,#workspace.time_tables.new,#workspace.time_tables.create,#workspace.time_tables.update { @@ -110,17 +116,17 @@ #dates,#excluded_dates,#periods{ .nested-fields { margin: 5px; - - ol { + + ol { li { display: inline; } } } - + margin-left: 25%; } - + .day_type ol { float: left; margin: 0; @@ -145,14 +151,14 @@ padding-left: 10%; margin-top: 0; } - + a.add_fields { margin-left: 25%; margin-top: 20px; padding-left: 18px; background: url(image-path('icons/add.png')) no-repeat 0% 50%; } - + a.remove_fields { margin-left: 10px; padding-left: 18px; @@ -162,5 +168,5 @@ .actions{ margin-top: 20px; } - + } diff --git a/app/assets/stylesheets/main/vehicle_journeys.css.scss b/app/assets/stylesheets/main/vehicle_journeys.css.scss index f6e21ad68..fb872738d 100644 --- a/app/assets/stylesheets/main/vehicle_journeys.css.scss +++ b/app/assets/stylesheets/main/vehicle_journeys.css.scss @@ -9,13 +9,13 @@ color: white; font-weight: bold; } - + .journey_pattern_dependent_list { tr.no_stop { display: none; } } - + .time_table_list { padding-left: 25%; } - + .vehicle_journey_at_stops { margin-left: 25%; @@ -31,9 +31,9 @@ .slide{ margin-left: 30px; - + } - } + } } #workspace.vehicle_journeys.index @@ -42,7 +42,7 @@ .panel-heading .btn{ margin-left: 20px; } - + ul.token-input-list{ display: inline-block; vertical-align: middle; @@ -53,9 +53,9 @@ .advanced_search_link{ vertical-align: -webkit-baseline-middle; } - + } - + table{ margin: 20px 0 0 0; @@ -65,34 +65,34 @@ } .stop_area{ width: 200px; } - } - + } + } -#workspace.vehicle_journeys.show, #workspace.vehicle_journeys.edit, #workspace.vehicle_journeys.update, #workspace.vehicle_journeys.create, #workspace.vehicle_journeys.new { - +#workspace.vehicle_journeys.show, #workspace.vehicle_journeys.edit, #workspace.vehicle_journeys.update, #workspace.vehicle_journeys.create, #workspace.vehicle_journeys.new { + .to_departures { cursor: pointer; } - + .to_arrivals { cursor: pointer; - } - + } + .slide { cursor: pointer; - } + } } #workspace.vehicle_journeys.show { .summary p label { font-weight: bold; - } + } .time_tables { margin-top: 20px; - } + } .time_table { span.included_day_type { @@ -101,15 +101,40 @@ } span.excluded_day_type { } + + .state-code { + width: 25px; + height: 64px; + float: left; + margin-right: 10px; + + .validity_out { + background-color: #FC4903; + width: 25px; + height: 25px; + } + + .validity_out_soon { + background-color: orange; + width: 25px; + height: 25px; + } + + .validity_regular { + background-color: #86B41D; + width: 25px; + height: 25px; + } + } } -} +} #workspace.vehicle_journeys.timeless { .summary p label { font-weight: bold; } - + .vehicle_journeys { margin-top: 20px; } @@ -123,7 +148,7 @@ span.excluded_day_type { } } -} +} diff --git a/app/helpers/time_tables_helper.rb b/app/helpers/time_tables_helper.rb index 100dfc656..e0c1fc2db 100644 --- a/app/helpers/time_tables_helper.rb +++ b/app/helpers/time_tables_helper.rb @@ -8,9 +8,12 @@ module TimeTablesHelper "validity_regular" end end + def tag_list_shortened(time_table) + time_table.tags.join(', ').truncate(30, separator: ',') + end def bounding_info(time_table) return t('time_tables.time_table.empty') if time_table.bounding_dates.empty? - t('time_tables.time_table.bounding', + t('time_tables.time_table.bounding', :start => l(time_table.bounding_dates.min), :end => l(time_table.bounding_dates.max)) end @@ -37,17 +40,17 @@ module TimeTablesHelper elsif time_table.periods.empty? t('time_tables.time_table.dates_count', :count => time_table.dates.count) else - t('time_tables.time_table.periods_dates_count', + t('time_tables.time_table.periods_dates_count', :dates_count => time_table.dates.count, :periods_count => time_table.periods.count) end end - + def time_table_description(time_table) if time_table.bounding_dates.empty? "#{time_table.comment} (vide)" else - "#{time_table.comment} : #{time_table_bounding( time_table)} - #{composition_info(time_table)}" + "#{time_table.comment} : #{time_table_bounding( time_table)} - #{composition_info(time_table)}" end end end diff --git a/app/views/time_tables/_cell_info.html.erb b/app/views/time_tables/_cell_info.html.erb new file mode 100644 index 000000000..6ca63ba77 --- /dev/null +++ b/app/views/time_tables/_cell_info.html.erb @@ -0,0 +1,14 @@ + <%= time_tables_shortest_info(time_table) %> + <% unless time_table.periods.empty? %> +
+ <% %w(monday tuesday wednesday thursday friday saturday sunday).each do |day_type| %> + "> + <%= time_table.human_attribute_name(day_type).first(2) %> + + <% end %> +
+ <% end %> + <% unless time_table.tags.empty? %> +
<%= tag_list_shortened(time_table) %>
+ <% end %> + diff --git a/app/views/time_tables/_cell_title.html.erb b/app/views/time_tables/_cell_title.html.erb new file mode 100644 index 000000000..22ada09eb --- /dev/null +++ b/app/views/time_tables/_cell_title.html.erb @@ -0,0 +1,10 @@ + <%= link_to([@referential, time_table]) do %> +
+
+
+
+ <% end %> +
+ <%= link_to truncate(time_table.comment, :length => 30), [@referential, time_table], :title => "#{Chouette::TimeTable.model_name.human.capitalize} #{time_table.comment}"%> +
+ diff --git a/app/views/time_tables/_time_table.html.erb b/app/views/time_tables/_time_table.html.erb index 0679008fc..bf3ace290 100644 --- a/app/views/time_tables/_time_table.html.erb +++ b/app/views/time_tables/_time_table.html.erb @@ -1,17 +1,8 @@ <%= div_for(time_table) do %> - <%= link_to([@referential, time_table]) do %> -
-
-
-
- <% end %> -
- <%= link_to truncate(time_table.comment, :length => 30), [@referential, time_table], :title => "#{Chouette::TimeTable.model_name.human.capitalize} #{time_table.comment}"%> -
+ <%= render "cell_title", time_table: time_table %>
- <%= time_tables_shortest_info(time_table) %> - - <%= composition_info(time_table) %> -
+ <%= render "cell_info", time_table: time_table %> +
<%= link_to t("actions.edit"), edit_referential_time_table_path(@referential, time_table), :class => "edit" %> | <%= link_to t("actions.destroy"), referential_time_table_path(@referential, time_table), :method => :delete, :data => {:confirm => t('time_tables.actions.destroy_confirm')}, :class => "remove" %>
diff --git a/app/views/vehicle_journeys/_time_table.html.erb b/app/views/vehicle_journeys/_time_table.html.erb index 61043ab3b..f9e51ac37 100644 --- a/app/views/vehicle_journeys/_time_table.html.erb +++ b/app/views/vehicle_journeys/_time_table.html.erb @@ -1,15 +1,7 @@ <%= div_for(time_table, :class => "time_table") do %> - <%= link_to time_table.comment, [@referential, time_table] %> + <%= render "time_tables/cell_title", time_table: time_table %>
- <%= composition_info(time_table) %> - - <% unless time_table.periods.empty? %> - <% %w(monday tuesday wednesday thursday friday saturday sunday).each do |day_type| %> - "> - <%= time_table.human_attribute_name(day_type).first(2) %> - - <% end %> - <% end %> - - <%= bounding_info(time_table) %> + <%= render "time_tables/cell_info", time_table: time_table %>
<% end %> -- cgit v1.2.3 From 80c862d0e0806772abf3449778ba93bb91ff9161 Mon Sep 17 00:00:00 2001 From: Marc Florisson Date: Mon, 22 Sep 2014 18:19:44 +0200 Subject: extend tag selection --- app/controllers/time_tables_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb index 2b3b556c8..620bc98c0 100644 --- a/app/controllers/time_tables_controller.rb +++ b/app/controllers/time_tables_controller.rb @@ -67,7 +67,7 @@ class TimeTablesController < ChouetteController tag_search = ransack_params["tag_search"].split(",").collect(&:strip) if ransack_params.present? && ransack_params["tag_search"].present? ransack_params.delete("tag_search") if ransack_params.present? - selected_time_tables = tag_search ? select_time_tables.tagged_with(tag_search) : select_time_tables + selected_time_tables = tag_search ? select_time_tables.tagged_with(tag_search, :wild => true, :any => true) : select_time_tables @q = selected_time_tables.search(ransack_params) @time_tables ||= @q.result(:distinct => true).order(:comment).paginate(:page => params[:page]) end -- cgit v1.2.3 From 3aeb2937f4a354bd45194ecae408667cd9f1ccc1 Mon Sep 17 00:00:00 2001 From: Marc Florisson Date: Tue, 23 Sep 2014 10:52:37 +0200 Subject: refactor time table list on #index and vehicle_joruney#show --- app/inputs/search_time_table_input.rb | 17 +++++++++++++++-- app/views/time_tables/index.json.rabl | 8 ++++++-- app/views/vehicle_journeys/_form.html.erb | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/inputs/search_time_table_input.rb b/app/inputs/search_time_table_input.rb index bdfe79451..6f40d7e1e 100644 --- a/app/inputs/search_time_table_input.rb +++ b/app/inputs/search_time_table_input.rb @@ -5,6 +5,19 @@ class SearchTimeTableInput < Formtastic::Inputs::SearchInput tokenLimit = options[:tokenLimit].present? ? options[:tokenLimit] : "null" template.content_tag( :script, ("$(document).ready(function() { + var time_table_formatter = function(item){ + var day_types = ''; + if ( item.day_types.length >0 ){ + day_types = '' + item.day_types + '' ; + } + var tags = ''; + if ( item.tags.length >0 ){ + tags = '
' + item.tags + '
' ; + } + return '
  • ' + item.comment + + '
    ' + item.time_table_bounding + day_types + '
    ' + + tags + '
  • '; + }; $('##{dom_id}').tokenInput('#{options[:json]}', { crossDomain: false, tokenLimit: #{tokenLimit}, @@ -15,8 +28,8 @@ class SearchTimeTableInput < Formtastic::Inputs::SearchInput hintText: '#{options[:hint_text]}', noResultsText: '#{options[:no_result_text]}', searchingText: '#{options[:searching_text]}', - resultsFormatter: function(item){ return '
  • ' + item.comment + '
    ' + item.time_table_bounding + '
    ' + item.composition_info + '
  • ' }, - tokenFormatter: function(item){ return '
  • ' + item.comment + '
    ' + item.time_table_bounding + '
    ' + item.composition_info + '
  • ' }, + resultsFormatter: time_table_formatter, + tokenFormatter: time_table_formatter, }); });").html_safe) end diff --git a/app/views/time_tables/index.json.rabl b/app/views/time_tables/index.json.rabl index dec29cb69..443cb13a2 100644 --- a/app/views/time_tables/index.json.rabl +++ b/app/views/time_tables/index.json.rabl @@ -1,5 +1,9 @@ collection @time_tables, :object_root => false node do |time_table| - { :id => time_table.id, :comment => time_table.comment, :time_table_bounding => time_table_bounding( time_table), :composition_info => composition_info(time_table) } -end + { :id => time_table.id, :comment => time_table.comment, + :time_table_bounding => time_table_bounding( time_table), + :composition_info => composition_info(time_table), + :tags => time_table.tags.join(','), + :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('')} +end diff --git a/app/views/vehicle_journeys/_form.html.erb b/app/views/vehicle_journeys/_form.html.erb index 459e8ea07..67fc21803 100644 --- a/app/views/vehicle_journeys/_form.html.erb +++ b/app/views/vehicle_journeys/_form.html.erb @@ -12,7 +12,7 @@ <%= form.input :facility %> <%= form.input :vehicle_type_identifier%> <%= form.input :objectid, :required => !@vehicle_journey.new_record?, :input_html => { :title => t("formtastic.titles.vehicle_journey.objectid")} %> - <%= form.input :time_table_tokens, :label => t('.time_tables'), :as => :search_time_table, :json => referential_time_tables_path(@referential, :format => :json), :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => ( @vehicle_journey.time_tables.map{ |time_table| { :id => time_table.id, :comment => time_table.comment, :time_table_bounding => time_table_bounding( time_table), :composition_info => composition_info(time_table) } } ).to_json } %> + <%= form.input :time_table_tokens, :label => t('.time_tables'), :as => :search_time_table, :json => referential_time_tables_path(@referential, :format => :json), :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :input_html => { :"data-pre" => ( @vehicle_journey.time_tables.map{ |time_table| { :id => time_table.id, :tags => time_table.tags.join(','), :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(''), :comment => time_table.comment, :time_table_bounding => time_table_bounding( time_table), :composition_info => composition_info(time_table) } } ).to_json } %>
  • <%= form.label @vehicle_journey.human_attribute_name(:vehicle_journey_at_stop_ids), :class => "label" %>
  • -- cgit v1.2.3