mirror of
				https://github.com/fspc/BikeShed-1.git
				synced 2025-10-31 00:45:35 -04:00 
			
		
		
		
	Some Transactions view adjustments
-moved js to customers and users components, in order to use accordion. -Made the transaction form a little prettier
This commit is contained in:
		
							parent
							
								
									2d51bd1d9a
								
							
						
					
					
						commit
						55d0b8f2f7
					
				| @ -10,7 +10,7 @@ class AppTabPanel < Netzke::Basepack::TabPanel | ||||
| 
 | ||||
|     #all users | ||||
|     #  (had to use hash for borders to get the title to display properly) | ||||
|     @@app_tab_panel_items = [ :transactions_border, :bikes_border, {layout: :fit, wrappedComponent: :brands_and_models_border, title: "Brands/Models"}] | ||||
|     @@app_tab_panel_items = [ :transactions_border, {layout: :fit, wrappedComponent: :bikes_border, title: "Bikes"}, {layout: :fit, wrappedComponent: :brands_and_models_border, title: "Brands/Models"}] | ||||
| 
 | ||||
|     #for users | ||||
|     if controller.current_user.user? | ||||
|  | ||||
| @ -6,6 +6,7 @@ class BikesBorder < Netzke::Base | ||||
| 
 | ||||
