diff options
| author | Michel Etienne | 2012-10-01 20:31:41 +0200 |
|---|---|---|
| committer | Michel Etienne | 2012-10-01 20:31:41 +0200 |
| commit | a3fa25fe5ca2e1c02d88a7898ddc8ad7c8757475 (patch) | |
| tree | e1c066baca790deb8aab36108766208f54f58bb9 | |
| parent | 8d09e6fbf7c7e804e9c4c80fce195755b572492c (diff) | |
| download | chouette-core-a3fa25fe5ca2e1c02d88a7898ddc8ad7c8757475.tar.bz2 | |
refactor time-table-edit
| -rw-r--r-- | Gemfile | 8 | ||||
| -rw-r--r-- | Gemfile.lock | 30 | ||||
| -rw-r--r-- | app/assets/javascripts/public/jquery.ui.datepicker-i18n.js | 9 | ||||
| -rw-r--r-- | app/assets/javascripts/time_tables.js.coffee | 39 | ||||
| -rw-r--r-- | app/assets/stylesheets/time_tables.css.scss | 61 | ||||
| -rw-r--r-- | app/views/time_tables/_date_fields.erb | 4 | ||||
| -rw-r--r-- | app/views/time_tables/_dates.html.erb | 4 | ||||
| -rw-r--r-- | app/views/time_tables/_form.erb | 37 | ||||
| -rw-r--r-- | app/views/time_tables/_period_fields.erb | 5 | ||||
| -rw-r--r-- | app/views/time_tables/_periods.html.erb | 3 | ||||
| -rw-r--r-- | app/views/time_tables/show.html.erb | 27 | ||||
| -rw-r--r-- | config/locales/time_tables.yml | 4 | ||||
| -rw-r--r-- | db/migrate/20120926144618_add_id_to_time_table_date.ninoxe_engine.rb | 13 | ||||
| -rw-r--r-- | db/migrate/20120926144619_add_id_to_time_table_period.ninoxe_engine.rb | 13 | ||||
| -rw-r--r-- | db/schema.rb | 33 |
15 files changed, 233 insertions, 57 deletions
@@ -24,8 +24,8 @@ end gem "map_layers", "~> 0.0.4" gem "georuby-ext", :git => 'git://github.com/dryade/georuby-ext.git' -gem 'user_interface', :git => 'git://github.com/dryade/user-interface.git' -#gem 'user_interface', :git => 'git://sim.dryade.priv/user_interface' #, :path => '~/Projects/UserInterfaceDryade' +#gem 'user_interface', :git => 'git://github.com/dryade/user-interface.git' +gem 'user_interface', :git => 'git://sim.dryade.priv/user_interface' #, :path => '~/Projects/UserInterfaceDryade' gem 'json' gem 'cocoon' gem 'formtastic' @@ -39,9 +39,9 @@ gem "modernizr-rails", "~> 2.0.6" gem 'gravatar_image_tag' gem "acts_as_tree", :git => "git://github.com/dryade/acts_as_tree.git" -gem 'ninoxe', :git => 'git://github.com/dryade/ninoxe.git' +#gem 'ninoxe', :git => 'git://github.com/dryade/ninoxe.git' #gem 'ninoxe', :git => 'git://github.com/dryade/ninoxe.git', :branch => 'V2_0_0' -#gem 'ninoxe', :git => 'git://chouette.dryade.priv/ninoxe' #, :path => '~/Projects/Ninoxe' +gem 'ninoxe', :git => 'git://chouette.dryade.priv/ninoxe' #, :path => '~/Projects/Ninoxe' gem 'acts_as_list', '0.1.6' #gem 'composite_primary_keys', '~> 5.0.8' diff --git a/Gemfile.lock b/Gemfile.lock index 3de1ba403..b526715f7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,4 +1,16 @@ GIT + remote: git://chouette.dryade.priv/ninoxe + revision: f6d327cfa9380bca083eacd5b6c060117a74f31b + specs: + ninoxe (0.0.8) + GeoRuby + activerecord (>= 3.1.3) + acts_as_list (= 0.1.6) + composite_primary_keys (>= 4.1.2) + geokit + rails (>= 3.1.3) + +GIT remote: git://github.com/dnagir/database_cleaner.git revision: 0c0aa44f13ae392000a6f506b62d5d1602cb4e53 branch: postgre_jruby_issue @@ -48,20 +60,8 @@ GIT rgeo (~> 0.3.8) GIT - remote: git://github.com/dryade/ninoxe.git - revision: 848e356ff197dc5dcd143057e770373646b4c62c - specs: - ninoxe (0.0.8) - GeoRuby - activerecord (>= 3.1.3) - acts_as_list (= 0.1.6) - composite_primary_keys (>= 4.1.2) - geokit - rails (>= 3.1.3) - -GIT - remote: git://github.com/dryade/user-interface.git - revision: 2a30a4eb3ff446f9d2b2de12ecacb5f923e5623c + remote: git://sim.dryade.priv/user_interface + revision: d828d7107f2b4025853cbfa7cc0e76cceca27da6 specs: user_interface (0.0.1) rails (> 3.1.0) @@ -235,7 +235,7 @@ GEM rack (>= 0.4) rack-ssl (1.3.2) rack - rack-test (0.6.1) + rack-test (0.6.2) rack (>= 1.0) rails (3.2.6) actionmailer (= 3.2.6) diff --git a/app/assets/javascripts/public/jquery.ui.datepicker-i18n.js b/app/assets/javascripts/public/jquery.ui.datepicker-i18n.js index 3d0d55b46..b7748a77a 100644 --- a/app/assets/javascripts/public/jquery.ui.datepicker-i18n.js +++ b/app/assets/javascripts/public/jquery.ui.datepicker-i18n.js @@ -53,7 +53,14 @@ jQuery(function($){ monthNamesShort: $.datepicker.regional[ $('html').attr('lang') ].monthNamesShort, monthNames: $.datepicker.regional[ $('html').attr('lang') ].monthNames } ); - $(element).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $(element).val() ) ); + if ($(element).val().indexOf('/') >= 0) + { + $(element).datepicker("setDate", $.datepicker.parseDate('dd/mm/y', $(element).val() ) ); + } + else + { + $(element).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $(element).val() ) ); + } }); $("form").submit(function(event) { diff --git a/app/assets/javascripts/time_tables.js.coffee b/app/assets/javascripts/time_tables.js.coffee new file mode 100644 index 000000000..b85376edb --- /dev/null +++ b/app/assets/javascripts/time_tables.js.coffee @@ -0,0 +1,39 @@ +jQuery -> +# add trigger to hide/show application dates and periods + switch_dates = (event) -> + event.preventDefault() + $('.time_tables .dates.content').toggle('slow') + $('a.dates .switcher').toggle() + + $('.time_tables a.dates').click(switch_dates) + + switch_periods = (event) -> + event.preventDefault() + $('.time_tables .periods.content').toggle('slow') + $('a.periods .switcher').toggle() + + $('.time_tables a.periods').click(switch_periods) + +# add trigger when creating new date or period entries to activate datepicker + tt_datepickerI18n = (index, element) -> + # do nothig if a datepicker is already attached + return if ($(element).hasClass('hasDatepicker') ) + $(element).datepicker({ + dateFormat: "dd/mm/y", + dayNamesShort: $.datepicker.regional[ $('html').attr('lang') ].dayNamesShort, + dayNames: $.datepicker.regional[ $('html').attr('lang') ].dayNames, + monthNamesShort: $.datepicker.regional[ $('html').attr('lang') ].monthNamesShort, + monthNames: $.datepicker.regional[ $('html').attr('lang') ].monthNames + }) + $(element).datepicker("setDate", $.datepicker.parseDate('dd/mm/y', $(element).val() ) ) if ($(element).val().indexOf('/') >= 0) + $(element).datepicker("setDate", $.datepicker.parseDate('yy-mm-dd', $(element).val() ) ) if ($(element).val().indexOf('/') < 0) + + after_inserts = -> + $('input[type="date"]').each(tt_datepickerI18n) + + bind_after_inserts = -> + $('#periods_content').bind('insertion-callback',after_inserts) + $('#dates_content').bind('insertion-callback',after_inserts) + #after_inserts() + + $(document).ready(bind_after_inserts) if $('.time_tables').length > 0 diff --git a/app/assets/stylesheets/time_tables.css.scss b/app/assets/stylesheets/time_tables.css.scss index 6a168eb4f..f1ff7b3d2 100644 --- a/app/assets/stylesheets/time_tables.css.scss +++ b/app/assets/stylesheets/time_tables.css.scss @@ -103,6 +103,16 @@ #workspace.time_tables.edit,#workspace.time_tables.new,#workspace.time_tables.create,#workspace.time_tables.update { + h3 { + .dates { + cursor: pointer; + } + .periods { + cursor: pointer; + } + } + + .day_type ol { float: left; margin: 0; @@ -126,4 +136,55 @@ .day_type ol li label { padding-left: 10%; } + + .dates ol { + margin-top: -0.3em; + margin-bottom: 1em; + margin-left: 25%; + padding: 0; + width: 75%; + } + .dates ol li { padding : 0.3em 0; } + + .dates ol li label { + width: 40%; + margin-top: -0.3em; + } + .dates ol li.fl1 {float: left; width: 30% ;} + .dates ol li.fl1 label {width: 40%; margin-top: -0.3em; } + .dates ol li.fl1 input { width: 50%; } + + + .periods ol { + margin-top: -0.3em; + margin-bottom: 1em; + margin-left: 25%; + padding: 0; + width: 75%; + } + .periods ol li { padding : 0.3em 0; } + + .periods ol li label { + width: 40%; + margin-top: -0.3em; + } + .periods ol li.fl1 {float: left; width: 30% ;} + .periods ol li.fl1 label {width: 40%; margin-top: -0.3em; } + .periods ol li.fl1 input { width: 50%; } + + .periods ol li.fl2 {float: left; width: 30% ;} + .periods ol li.fl2 label {width: 40%; margin-top: -0.3em;} + .periods ol li.fl2 input { width: 50%; } + a.add_fields { + margin-left: 25%; + color: #666; + padding-left: 18px; + background: url(image-path('user_interface/ui/add.png')) no-repeat 0% 50%; + } + a.remove_fields { + color: #666; + padding-left: 18px; + background: url(image-path('user_interface/ui/remove.png')) no-repeat 0% 50%; + } + } diff --git a/app/views/time_tables/_date_fields.erb b/app/views/time_tables/_date_fields.erb new file mode 100644 index 000000000..5d24456a3 --- /dev/null +++ b/app/views/time_tables/_date_fields.erb @@ -0,0 +1,4 @@ +<%= f.inputs :class => 'dates nested-fields' do %> + <%= f.input :date, :as => :date_picker, :label => @time_table.human_attribute_name("date"), :wrapper_html => { :class => 'fl1' }%> + <%= link_to_remove_association t('actions.destroy'), f %> +<% end %> diff --git a/app/views/time_tables/_dates.html.erb b/app/views/time_tables/_dates.html.erb index 47ae01710..663efec58 100644 --- a/app/views/time_tables/_dates.html.erb +++ b/app/views/time_tables/_dates.html.erb @@ -1,10 +1,6 @@ <ul class='dates'> <% @time_table.dates.each do |tmd| %> <li class="<%= (tmd.position%2==0) ? 'odd' : 'even' %>"><%= l tmd.date %> - <div class="actions"> - <%= link_to t("actions.destroy"), referential_time_table_time_table_date_path(@referential, @time_table,tmd), :method => :delete, :confirm => t('time_tables.actions.destroy_date_confirm'), :class => "remove" %> - </div> - </li> <% end %> </ul> diff --git a/app/views/time_tables/_form.erb b/app/views/time_tables/_form.erb index fbced7bd4..3325b97a5 100644 --- a/app/views/time_tables/_form.erb +++ b/app/views/time_tables/_form.erb @@ -17,6 +17,43 @@ <%= form.input :objectid, :required => !@time_table.new_record?, :input_html => { :disabled => !@time_table.new_record? } %> <% end %> + <h3 class="time_table_dates"> + <a class="dates"><%= @time_table.human_attribute_name("dates") %> + <%= image_tag("icons/plus.png" , :class => "switcher", :style => "display: none;") %> + <%= image_tag("icons/minus.png" , :class => "switcher" ) %> + </a> + </h3> + + <div class="dates content" id="dates_content"> + <div id="dates"> + <%= form.semantic_fields_for :dates do |p| %> + <%= render "date_fields", :f => p %> + <% end %> + </div> + <%= link_to_add_association t("time_tables.actions.add_date"), form, :dates , + :"data-association-insertion-method" => "append", + :"data-association-insertion-node" => "div#dates" %> + </div> + + + <h3 class="time_table_periods"> + <a class="periods"><%= @time_table.human_attribute_name("periods") %> + <%= image_tag("icons/plus.png" , :class => "switcher", :style => "display: none;") %> + <%= image_tag("icons/minus.png" , :class => "switcher" ) %> + </a> + + </h3> + <div class="periods content" id="periods_content"> + <div id="periods"> + <%= form.semantic_fields_for :periods do |p| %> + <%= render "period_fields", :f => p %> + <% end %> + </div> + <%= link_to_add_association t("time_tables.actions.add_period"), form, :periods , + :"data-association-insertion-method" => "append", + :"data-association-insertion-node" => "div#periods"%> + </div> + <p/> <%= form.actions do %> <%= form.action :submit, :as => :button %> <%= form.action :cancel, :as => :link %> diff --git a/app/views/time_tables/_period_fields.erb b/app/views/time_tables/_period_fields.erb new file mode 100644 index 000000000..120a526bb --- /dev/null +++ b/app/views/time_tables/_period_fields.erb @@ -0,0 +1,5 @@ +<%= f.inputs :class => 'periods nested-fields' do %> + <%= f.input :period_start, :as => :date_picker, :label => @time_table.human_attribute_name("period_start"), :wrapper_html => { :class => 'fl1' }%> + <%= f.input :period_end, :as => :date_picker, :label => @time_table.human_attribute_name("period_end"), :wrapper_html => { :class => 'fl2' }%> + <%= link_to_remove_association t('actions.destroy'), f %> +<% end %> diff --git a/app/views/time_tables/_periods.html.erb b/app/views/time_tables/_periods.html.erb index 9f3974735..1f0aea057 100644 --- a/app/views/time_tables/_periods.html.erb +++ b/app/views/time_tables/_periods.html.erb @@ -1,9 +1,6 @@ <ul class='periods'> <% @time_table.periods.each do |tmp| %> <li class='period'><%= t('time_tables.show.from')%> <%= l tmp.period_start %> <%= t('time_tables.show.to')%> <%= l tmp.period_end %> - <div class="actions"> - <%= link_to t("actions.destroy"), referential_time_table_time_table_period_path(@referential, @time_table,tmp), :method => :delete, :confirm => t('time_tables.actions.destroy_period_confirm'), :class => "remove" %> - </div> </li> <% end %> </ul> diff --git a/app/views/time_tables/show.html.erb b/app/views/time_tables/show.html.erb index 60eee8d04..3536dedae 100644 --- a/app/views/time_tables/show.html.erb +++ b/app/views/time_tables/show.html.erb @@ -70,18 +70,33 @@ <%= @time_table.creator_id %> </p> </div> - <h3 class="dates"><%= t('.dates') %></h3> - <%= render "dates" %> - <h3 class="periods"><%= t('.periods') %></h3> - <%= render "periods" %> + <h3 class="time_table_dates"> + <a class="dates"><%= @time_table.human_attribute_name("dates") %> + <%= image_tag("icons/plus.png" , :class => "switcher", :style => "display: none;") %> + <%= image_tag("icons/minus.png" , :class => "switcher" ) %> + </a> + </h3> + + <div class="dates content"> + <%= render "dates" %> + </div> + + <h3 class="time_table_periods"> + <a class="periods"><%= @time_table.human_attribute_name("periods") %> + <%= image_tag("icons/plus.png" , :class => "switcher", :style => "display: none;") %> + <%= image_tag("icons/minus.png" , :class => "switcher" ) %> + </a> + + </h3> + <div class="periods content"> + <%= render "periods" %> + </div> </div> <% content_for :sidebar do %> <ul class="actions"> <li><%= link_to t('time_tables.actions.edit'), edit_referential_time_table_path(@referential, @time_table), :class => "edit" %></li> <li><%= link_to t('time_tables.actions.destroy'), referential_time_table_path(@referential, @time_table), :method => :delete, :confirm => t('time_tables.actions.destroy_confirm'), :class => "remove" %></li> - <li><%= link_to t('time_tables.show.add_date'), new_referential_time_table_time_table_date_path(@referential, @time_table), :class => 'add' %></li> - <li><%= link_to t('time_tables.show.add_period'), new_referential_time_table_time_table_period_path(@referential, @time_table), :class => 'add' %></li> <br> </ul> <% end %> diff --git a/config/locales/time_tables.yml b/config/locales/time_tables.yml index d2fd44887..469875c1d 100644 --- a/config/locales/time_tables.yml +++ b/config/locales/time_tables.yml @@ -56,7 +56,7 @@ en: creation_time: Created on creator_id: Created by dates: Application dates - date: Le + date: On periods: Application periods period_start: From period_end: to @@ -81,6 +81,8 @@ fr: destroy_confirm: Etes vous sûr de détruire ce calendrier ? destroy_date_confirm: Etes vous sûr de détruire cette date ? destroy_period_confirm: Etes vous sûr de détruire cette période ? + add_period: Ajouter une période + add_date: Ajouter une date new: title: Ajouter un calendrier edit: diff --git a/db/migrate/20120926144618_add_id_to_time_table_date.ninoxe_engine.rb b/db/migrate/20120926144618_add_id_to_time_table_date.ninoxe_engine.rb new file mode 100644 index 000000000..35f1d8a2f --- /dev/null +++ b/db/migrate/20120926144618_add_id_to_time_table_date.ninoxe_engine.rb @@ -0,0 +1,13 @@ +# This migration comes from ninoxe_engine (originally 20120926141405) +class AddIdToTimeTableDate < ActiveRecord::Migration + def change + # active record can't add primary key after table creation + # must do SQL direct command + execute <<-SQL + ALTER TABLE time_table_dates ADD COLUMN id bigserial + SQL + execute <<-SQL + ALTER TABLE time_table_dates ADD CONSTRAINT time_table_dates_pkey PRIMARY KEY (id) + SQL + end +end diff --git a/db/migrate/20120926144619_add_id_to_time_table_period.ninoxe_engine.rb b/db/migrate/20120926144619_add_id_to_time_table_period.ninoxe_engine.rb new file mode 100644 index 000000000..0211d49ac --- /dev/null +++ b/db/migrate/20120926144619_add_id_to_time_table_period.ninoxe_engine.rb @@ -0,0 +1,13 @@ +# This migration comes from ninoxe_engine (originally 20120926141415) +class AddIdToTimeTablePeriod < ActiveRecord::Migration + def change + # active record can't add primary key after table creation + # must do SQL direct command + execute <<-SQL + ALTER TABLE time_table_periods ADD COLUMN id bigserial + SQL + execute <<-SQL + ALTER TABLE time_table_periods ADD CONSTRAINT time_table_periods_pkey PRIMARY KEY (id) + SQL + end +end diff --git a/db/schema.rb b/db/schema.rb index 2895423a1..bf0284d15 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120905125251) do +ActiveRecord::Schema.define(:version => 20120926144619) do create_table "access_links", :force => true do |t| t.integer "access_point_id", :limit => 8 @@ -176,8 +176,6 @@ ActiveRecord::Schema.define(:version => 20120905125251) do t.integer "choice_code" end - add_index "facilities_features", ["facility_id"], :name => "idx_facility_id" - create_table "file_validation_log_messages", :force => true do |t| t.integer "file_validation_id" t.string "key" @@ -192,7 +190,7 @@ ActiveRecord::Schema.define(:version => 20120905125251) do create_table "file_validations", :force => true do |t| t.string "status" - t.string "options", :limit => 2000 + t.string "options" t.string "file_name" t.string "file_type" t.datetime "created_at" @@ -212,13 +210,10 @@ ActiveRecord::Schema.define(:version => 20120905125251) do add_index "group_of_lines", ["objectid"], :name => "group_of_lines_objectid_key", :unique => true create_table "group_of_lines_lines", :id => false, :force => true do |t| - t.integer "group_of_line_id", :limit => 8, :null => false - t.integer "line_id", :limit => 8, :null => false + t.integer "group_of_line_id", :limit => 8 + t.integer "line_id", :limit => 8 end - add_index "group_of_lines_lines", ["group_of_line_id"], :name => "idx_grli_gr" - add_index "group_of_lines_lines", ["line_id"], :name => "idx_grli_li" - create_table "import_log_messages", :force => true do |t| t.integer "import_id" t.string "key" @@ -260,11 +255,10 @@ ActiveRecord::Schema.define(:version => 20120905125251) do add_index "journey_patterns", ["objectid"], :name => "journey_patterns_objectid_key", :unique => true create_table "journey_patterns_stop_points", :id => false, :force => true do |t| - t.integer "journey_pattern_id", :limit => 8, :null => false - t.integer "stop_point_id", :limit => 8, :null => false + t.integer "journey_pattern_id", :limit => 8 + t.integer "stop_point_id", :limit => 8 end - add_index "journey_patterns_stop_points", ["journey_pattern_id"], :name => "idx_jpsp_jpid" add_index "journey_patterns_stop_points", ["journey_pattern_id"], :name => "index_journey_pattern_id_on_journey_patterns_stop_points" create_table "lines", :force => true do |t| @@ -361,9 +355,6 @@ ActiveRecord::Schema.define(:version => 20120905125251) do t.integer "line_id", :limit => 8 end - add_index "routing_constraints_lines", ["line_id"], :name => "idx_rcli_li" - add_index "routing_constraints_lines", ["stop_area_id"], :name => "idx_rcli_st" - create_table "stop_areas", :force => true do |t| t.integer "parent_id", :limit => 8 t.string "objectid", :null => false @@ -420,7 +411,7 @@ ActiveRecord::Schema.define(:version => 20120905125251) do add_index "time_slots", ["objectid"], :name => "time_slots_objectid_key", :unique => true - create_table "time_table_dates", :id => false, :force => true do |t| + create_table "time_table_dates", :force => true do |t| t.integer "time_table_id", :limit => 8, :null => false t.date "date" t.integer "position", :null => false @@ -428,7 +419,7 @@ ActiveRecord::Schema.define(:version => 20120905125251) do add_index "time_table_dates", ["time_table_id"], :name => "index_time_table_dates_on_time_table_id" - create_table "time_table_periods", :id => false, :force => true do |t| + create_table "time_table_periods", :force => true do |t| t.integer "time_table_id", :limit => 8, :null => false t.date "period_start" t.date "period_end" @@ -450,8 +441,8 @@ ActiveRecord::Schema.define(:version => 20120905125251) do add_index "time_tables", ["objectid"], :name => "time_tables_objectid_key", :unique => true create_table "time_tables_vehicle_journeys", :id => false, :force => true do |t| - t.integer "time_table_id", :limit => 8, :null => false - t.integer "vehicle_journey_id", :limit => 8, :null => false + t.integer "time_table_id", :limit => 8 + t.integer "vehicle_journey_id", :limit => 8 end add_index "time_tables_vehicle_journeys", ["time_table_id"], :name => "index_time_tables_vehicle_journeys_on_time_table_id" @@ -501,12 +492,8 @@ ActiveRecord::Schema.define(:version => 20120905125251) do t.time "waiting_time" t.time "elapse_duration" t.time "headway_frequency" - t.integer "position", :limit => 8 - t.boolean "is_departure", :default => false - t.boolean "is_arrival", :default => false end - add_index "vehicle_journey_at_stops", ["stop_point_id"], :name => "index_vehicle_journey_at_stops_on_stop_point_id" add_index "vehicle_journey_at_stops", ["stop_point_id"], :name => "index_vehicle_journey_at_stops_on_stop_pointid" add_index "vehicle_journey_at_stops", ["vehicle_journey_id"], :name => "index_vehicle_journey_at_stops_on_vehicle_journey_id" |
