Refactor products view(s) per new master pattern.
Finally!
This commit is contained in:
		
							parent
							
								
									254c68034a
								
							
						
					
					
						commit
						583548cad5
					
				
					 12 changed files with 421 additions and 394 deletions
				
			
		|  | @ -20,7 +20,7 @@ | |||
| 
 | ||||
|   <div class="buttons"> | ||||
|     ${h.submit('create', "Create Batch")} | ||||
|     <button type="button" onclick="location.href = '${url('products')}';">Cancel</button> | ||||
|     ${h.link_to("Cancel", url('products'), class_='button')} | ||||
|   </div> | ||||
| 
 | ||||
|   ${h.end_form()} | ||||
|  |  | |||
|  | @ -1,16 +0,0 @@ | |||
| ## -*- coding: utf-8 -*- | ||||
| <%inherit file="/crud.mako" /> | ||||
| 
 | ||||
| <%def name="context_menu_items()"> | ||||
|   <li>${h.link_to("Back to Products", url('products'))}</li> | ||||
|   % if form.readonly and request.has_perm('products.update'): | ||||
|       <li>${h.link_to("Edit this Product", url('product.update', uuid=form.fieldset.model.uuid))}</li> | ||||
|   % elif form.updating: | ||||
|       <li>${h.link_to("View this Product", url('product.read', uuid=form.fieldset.model.uuid))}</li> | ||||
|   % endif | ||||
|   % if version_count is not Undefined and request.has_perm('product.versions.view'): | ||||
|       <li>${h.link_to("View Change History ({0})".format(version_count), url('product.versions', uuid=form.fieldset.model.uuid))}</li> | ||||
|   % endif | ||||
| </%def> | ||||
| 
 | ||||
| ${parent.body()} | ||||
							
								
								
									
										11
									
								
								tailbone/templates/products/edit.mako
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								tailbone/templates/products/edit.mako
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,11 @@ | |||
| ## -*- coding: utf-8 -*- | ||||
| <%inherit file="/master/edit.mako" /> | ||||
| 
 | ||||
| <%def name="context_menu_items()"> | ||||
|   ${parent.context_menu_items()} | ||||
|   % if version_count is not Undefined and request.has_perm('product.versions.view'): | ||||
|       <li>${h.link_to("View Change History ({})".format(version_count), url('product.versions', uuid=instance.uuid))}</li> | ||||
|   % endif | ||||
| </%def> | ||||
| 
 | ||||
| ${parent.body()} | ||||
|  | @ -1,7 +1,5 @@ | |||
| ## -*- coding: utf-8 -*- | ||||
| <%inherit file="/grid.mako" /> | ||||
| 
 | ||||
| <%def name="title()">Products</%def> | ||||
| <%inherit file="/master/index.mako" /> | ||||
| 
 | ||||
| <%def name="head_tags()"> | ||||
|   ${parent.head_tags()} | ||||
|  | @ -35,49 +33,48 @@ | |||
|      | ||||
|   </style> | ||||
|   % if label_profiles and request.has_perm('products.print_labels'): | ||||
|       <script language="javascript" type="text/javascript"> | ||||
|       <script type="text/javascript"> | ||||
| 
 | ||||
