Commit cb760576349ac29fc6caf1f8a28ec405bb61115e

Authored by Diego Camarinha
Committed by Guilherme Rojas
1 parent e184e4ac

Calendar.

Created dropdown boxes to insert a date to get the processing from.

Signed-off-by: Renan Fichberg <rfichberg@gmail.com>
app/assets/javascripts/module/graphic.js.coffee
... ... @@ -15,4 +15,4 @@ class Module.Graphic
15 15 display(data,container)
16 16  
17 17 display: (data, container) ->
18   - $('div#'+container).html('<img id="' + container + '" src="data:image/png;base64,' + data + '" class="img-rounded"/>')
19 18 \ No newline at end of file
  19 + $('div#'+container).html('<img id="' + container + '" src="data:image/png;base64,' + data + '" class="img-rounded"/>')
... ...
app/helpers/repository_helper.rb
... ... @@ -14,4 +14,16 @@ module RepositoryHelper
14 14 end
15 15 return "Undefined"
16 16 end
17   -end
18 17 \ No newline at end of file
  18 +
  19 + def day_options
  20 + (1..31).to_a.map {|day| [day, day]}
  21 + end
  22 +
  23 + def month_options
  24 + (1..12).to_a.map {|month| [month, month]}
  25 + end
  26 +
  27 + def year_options
  28 + (2013..2020).to_a.map {|year| [year, year]}
  29 + end
  30 +end
... ...
app/views/repositories/show.html.erb
... ... @@ -32,6 +32,14 @@
32 32 <%= @configuration.name %>
33 33 </p>
34 34  
  35 +<p><strong> Retrieve a processing information from: </strong></p>
  36 +
  37 +<p> Day: <%= select_tag(:day, options_for_select(day_options), :style => "width:55px; margin-top:5px") %>
  38 +Month: <%= select_tag(:month, options_for_select(month_options), :style => "width:55px; margin-top:5px") %>
  39 +Year: <%= select_tag(:year, options_for_select(year_options), :style => "width:70px; margin-top:5px") %>
  40 +<%= link_to 'Search', "#", class: 'btn btn-info' , style: 'margin-bottom:5px' %> </p>
  41 +</p>
  42 +
35 43 <hr/>
36 44  
37 45 <div id="repository-accordion">
... ...
config/routes.rb
... ... @@ -7,6 +7,7 @@ Mezuro::Application.routes.draw do
7 7 resources :projects do
8 8 resources :repositories, except: [:update, :index]
9 9 get '/repositories/:id/modules/:module_result_id' => 'repositories#show', as: :repository_module
  10 + get '/repositories/:id/date' => 'repositories#date', as: :repository_date
10 11 post '/repositories/:id/state' => 'repositories#state', as: :repository_state
11 12 put '/repositories/:id' => 'repositories#update', as: :repository_update
12 13 get '/repositories/:id/process' => 'repositories#process_repository', as: :repository_process
... ...
spec/helpers/repository_helper_spec.rb
... ... @@ -23,4 +23,22 @@ describe RepositoryHelper do
23 23 helper.periodicity_option(nil).should eq "Undefined"
24 24 end
25 25 end
26   -end
27 26 \ No newline at end of file
  27 +
  28 + describe 'calendar' do
  29 + it 'should return an array with the number of days' do
  30 + days = (1..31).to_a.map {|day| [day, day]}
  31 + helper.day_options.should eq days
  32 + end
  33 +
  34 + it 'should return an array with the number of months' do
  35 + months = (1..12).to_a.map {|month| [month, month]}
  36 + helper.month_options.should eq months
  37 + end
  38 +
  39 + it 'should return a range of years' do
  40 + years = (2013..2020).to_a.map {|year| [year, year]}
  41 + helper.year_options.should eq years
  42 + end
  43 + end
  44 +
  45 +end
... ...
spec/routing/repositories_routing_spec.rb
... ... @@ -22,5 +22,7 @@ describe RepositoriesController do
22 22 to(controller: :repositories, action: :state, project_id: 1, id: 1) }
23 23 it { should route(:get, '/projects/1/repositories/1/process').
24 24 to(controller: :repositories, action: :process_repository, project_id: 1, id: 1) }
25   - end
  25 + it { should route(:get, '/projects/1/repositories/1/date').
  26 + to(controller: :repositories, action: :date, project_id: 1, id: 1) }
  27 + end
26 28 end
... ...