Commit f5e5634215f30874ec4b21539b2641df0501ee45
Committed by
Paulo Meireles
1 parent
2a4ebbf7
Exists in
master
and in
29 other branches
[Mezuro] Saving date from form and reloading project_result
Showing
4 changed files
with
59 additions
and
19 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
| @@ -17,20 +17,25 @@ class MezuroPluginProfileController < ProfileController | @@ -17,20 +17,25 @@ class MezuroPluginProfileController < ProfileController | ||
| 17 | 17 | ||
| 18 | def project_result | 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 | project = content.project | 23 | project = content.project |
| 23 | render :partial => 'content_viewer/project_result', :locals => { :project_result => project_result} | 24 | render :partial => 'content_viewer/project_result', :locals => { :project_result => project_result} |
| 24 | end | 25 | end |
| 25 | 26 | ||
| 26 | def module_result | 27 | def module_result |
| 27 | content = profile.articles.find(params[:id]) | 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 | module_result = content.module_result(params[:module_name]) | 31 | module_result = content.module_result(params[:module_name]) |
| 29 | render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result} | 32 | render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result} |
| 30 | end | 33 | end |
| 31 | 34 | ||
| 32 | def project_tree | 35 | def project_tree |
| 33 | content = profile.articles.find(params[:id]) | 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 | project_result = content.project_result | 39 | project_result = content.project_result |
| 35 | source_tree = project_result.node_of(params[:module_name]) | 40 | source_tree = project_result.node_of(params[:module_name]) |
| 36 | render :partial =>'content_viewer/source_tree', :locals => { :source_tree => source_tree, :project_name => content.project.name} | 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,10 +20,19 @@ class MezuroPlugin::ProjectContent < Article | ||
| 20 | def project | 20 | def project |
| 21 | @project ||= Kalibro::Client::ProjectClient.project(name) | 21 | @project ||= Kalibro::Client::ProjectClient.project(name) |
| 22 | end | 22 | end |
| 23 | + | ||
| 24 | + def project | ||
| 25 | + @project ||= Kalibro::Client::ProjectClient.project(name) | ||
| 26 | + end | ||
| 23 | 27 | ||
| 24 | def project_result | 28 | def project_result |
| 25 | @project_result ||= Kalibro::Client::ProjectResultClient.last_result(name) | 29 | @project_result ||= Kalibro::Client::ProjectResultClient.last_result(name) |
| 26 | end | 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 | def module_result(module_name) | 37 | def module_result(module_name) |
| 29 | @module_client ||= Kalibro::Client::ModuleResultClient.module_result(self, module_name) | 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 +11,6 @@ function showProjectContent() { | ||
| 11 | callAction('project_state', {}, showProjectContentFor); | 11 | callAction('project_state', {}, showProjectContentFor); |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | -function reloadProjectWithDate(){ | ||
| 15 | - reloadProject(); | ||
| 16 | - return false; | ||
| 17 | -} | ||
| 18 | - | ||
| 19 | function toggle_mezuro(){ | 14 | function toggle_mezuro(){ |
| 20 | var element = jQuery(this).attr('data-show'); | 15 | var element = jQuery(this).attr('data-show'); |
| 21 | jQuery(element).toggle(); | 16 | jQuery(element).toggle(); |
| @@ -31,12 +26,23 @@ function reloadModule(){ | @@ -31,12 +26,23 @@ function reloadModule(){ | ||
| 31 | return false; | 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 | showLoadingProcess(true); | 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 | function showProjectContentFor(state){ | 48 | function showProjectContentFor(state){ |
| @@ -44,7 +50,7 @@ function showProjectContentFor(state){ | @@ -44,7 +50,7 @@ function showProjectContentFor(state){ | ||
| 44 | callAction('project_error', {}, showProjectResult); | 50 | callAction('project_error', {}, showProjectResult); |
| 45 | else if (state == 'READY') { | 51 | else if (state == 'READY') { |
| 46 | callAction('project_result', {}, showProjectResult); | 52 | callAction('project_result', {}, showProjectResult); |
| 47 | - //callAction('project_tree', {}, showProjectTree); | 53 | + callAction('project_tree', {}, showProjectTree); |
| 48 | var project_name = jQuery("#project-result").attr('data-project-name'); | 54 | var project_name = jQuery("#project-result").attr('data-project-name'); |
| 49 | callAction('module_result', {module_name: project_name}, showModuleResult); | 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 | <% form_for :project_date, :html=>{:id=>"project_history_date"} do |f| %> | 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 | <% end %> | 30 | <% end %> |
| 11 | 31 | ||
| 12 | 32 |