Skip to content

Commit

Permalink
tried to integrate new date fields into view but date select popup is…
Browse files Browse the repository at this point in the history
… not displayed

added abbreviation values to settings.yml
  • Loading branch information
ingojaeckel committed Nov 3, 2009
1 parent 96cdd22 commit 93299df
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 9 deletions.
1 change: 1 addition & 0 deletions app/controllers/proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def show
# GET /proposals/new.xml
def new
@proposal = Proposal.new(:user => @current_user)
@abbreviation = Setting.proposal_abbreviation[0..-1]
@users = User.except(@current_user).all
if params[:related]
model, id = params[:related].split("_")
Expand Down
27 changes: 23 additions & 4 deletions app/models/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,38 @@
# :access, :string, :limit => 8, :default => "Private"
# :user_id, :integer
# :assigned_to, :integer
# add_column :proposals, :abbreviation, :string, :default => "WEB"
# add_column :proposals, :state, :string, :default => "draft"
# add_column :proposals, :deadline, :date
# add_column :proposals, :client_account_id, :integer
# add_column :proposals, :client_contact_id, :integer
# add_column :proposals, :client_technical_contact_id, :integer
# add_column :proposals, :employee_contact_id, :integer
# add_column :proposals, :employee_technical_contact_id, :integer
#
class Proposal < ActiveRecord::Base
belongs_to :user
belongs_to :assignee, :class_name => "User", :foreign_key => :assigned_to
has_many :tasks, :as => :asset, :dependent => :destroy, :order => 'created_at DESC'
enum_attr :abbreviation, %w(WEB FS LVN)

belongs_to :user
belongs_to :assignee, :class_name => "User", :foreign_key => :assigned_to

belongs_to :client_account, :class_name => "Account"
belongs_to :client_contact, :class_name => "Contact"
belongs_to :client_technical_contact, :class_name => "Contact"
# TODO when we have an employees module we should link proposals to employees instead of contacts. we assume that contacts are persons not working in the crm organisation but in other companies (clients).
belongs_to :employee_contact, :class_name => "Contact"
belongs_to :employee_technical_contact, :class_name => "Contact"

has_many :tasks, :as => :asset, :dependent => :destroy, :order => 'created_at DESC'
has_many :activities, :as => :subject, :order => 'created_at DESC'

named_scope :created_by, lambda { |user| { :conditions => "user_id = #{user.id}" } }
named_scope :assigned_to, lambda { |user| { :conditions => "assigned_to = #{user.id}" } }

simple_column_search :name, :match => :middle, :escape => lambda { |query| query.gsub(/[^\w\s\-\.']/, "").strip }

versioned
# versioning plugin not installed properly -> disable versioning
#versioned
uses_user_permissions
acts_as_commentable
acts_as_paranoid
Expand Down
5 changes: 2 additions & 3 deletions app/views/proposals/_proposal.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
= link_to_delete(proposal) + "&nbsp;"
= link_to(proposal.name, proposal) << " &ndash; "
%tt
= proposal.category_id
= proposal.name
== added #{time_ago_in_words(proposal.created_at)} ago by
== #{proposal.user.id == @current_user.id ? "me" : proposal.user.full_name}
- unless @current_user.preference[:proposal_outline] == "brief"
%dt
= number_to_currency(proposal.price) << " | "
= pluralize(proposal.proposal_packages.count, "packaged proposals")
= proposal.abbreviation
= hook(:proposal_bottom, self, :proposal => proposal)
17 changes: 15 additions & 2 deletions app/views/proposals/_top_section.html.haml
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
.section
%table{ :width => 500, :cellpadding => 0, :cellspacing => 0 }
%tr
%td{ :valign => :top }
%td{ :colspan => 3, :valign => :top }
.label.top.req Name:
= f.text_field :name, :style => "width:324px"
%tr
%td{ :valign => :top }
%td{ :colspan => 3, :valign => :top }
.label.top.req Abbreviation
%tr
%td
.label Start Date:
= f.text_field :start_date, :value => f.object.start_date ? f.object.start_date.to_s(:mmddyyyy) : "", :style => "width:110px", :autocomplete => :off
%td
.label End Date:
= f.text_field :end_date, :value => f.object.end_date ? f.object.end_date.to_s(:mmddyyyy) : "", :style => "width:110px", :autocomplete => :off
%td
.label Deadline:
= f.text_field :deadline, :value => f.object.deadline ? f.object.deadline.to_s(:mmddyyyy) : "", :style => "width:110px", :autocomplete => :off
%tr
%td{ :colspan => 3, :valign => :top }
.label.top.req Assigned to:
= collection_select :proposal, :assigned_to, @users, :id, :full_name, { :include_blank => "Myself" }, { :style => "width:160px" }
= hook(:proposal_top_section_bottom, self, :f => f)
3 changes: 3 additions & 0 deletions app/views/proposals/create.js.rjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ if @proposal.valid?
page.call "crm.flick", :empty, :remove
else
page[:create_proposal].replace_html :partial => "create"
page.call "crm.date_select_popup", :proposal_start_date
page.call "crm.date_select_popup", :proposal_end_date
page.call "crm.date_select_popup", :proposal_deadline
page[:create_proposal].visual_effect :shake, :duration => 0.25, :distance => 6
page[:proposal_name].focus
end
7 changes: 7 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,10 @@ task_completed: [
[ "This month", :completed_this_month ],
[ "Last month", :completed_last_month ]
]

# NOTE: no tabs allowed. use spaces instead.
proposal_abbreviation: [
[ "WEB", :WEB ],
[ "FS", :FS ],
[ "LVN", :LVN ]
]

0 comments on commit 93299df

Please sign in to comment.