← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13157: context-menus in maint-patient module, wip

 

------------------------------------------------------------
revno: 13157
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-12-05 13:21:59 +0100
message:
  context-menus in maint-patient module, wip
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientIdentifierType.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/relationship.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientIdentifierType.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/relationshipType.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-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientIdentifierType.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientIdentifierType.js	2013-09-17 06:08:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientIdentifierType.js	2013-12-05 12:21:59 +0000
@@ -1,48 +1,54 @@
+$(function() {
+  dhis2.contextmenu.makeContextMenu({
+    menuId: 'contextMenu',
+    menuItemActiveClass: 'contextMenuItemActive'
+  });
+});
+
 // -----------------------------------------------------------------------------
 // View details
 // -----------------------------------------------------------------------------
 
-function showPatientIdentifierTypeDetails( patientIdentifierTypeId )
-{
-	jQuery.getJSON( 'getPatientIdentifierType.action', { id: patientIdentifierTypeId },
-		function ( json ) {
-			setInnerHTML( 'nameField', json.patientIdentifierType.name );	
-			setInnerHTML( 'descriptionField', json.patientIdentifierType.description );
-			
-			var boolValueMap = { 'true':i18n_yes, 'false':i18n_no };
-			var boolType = json.patientIdentifierType.mandatory;
-			setInnerHTML( 'mandatoryField', boolValueMap[boolType] );
-			
-			boolType = json.patientIdentifierType.related;
-			setInnerHTML( 'relatedField', boolValueMap[boolType] );
-			setInnerHTML( 'noCharsField', json.patientIdentifierType.noChars );
-			
-			var valueTypeMap = { 'string':i18n_string, 'number':i18n_number, 'letter':i18n_letter_only, 'orgunitCount': i18n_orgunit_count };
-			var valueType = json.patientIdentifierType.type;
-			setInnerHTML( 'typeField', valueTypeMap[valueType] );
-			
-			showDetails();
-	});
+function showUpdatePatientIdentifierTypeForm( context ) {
+  location.href = 'showUpdatePatientIdentifierTypeForm.action?id=' + context.id;
+}
+
+function showPatientIdentifierTypeDetails( context ) {
+  jQuery.getJSON('getPatientIdentifierType.action', { id: context.id },
+    function( json ) {
+      setInnerHTML('nameField', json.patientIdentifierType.name);
+      setInnerHTML('descriptionField', json.patientIdentifierType.description);
+
+      var boolValueMap = { 'true': i18n_yes, 'false': i18n_no };
+      var boolType = json.patientIdentifierType.mandatory;
+      setInnerHTML('mandatoryField', boolValueMap[boolType]);
+
+      boolType = json.patientIdentifierType.related;
+      setInnerHTML('relatedField', boolValueMap[boolType]);
+      setInnerHTML('noCharsField', json.patientIdentifierType.noChars);
+
+      var valueTypeMap = { 'string': i18n_string, 'number': i18n_number, 'letter': i18n_letter_only, 'orgunitCount': i18n_orgunit_count };
+      var valueType = json.patientIdentifierType.type;
+      setInnerHTML('typeField', valueTypeMap[valueType]);
+
+      showDetails();
+    });
 }
 
 // -----------------------------------------------------------------------------
 // Remove Patient Identifier Type
 // -----------------------------------------------------------------------------
 
-function removePatientIdentifierType( patientIdentifierTypeId, name )
-{
-    removeItem( patientIdentifierTypeId, name, i18n_confirm_delete, 'removePatientIdentifierType.action' );
+function removePatientIdentifierType( context ) {
+  removeItem(context.id, context.name, i18n_confirm_delete, 'removePatientIdentifierType.action');
 }
 
-function typeOnChange()
-{
-	var type = getFieldValue('type');
-	if(type=='localId')
-	{
-		jQuery('[name=localIdField]').show();
-	}
-	else
-	{
-		jQuery('[name=localIdField]').hide();
-	}
-}
\ No newline at end of file
+function typeOnChange() {
+  var type = getFieldValue('type');
+  if( type == 'localId' ) {
+    jQuery('[name=localIdField]').show();
+  }
+  else {
+    jQuery('[name=localIdField]').hide();
+  }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/relationship.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/relationship.js	2012-03-13 09:47:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/relationship.js	2013-12-05 12:21:59 +0000
@@ -1,84 +1,83 @@
+$(function() {
+  dhis2.contextmenu.makeContextMenu({
+    menuId: 'contextMenu',
+    menuItemActiveClass: 'contextMenuItemActive'
+  });
+});
+
 // -----------------------------------------------------------------------------
 // View details
 // -----------------------------------------------------------------------------
 
-function showRelationshipTypeDetails( relationshipTypeId )
-{
-  	jQuery.getJSON( 'getRelationshipType.action', { id: relationshipTypeId }, function ( json ) {
-		setInnerHTML( 'aIsToBField', json.relationshipType.aIsToB );	
-		setInnerHTML( 'bIsToAField', json.relationshipType.bIsToA );       
-		setInnerHTML( 'descriptionField', json.relationshipType.description );
-   
-		showDetails();
-	});
+function showUpdateRelationshipTypeForm( context ) {
+  location.href = 'showUpdateRelationshipTypeForm.action?id=' + context.id;
+}
+
+function showRelationshipTypeDetails( context ) {
+  jQuery.getJSON('getRelationshipType.action', { id: context.id }, function( json ) {
+    setInnerHTML('aIsToBField', json.relationshipType.aIsToB);
+    setInnerHTML('bIsToAField', json.relationshipType.bIsToA);
+    setInnerHTML('descriptionField', json.relationshipType.description);
+
+    showDetails();
+  });
 }
 
 // -----------------------------------------------------------------------------
 // Add RelationshipType
 // -----------------------------------------------------------------------------
 
-function validateAddRelationshipType()
-{
-	$.postUTF8(
-    	    'validateRelationshipType.action',
-    	    {
-    	        "aIsToB": getFieldValue( 'aIsToB' ),
-				"bIsToA": getFieldValue( 'bIsToA' )
-    	    },
-    	    function( json )
-    	    {
-    	    	if ( json.response == "success" )
-    	    	{
-					var form = document.getElementById( 'addRelationshipTypeForm' );        
-					form.submit();
-    	    	}else if ( json.response == "input" )
-    	    	{
-    	    		setHeaderMessage( json.message );
-    	    	}
-    	    	else if ( json.response == "error" )
-    	    	{
-    	    		setHeaderMessage( json.message );
-    	    	}
-    	    }
-    	);
+function validateAddRelationshipType() {
+  $.postUTF8(
+    'validateRelationshipType.action',
+    {
+      "aIsToB": getFieldValue('aIsToB'),
+      "bIsToA": getFieldValue('bIsToA')
+    },
+    function( json ) {
+      if( json.response == "success" ) {
+        var form = document.getElementById('addRelationshipTypeForm');
+        form.submit();
+      } else if( json.response == "input" ) {
+        setHeaderMessage(json.message);
+      }
+      else if( json.response == "error" ) {
+        setHeaderMessage(json.message);
+      }
+    }
+  );
 }
 
 // -----------------------------------------------------------------------------
 // Update RelationshipType
 // -----------------------------------------------------------------------------
 
-function validateUpdateRelationshipType()
-{
-	$.postJSON(
-    	    'validateRelationshipType.action',
-    	    {
-				"id": getFieldValue( 'id' ),
-    	        "aIsToB": getFieldValue( 'aIsToB' ),
-				"bIsToA": getFieldValue( 'bIsToA' )
-    	    },
-    	    function( json )
-    	    {
-    	    	if ( json.response == "success" )
-    	    	{
-					var form = document.getElementById( 'updateRelationshipTypeForm' );        
-					form.submit();
-    	    	}else if ( json.response == "input" )
-    	    	{
-    	    		setHeaderMessage( json.message );
-    	    	}
-    	    	else if ( json.response == "error" )
-    	    	{
-    	    		setHeaderMessage( json.message );
-    	    	}
-    	    }
-    	);
+function validateUpdateRelationshipType() {
+  $.postJSON(
+    'validateRelationshipType.action',
+    {
+      "id": getFieldValue('id'),
+      "aIsToB": getFieldValue('aIsToB'),
+      "bIsToA": getFieldValue('bIsToA')
+    },
+    function( json ) {
+      if( json.response == "success" ) {
+        var form = document.getElementById('updateRelationshipTypeForm');
+        form.submit();
+      } else if( json.response == "input" ) {
+        setHeaderMessage(json.message);
+      }
+      else if( json.response == "error" ) {
+        setHeaderMessage(json.message);
+      }
+    }
+  );
 }
 
 // -----------------------------------------------------------------------------
 // Remove RelationshipType
 // -----------------------------------------------------------------------------	
 
-function removeRelationshipType( relationshipTypeId, aIsToB, bIsToA )
-{
-    removeItem( relationshipTypeId, aIsToB + "/" + bIsToA, i18n_confirm_delete, 'removeRelationshipType.action' );
+function removeRelationshipType( context ) {
+  removeItem(context.id, context.name, i18n_confirm_delete, 'removeRelationshipType.action');
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientIdentifierType.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientIdentifierType.vm	2013-07-02 15:18:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientIdentifierType.vm	2013-12-05 12:21:59 +0000
@@ -1,46 +1,50 @@
 
 <h3>$i18n.getString( "patient_identifier_type_management" ) #openHelp( "patient_identifier_type" )</h3>
 
+<div id="contextMenu" class="contextMenu">
+  <ul id="contextMenuItems" class="contextMenuItems">
+    <li><a data-target-fn="showUpdatePatientIdentifierTypeForm"><i class="fa fa-edit"></i>&nbsp;&nbsp;$i18n.getString( "edit" )</a></li>
+    <li><a data-target-fn="translateWithContext"><i class="fa fa-globe"></i>&nbsp;&nbsp;$i18n.getString( "translation_translate" )</a></li>
+    <li><a data-target-fn="removePatientIdentifierType"><i class="fa fa-trash-o"></i>&nbsp;&nbsp;$i18n.getString( "remove" )</a></li>
+    <li><a data-target-fn="showPatientIdentifierTypeDetails"><i class="fa fa-info-circle"></i>&nbsp;&nbsp;$i18n.getString( "show_details" )</a></li>
+  </ul>
+</div>
+
 <table class="mainPageTable">
   <tr>
     <td style="vertical-align:top">
-    
-      <table class="listTable">
-          <col>          
-          <col width="120">
-		  <tr>
-		  	<td></td>
-			<td colspan="4" style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddPatientIdentifierTypeForm.action'" style="width:70px"></td>
-		  </tr>
-          <tr>            
-            <th>$i18n.getString( "name" )</th>
-            <th colspan="4">$i18n.getString( "operations" )</th>
-          </tr>
-
-          <tbody id="list">
-            #foreach( $identifierType in $identifierTypes )
-              <tr id="tr${identifierType.id}">
-              
-                <td onclick="showPatientIdentifierTypeDetails( $identifierType.id )">$encoder.htmlEncode( $identifierType.displayName )</td>                
-                
-                <td style="text-align:center"#alternate( $mark )>
-                  <a href="showUpdatePatientIdentifierTypeForm.action?id=$identifierType.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
-                  <a href="javascript:translate( 'PatientIdentifierType', '$identifierType.id' )" title="$i18n.getString( 'translation_translate' )"><img src="../images/i18n.png" alt="$i18n.getString( 'translation_translate' )"/></a>
-				  <a href="javascript:removePatientIdentifierType( '$identifierType.id', '$encoder.jsEncode( $identifierType.displayName )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
-                  <a href="javascript:showPatientIdentifierTypeDetails( $identifierType.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
-                </td>
-                
-              </tr>
-            #end
-
-          </tbody>
-
-        </table>
+    <table width="100%">
+      <tr>
+        <td>
+          $i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:250px"/>
+        </td>
+        <td colspan="3" style="text-align:right">
+          <input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddPatientIdentifierTypeForm.action'" style="width:70px">
+        </td>
+      </tr>
+    </table>
+
+    <table class="listTable">
+      <tr>
+        <th>$i18n.getString( "name" )</th>
+      </tr>
+
+      <tbody id="list">
+      #foreach( $identifierType in $identifierTypes )
+        <tr id="tr${identifierType.id}" data-id="$!identifierType.id" data-uid="$!identifierType.uid" data-type="PatientIdentifierType" data-name="$encoder.htmlEncode( $!identifierType.displayName )"
+            data-can-manage="$security.canManage( $identifierType )"
+            data-can-update="$security.canUpdate( $identifierType )"
+            data-can-delete="$security.canDelete( $identifierType )">
+            <td>$encoder.htmlEncode( $!identifierType.displayName )</td>
+        </tr>
+      #end
+      </tbody>
+    </table>
     </td>
+
 		<td id="detailsData">
-
-            <div id="detailsArea">
-                <div id="hideDetailsArea">
+      <div id="detailsArea">
+        <div id="hideDetailsArea">
 					<a href="javascript:hideDetails()" title="$i18n.getString( 'hide_details' )"><img src="../images/hide.png" alt="$i18n.getString( 'hide_details' )"></a>
 				</div>				
 				<p><label class="bold">$i18n.getString( "name" ):</label><br><span id="nameField"></span></p>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/relationshipType.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/relationshipType.vm	2013-06-29 14:16:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/relationshipType.vm	2013-12-05 12:21:59 +0000
@@ -1,56 +1,57 @@
 
 <h3>$i18n.getString( "relationship_type_management" ) #openHelp( "relationship_type" )</h3>
 
+<div id="contextMenu" class="contextMenu">
+  <ul id="contextMenuItems" class="contextMenuItems">
+    <li><a data-target-fn="showUpdateRelationshipTypeForm"><i class="fa fa-edit"></i>&nbsp;&nbsp;$i18n.getString( "edit" )</a></li>
+    <li><a data-target-fn="translateWithContext"><i class="fa fa-globe"></i>&nbsp;&nbsp;$i18n.getString( "translation_translate" )</a></li>
+    <li><a data-target-fn="removeRelationshipType"><i class="fa fa-trash-o"></i>&nbsp;&nbsp;$i18n.getString( "remove" )</a></li>
+    <li><a data-target-fn="showRelationshipTypeDetails"><i class="fa fa-info-circle"></i>&nbsp;&nbsp;$i18n.getString( "show_details" )</a></li>
+  </ul>
+</div>
+
 <table class="mainPageTable">
   <tr>
     <td style="vertical-align:top">
-    
-      <table class="listTable">          
-          <col>
-		  <col>
-          <col width="120">
-		  <tr>
-		  	<td></td>
-		  	<td></td>
-			<td colspan="3" style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddRelationshipTypeForm.action'" style="width:70px"></td>
-		  </tr>
-          <tr>
-            <th>$i18n.getString( "relationship_type" )</th>            
-            <th>$i18n.getString( "name" )</th>
-            <th>$i18n.getString( "operations" )</th>
+    <table width="100%">
+      <tr>
+        <td>
+          $i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:250px"/>
+        </td>
+        <td colspan="3" style="text-align:right">
+          <input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddRelationshipTypeForm.action'" style="width:70px">
+        </td>
+      </tr>
+    </table>
+
+      <table class="listTable">
+        <tr>
+          <th>$i18n.getString( "relationship_type" )</th>
+          <th>$i18n.getString( "name" )</th>
+        </tr>
+        <tbody id="list">
+        #foreach( $relationshipType in $relationshipTypes )
+          <tr id="tr${relationshipType.id}" data-id="$!relationshipType.id" data-uid="$!relationshipType.uid" data-type="RelationshipType" data-name="$encoder.htmlEncode( $relationshipType.aIsToB )/$encoder.htmlEncode( $relationshipType.bIsToA )"
+              data-can-manage="$security.canManage( $relationshipType )"
+              data-can-update="$security.canUpdate( $relationshipType )"
+              data-can-delete="$security.canDelete( $relationshipType )">
+              <td>$encoder.htmlEncode( $relationshipType.aIsToB )/$encoder.htmlEncode( $relationshipType.bIsToA )</td>
+              <td>$encoder.htmlEncode( $!relationshipType.displayName )</td>
           </tr>
-
-          <tbody id="list">
-            #foreach( $relationshipType in $relationshipTypes )
-              <tr id="tr${relationshipType.id}">
-              
-                <td onclick="showRelationshipTypeDetails( $relationshipType.id )">$encoder.htmlEncode( $relationshipType.aIsToB )/$encoder.htmlEncode( $relationshipType.bIsToA )</td>
-                
-                <td onclick="showRelationshipTypeDetails( $relationshipType.id )">$encoder.htmlEncode( $relationshipType.displayName )</td>               
-                
-                <td style="text-align:center"#alternate( $mark )>
-                  <a href="showUpdateRelationshipTypeForm.action?id=$relationshipType.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
-				  <a href="javascript:translate( 'RelationshipType', '$relationshipType.id' )" title="$i18n.getString( 'translation_translate' )"><img src="../images/i18n.png" alt="$i18n.getString( 'translation_translate' )"/></a>  
-				  <a href="javascript:removeRelationshipType( '$relationshipType.id', '$encoder.jsEncode( $relationshipType.aIsToB )', '$encoder.jsEncode( $relationshipType.bIsToA )'  )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
-                  <a href="javascript:showRelationshipTypeDetails( $relationshipType.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"></a>
-                </td>           
-                
-              </tr>
-            #end
-
-          </tbody>
-
+        #end
+        </tbody>
         </table>
     </td>
+
     <td id="detailsData">
-            <div id="detailsArea">
-                <div id="hideDetailsArea">
-                <a href="javascript:hideDetails()" title="$i18n.getString( 'hide_details' )"><img src="../images/hide.png" alt="$i18n.getString( 'hide_details' )"></a>
-            </div>              
-            <p><label class="bold">$i18n.getString( "a_is_to_b" ):</label><br><span id="aIsToBField"></span></p>
-            <p><label class="bold">$i18n.getString( "b_is_to_a" ):</label><br><span id="bIsToAField"></span></p>
-            <p><label class="bold">$i18n.getString( "description" ):</label><br><span id="descriptionField"></span></p>                            
-        </div>
+        <div id="detailsArea">
+          <div id="hideDetailsArea">
+            <a href="javascript:hideDetails()" title="$i18n.getString( 'hide_details' )"><img src="../images/hide.png" alt="$i18n.getString( 'hide_details' )"></a>
+          </div>
+          <p><label class="bold">$i18n.getString( "a_is_to_b" ):</label><br><span id="aIsToBField"></span></p>
+          <p><label class="bold">$i18n.getString( "b_is_to_a" ):</label><br><span id="bIsToAField"></span></p>
+          <p><label class="bold">$i18n.getString( "description" ):</label><br><span id="descriptionField"></span></p>
+      </div>
     </td>
   </tr>
 </table>