aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinhui2017-04-06 16:15:53 +0200
committerXinhui2017-04-06 16:15:59 +0200
commit4f336496d52cf024de9fbce2c6133592bb300aa5 (patch)
tree36b1efe2c797986ce046d7c60cfa8472c23d388b
parent45a789aa0041cbfeca535a8679f3d88ccbe01757 (diff)
downloadchouette-core-4f336496d52cf024de9fbce2c6133592bb300aa5.tar.bz2
Refactoring TimeTables#show json format
-rw-r--r--app/helpers/time_tables_helper.rb6
-rw-r--r--app/views/time_tables/show.rabl17
2 files changed, 13 insertions, 10 deletions
diff --git a/app/helpers/time_tables_helper.rb b/app/helpers/time_tables_helper.rb
index 9fdb791b1..b1175d359 100644
--- a/app/helpers/time_tables_helper.rb
+++ b/app/helpers/time_tables_helper.rb
@@ -1,3 +1,9 @@
module TimeTablesHelper
+
+ def month_periode_enum(years)
+ start_date = Date.today - years.years
+ end_date = Date.today + years.years
+ (start_date..end_date).map(&:beginning_of_month).uniq.map(&:to_s)
+ end
end
diff --git a/app/views/time_tables/show.rabl b/app/views/time_tables/show.rabl
index 1e57e069e..8543377a9 100644
--- a/app/views/time_tables/show.rabl
+++ b/app/views/time_tables/show.rabl
@@ -1,26 +1,23 @@
object @time_table
+attributes :id, :comment
node do |tt|
{
time_table_bounding: tt.presenter.time_table_bounding,
- composition_info: tt.presenter.composition_info,
- day_types: %w(monday tuesday wednesday thursday friday saturday sunday).select{ |d| tt.send(d) }.map{ |d| tt.human_attribute_name(d).first(2)}.join('')
+ tags: tt.tags.map(&:name),
+ day_types: %w(monday tuesday wednesday thursday friday saturday sunday).select{ |d| tt.send(d) }.map{ |d| tt.human_attribute_name(d).first(2)}.join(''),
+ periode_range: month_periode_enum(3)
}
end
-attributes :id, :comment
child(:periods, object_root: false) do
- attributes :id, :period_start, :period_end, :position
+ attributes :id, :period_start, :period_end
end
child(:dates, object_root: false) do
- attributes :id, :date, :position, :in_out
+ attributes :id, :date, :in_out
end
child(:calendar) do
- attributes :id, :name, :short_name
-end
-
-child(:tags, object_root: false) do
- attributes :name
+ attributes :id, :name
end