Commit f5e5634215f30874ec4b21539b2641df0501ee45

Authored by Caio Salgado + Alessandro Palmeira
Committed by Paulo Meireles
1 parent 2a4ebbf7

[Mezuro] Saving date from form and reloading project_result

plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
... ... @@ -17,20 +17,25 @@ class MezuroPluginProfileController < ProfileController
17 17  
18 18 def project_result
19 19  
20   - content = profile.articles.find(params[:id])
21   - project_result = content.project_result
  20 + content = profile.articles.find(params[:id])
  21 + date = params[:date]
  22 + project_result = date.nil? ? content.project_result : content.get_date_project_result(date)
22 23 project = content.project
23 24 render :partial => 'content_viewer/project_result', :locals => { :project_result => project_result}
24 25 end
25 26  
26 27 def module_result
27 28 content = profile.articles.find(params[:id])
  29 +# date = params[:date]
  30 +# project_result = date.nil? ? content.project_result : content.get_date_module_results(date)
28 31 module_result = content.module_result(params[:module_name])
29 32 render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result}
30 33 end
31 34  
32 35 def project_tree
33 36 content = profile.articles.find(params[:id])
  37 +# date = params[:date]
  38 +# project_result = date.nil? ? content.project_result : content.get_date_project_tree(date)
34 39 project_result = content.project_result
35 40 source_tree = project_result.node_of(params[:module_name])
36 41 render :partial =>'content_viewer/source_tree', :locals => { :source_tree => source_tree, :project_name => content.project.name}
... ...
plugins/mezuro/lib/mezuro_plugin/project_content.rb
... ... @@ -20,10 +20,19 @@ class MezuroPlugin::ProjectContent < Article
20 20 def project
21 21 @project ||= Kalibro::Client::ProjectClient.project(name)
22 22 end
  23 +
  24 + def project
  25 + @project ||= Kalibro::Client::ProjectClient.project(name)
  26 + end
23 27  
24 28 def project_result
25 29 @project_result ||= Kalibro::Client::ProjectResultClient.last_result(name)
26 30 end
  31 +
  32 + def get_date_result(date)
  33 + client = Kalibro::Client::ProjectResultClient.new
  34 + @project_result ||= client.has_results_before(name, date) ? client.last_result_before(name, date) : client.first_result_after(name, date)
  35 + end
27 36  
28 37 def module_result(module_name)
29 38 @module_client ||= Kalibro::Client::ModuleResultClient.module_result(self, module_name)
... ...
plugins/mezuro/public/javascripts/project_content.js
... ... @@ -11,11 +11,6 @@ function showProjectContent() {
11 11 callAction('project_state', {}, showProjectContentFor);
12 12 }
13 13  
14   -function reloadProjectWithDate(){
15   - reloadProject();
16   - return false;
17   -}
18   -
19 14 function toggle_mezuro(){
20 15 var element = jQuery(this).attr('data-show');
21 16 jQuery(element).toggle();
... ... @@ -31,12 +26,23 @@ function reloadModule(){
31 26 return false;
32 27 }
33 28  
34   -function reloadProject(){
  29 +function reloadProjectWithDate(){
  30 + var day = jQuery("#project_date_day").val();
  31 + var month = jQuery("#project_date_month").val();
  32 + var year = jQuery("#project_date_year").val();
  33 +
  34 + var date = year + "-" + month + "-" + day + "T00:00:00+00:00";
  35 +
  36 + reloadProject(date);
  37 + return false;
  38 +}
  39 +
  40 +function reloadProject(date){
35 41 showLoadingProcess(true);
36 42  
37   - callAction('project_result', {}, showProjectResult);
38   - callAction('project_tree', {}, showProjectTree);
39   - callAction('module_result', {}, showModuleResult);
  43 + callAction('project_result', {date: date}, showProjectResult);
  44 + callAction('project_tree', {date: date}, showProjectTree);
  45 + callAction('module_result', {date: date}, showModuleResult);
40 46 }
41 47  
42 48 function showProjectContentFor(state){
... ... @@ -44,7 +50,7 @@ function showProjectContentFor(state){
44 50 callAction('project_error', {}, showProjectResult);
45 51 else if (state == 'READY') {
46 52 callAction('project_result', {}, showProjectResult);
47   - //callAction('project_tree', {}, showProjectTree);
  53 + callAction('project_tree', {}, showProjectTree);
48 54 var project_name = jQuery("#project-result").attr('data-project-name');
49 55 callAction('module_result', {module_name: project_name}, showModuleResult);
50 56 }
... ...
plugins/mezuro/views/content_viewer/_project_result.rhtml
1   -Project history
2 1  
3 2 <% form_for :project_date, :html=>{:id=>"project_history_date"} do |f| %>
4   - <%= f.text_field :day, :size => 1, :maxlength => 2 %>
5   - <%= f.text_field :month, :size => 1, :maxlength => 2 %>
6   - <%= f.text_field :year, :size => 1, :maxlength => 4 %>
7   - <p>
8   - <%= f.submit "Save" %>
9   - </p>
  3 + <%= f.label :day, "Choose project date:" %>
  4 +
  5 +<table>
  6 + <tr>
  7 + <td>
  8 + Day
  9 + </td>
  10 + <td>
  11 + Month
  12 + </td>
  13 + <td>
  14 + Year
  15 + </td>
  16 + </tr>
  17 + <tr>
  18 + <td>
  19 + <%= f.text_field :day, :size => 1, :maxlength => 2, :placeholder =>"dd" %>
  20 + </td>
  21 + <td>
  22 + <%= f.text_field :month, :size => 1, :maxlength => 2, :placeholder =>"mm" %>
  23 + </td>
  24 + <td>
  25 + <%= f.text_field :year, :size => 1, :maxlength => 4, :placeholder =>"yyyy" %>
  26 + </td>
  27 + </tr>
  28 +</table>
  29 + <%= f.submit "Refresh" %>
10 30 <% end %>
11 31  
12 32  
... ...