1
// -----------------------------------------------------------------------------
3
// -----------------------------------------------------------------------------
5
function showProgramAttributeDetails( programAttributeId )
8
url: 'getProgramAttribute.action?id=' + programAttributeId,
11
success: programAttributeReceived
15
function programAttributeReceived( programAttributeElement )
17
setInnerHTML( 'idField', $( programAttributeElement).find('id' ).text() );
18
setInnerHTML( 'nameField', $( programAttributeElement).find('name').text() );
19
setInnerHTML( 'descriptionField', $( programAttributeElement).find('description').text() );
21
var valueTypeMap = { 'NUMBER':i18n_number, 'BOOL':i18n_yes_no, 'TEXT':i18n_text, 'DATE':i18n_date, 'COMBO':i18n_combo };
22
var valueType = $( programAttributeElement).find('valueType' ).text();
24
setInnerHTML( 'valueTypeField', valueTypeMap[valueType] );
29
// -----------------------------------------------------------------------------
30
// Remove Program Attribute
31
// -----------------------------------------------------------------------------
33
function removeProgramAttribute( programAttributeId, name )
35
removeItem( programAttributeId, name, i18n_confirm_delete, 'removeProgramAttribute.action' );
40
selectValueType : function (this_)
42
if ( jQuery(this_).val() == "COMBO" )
44
jQuery("#attributeComboRow").show();
45
if( jQuery("#attrOptionContainer").find("input").length ==0 )
47
ATTRIBUTE_OPTION.addOption();
48
ATTRIBUTE_OPTION.addOption();
51
jQuery("#attributeComboRow").hide();
54
checkOnSubmit : function ()
56
if( jQuery("#valueType").val() != "COMBO" )
58
jQuery("#attrOptionContainer").children().remove();
61
$("input","#attrOptionContainer").each(function(){
62
if( !jQuery(this).val() )
63
jQuery(this).remove();
65
if( $("input","#attrOptionContainer").length < 2)
67
alert(i18n_at_least_2_option);
72
addOption : function ()
74
jQuery("#attrOptionContainer").append(ATTRIBUTE_OPTION.createInput());
76
remove : function (this_, optionId)
78
if( jQuery(this_).siblings("input").attr("name") != "attrOptions")
80
jQuery.getJSON("removeProgramAttributeOption.action",
85
var type = json.response;
87
if( type == "success")
89
jQuery(this_).parent().parent().remove();
90
showSuccessMessage(json.message);
93
showWarningMessage(json.message);
98
jQuery(this_).parent().parent().remove();
101
removeInAddForm : function(this_)
103
jQuery(this_).parent().parent().remove();
105
createInput : function ()
107
return "<tr><td><input type='text' name='attrOptions' style='width:28em'/><a href='#' style='text-decoration: none; margin-left:0.5em;' title='"+i18n_remove_option+"' onClick='ATTRIBUTE_OPTION.remove(this,null)'>[ - ]</a></td></tr>";
b'\\ No newline at end of file'