|         $(function() { | ||||
|             $('div.grid a.print-label').live('click', function() { | ||||
|                 var quantity = $('#label-quantity').val(); | ||||
|                 if (isNaN(quantity)) { | ||||
|                     alert("You must provide a valid label quantity."); | ||||
|                     $('#label-quantity').select(); | ||||
|                     $('#label-quantity').focus(); | ||||
|                 } else { | ||||
|                     $.ajax({ | ||||
|                         url: '${url('products.print_labels')}', | ||||
|                         data: { | ||||
|                             'product': get_uuid(this), | ||||
|                             'profile': $('#label-profile').val(), | ||||
|                             'quantity': quantity, | ||||
|                         }, | ||||
|                         success: function(data) { | ||||
|                             if (data.error) { | ||||
|                                 alert("An error occurred while attempting to print:\n\n" + data.error); | ||||
|                             } else if (quantity == '1') { | ||||
|                                 alert("1 label has been printed."); | ||||
|                             } else { | ||||
|                                 alert(quantity + " labels have been printed."); | ||||
|                             } | ||||
|                         }, | ||||
|                     }); | ||||
|                 } | ||||
|                 return false; | ||||
|             }); | ||||
|         }); | ||||
|       $(function() { | ||||
|           $('.newgrid-wrapper').on('click', 'a.print_label', function() { | ||||
|               var quantity = $('table.label-printing #label-quantity'); | ||||
|               if (isNaN(quantity.val())) { | ||||
|                   alert("You must provide a valid label quantity."); | ||||
|                   quantity.select(); | ||||
|                   quantity.focus(); | ||||
|               } else { | ||||
|                   quantity = quantity.val(); | ||||
|                   var data = { | ||||
|                       product: get_uuid(this), | ||||
|                       profile: $('#label-profile').val(), | ||||
|                       quantity: quantity | ||||
|                   }; | ||||
|                   console.log(data); | ||||
|                   $.get('${url('products.print_labels')}', data, function(data) { | ||||
|                       if (data.error) { | ||||
|                           alert("An error occurred while attempting to print:\n\n" + data.error); | ||||
|                       } else if (quantity == '1') { | ||||
|                           alert("1 label has been printed."); | ||||
|                       } else { | ||||
|                           alert(quantity + " labels have been printed."); | ||||
|                       } | ||||
|                   }); | ||||
|               } | ||||
|               return false; | ||||
|           }); | ||||
|       }); | ||||
| 
 | ||||
|       </script> | ||||
|   % endif | ||||
| </%def> | ||||
| 
 | ||||
| <%def name="tools()"> | ||||
| <%def name="grid_tools()"> | ||||
|   % if label_profiles and request.has_perm('products.print_labels'): | ||||
|       <table> | ||||
|       <table class="label-printing"> | ||||
|         <thead> | ||||
|           <tr> | ||||
|             <td>Label</td> | ||||
|             <td>Qty.</td> | ||||
|             <th>Label</th> | ||||
|             <th>Qty.</th> | ||||
|           </tr> | ||||
|         </thead> | ||||
|         <tbody> | ||||
|  | @ -97,9 +94,7 @@ | |||
| </%def> | ||||
| 
 | ||||
| <%def name="context_menu_items()"> | ||||
|   % if request.has_perm('products.create'): | ||||
|       <li>${h.link_to("Create a new Product", url('product.create'))}</li> | ||||
|   % endif | ||||
|   ${parent.context_menu_items()} | ||||
|   % if request.has_perm('batches.create'): | ||||
|       <li>${h.link_to("Create Batch from Results", url('products.create_batch'))}</li> | ||||
|   % endif | ||||
|  |  | |||
|  | @ -1,7 +1,9 @@ | |||
| ## -*- coding: utf-8 -*- | ||||
| <%inherit file="/products/crud.mako" /> | ||||
| <%inherit file="/master/view.mako" /> | ||||
| <%namespace file="/forms/lib.mako" import="render_field_readonly" /> | ||||
| 
 | ||||
| <% product = instance %> | ||||
| 
 | ||||
| <%def name="head_tags()"> | ||||
|   ${parent.head_tags()} | ||||
|   <style type="text/css"> | ||||
|  | @ -20,7 +22,12 @@ | |||
|   </style> | ||||
| </%def> | ||||
| 
 | ||||
| <% product = form.fieldset.model %> | ||||
| <%def name="context_menu_items()"> | ||||
|   ${parent.context_menu_items()} | ||||
|   % if version_count is not Undefined and request.has_perm('product.versions.view'): | ||||
|       <li>${h.link_to("View Change History ({})".format(version_count), url('product.versions', uuid=product.uuid))}</li> | ||||
|   % endif | ||||
| </%def> | ||||
| 
 | ||||
| <%def name="render_organization_fields(form)"> | ||||
|     ${render_field_readonly(form.fieldset.department)} | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar