diff --git a/app/views/contracts/new.html.erb b/app/views/contracts/new.html.erb
new file mode 100644
index 0000000..654c315
--- /dev/null
+++ b/app/views/contracts/new.html.erb
@@ -0,0 +1,34 @@
+<%= content_tag(:h2, l(:text_new_contract)) %>
+
+<% semantic_form_for resource, :html => {:class => 'tabular'} do |form| %>
+<% form.inputs do %>
+ <%= form.input :name, :required => true %>
+ <%= form.input :account_executive, :required => true %>
+
+ <%= label('contract', 'executed') %>
+ <%= check_box 'contract', 'executed' %>
+
+ <%= form.input :start_date, :required => true, :as => :string, :input_html => {:size => 10}, :hint => calendar_for('contract_start_date') %>
+ <%= form.input :end_date, :required => true, :as => :string, :input_html => {:size => 10}, :hint => calendar_for('contract_end_date') %>
+ <%= form.input :billable_rate, :input_html => {:size => 20}, :hint => l(:field_billable_rate_hint) %>
+ <%= form.input :discount, :input_html => {:size => 20}, :hint => l(:field_discount_hint) %>
+ <%= form.input :discount_note, :input_html => {:class => 'wiki-edit', :rows => '5'} %>
+ <%= form.input :payment_terms %> <%# TODO: select %>
+ <%= form.input :client_ap_contact_information, :input_html => {:class => 'wiki-edit', :rows => '5'} %>
+ <%= form.input :po_number %>
+ <%= form.input :details, :input_html => {:class => 'wiki-edit'} %>
+<% end %>
+<% form.buttons do %>
+ <%= form.commit_button %>
+ <%= link_to(l(:button_cancel), contracts_path) %>
+<% end %>
+<% end %>
+
+<%= wikitoolbar_for 'contract_discount_note' %>
+<%= wikitoolbar_for 'contract_client_ap_contact_information' %>
+<%= wikitoolbar_for 'contract_details' %>
+
+
+<% content_for(:header_tags) do %>
+ <%= stylesheet_link_tag "redmine_contracts", :plugin => "redmine_contracts", :media => "screen" %>
+<% end %>
diff --git a/assets/stylesheets/redmine_contracts.css b/assets/stylesheets/redmine_contracts.css
new file mode 100644
index 0000000..82648f2
--- /dev/null
+++ b/assets/stylesheets/redmine_contracts.css
@@ -0,0 +1,17 @@
+/* Modification of Redmine's tabular forms to support formtastic */
+.tabular li{
+margin: 0;
+padding: 5px 0 8px 0;
+padding-left: 180px; /*width of left column containing the label elements*/
+height: 1%;
+clear:left;
+list-style: none;
+}
+
+html>body .tabular li {overflow:hidden;}
+
+.tabular .inline-hints { color:#666; margin:0.5em 0 0 0; padding: 0px; display: inline; }
+
+.tabular li.required label { color: #000000; }
+.tabular li.required label span.required {color: #bb0000;}
+
diff --git a/config/locales/en.yml b/config/locales/en.yml
index fe309b9..8dd19e9 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -6,4 +6,13 @@ en:
field_account_executive: Account Executive
field_account_executive_short: "Acct. Mgr."
field_end_date: "End Date"
-
+ text_new_contract: "New Contract"
+ field_billable_rate: "Billable Rate"
+ field_billable_rate_hint: "$"
+ field_discount: "Discount"
+ field_discount_hint: "$, %"
+ field_discount_note: "Discounts Notes"
+ field_payment_terms: "Payment Terms"
+ field_client_ap_contact_information: "AP Contact Info"
+ field_po_number: "PO Number"
+ field_details: "Details"
diff --git a/init.rb b/init.rb
index 79c3c1e..46d8414 100644
--- a/init.rb
+++ b/init.rb
@@ -1,3 +1,5 @@
+config.gem 'formtastic', :version => '0.9.10'
+
require 'redmine'
Redmine::Plugin.register :redmine_contracts do
@@ -12,7 +14,7 @@ Redmine::Plugin.register :redmine_contracts do
requires_redmine_plugin :redmine_rate, :version_or_higher => '0.1.0'
project_module :contracts do
- permission :manage_budget, {:contracts => [:index] }, :public => true
+ permission :manage_budget, {:contracts => [:index, :new] }, :public => true
end
menu(:project_menu,
@@ -20,6 +22,14 @@ Redmine::Plugin.register :redmine_contracts do
{:controller => 'contracts', :action => 'index'},
:caption => :text_contracts,
:param => :project_id)
+
+ menu(:project_menu,
+ :new_contract,
+ {:controller => 'contracts', :action => 'new'},
+ :caption => :text_new_contract,
+ :param => :project_id,
+ :parent => :contracts)
+
end
require 'dispatcher'
@@ -29,6 +39,16 @@ Dispatcher.to_prepare :redmine_contracts do
require_dependency 'inherited_resources'
require_dependency 'inherited_resources/base'
+ # Load and bootstrap formtastic
+ gem 'formtastic', :version => '0.9.10'
+ require_dependency 'formtastic'
+ require_dependency 'formtastic/layout_helper'
+ ActionView::Base.send :include, Formtastic::SemanticFormHelper
+ ActionView::Base.send :include, Formtastic::LayoutHelper
+
+ Formtastic::SemanticFormBuilder.all_fields_required_by_default = false
+ Formtastic::SemanticFormBuilder.required_string = " *"
+
require_dependency 'project'
Project.send(:include, RedmineContracts::Patches::ProjectPatch)
end
diff --git a/test/integration/contracts_new_test.rb b/test/integration/contracts_new_test.rb
new file mode 100644
index 0000000..4b20cbb
--- /dev/null
+++ b/test/integration/contracts_new_test.rb
@@ -0,0 +1,18 @@
+require 'test_helper'
+
+class ContractsNewTest < ActionController::IntegrationTest
+ include Redmine::I18n
+
+ def setup
+ @project = Project.generate!(:identifier => 'main')
+ end
+
+ should "allow any user to open the new contracts form" do
+ visit_contracts_for_project(@project)
+ click_link 'New Contract'
+ assert_response :success
+
+ assert_select "form#new_contract"
+ end
+
+end