|   def configure(c) | ||||
|     super | ||||
|     c.header = false | ||||
|     c.title = "Bikes" | ||||
|     c.items = [ | ||||
|      { netzke_component: :bikes, region: :center, split: true }, | ||||
|  | ||||
| @ -7,4 +7,15 @@ class Customers < Netzke::Basepack::Grid | ||||
|   def default_bbar | ||||
|     [ :apply, :add_in_form, :search ] | ||||
|   end | ||||
| 
 | ||||
|   #needed for transactions customer selection | ||||
|   js_configure do |c| | ||||
|     c.mixin :init_component | ||||
|   end | ||||
| 
 | ||||
|   #needed for transactions customer selection | ||||
|   endpoint :select_customer do |params, this| | ||||
|     session[:selected_customer_id] = params[:customer_id] | ||||
|     session[:selected_customer_type] = params[:customer_type] | ||||
|   end | ||||
| end | ||||
|  | ||||
							
								
								
									
										11
									
								
								app/components/customers/javascripts/init_component.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								app/components/customers/javascripts/init_component.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| { | ||||
|   initComponent: function(){ | ||||
|     // calling superclass's initComponent
 | ||||
|     this.callParent(); | ||||
|     this.getView().on('itemclick', function(view, record){ | ||||
|       // The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
 | ||||
|       console.log("user: " + record.get('id') ); | ||||
|       this.selectCustomer({customer_id: record.get('id'), customer_type: 'Customer'}); | ||||
|     }, this); | ||||
|   } | ||||
| } | ||||
| @ -15,6 +15,11 @@ class Transactions < Netzke::Basepack::Grid | ||||
|                                               user = rec.vendor | ||||
|                                               user.nil? ? "" : "#{user.first_name} #{user.last_name}" | ||||
|                                            } | ||||
|       }, | ||||
|       { :name => :customer, :getter => lambda { |rec| | ||||
|                                               user = rec.customer | ||||
|                                               user.nil? ? "" : "#{user.first_name} #{user.last_name}" | ||||
|                                            } | ||||
|       } | ||||
|     ] | ||||
|      | ||||
| @ -32,7 +37,7 @@ class Transactions < Netzke::Basepack::Grid | ||||
|      | ||||
|     customer = "No User Selected" if customer.nil? | ||||
|     [ | ||||
|       { :no_binding => true, :xtype => 'label', :text => "Creating Transaction for: #{customer.to_s}"}, | ||||
|       { :no_binding => true, :xtype => 'displayfield', :fieldLabel => "Creating Transaction for:", :value => "#{customer.to_s}"}, | ||||
|       :amount, | ||||
|       :item, | ||||
|       { :name => :for_bike, :checkboxName => :bike_item, :inputValue => true, :title => "Selling a bike?", | ||||
|  | ||||
| @ -1,18 +1,17 @@ | ||||
| class TransactionsBorder < Netzke::Base | ||||
|   # Remember regions collapse state and size | ||||
|   include Netzke::Basepack::ItemPersistence | ||||
|   #users and customers components are required for the transactions form | ||||
|   component :transactions | ||||
|   component :users | ||||
|   component :customers | ||||
|   #users and customers components are required for the transactions form | ||||
|   component :users_and_customers_accordian | ||||
| 
 | ||||
|   def configure(c) | ||||
|     super | ||||
|     c.header = false | ||||
|     c.title = "Transactions" | ||||
|     c.items = [ | ||||
|      { netzke_component: :transactions, region: :west, width: 300, split: true }, | ||||
|      { netzke_component: :users, region: :center, width: 300, split: true }, | ||||
|      { netzke_component: :customers, region: :east, width: 300, split: true } | ||||
|      { netzke_component: :transactions, region: :center, height: 300, split: true }, | ||||
|      { netzke_component: :users_and_customers_accordian, region: :south, height: 300, split: true } | ||||
|     ] | ||||
|   end | ||||
| 
 | ||||
|  | ||||
| @ -1,19 +0,0 @@ | ||||
| { | ||||
|   initComponent: function(){ | ||||
|     // calling superclass's initComponent
 | ||||
|     this.callParent(); | ||||
| 
 | ||||
|     // setting the 'rowclick' event
 | ||||
|     var user_view = this.getComponent('users').getView(); | ||||
|     var customer_view = this.getComponent('customers').getView(); | ||||
|     user_view.on('itemclick', function(view, record){ | ||||
|       // The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
 | ||||
|       console.log("user: " + record.get('id') ); | ||||
|       this.selectCustomer({customer_id: record.get('id'), customer_type: 'User'}); | ||||
|     }, this); | ||||
|     customer_view.on('itemclick', function(view, record){ | ||||
|       console.log("user: " + record.get('id') ); | ||||
|       this.selectCustomer({customer_id: record.get('id'), customer_type: 'Customer'}); | ||||
|     }, this); | ||||
|   } | ||||
| } | ||||
| @ -1,6 +1,7 @@ | ||||
| class Users < Netzke::Basepack::Grid | ||||
|   def configure(c) | ||||
|     super | ||||
|     c.header = false | ||||
|     c.model = "User" | ||||
| 
 | ||||
|     c.columns = [ | ||||
| @ -15,6 +16,17 @@ class Users < Netzke::Basepack::Grid | ||||
| 
 | ||||
|   #override with nil to remove actions | ||||
|   def default_bbar | ||||
|     [ :apply, :add_in_form ] | ||||
|     [ :apply, :add_in_form, :search ] | ||||
|   end | ||||
| 
 | ||||
|   #needed for transactions customer selection | ||||
|   js_configure do |c| | ||||
|     c.mixin :init_component | ||||
|   end | ||||
| 
 | ||||
|   #needed for transactions customer selection | ||||
|   endpoint :select_customer do |params, this| | ||||
|     session[:selected_customer_id] = params[:customer_id] | ||||
|     session[:selected_customer_type] = params[:customer_type] | ||||
|   end | ||||
| end | ||||
|  | ||||
							
								
								
									
										11
									
								
								app/components/users/javascripts/init_component.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								app/components/users/javascripts/init_component.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| { | ||||
|   initComponent: function(){ | ||||
|     // calling superclass's initComponent
 | ||||
|     this.callParent(); | ||||
|     this.getView().on('itemclick', function(view, record){ | ||||
|       // The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
 | ||||
|       console.log("user: " + record.get('id') ); | ||||
|       this.selectCustomer({customer_id: record.get('id'), customer_type: 'User'}); | ||||
|     }, this); | ||||
|   } | ||||
| } | ||||
							
								
								
									
										10
									
								
								app/components/users_and_customers_accordian.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								app/components/users_and_customers_accordian.rb
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| class UsersAndCustomersAccordian < Netzke::Basepack::Accordion | ||||
|   component :customers | ||||
|   component :users | ||||
| 
 | ||||
|   def configure(c) | ||||
|     c.prevent_header = true | ||||
|     c.items = [ :customers, :users ] | ||||
|     super | ||||
|   end | ||||
| end | ||||
| @ -9,7 +9,7 @@ class UsersAndProfilesBorder < Netzke::Base | ||||
|     super | ||||
|     c.header = false | ||||
|     c.items = [ | ||||
|      { netzke_component: :users, region: :center, width: 300, split: true }, | ||||
|      { netzke_component: :users, header: "Users", region: :center, width: 300, split: true }, | ||||
|      { netzke_component: :user_profiles, region: :south, height: 150, split: true}, | ||||
|      { netzke_component: :user_logs, region: :east, split: true} | ||||
|     ] | ||||
|  | ||||
| @ -14,6 +14,8 @@ class Customer < ActiveRecord::Base | ||||
|   #validates :phone, :presence => true | ||||
|   #validates :email, :presence => true | ||||
| 
 | ||||
|   self.per_page = 15 | ||||
| 
 | ||||
|   def to_s | ||||
|     "#{first_name} #{last_name}" | ||||
|   end | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user