Permalink
Browse files

Merge branch 'master' of https://github.com/portablemind/compass_agil…

  • Loading branch information...
2 parents dba1287 + aed80df commit 6d51a29e1796b615cf339d66cc0202f180c5cd38 @cwoodward cwoodward committed Aug 26, 2011
Showing 3,972 changed files with 111,935 additions and 229,482 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
@@ -1,9 +1,10 @@
class Agreement < ActiveRecord::Base
- belongs_to :agreement_type
- has_many :agreement_items
- has_many :agreement_party_roles
- has_many :parties, :through => :agreement_party_roles
+ belongs_to :agreement_type
+ has_many :agreement_items
+ has_many :agreement_party_roles
+ has_many :parties, :through => :agreement_party_roles
+ belongs_to :agreement_record, :polymorphic => true, :dependent => :destroy
def agreement_relationships
AgreementRelationship.find(:all, :conditions => ['agreement_id_from = ? OR agreement_id_to = ?',id,id])
@@ -17,6 +18,10 @@ def to_label
to_s
end
+ def find_parties_by_role(role)
+ self.parties.find(:all, :include => [:agreement_party_roles], :conditions => ["role_type_id = ?", role.id])
+ end
+
def get_item_by_item_type_internal_identifier(item_type_internal_identifier)
agreement_items.each do |agreement_item|
if (agreement_item.agreement_item_type.internal_identifier == item_type_internal_identifier)
@@ -1,7 +1,9 @@
ErpBaseErpSvcs::Currency.class_eval do
- has_many_polymorphs :locales,
- :from => [:"iso_country_codes", :"loyalty_program_codes"],
- :through => :"currencies_locale"
+# refactor for has_many_polymorphic. Not used at the moment
+#
+# has_many_polymorphs :locales,
+# :from => [:"iso_country_codes", :"loyalty_program_codes"],
+# :through => :"currencies_locale"
end
@@ -5,6 +5,7 @@ def after_save(agreement)
#may not have a party yet
agreement.agreement_party_roles.each do |agreement_party_role|
PartySearchFact.update_search_fact(agreement_party_role.party)
+ #OlPartySearchFact.update_search_fact(agreement_party_role.party)
end
rescue
end
@@ -17,6 +18,7 @@ def after_detroy(agreement)
agreement.agreement_party_roles.each do |agreement_party_role|
party = Party.find(agreement_party_role.party.id)
PartySearchFact.update_search_fact(party)
+ #OlPartySearchFact.update_search_fact(party)
end
rescue
end
@@ -50,7 +50,7 @@ def update
application.save
preferences = application.preferences(user)
- ext_json = "{success:true, shortcutId:'#{application.shortcut_id}', shortcut:'#{application.get_user_preference(user, :desktop_shortcut)}', preferences:#{preferences.to_json(:include => [:preference_type, :preference_option])}}"
+ ext_json = "{success:true, description:'#{application.description}', shortcutId:'#{application.shortcut_id}', shortcut:'#{application.get_user_preference(user, :desktop_shortcut)}', preferences:#{preferences.to_json(:include => [:preference_type, :preference_option])}}"
render :inline => ext_json
end
@@ -15,8 +15,6 @@ def desktop_preferences
end
def selected_desktop_preferences
- ::Desktop.include_root_in_json = false
-
user = current_user
desktop = ::Desktop.find_by_user(user)
preferences = desktop.preferences
@@ -29,7 +29,7 @@ def get_active_ext_models
result = []
models.each do |model|
- result << {:text => model, :id => model.underscore, :iconCls => 'icon-grid', :leaf => true}
+ result << {:text => model, :model => model.underscore, :iconCls => 'icon-grid', :leaf => true}
end
render :inline => result.to_json
@@ -1,18 +0,0 @@
-class ErpApp::Desktop::Scaffold::RoleController < ErpApp::Desktop::Scaffold::BaseController
- active_ext Role do |options|
- options[:inline_edit] = false
- options[:use_ext_forms] = false
- options[:ignore_associations] = true
- options[:show_id] = true
- options[:show_timestamps] = true
- options[:only] = [
- {:description => {:required => true, :readonly => false}},
- {:internal_identifier => {:required => true, :readonly => false}},
- {:external_identifier => {:required => false, :readonly => false}}
- ]
- options
- end
-
-end
-
-
@@ -49,7 +49,7 @@ def save_roles
def roles_to_node_hashes(roles)
node_hashes = []
roles.each do |role|
- node_hashes << {:text => role.description, :is_leaf => true, :icon_cls => 'icon-user', :id => role.id}
+ node_hashes << {:text => role.description, :is_leaf => true, :icon_cls => 'icon-user', :attributes => {:role_id => role.id}}
end
node_hashes
@@ -56,7 +56,7 @@ def save_applications
def applications_to_node_hashes(applications)
node_hashes = []
applications.each do |application|
- node_hashes << {:text => application.description, :icon_cls => application.icon, :is_leaf => true, :id => application.id}
+ node_hashes << {:text => application.description, :attributes => {:app_id => application.id}, :icon_cls => application.icon, :is_leaf => true}
end
node_hashes
@@ -12,7 +12,7 @@ def index
users = User.find(:all, :conditions => ['login like ?', "%#{login}%"])
end
- ext_json = "{data:#{users.to_json(:only => [:id, :login, :email])}}"
+ ext_json = "{data:#{users.to_json(:only => [:id, :login, :email, :party_id])}}"
render :inline => ext_json
end
@@ -35,7 +35,7 @@ def save_roles
def roles_to_node_hashes(roles)
node_hashes = []
roles.each do |role|
- node_hashes << {:text => role.description, :icon_cls => 'icon-user', :is_leaf => true, :id => role.id}
+ node_hashes << {:text => role.description, :icon_cls => 'icon-user', :is_leaf => true, :attributes => {:role_id => role.id}}
end
node_hashes
@@ -10,4 +10,46 @@ def index
@user = current_user
end
+ #organizer user preferences
+
+ def get_preferences
+ user = current_user
+ organizer = ::Organizer.find_by_user(user)
+ preferences = organizer.preferences
+
+ ext_json = "{success:true, preferences:#{preferences.to_json(:include => [:preference_type, :preference_option])}}"
+
+ render :inline => ext_json
+ end
+
+ def setup_preferences
+ PreferenceType.include_root_in_json = false
+ PreferenceOption.include_root_in_json = false
+
+ user = current_user
+ ext_json = '{success:true,preference_types:'
+
+ organizer = ::Organizer.find_by_user(user)
+ preference_types = organizer.preference_types
+ ext_json << preference_types.to_json(:include => :preference_options)
+ ext_json << "}"
+ render :inline => ext_json
+ end
+
+ def update_preferences
+ user = current_user
+ organizer = ::Organizer.find_by_user(user)
+
+ params.each do |k,v|
+ organizer.set_preference(k, v) unless k.to_s == 'action' or k.to_s == 'controller'
+ end
+
+ organizer.save
+
+ preferences = organizer.preferences
+
+ ext_json = "{success:true, preferences:#{preferences.to_json(:include => [:preference_type, :preference_option])}}"
+
+ render :inline => ext_json
+ end
end
@@ -2,8 +2,8 @@ class ErpApp::Organizer::Crm::BaseController < ErpApp::Organizer::BaseController
def menu
menu = []
- menu << {:text => 'Individuals', :id => 'individualsNode', :leaf => true, :iconCls => 'icon-user', :href => "javascript:void(\'\');Compass.Component.UserApp.Util.setActiveCenterItem(\'individuals_search_grid\');"}
- menu << {:text => 'Organizations', :id => 'organizationNode', :leaf => true, :iconCls => 'icon-user', :href => "javascript:void(\'\');Compass.Component.UserApp.Util.setActiveCenterItem(\'organizations_search_grid\');"}
+ menu << {:text => 'Individuals', :businessPartType => 'individual', :leaf => true, :iconCls => 'icon-user', :applicationCardId => "individuals_search_grid"}
+ menu << {:text => 'Organizations',:businessPartType => 'organization', :leaf => true, :iconCls => 'icon-user', :applicationCardId => "organizations_search_grid"}
render :inline => menu.to_json
end
@@ -79,9 +79,10 @@ def create_party
def update_party(json_text)
party_type = params[:party_type]
business_party_data = params[:data]
- businesss_party_id = business_party_data['business_party.id']
+ businesss_party_id = business_party_data['business_party_id']
enterprise_identifier = business_party_data[:enterprise_identifier]
business_party_data.delete(:id)
+ business_party_data.delete(:business_party_id)
business_party_data.delete(:enterprise_identifier)
klass = party_type.constantize
@@ -153,15 +154,9 @@ def get_parties(json_text)
end
def delete_party(json_text)
- businesss_party_id = params[:id]
party_type = params[:party_type]
-
- klass = party_type.constantize
- business_party = klass.find(businesss_party_id)
- party = business_party.party
-
- party.destroy
-
+ Party.destroy(params[:id])
+
json_text += "[],message:\"#{party_type} deleted\"}"
json_text
@@ -0,0 +1,49 @@
+class ErpApp::Shared::NotesController < ErpApp::ApplicationController
+
+ def view
+ if params[:party_id].to_i == 0
+ render :json => {:totalCount => 0, :notes => []}
+ else
+ sort_hash = params[:sort].blank? ? {} : Hash.symbolize_keys(JSON.parse(params[:sort]).first)
+ limit = params[:limit] || 30
+ start = params[:start] || 0
+
+ sort = sort_hash[:property] || 'created_at'
+ dir = sort_hash[:direction] || 'DESC'
+
+ Note.include_root_in_json = false
+
+ party = Party.find(params[:party_id])
+ notes = party.notes.find(:all, :order => "#{sort} #{dir}", :offset => start, :limit => limit)
+
+ render :inline => "{\"totalCount\":#{party.notes.count}, \"notes\":#{notes.to_json(:only => [:id, :content, :created_at], :methods => [:summary, :note_type_desc, :created_by_login])}}"
+ end
+ end
+
+ def create
+ content = params[:content]
+ note_type = NoteType.find(params[:note_type_id])
+ party = Party.find(params[:party_id])
+
+ note = Note.create(
+ :note_type => note_type,
+ :content => content,
+ :created_by_id => current_user.party.id
+ )
+
+ party.notes << note
+ party.save
+
+ render :json => {:success => true}
+ end
+
+ def delete
+ Note.find(params[:id]).destroy ? (render :json => {:success => true}) : (render :json => {:success => false})
+ end
+
+ def note_types
+ NoteType.include_root_in_json = false
+
+ render :json => {:note_types => NoteType.all}
+ end
+end
@@ -16,4 +16,8 @@ def get_preference(preference_type_iid)
def set_preference(preference_type_iid, preference_option_iid)
set_user_preference(self.user, preference_type_iid, preference_option_iid)
end
+
+ def setup_default_preferences
+ #template method
+ end
end
@@ -3,9 +3,19 @@ class Desktop < ActiveRecord::Base
BACKGROUND_FILE_PATH = "#{RAILS_ROOT}/vendor/plugins/erp_app/public/images/wallpaper"
+ def shortcuts
+ self.applications.select{|app| app.get_user_preference(self.user, :desktop_shortcut) === 'yes'}
+ end
+
+ def autoloads
+ self.applications.select{|app| app.get_user_preference(self.user, :autoload_application) === 'yes'}
+ end
+
def setup_default_preferences
+ #setup desktop background
desktop_backgroud_pt = PreferenceType.iid('desktop_background')
desktop_backgroud_pt.preferenced_records << self
+ desktop_backgroud_pt.save
pref = Preference.create(
:preference_type => desktop_backgroud_pt,
@@ -17,44 +27,62 @@ def setup_default_preferences
:preference => pref
)
+ #setup theme
+ theme_pt = PreferenceType.iid('extjs_theme')
+ theme_pt.preferenced_records << self
+ theme_pt.save
+
+ pref = Preference.create(
+ :preference_type => theme_pt,
+ :preference_option => PreferenceOption.iid('blue_extjs_theme')
+ )
+
+ self.user_preferences << UserPreference.create(
+ :user => self.user,
+ :preference => pref
+ )
+
self.save
end
- def self.add_background(description, image_data)
- result = {:success => true, :msg => nil}
- name = image_data.original_path
- #make sure this is an image
- if name != /^.?[^\.]+\.(jpe?g|png|gif|tiff)$/
- #check to make sure this description is not already being used
- unless !PreferenceOption.iid(description.gsub(' ','').underscore).nil?
- #check the file does not already exist
- unless File.exists? File.join(BACKGROUND_FILE_PATH,name)
- if image_data.respond_to?(:read)
- contents = image_data.read
- elsif image_data.respond_to?(:path)
- contents = File.read(image_data.path)
+ class << self
+ def add_background(description, image_data)
+ result = {:success => true, :msg => nil}
+ name = image_data.original_path
+ #make sure this is an image
+ if name != /^.?[^\.]+\.(jpe?g|png|gif|tiff)$/
+ #check to make sure this description is not already being used
+ unless !PreferenceOption.iid(description.gsub(' ','').underscore).nil?
+ #check the file does not already exist
+ unless File.exists? File.join(BACKGROUND_FILE_PATH,name)
+ if image_data.respond_to?(:read)
+ contents = image_data.read
+ elsif image_data.respond_to?(:path)
+ contents = File.read(image_data.path)
+ end
+ File.open(File.join(BACKGROUND_FILE_PATH,name), 'wb'){|f| f.write(contents)}
+ pref_type = PreferenceType.iid('desktop_background')
+ pref_type.preference_options << PreferenceOption.create(:description => description, :internal_identifier => (description.gsub(' ','').underscore + '_desktop_background'), :value => name)
+ pref_type.save
+ else
+ result[:success] = false
+ result[:msg] = 'Image file already exists'
end
- File.open(File.join(BACKGROUND_FILE_PATH,name), 'wb'){|f| f.write(contents)}
- pref_type = PreferenceType.iid('desktop_background')
- pref_type.preference_options << PreferenceOption.create(:description => description, :internal_identifier => (description.gsub(' ','').underscore + '_desktop_background'), :value => name)
- pref_type.save
else
result[:success] = false
- result[:msg] = 'Image file already exists'
+ result[:msg] = 'Description already used'
end
else
result[:success] = false
- result[:msg] = 'Description already used'
+ result[:msg] = 'Invalid file type. Must be an image'
end
- else
- result[:success] = false
- result[:msg] = 'Invalid file type. Must be an image'
- end
- result
- end
+ result
+ end
- def self.find_by_user(user)
- find_by_user_and_klass(user, Desktop)
+ def find_by_user(user)
+ find_by_user_and_klass(user, Desktop)
+ end
end
+
end
Oops, something went wrong.

0 comments on commit 6d51a29

Please sign in to comment.