=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2014-03-26 17:39:16 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/AddAttributeAction.java 2014-04-03 08:06:06 +0000 @@ -175,7 +175,7 @@ inherit = (inherit == null) ? false : true; attribute.setInherit( inherit ); - if ( valueType.equals( TrackedEntityAttribute.VALUE_TYPE_LOCAL_ID ) ) + if ( unique ) { orgunitScope = (orgunitScope == null) ? false : orgunitScope; programScope = (programScope == null) ? false : programScope; === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java 2014-03-26 17:39:16 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentityattribute/UpdateAttributeAction.java 2014-04-03 08:06:06 +0000 @@ -184,7 +184,7 @@ inherit = (inherit == null) ? false : true; attribute.setInherit( inherit ); - if ( valueType.equals( TrackedEntityAttribute.VALUE_TYPE_LOCAL_ID ) ) + if ( unique ) { orgunitScope = (orgunitScope == null) ? false : orgunitScope; programScope = (programScope == null) ? false : programScope; === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2014-04-03 07:30:22 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/addAttributeForm.vm 2014-04-03 08:06:06 +0000 @@ -80,39 +80,22 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js 2014-03-26 17:39:16 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/addAttributeForm.js 2014-04-03 08:06:06 +0000 @@ -1,9 +1,13 @@ -jQuery(document).ready( function(){ +$(document).ready( function(){ validation( 'addAttributeForm', function(form){ form.submit(); - }) + }); checkValueIsExist( "name", "validateAttribute.action"); checkValueIsExist( "shortName", "validateAttribute.action"); checkValueIsExist( "code", "validateAttribute.action"); -}); \ No newline at end of file + + $('#unique').on('click', function() { + $("[name='localIdField']").toggle(); + }); +}); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js 2014-03-20 05:43:18 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/attribute.js 2014-04-03 08:06:06 +0000 @@ -1,4 +1,3 @@ - $(function() { dhis2.contextmenu.makeContextMenu({ menuId: 'contextMenu', @@ -15,63 +14,59 @@ } function showAttributeDetails( context ) { - jQuery.getJSON( 'getAttribute.action', { id: context.id }, - function ( json ) { - setInnerHTML( 'nameField', json.attribute.name ); - setInnerHTML( 'descriptionField', json.attribute.description ); - setInnerHTML( 'optionSetField', json.attribute.optionSet ); - - var unique = ( json.attribute.unique == 'true') ? i18n_yes : i18n_no; - setInnerHTML( 'uniqueField', unique ); - - var inherit = ( json.attribute.inherit == 'true') ? i18n_yes : i18n_no; - setInnerHTML( 'inheritField', inherit ); - - var valueType = json.attribute.valueType; - var typeMap = attributeTypeMap(); - setInnerHTML( 'valueTypeField', typeMap[valueType] ); - - showDetails(); - }); + jQuery.getJSON('getAttribute.action', { id: context.id }, + function( json ) { + setInnerHTML('nameField', json.attribute.name); + setInnerHTML('descriptionField', json.attribute.description); + setInnerHTML('optionSetField', json.attribute.optionSet); + + var unique = ( json.attribute.unique == 'true') ? i18n_yes : i18n_no; + setInnerHTML('uniqueField', unique); + + var inherit = ( json.attribute.inherit == 'true') ? i18n_yes : i18n_no; + setInnerHTML('inheritField', inherit); + + var valueType = json.attribute.valueType; + var typeMap = attributeTypeMap(); + setInnerHTML('valueTypeField', typeMap[valueType]); + + showDetails(); + }); } -function attributeTypeMap() -{ - var typeMap = []; - typeMap['number'] = i18n_number; - typeMap['string'] = i18n_text; - typeMap['bool'] = i18n_yes_no; - typeMap['trueOnly'] = i18n_yes_only; - typeMap['date'] = i18n_date; - typeMap['phoneNumber'] = i18n_phone_number; - typeMap['trackerAssociate'] = i18n_tracker_associate; - typeMap['combo'] = i18n_attribute_combo_type; - return typeMap; +function attributeTypeMap() { + var typeMap = []; + typeMap['number'] = i18n_number; + typeMap['string'] = i18n_text; + typeMap['bool'] = i18n_yes_no; + typeMap['trueOnly'] = i18n_yes_only; + typeMap['date'] = i18n_date; + typeMap['phoneNumber'] = i18n_phone_number; + typeMap['trackerAssociate'] = i18n_tracker_associate; + typeMap['combo'] = i18n_attribute_combo_type; + return typeMap; } // ----------------------------------------------------------------------------- // Remove Attribute // ----------------------------------------------------------------------------- -function removeAttribute( context ) -{ - removeItem( context.id, context.name, i18n_confirm_delete, 'removeAttribute.action' ); +function removeAttribute( context ) { + removeItem(context.id, context.name, i18n_confirm_delete, 'removeAttribute.action'); } - function typeOnChange() { - var type = getFieldValue('valueType'); - if( type=="combo"){ - showById("optionSetRow"); - jQuery('[name=localIdField]').hide(); - } - else if( type == 'localId' ) { - jQuery('[name=localIdField]').show(); - hideById("optionSetRow"); - } - else { - jQuery('[name=localIdField]').hide(); - hideById("optionSetRow"); - } + var type = getFieldValue('valueType'); + if( type == "combo" ) { + showById("optionSetRow"); + jQuery('[name=localIdField]').hide(); + } + else if( type == 'localId' ) { + jQuery('[name=localIdField]').show(); + hideById("optionSetRow"); + } + else { + jQuery('[name=localIdField]').hide(); + hideById("optionSetRow"); + } } - === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js 2014-03-26 17:39:16 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/updateAttributeForm.js 2014-04-03 08:06:06 +0000 @@ -1,9 +1,17 @@ -jQuery(document).ready( function(){ - validation( 'updateAttributeForm', function(form){ - form.submit(); - }); - - checkValueIsExist( "name", "validateAttribute.action", {id:getFieldValue('id')}); - checkValueIsExist( "shortName", "validateAttribute.action", {id:getFieldValue('id')}); - checkValueIsExist( "code", "validateAttribute.action", {id:getFieldValue('id')}); -}); \ No newline at end of file +jQuery(document).ready(function() { + validation('updateAttributeForm', function( form ) { + form.submit(); + }); + + checkValueIsExist("name", "validateAttribute.action", {id: getFieldValue('id')}); + checkValueIsExist("shortName", "validateAttribute.action", {id: getFieldValue('id')}); + checkValueIsExist("code", "validateAttribute.action", {id: getFieldValue('id')}); + + if( $('#unique').is(':checked') ) { + $("[name='localIdField']").show(); + } + + $('#unique').on('click', function() { + $("[name='localIdField']").toggle(); + }); +}); === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm 2014-04-03 07:30:22 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/updateAttibuteForm.vm 2014-04-03 08:06:06 +0000 @@ -77,6 +77,9 @@ +programScope: $attribute.programScope +orgunitScope: $attribute.orgunitScope + @@ -88,7 +91,7 @@ - + @@ -96,20 +99,7 @@ - - - - - - - - - +