Open funnylookinhat opened 10 years ago
This should - at the very least - manage to separate large chunks of the Javascript apart based on specific function, and create a broad basis for easily inheriting common functionality. I'd like to ideally see a replacement of code like this:
$('#customers-sales-create input[name="customer"]').select2('data',{});
$('#customers-sales-create input[name="customer"]').select2('enable');
$('#customers-sales-create select[name="account"]').select2('data',{});
$('#customers-sales-create select[name="account"]').attr('disabled',false).attr('readonly',false).select2('enable');
if( $('#customers-sales-create select[name="account"]').attr('rel') &&
$('#customers-sales-create select[name="account"]').attr('rel').length ) {
$('#customers-sales-create select[name="account"]').select2('data',{
id: $('#customers-sales-create select[name="account"]').attr('rel'),
text: $('#customers-sales-create select[name="account"] option[value="'+$('#customers-sales-create select[name="account"]').attr('rel')+'"]').text()
});
}
$('#customers-sales-create .select').removeClass('disabled');
$('#customers-sales-create .customer-sales-create-new-buttons').show();
$('#customers-sales-create .customer-sales-create-edit-buttons').hide();
$('#customers-sales-create-form-refund').attr('disabled','disabled');
$('#customers-sales-create-form-convertinvoice').attr('readonly',false);
$('#customers-sales-create-form-edit').attr('readonly',false);
$('#customers-sales-create-form-delete').attr('readonly',false);
$('#customers-sales-create-form-subtotal').text(monetaryPrint(0.00)).attr('rel','');
$('#customers-sales-create-form-taxes').text(monetaryPrint(0.00)).attr('rel','');
$('#customers-sales-create-form-total').text(monetaryPrint(0.00)).attr('rel','');
$('#customers-sales-create-form-balance').text(monetaryPrint(0.00)).attr('rel','');
Something along the lines of this would be ideal:
$('customer-sale-create-form').trigger('clear');
The Javascript powering the front-end of BeansBooks needs to be cleaned up and normalized. While the work for this won't take place until the v2.0 development roadmap, we need to begin outlaying the design patterns for that shift now.
If you have any interest in well-structured and clearly-defined UI/UX Javascript, feel free to start a discussion on this post and begin creating the design pattern to be used.