=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm 2015-10-12 17:55:30 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm 2015-12-10 11:07:47 +0000 @@ -15,6 +15,7 @@ + #foreach ( $style in $stylesheets ) #end @@ -62,6 +63,7 @@ + #if( $keyCalendar == "coptic" || $keyCalendar == "ethiopian" || $keyCalendar == "islamic" || $keyCalendar == "julian" || $keyCalendar == "nepali" || $keyCalendar == "thai" ) #end === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2015-12-08 13:14:21 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2015-12-10 11:07:47 +0000 @@ -563,14 +563,7 @@ var split = dhis2.de.splitFieldId( id ); var dataElementId = split.dataElementId; - var optionComboId = split.optionComboId; - - /*$( this ).unbind( 'focus' ); - $( this ).unbind( 'change' ); - - $( this ).focus( valueFocus ); - - $( this ).blur( valueBlur );*/ + var optionComboId = split.optionComboId; $( this ).change( function() { @@ -605,13 +598,7 @@ var dataElementId = split.dataElementId; var optionComboId = split.optionComboId; - - $( this ).unbind( 'focus' ); - $( this ).unbind( 'change' ); - - $( this ).focus( valueFocus ); - $( this ).blur( valueBlur ); - + $( this ).change( function() { saveVal( dataElementId, optionComboId, id ); @@ -1555,13 +1542,11 @@ $( '.entryfield' ).val( '' ); $( '.entryselect' ).removeAttr( 'checked' ); $( '.entrytrueonly' ).removeAttr( 'checked' ); - $( '.entryoptionset' ).val( '' ); $( '.entryfield' ).css( 'background-color', dhis2.de.cst.colorWhite ).css( 'border', '1px solid ' + dhis2.de.cst.colorBorder ); $( '.entryselect' ).css( 'background-color', dhis2.de.cst.colorWhite ).css( 'border', '1px solid ' + dhis2.de.cst.colorBorder ); $( '.indicator' ).css( 'background-color', dhis2.de.cst.colorWhite ).css( 'border', '1px solid ' + dhis2.de.cst.colorBorder ); $( '.entrytrueonly' ).css( 'background-color', dhis2.de.cst.colorWhite ); - $( '.entryoptionset' ).css( 'background-color', dhis2.de.cst.colorWhite ); clearFileEntryFields(); @@ -1646,14 +1631,12 @@ if ( json.locked ) { $( '#contentDiv input').attr( 'readonly', 'readonly' ); - $( '.entryoptionset').autocomplete( 'disable' ); $( '.sectionFilter').removeAttr( 'disabled' ); $( '#completenessDiv' ).hide(); setHeaderDelayMessage( i18n_dataset_is_locked ); } else { - $( '.entryoptionset' ).autocomplete( 'enable' ); $( '#contentDiv input' ).removeAttr( 'readonly' ); $( '#completenessDiv' ).show(); } @@ -2913,7 +2896,9 @@ if ( obj && obj.optionSet && obj.optionSet.options ) { $.each( obj.optionSet.options, function( inx, option ) { if ( option && option.code == value.val ) { - $( fieldId ).val( option.name ); + option.id = option.code; + option.text = option.name; + $( fieldId ).select2("val", option.text ); return false; } } ); @@ -3050,18 +3035,40 @@ { $( '.entryoptionset').each( function( idx, item ) { var optionSetKey = dhis2.de.splitFieldId( item.id ); - + var s2prefix = 's2id_'; + optionSetKey.dataElementId = optionSetKey.dataElementId.indexOf(s2prefix) != -1 ? optionSetKey.dataElementId.substring(s2prefix.length, optionSetKey.dataElementId.length) : optionSetKey.dataElementId; + if ( dhis2.de.multiOrganisationUnit ) { item = optionSetKey.organisationUnitId + '-' + optionSetKey.dataElementId + '-' + optionSetKey.optionComboId; } else { item = optionSetKey.dataElementId + '-' + optionSetKey.optionComboId; } - + item = item + '-val'; optionSetKey = optionSetKey.dataElementId + '-' + optionSetKey.optionComboId; var optionSetUid = dhis2.de.optionSets[optionSetKey].uid; - dhis2.de.autocompleteOptionSetField( item, optionSetUid ); + //dhis2.de.autocompleteOptionSetField( item, optionSetUid ); + + DAO.store.get( 'optionSets', optionSetUid ).done( function( obj ) { + if ( obj && obj.optionSet && obj.optionSet.options ) { + + $.each( obj.optionSet.options, function( inx, option ) { + option.text = option.name; + option.id = option.code; + } ); + + $("#" + item).select2({ + placeholder: i18n_select_option , + allowClear: true, + dataType: 'json', + data: obj.optionSet.options + }).on("select2:unselecting", function (e) { + $(this).select2("val", ""); + e.preventDefault(); + }); + } + } ); } ); }; === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css 2015-10-19 23:11:55 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/style/dhis-web-dataentry.css 2015-12-10 11:07:47 +0000 @@ -140,6 +140,11 @@ border: 1px solid #aaa; } +.entryoptionset { + width: 85%; + max-height: 400px; +} + .entryselect { padding: 4px 1px; @@ -400,4 +405,17 @@ display: inline-block; position: absolute; top: 16px; +} + +.select2-container .select2-choice { + border-radius: 0; +} + + +.select2-container .select2-choice .select2-arrow { + border-radius: 0; +} + +.select2-chosen { + padding-top: 6px; } \ No newline at end of file