Permalink
Browse files

put libs in subdir to avoid collisions, modularize options

  • Loading branch information...
1 parent 0f07fc6 commit 2cf027ae03a6aab3a83791124a1f7aa25acd183e @thegcat committed Dec 31, 2010
View
9 app/views/doodles/_form.html.erb
@@ -6,15 +6,10 @@
<p><%= f.text_area :description, :cols => 60, :rows => 3 %>
<% if @doodle.new_record? %>
<div id="options">
- <% @doodle.options.each do |option| %>
- <div class="option">
- <p><%= label "doodle_options_", nil, l(:field_option) %> <%= text_field_tag "doodle[options][]", option, :size => 60 %> <%= link_to_function l(:button_delete), "$(this).up('.option').remove()" %></p>
- </div>
- <% end unless @doodle.options.nil? %>
- <%= render :partial => 'option' %>
+ <%= render :partial => 'options', :locals => {:options => @doodle.options} %>
</div>
<p><%= link_to_function l(:label_add_options) do |page|
- page.insert_html :bottom, :options, :partial => 'option'
+ page.insert_html :bottom, :options, :partial => 'options', :locals => {:options => nil}
end %></p>
<p><label><%= l(:label_doodle_should_answer) %></label>
<% @project.users.sort.each do |user| -%>
View
5 app/views/doodles/_option.html.erb
@@ -1,5 +0,0 @@
-<% 5.times do %>
- <div class="option">
- <p><%= label "doodle_options_", nil, l(:field_option) %> <%= text_field_tag "doodle[options][]", nil, :size => 60 %> <%= link_to_function l(:button_delete), "$(this).up('.option').remove()" %></p>
- </div>
-<% end %>
View
5 app/views/doodles/_options.html.erb
@@ -0,0 +1,5 @@
+<% (options.nil? ? Array.new(5, "") : (options + Array.new(options.length < 5 ? (5 - options.length) : 0,""))).each do |option| %>
+ <div class="option">
+ <p><%= label "doodle_options_", nil, l(:field_option) %> <%= text_field_tag "doodle[options][]", option, :size => 60 %> <%= link_to_function l(:button_delete), "$(this).up('.option').remove()" %></p>
+ </div>
+<% end %>
View
18 config/routes.rb
@@ -1,18 +1,8 @@
#custom routes for this plugin
ActionController::Routing::Routes.draw do |map|
- map.with_options :controller => 'doodles' do |doodles_routes|
- doodles_routes.connect "projects/:project_id/doodles", :conditions => { :method => :get }, :action => 'index'
- doodles_routes.connect "projects/:project_id/doodles", :conditions => { :method => :post }, :action => 'create'
- doodles_routes.connect "projects/:project_id/doodles/new", :conditions => { :method => :get }, :action => 'new'
- doodles_routes.connect "projects/:project_id/doodles/preview", :conditions => { :method => [:post, :put] }, :action => 'preview'
- doodles_routes.connect "doodles/:id", :conditions => { :method => :get }, :action => 'show', :id => /\d+/
- doodles_routes.connect "doodles/:id", :conditions => { :method => :put }, :action => 'update', :id => /\d+/
- doodles_routes.connect "doodles/:id", :conditions => { :method => :delete }, :action => 'destroy', :id => /\d+/
- doodles_routes.connect "doodles/:id/edit", :conditions => { :method => :get }, :action => 'edit', :id => /\d+/
- doodles_routes.connect "doodles/:id/lock", :conditions => { :method => :post }, :action => 'lock', :id => /\d+/
- end
- map.with_options :controller => 'doodle_answers' do |doodle_answers_routes|
- doodle_answers_routes.connect "doodles/:doodle_id/doodle_answers", :conditions => { :method => :post }, :action => 'create'
- doodle_answers_routes.connect "doodle_answers/:id", :conditions => { :method => :put }, :action => 'update', :id => /\d+/
+ map.resources :projects, :only => [] do |project|
+ project.resources :doodles, :shallow => true, :new => {:preview => :post}, :member => {:lock => :post} do |doodle|
+ doodle.resources :doodle_answers, :shallow => true, :only => [:create, :update]
+ end
end
end
View
4 init.rb
@@ -4,13 +4,13 @@
Dispatcher.to_prepare do
require_dependency 'project'
require_dependency 'mailer'
- require 'patch_redmine_classes'
+ require 'redmine_doodles/patch_redmine_classes'
Project.send(:include, ::Plugin::Doodles::Project)
Mailer.send(:include, ::Plugin::Doodles::Mailer)
end
-require_dependency 'view_hooks'
+require_dependency 'redmine_doodles/view_hooks'
Redmine::Plugin.register :redmine_doodles do
name 'Redmine Doodles plugin'
View
0 lib/patch_redmine_classes.rb → lib/redmine_doodles/patch_redmine_classes.rb
File renamed without changes.
View
2 lib/view_hooks.rb → lib/redmine_doodles/view_hooks.rb
@@ -1,7 +1,7 @@
module Plugin
module Doodles
class ViewHooks < Redmine::Hook::ViewListener
- def view_layouts_base_html_head(context={ })
+ def view_layouts_base_html_head(context={})
stylesheet_link_tag 'redmine_doodles', :plugin => 'redmine_doodles'
end
end

0 comments on commit 2cf027a

Please sign in to comment.