dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43510
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22052: program attribute names in custom registraton form are now surrounded wit span tag and attribute ...
------------------------------------------------------------
revno: 22052
committer: Abyot Asalefew Gizaw <abyot@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2016-02-26 11:08:36 +0100
message:
program attribute names in custom registraton form are now surrounded wit span tag and attribute d2-input-label with value attributeId.uid
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/viewProgramEntryForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/viewProgramEntryForm.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2016-01-08 16:04:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/org/hisp/dhis/trackedentity/i18n_module.properties 2016-02-26 10:08:36 +0000
@@ -309,6 +309,7 @@
select_operator_number_of_visits_for_this_condition = Please select operator number of visit for this condition
design_prorgam_entry_form = Design program entry form
intro_tracked_entity_form = Create custom tracked entity data capture forms with tracked entity attributes.
+labels = Labels
properties = Properties
full_name = Full name
birth_date = Date of birth
@@ -330,8 +331,10 @@
min_dataelement_value = Minimum of data element values
max_dataelement_value = Maximum of data element values
property_is_inserted = Property already exists in form
+label_is_assigned_to = Label is already assigned to
please_insert_all_required_fields = Please insert all required fields
required_fields_valivation = Required fields validation
+insert_labels = Insert labels
insert_properties = Insert properties
insert_images = Insert images
insert_data_elements = Insert data elements
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/viewProgramEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/viewProgramEntryForm.js 2015-06-19 07:35:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/javascript/viewProgramEntryForm.js 2016-02-26 10:08:36 +0000
@@ -10,6 +10,7 @@
$("#deleteButton").button("option", "icons", { primary: "ui-icon-trash" });
$("#insertButton").button("option", "icons", { primary: "ui-icon-plusthick" });
$("#propertiesButton").button("option", "icons", { primary: "ui-icon-newwin" });
+ $("#labelsButton").button("option", "icons", { primary: "ui-icon-newwin" });
$("#insertImagesButton").button("option", "icons", { primary: "ui-icon-newwin" });
$("#insertImageButton").button("option", "icons", { primary: "ui-icon-plusthick" });
@@ -54,6 +55,25 @@
});
}
+function openLabelsSelector()
+{
+ $("#labelsButton").addClass("ui-state-active2");
+ $('#labelsDialog' ).dialog(
+ {
+ title:i18n_labels,
+ maximize:true,
+ closable:true,
+ modal:false,
+ overlay:{background:'#000000', opacity:0.1},
+ minWidth: 595,
+ minHeight: 263,
+ position: [($("body").width() - 555) - 50, 50],
+ close: function(ev, ui) {
+ $("#labelsButton").removeClass("ui-state-active2");
+ }
+ });
+}
+
function fixAttrOnClick()
{
$("#insertButton").click(function() {
@@ -266,6 +286,26 @@
}
}
+function checkLabelAssigned( id )
+{
+ var assigned = false;
+ var assignedTo = "";
+
+ var html = jQuery("#designTextarea").ckeditor().editor.getData();
+ var labels = jQuery( html ).find("span[d2-input-label]");
+
+ labels.each(function(i, item){
+ var labelAtt = jQuery(item).attr('d2-input-label');
+ if( labelAtt != undefined && labelAtt == id){
+ assigned = true;
+ assignedTo = jQuery(item).text();
+ return false;
+ }
+ });
+
+ return {assigned: assigned, assignedTo: assignedTo};
+}
+
function checkExisted( id )
{
var result = false;
@@ -296,56 +336,75 @@
}
function insertElement( type )
-{
+{
var id = '';
var value = '';
- if( type == 'fixedAttr' ){
- var element = jQuery('#fixedAttrSelector option:selected');
+ if(type == 'lbl') {
+ var selectedText = jQuery("#designTextarea").ckeditor().editor.getSelection().getSelectedText();
+ var element = jQuery('#labelsSelector option:selected');
+
if( element.length == 0 ) return;
- id = 'fixedattributeid="' + element.attr('value') + '"';
- value = element.text();
- }
- else if( type == 'attr' ){
- var element = jQuery('#attributesSelector option:selected');
- if( element.length == 0 ) return;
-
- id = 'attributeid="' + element.attr('value') + '"';
- value = element.text();
- }
- else if( type == 'prg' ){
- var element = jQuery('#programAttrSelector option:selected');
- if( element.length == 0 ) return;
-
- id = 'programid="' + element.attr('value') + '"';
- value = element.text();
- }
-
- var htmlCode = "<input " + id + " value=\"[" + value + "]\" title=\"" + value + "\" ";
-
- suggestedValue = getFieldValue('suggestedField');
- if( jQuery('#suggestedField').is(":visible") )
- {
- htmlCode += " suggested='" + suggestedValue + "' ";
- }
-
- var isHidden = jQuery('#hiddenField').attr('checked');
- if(isHidden)
- {
- htmlCode += " class='hidden' ";
- }
- htmlCode += " >";
-
- if( checkExisted( id ) ){
- // setMessage( "<span class='bold'>" + i18n_property_is_inserted + "</span>" );
- setHeaderDelayMessage(i18n_property_is_inserted);
- return;
- }else{
- var oEditor = jQuery("#designTextarea").ckeditor().editor;
- oEditor.insertHtml( htmlCode );
- setMessage("");
- }
-
+
+ id = 'attributeId.' + element.attr('value');
+
+ var assigned = checkLabelAssigned( id );
+ if( assigned && assigned.assigned ){
+ setHeaderDelayMessage( i18n_label_is_assigned_to + ': ' + assigned.assignedTo );
+ return;
+ }
+ else{
+ var label = '<span title="' + selectedText + '" d2-input-label="' + id + '">' + selectedText + '</span>';
+ var lEditor = jQuery("#designTextarea").ckeditor().editor;
+ lEditor.insertHtml( label );
+ }
+ }
+ else{
+ if( type == 'fixedAttr' ){
+ var element = jQuery('#fixedAttrSelector option:selected');
+ if( element.length == 0 ) return;
+ id = 'fixedattributeid="' + element.attr('value') + '"';
+ value = element.text();
+ }
+ else if( type == 'attr' ){
+ var element = jQuery('#attributesSelector option:selected');
+ if( element.length == 0 ) return;
+
+ id = 'attributeid="' + element.attr('value') + '"';
+ value = element.text();
+ }
+ else if( type == 'prg' ){
+ var element = jQuery('#programAttrSelector option:selected');
+ if( element.length == 0 ) return;
+
+ id = 'programid="' + element.attr('value') + '"';
+ value = element.text();
+ }
+ var htmlCode = "<input " + id + " value=\"[" + value + "]\" title=\"" + value + "\" ";
+
+ suggestedValue = getFieldValue('suggestedField');
+ if( jQuery('#suggestedField').is(":visible") )
+ {
+ htmlCode += " suggested='" + suggestedValue + "' ";
+ }
+
+ var isHidden = jQuery('#hiddenField').attr('checked');
+ if(isHidden)
+ {
+ htmlCode += " class='hidden' ";
+ }
+ htmlCode += " >";
+
+ if( checkExisted( id ) ){
+ // setMessage( "<span class='bold'>" + i18n_property_is_inserted + "</span>" );
+ setHeaderDelayMessage(i18n_property_is_inserted);
+ return;
+ }else{
+ var oEditor = jQuery("#designTextarea").ckeditor().editor;
+ oEditor.insertHtml( htmlCode );
+ setMessage("");
+ }
+ }
}
function deleteProgramEntryForm( id, name )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/viewProgramEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/viewProgramEntryForm.vm 2015-10-20 12:07:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/viewProgramEntryForm.vm 2016-02-26 10:08:36 +0000
@@ -39,7 +39,7 @@
padding: 2px;
}
-#attributesSelector, #programSelector {
+#attributesSelector, #programSelector, #labelSelector {
padding: 2px;
}
@@ -99,6 +99,7 @@
<button type="button" id="cancelButton" onclick="window.location='program.action'">$i18n.getString( 'cancel' )</button>
<span style="color:#606060">|</span>
<button type="button" id="propertiesButton" onclick="openPropertiesSelector()"/>$i18n.getString( 'insert_properties' )</button>
+ <button type="button" id="labelsButton" onclick="openLabelsSelector()"/>$i18n.getString( 'insert_labels' )</button>
<button type="button" id="insertImagesButton">$i18n.getString( 'insert_images' )</button>
<span style="color:#606060">|</span>
<button type="button" id="deleteButton" #if($!program.dataEntryForm) #else style='display:none;' #end onclick="javascript:deleteProgramEntryForm($program.id,'$program.displayName');" />$i18n.getString( 'delete_this_form' )</button>
@@ -170,6 +171,31 @@
</div>
+<div id='labelsDialog' class='hidden'>
+
+ <table>
+ <tr>
+ <td>
+ <input type='text' id='labelFilter' placeholder="$i18n.getString('filter')" style="width:400px;" onchange="filterList( this.value, 'labelsSelector' )">
+ <input type='button' value="$i18n.getString('filter')" style="width:80px;" onclick="filterList( getFieldValue('labelFilter'), 'labelsSelector' )">
+ <input type='button' value="$i18n.getString('clear')" style="width:80px;" onclick="setFieldValue('labelFilter','');filterList( '', 'labelsSelector' )">
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <select id="labelsSelector" multiple="multiple" style="height:200px;width:100%;" ondblclick="insertElement( 'lbl' )">
+ #foreach( $programAttribute in $programAttributes )
+ <option value="$programAttribute.attribute.uid" mandatory='programAttribute.mandatory'>$encoder.htmlEncode($programAttribute.attribute.displayName)</option>
+ #end
+ </select>
+ </td>
+ </tr>
+ </table>
+
+ <span id='message' style="width: 436px;"></span>
+
+</div>
+
<div id="imageDialog" title="$i18n.getString( 'insert_images' )" class='hidden'>
<div style="margin:4px">
<div>
@@ -187,11 +213,13 @@
<script>
var i18n_delete_program_data_entry_confirm = '$encoder.jsEscape( $i18n.getString( "delete_program_data_entry_confirm" ) , "'" )';
+ var i18n_label_is_assigned_to = '$encoder.jsEscape( $i18n.getString( "label_is_assigned_to" ) , "'" )';
var i18n_property_is_inserted = '$encoder.jsEscape( $i18n.getString( "property_is_inserted" ) , "'" )';
var i18n_please_insert_all_required_fields = '$encoder.jsEscape( $i18n.getString( "please_insert_all_required_fields" ) , "'" )';
var i18n_required_fields_valivation = '$encoder.jsEscape( $i18n.getString( "required_fields_valivation" ) , "'" )';
var i18n_full_name = '$encoder.jsEscape( $i18n.getString( "full_name" ) , "'" )';
var i18n_properties = '$encoder.jsEscape( $i18n.getString( "properties" ) , "'" )';
+ var i18n_labels = '$encoder.jsEscape( $i18n.getString( "labels" ) , "'" )';
var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_prorgam_entry_form_form" ) , "'" )';
var i18n_save_unsuccess_please_insert_all_required_fields = '$encoder.jsEscape( $i18n.getString( "save_unsuccess" ) , "'" )' + '. ' + '$encoder.jsEscape( $i18n.getString( "please_insert_all_required_fields" ) , "'" )';
var i18n_validate_success = '$encoder.jsEscape( $i18n.getString( "validate_success" ) , "'" )';