Skip to content

Commit

Permalink
Fix JS form issues with ThingyRecord. bug #10943
Browse files Browse the repository at this point in the history
  • Loading branch information
perlDreamer committed Sep 9, 2009
1 parent d7ca3df commit 08dc40c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions docs/changelog/7.x.x.txt
Expand Up @@ -26,6 +26,7 @@
- fixed #10928: EMS Print Ticket -- Time not processed for timezone
- fixed #10889: Old Matrixs break for Admin users
- fixed #10939: Commit with Approval workflow does not show confirmation screen
- fixed #10943: ThingyRecord JS Broken

7.7.19
- fixed #10838: Forwarded forum post email to new CS adds reply to original thread
Expand Down
2 changes: 1 addition & 1 deletion lib/WebGUI/Asset/Sku/ThingyRecord.pm
Expand Up @@ -206,7 +206,7 @@ sub drawEditFieldPrice {
my ( $self ) = @_;

my $fieldHtml = sprintf <<'ENDHTML', encode_entities( $self->get('fieldPrice') );
<div id="fieldPrice"></div><input type="hidden" name="fieldPrice" value="%s" />
<div id="fieldPrice"></div><input type="hidden" name="fieldPrice" value="%s" id="fieldPrice_formId"/>
ENDHTML

return $fieldHtml;
Expand Down
27 changes: 15 additions & 12 deletions www/extras/yui-webgui/build/thingyRecord/thingyRecord.js
Expand Up @@ -15,7 +15,7 @@ WebGUI.ThingyRecord.getThingFields
var callback = {
success : function (o) {
// Add fields to select list
var el = document.forms[0].elements['thingFields'];
var el = document.getElementById('thingFields_formId');
while ( el.options.length >= 1 )
el.remove(0);
var fields = YAHOO.lang.JSON.parse( o.responseText );
Expand All @@ -38,16 +38,17 @@ WebGUI.ThingyRecord.getThingFields
WebGUI.ThingyRecord.updateFieldPrices
= function ( ) {
var form = document.forms[0];
var fieldList = form.elements["thingFields"];
var fieldList = document.getElementById( 'thingFields_formId' );
var selected = [];
var div = document.getElementById( 'fieldPrice' );
var fieldPrice = document.getElementById( 'fieldPrice_formId' );
var currentPrices = {};
try {
currentPrices = YAHOO.lang.JSON.parse( form.elements["fieldPrice"].value );
currentPrices = YAHOO.lang.JSON.parse( fieldPrice.value );
}
catch (e) {
// Initialize if there's a parse error
form.elements["fieldPrice"].value = "{}";
fieldPrice.value = "{}";
}

// Get the selected fields
Expand All @@ -60,7 +61,7 @@ WebGUI.ThingyRecord.updateFieldPrices
currentPrices[ opt.value ] = 0;
}
}
form.elements['fieldPrice'].value = YAHOO.lang.JSON.stringify( currentPrices );
fieldPrice.value = YAHOO.lang.JSON.stringify( currentPrices );

// Clear out old records
while ( div.childNodes.length )
Expand All @@ -78,9 +79,9 @@ WebGUI.ThingyRecord.updateFieldPrices
price.value = currentPrices[ opt.value ] ? currentPrices[ opt.value ] : "0.00";
YAHOO.util.Event.addListener( price, "change", function () {
var fieldName = this.name.substr( "fieldPrice_".length );
var json = YAHOO.lang.JSON.parse( form.elements["fieldPrice"].value );
var json = YAHOO.lang.JSON.parse( fieldPrice.value );
json[fieldName] = this.value;
form.elements["fieldPrice"].value = YAHOO.lang.JSON.stringify( json );
fieldPrice.value = YAHOO.lang.JSON.stringify( json );
} );

label.appendChild( price );
Expand All @@ -93,19 +94,21 @@ WebGUI.ThingyRecord.updateFieldPrices

// Load the columns and field prices
YAHOO.util.Event.onDOMReady( function () {
var form = document.forms[0];
var form = document.forms[0];
var thingId = document.getElementById("thingId_formId");
var thingFields = document.getElementById("thingFields_formId")

// Add events to form fields
YAHOO.util.Event.addListener( form.elements["thingId"], "change", function () {
YAHOO.util.Event.addListener( thingId, "change", function () {
WebGUI.ThingyRecord.getThingFields( this.value );
} );

YAHOO.util.Event.addListener( form.elements['thingFields'], "change", function () {
YAHOO.util.Event.addListener( thingFields, "change", function () {
WebGUI.ThingyRecord.updateFieldPrices();
} );

// Populate the fields list if necessary
if ( form.elements[ "thingId" ].value ) {
WebGUI.ThingyRecord.getThingFields( form.elements[ "thingId"].value );
if ( thingId.value ) {
WebGUI.ThingyRecord.getThingFields( thingId.value );
}
} );

0 comments on commit 08dc40c

Please sign in to comment.