# HG changeset patch # User luisf # Date 1302192674 -3600 # Node ID 5562a95edbf7b99c08179ab51cfc392ac6e3d3a0 # Parent 8ed0a0a268e0d22a793af09c6ef70a661463a03d DEV commit - problems in the create action; diff -r 8ed0a0a268e0 -r 5562a95edbf7 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Apr 05 20:54:40 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Thu Apr 07 17:11:14 2011 +0100 @@ -32,29 +32,32 @@ end def new - session[:publication_params] ||= {} @publication = Publication.new @publication.current_step = session[:publication_step] - - if request.post? - parse_bibtex_text - @publication = Publication.new(params[:publication]) - - if @publication.save - logger.error "GRAVOU XXXdsfgXXX" - else - logger.error "nao gravou" - end - - end - + + logger.error @publication.current_step + + end - def create + def create + @publication = Publication.new(params[:publication]) - logger.error "AAAA create" + @publication.current_step = session[:publication_step] - @publication.save + if params[:back_button] + @publication.previous_step + else + @publication.next_step + end + + session[:publication_step] = @publication.current_step + + logger.error "AAAA" + logger.error session[:publication_step] + + + render "new" end def index diff -r 8ed0a0a268e0 -r 5562a95edbf7 vendor/plugins/redmine_bibliography/app/models/publication.rb --- a/vendor/plugins/redmine_bibliography/app/models/publication.rb Tue Apr 05 20:54:40 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Thu Apr 07 17:11:14 2011 +0100 @@ -15,6 +15,17 @@ def steps %w[new review] end + + def next_step + self.current_step = step[steps.index(current_step)+1] + end + def previous_step + self.current_step = step[steps.index(current_step)-1] + end + + def first_step? + current_step == steps.first + end end diff -r 8ed0a0a268e0 -r 5562a95edbf7 vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb Tue Apr 05 20:54:40 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_new_bibtex_step.html.erb Thu Apr 07 17:11:14 2011 +0100 @@ -1,13 +1,13 @@ +

New Bibtex

-

New Bibtex

-

- <%= f.label :title %> - <%= f.text_field :title %> -

+

+ <%= f.label :title %> + <%= f.text_field :title %> +

-

- <%=label_tag :bibtex_entry %> - <%=text_area_tag :bibtex_entry%> -

+

+ <%=label_tag :bibtex_entry %> + <%=text_area_tag :bibtex_entry%> +

diff -r 8ed0a0a268e0 -r 5562a95edbf7 vendor/plugins/redmine_bibliography/app/views/publications/_review_bibtex_step.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_review_bibtex_step.html.erb Tue Apr 05 20:54:40 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_review_bibtex_step.html.erb Thu Apr 07 17:11:14 2011 +0100 @@ -0,0 +1,2 @@ +

Review new entries

+ diff -r 8ed0a0a268e0 -r 5562a95edbf7 vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Tue Apr 05 20:54:40 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Thu Apr 07 17:11:14 2011 +0100 @@ -1,11 +1,12 @@

New Publication

-<% form_for :publication do |f| %> +<% form_for :publication, :url => { :action => "create" } do |f| %> <% f.error_messages %> - <% render :partial => "#{@publication.current_step}_bibtex_step", :locals => { :f => f } %> + <%= render :partial => "#{@publication.current_step}_bibtex_step", :locals => { :f => f } %> - <%= submit_tag l(:button_submit) %> + <%= f.submit "Continue" %> + <%= f.submit "Back", :name => "back_button" unless @publication.first_step? %> <% end %>