dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26553
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13142: context-menus for user module
------------------------------------------------------------
revno: 13142
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-12-04 15:39:36 +0100
message:
context-menus for user module
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allRole.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allUser.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/allRole.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/allUser.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/role.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user_tmpl.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/user.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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js 2013-12-04 12:58:11 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js 2013-12-04 14:39:36 +0000
@@ -79,7 +79,7 @@
var targetFn = $target.data('target-fn');
var fn = config.functionResolver(targetFn);
- $menu.hide();
+ dhis2.contextmenu.disable();
fn(context);
return false;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allRole.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allRole.vm 2013-06-29 14:16:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allRole.vm 2013-12-04 14:39:36 +0000
@@ -6,6 +6,14 @@
<h3>$i18n.getString( "user_role_management" ) #openHelp( "user_user_roles" )</h3>
+<div id="contextMenu" class="contextMenu">
+ <ul id="contextMenuItems" class="contextMenuItems">
+ <li><a data-target-fn="showUpdateRoleForm"><i class="fa fa-edit"></i> $i18n.getString( "edit" )</a></li>
+ <li><a data-target-fn="removeRole"><i class="fa fa-trash-o"></i> $i18n.getString( "remove" )</a></li>
+ <li><a data-target-fn="showRoleDetails"><i class="fa fa-info-circle"></i> $i18n.getString( "show_details" )</a></li>
+ </ul>
+</div>
+
<table style="width:100%">
<tr>
<td style="vertical-align:top">
@@ -16,23 +24,20 @@
</tr>
</table>
<table class="listTable" id="listTable">
- <thead>
+ <thead>
<tr>
<th>$i18n.getString( "role" )</th>
<th>$i18n.getString( "description" )</th>
- <th class="{sorter: false}" style="width:120px;">$i18n.getString( "operations" )</th>
</tr>
</thead>
<tbody id="list">
#foreach( $userAuthorityGroup in $userAuthorityGroups )
- <tr id="tr${userAuthorityGroup.id}">
- <td onclick="showRoleDetails( $userAuthorityGroup.id )">$!encoder.htmlEncode( $userAuthorityGroup.name )</td>
- <td onclick="showRoleDetails( $userAuthorityGroup.id )">$!encoder.htmlEncode( $userAuthorityGroup.description )</td>
- <td style="text-align:right">
- <a href="showUpdateRoleForm.action?id=$userAuthorityGroup.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>
- <a href="javascript:removeRole( $userAuthorityGroup.id, '$encoder.jsEncode( $userAuthorityGroup.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a>
- <a href="javascript:showRoleDetails( $userAuthorityGroup.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a>
- </td>
+ <tr id="tr${userAuthorityGroup.id}" data-id="$!userAuthorityGroup.id" data-uid="$!userAuthorityGroup.uid" data-type="UserAuthorityGroup" data-name="$encoder.htmlEncode( $!userAuthorityGroup.displayName )"
+ data-can-manage="$security.canManage( $userAuthorityGroup )"
+ data-can-update="$security.canUpdate( $userAuthorityGroup )"
+ data-can-delete="$security.canDelete( $userAuthorityGroup )">
+ <td>$encoder.htmlEncode( $!userAuthorityGroup.displayName )</td>
+ <td>$encoder.htmlEncode( $!userAuthorityGroup.description )</td>
</tr>
#end
</tbody>
@@ -44,15 +49,14 @@
</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>$i18n.getString( "name" ):</label><br/><span id="nameField"></span></p>
- <p><label>$i18n.getString( "members" ):</label><br/><span id="membersField"></span></p>
- <p><label>$i18n.getString( "data_sets" ):</label><br/><span id="dataSetsField"></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>$i18n.getString( "name" ):</label><br/><span id="nameField"></span></p>
+ <p><label>$i18n.getString( "members" ):</label><br/><span id="membersField"></span></p>
+ <p><label>$i18n.getString( "data_sets" ):</label><br/><span id="dataSetsField"></span></p>
+ </div>
<div id="warningArea">
<div id="hideDetailsArea">
@@ -61,6 +65,6 @@
<p><span id="warningField"></span></p>
</div>
- </td>
+ </td>
</tr>
</table>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allUser.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allUser.vm 2013-10-13 16:19:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/allUser.vm 2013-12-04 14:39:36 +0000
@@ -2,8 +2,8 @@
<script type="text/javascript">
var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_user" ) , "'")';
var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ) , "'")';
- var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ) , "'")';
- var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ) , "'")';
+ var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ) , "'")';
+ var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ) , "'")';
var i18n_edit = '$encoder.jsEscape( $i18n.getString( "edit" ) , "'")';
var i18n_remove = '$encoder.jsEscape( $i18n.getString( "remove" ) , "'")';
var i18n_show_details = '$encoder.jsEscape( $i18n.getString( "show_details" ) , "'")';
@@ -15,13 +15,25 @@
<h3>$i18n.getString( "user_management" ) #openHelp( "user_management" )</h3>
+<div id="contextMenu" class="contextMenu">
+ <ul id="contextMenuItems" class="contextMenuItems">
+ <li><a data-target-fn="showUserProfile"><i class="fa fa-user"></i> $i18n.getString( "profile" )</a></li>
+ <li data-enabled="canUpdate"><a data-target-fn="showUpdateUserForm"><i class="fa fa-edit"></i> $i18n.getString( "edit" )</a></li>
+ <li data-enabled="canDelete"><a data-target-fn="removeUser"><i class="fa fa-trash-o"></i> $i18n.getString( "remove" )</a></li>
+ <li><a data-target-fn="showUserDetails"><i class="fa fa-info-circle"></i> $i18n.getString( "show_details" )</a></li>
+
+ <li data-enabled="userEnabled"><a data-target-fn="disableUser"><i class="fa fa-ban"></i> $i18n.getString( "disable")</a></li>
+ <li data-enabled="userDisabled"><a data-target-fn="enableUser"><i class="fa fa-ban"></i> $i18n.getString( "enable" )</a></li>
+ </ul>
+</div>
+
<table style="width:100%">
<tr>
<td style="vertical-align:top">
<table width="100%">
<tr>
<td>
- #filterDiv( "alluser" )
+ #filterDiv( "alluser" )
</td>
<td>
<label>$i18n.getString( "inactive_for" ):</label><br>
@@ -39,47 +51,25 @@
</tr>
</table>
<table class="listTable" id="userList" width='100%'>
- <col/>
- <col/>
- <thead>
+ <thead>
<tr>
<th>$i18n.getString( "username" )</th>
<th>$i18n.getString( "name" )</th>
- <th class="{sorter: false}" style="width:120px;">$i18n.getString( "operations" )</th>
</tr>
</thead>
<tbody id="list">
- #set( $mark = false )
#foreach( $userCredentials in $userCredentialsList )
- <tr id="tr${userCredentials.id}" #alternate( $mark )>
- <td><a href="../dhis-web-dashboard-integration/profile.action?id=${userCredentials.user.uid}">$encoder.htmlEncode( $userCredentials.username )</a></td>
- <td>$encoder.htmlEncode( $userCredentials.user.surname ), $encoder.htmlEncode( $userCredentials.user.firstName )</td>
- <td style="text-align:right">
- <a href="showUpdateUserForm.action?id=$userCredentials.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>
-
- #if( $currentUserName != $userCredentials.username && !$userCredentials.disabled )
- <img id="disableImg${userCredentials.id}" src="../images/disable.png"
- onclick="disableUser( $userCredentials.id, '$encoder.jsEncode( $userCredentials.username )' )" style="cursor:pointer" title="$i18n.getString( 'disable' )">
- #elseif( $currentUserName != $userCredentials.username && $userCredentials.disabled )
- <img id="disableImg${userCredentials.id}" src="../images/add.png"
- onclick="enableUser( $userCredentials.id, '$encoder.jsEncode( $userCredentials.username )' )" style="cursor:pointer" title="$i18n.getString( 'enable' )">
- #else
- <img src="../images/disable_denied.png">
- #end
-
- #if( $currentUserName != $userCredentials.username )
- <a href="javascript:removeUser( $userCredentials.id, '$encoder.jsEncode( $userCredentials.username )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png"></a>
- #else
- <img src="../images/delete-denied.png" alt="$i18n.getString( 'remove' )"/>
- #end
- <a href="javascript:showUserDetails( $userCredentials.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a>
- </td>
- </tr>
- #if( $mark )
- #set( $mark = false )
- #else
- #set( $mark = true )
- #end
+ <tr id="tr${userCredentials.id}" data-id="$!userCredentials.id" data-uid="$!userCredentials.uid" data-type="UserCredentials"
+ data-name="$encoder.htmlEncode( $!userCredentials.displayName )"
+ data-username="$encoder.htmlEncode( $!userCredentials.username )"
+ data-can-manage="$security.canManage( $userCredentials )"
+ data-can-update="$security.canUpdate( $userCredentials )"
+ data-can-delete="$security.canDelete( $userCredentials )"
+ data-user-enabled="#if( !$userCredentials.disabled )true#{else}false#end"
+ data-user-disabled="$userCredentials.disabled">
+ <td>$encoder.htmlEncode( $!userCredentials.username )</td>
+ <td>$encoder.htmlEncode( $!userCredentials.displayName )</td>
+ </tr>
#end
</tbody>
</table>
@@ -88,19 +78,19 @@
#parse( "/dhis-web-commons/paging/paging.vm" )
</div>
</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>
+ <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>$i18n.getString( "username" ):</label><br><span id="usernameField"></span></p>
<p><label>$i18n.getString( "fullname" ):</label><br><span id="fullNameField"></span></p>
<p><label>$i18n.getString( "email" ):</label><br><span id="emailField"></span></p>
- <p><label>$i18n.getString( "phone_number" ):</label><br><span id="phoneNumberField"></span></p>
+ <p><label>$i18n.getString( "phone_number" ):</label><br><span id="phoneNumberField"></span></p>
<p><label>$i18n.getString( "last_login"):</label><br><span id="lastLoginField"></span></p>
<p><label>$i18n.getString( "created" ):</label><br><span id="createdField"></span></p>
- <p><label>$i18n.getString( "disabled" ):</label><br><span id="disabledField"></span></p>
+ <p><label>$i18n.getString( "disabled" ):</label><br><span id="disabledField"></span></p>
<p><label>$i18n.getString( "organisation_units" ):</label><br/><span id="assignedOrgunitField"></span></p>
<p><label>$i18n.getString( "roles" ):</label><br/><span id="roleField"></span></p>
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/allRole.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/allRole.js 2011-03-14 21:10:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/allRole.js 2013-12-04 14:39:36 +0000
@@ -1,4 +1,13 @@
-jQuery( document ).ready( function()
-{
- tableSorter( 'listTable' );
-} );
+
+jQuery(document).ready(function() {
+ tableSorter('listTable');
+
+ dhis2.contextmenu.makeContextMenu({
+ menuId: 'contextMenu',
+ menuItemActiveClass: 'contextMenuItemActive'
+ });
+});
+
+function showUpdateRoleForm( context ) {
+ location.href = 'showUpdateRoleForm.action?id=' + context.id;
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/allUser.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/allUser.js 2011-03-14 21:10:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/allUser.js 2013-12-04 14:39:36 +0000
@@ -1,4 +1,9 @@
-jQuery( document ).ready( function()
-{
- tableSorter( 'userList' );
-} );
+jQuery(document).ready(function() {
+ tableSorter('userList');
+
+ dhis2.contextmenu.makeContextMenu({
+ menuId: 'contextMenu',
+ menuItemActiveClass: 'contextMenuItemActive',
+ listItemProps: ['id', 'uid', 'name', 'type', 'username']
+ });
+});
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/role.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/role.js 2011-09-28 07:11:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/role.js 2013-12-04 14:39:36 +0000
@@ -1,24 +1,21 @@
-
// -----------------------------------------------------------------------------
// View details
// -----------------------------------------------------------------------------
-function showRoleDetails( roleId )
-{
- jQuery.post( 'getRole.action', { id: roleId }, function ( json ) {
- setInnerHTML( 'nameField', json.userRole.name );
- setInnerHTML( 'membersField', json.userRole.members );
- setInnerHTML( 'dataSetsField', json.userRole.dataSets );
+function showRoleDetails( context ) {
+ jQuery.post('getRole.action', { id: context.id }, function( json ) {
+ setInnerHTML('nameField', json.userRole.name);
+ setInnerHTML('membersField', json.userRole.members);
+ setInnerHTML('dataSetsField', json.userRole.dataSets);
- showDetails();
- });
+ showDetails();
+ });
}
// -----------------------------------------------------------------------------
// Remove role
// -----------------------------------------------------------------------------
-function removeRole(id, role)
-{
- removeItem( id, role, i18n_confirm_delete, 'removeRole.action' );
-}
\ No newline at end of file
+function removeRole( context ) {
+ removeItem(context.id, context.name, i18n_confirm_delete, 'removeRole.action');
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user.js 2013-03-12 06:51:28 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user.js 2013-12-04 14:39:36 +0000
@@ -1,129 +1,112 @@
-
// -----------------------------------------------------------------------------
// Export to PDF file
// -----------------------------------------------------------------------------
-function exportPDF( type )
-{
- var params = "type=" + type;
- params += "&months=" + jQuery( '#months' ).val();
+function exportPDF( type ) {
+ var params = "type=" + type;
+ params += "&months=" + jQuery('#months').val();
- exportPdfByType( type, params );
+ exportPdfByType(type, params);
}
// -----------------------------------------------------------------------------
// Search users
// -----------------------------------------------------------------------------
-function searchUserName()
-{
- var key = getFieldValue( 'key' );
-
- if ( key != '' )
- {
- jQuery( '#userForm' ).load( 'searchUser.action', {key:key}, unLockScreen );
- lockScreen();
- }
- else
- {
- jQuery( '#userForm' ).submit();
- }
+function searchUserName() {
+ var key = getFieldValue('key');
+
+ if( key != '' ) {
+ jQuery('#userForm').load('searchUser.action', {key: key}, unLockScreen);
+ lockScreen();
+ }
+ else {
+ jQuery('#userForm').submit();
+ }
}
-function getInactiveUsers()
-{
- var months = $( '#months' ).val();
-
- window.location.href = 'alluser.action?months=' + months;
+function getInactiveUsers() {
+ var months = $('#months').val();
+
+ window.location.href = 'alluser.action?months=' + months;
}
// -----------------------------------------------------------------------------
// View details
// -----------------------------------------------------------------------------
-function showUserDetails( userId )
-{
- jQuery.post( 'getUser.action', { id: userId }, function ( json ) {
- setInnerHTML( 'usernameField', json.user.username );
-
- var fullName = json.user.firstName + ", " + json.user.surname;
- setInnerHTML( 'fullNameField', fullName );
-
- var email = json.user.email;
- setInnerHTML( 'emailField', email ? email : '[' + i18n_none + ']' );
-
- var phoneNumber = json.user.phoneNumber;
- setInnerHTML( 'phoneNumberField', phoneNumber ? phoneNumber : '[' + i18n_none + ']' );
-
- var lastLogin = json.user.lastLogin;
- setInnerHTML( 'lastLoginField', lastLogin ? lastLogin : '[' + i18n_none + ']' );
-
- var created = json.user.created;
- setInnerHTML( 'createdField', created ? created : '[' + i18n_none + ']' );
-
- var disabled = json.user.disabled;
- setInnerHTML( 'disabledField', disabled ? i18n_yes : i18n_no );
-
- var organisationUnits = joinNameableObjects( json.user.organisationUnits );
- setInnerHTML( 'assignedOrgunitField', organisationUnits ? organisationUnits : '[' + i18n_none + ']' );
-
- var roles = joinNameableObjects( json.user.roles );
- setInnerHTML( 'roleField', roles ? roles : '[' + i18n_none + ']' );
-
- showDetails();
- });
+function showUpdateUserForm( context ) {
+ location.href = 'showUpdateUserForm.action?id=' + context.id;
+}
+
+function showUserProfile( context ) {
+ location.href = '../dhis-web-dashboard-integration/profile.action?id=' + context.id;
+}
+
+function showUserDetails( context ) {
+ jQuery.post('getUser.action', { id: context.id }, function( json ) {
+ setInnerHTML('usernameField', json.user.username);
+
+ var fullName = json.user.firstName + ", " + json.user.surname;
+ setInnerHTML('fullNameField', fullName);
+
+ var email = json.user.email;
+ setInnerHTML('emailField', email ? email : '[' + i18n_none + ']');
+
+ var phoneNumber = json.user.phoneNumber;
+ setInnerHTML('phoneNumberField', phoneNumber ? phoneNumber : '[' + i18n_none + ']');
+
+ var lastLogin = json.user.lastLogin;
+ setInnerHTML('lastLoginField', lastLogin ? lastLogin : '[' + i18n_none + ']');
+
+ var created = json.user.created;
+ setInnerHTML('createdField', created ? created : '[' + i18n_none + ']');
+
+ var disabled = json.user.disabled;
+ setInnerHTML('disabledField', disabled ? i18n_yes : i18n_no);
+
+ var organisationUnits = joinNameableObjects(json.user.organisationUnits);
+ setInnerHTML('assignedOrgunitField', organisationUnits ? organisationUnits : '[' + i18n_none + ']');
+
+ var roles = joinNameableObjects(json.user.roles);
+ setInnerHTML('roleField', roles ? roles : '[' + i18n_none + ']');
+
+ showDetails();
+ });
}
// -----------------------------------------------------------------------------
// Remove user
// -----------------------------------------------------------------------------
-function removeUser( userId, username )
-{
- removeItem( userId, username, i18n_confirm_delete, "removeUser.action" );
-}
-
-function disableUser( userId, username )
-{
- var confirmation = confirm( "Are you sure you want to disable this user?\n\n" + username );
-
- if ( confirmation )
- {
- $.post( "disableUser.action",
- {
- username: username
- },
- function( json )
- {
- if ( json.response == "success" ) {
- $( "#disableImg" + userId ).attr( "src", "../images/add.png" );
- $( "#disableImg" + userId ).removeAttr( "onclick" ).off( "click" ).click( function() {
- enableUser( userId, username )
- } );
- }
- } );
- }
-}
-
-function enableUser( userId, username )
-{
- var confirmation = confirm( "Are you sure you want to enable this user?\n\n" + username );
-
- if ( confirmation )
- {
- $.post( "disableUser.action",
- {
- username: username,
- enable: true
- },
- function( json )
- {
- if ( json.response == "success" ) {
- $( "#disableImg" + userId ).attr( "src", "../images/disable.png" );
- $( "#disableImg" + userId ).removeAttr( "onclick" ).off( "click" ).click( function() {
- disableUser( userId, username )
- } );
- }
- } );
- }
+function removeUser( context ) {
+ removeItem(context.id, context.name, i18n_confirm_delete, "removeUser.action");
+}
+
+function disableUser( context ) {
+ var confirmation = confirm("Are you sure you want to disable this user?\n\n" + context.username);
+
+ if( confirmation ) {
+ $.post("disableUser.action", {
+ username: context.username
+ },
+ function( json ) {
+ location.reload();
+ });
+ }
+}
+
+function enableUser( context ) {
+ var confirmation = confirm("Are you sure you want to enable this user?\n\n" + context.username );
+
+ if( confirmation ) {
+ $.post("disableUser.action",
+ {
+ username: context.username,
+ enable: true
+ },
+ function( json ) {
+ location.reload();
+ });
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user_tmpl.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user_tmpl.js 2011-08-11 11:31:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/user_tmpl.js 2013-12-04 14:39:36 +0000
@@ -1,12 +1,19 @@
/* user.js already exists. This file is for user.vm */
-jQuery( document ).ready( function()
-{
- tableSorter( 'userList' );
- selection.setListenerFunction( orgUnitSelected, true );
-} );
-
-function orgUnitSelected( orgUnitIds )
-{
- window.location.href = "user.action";
+jQuery(document).ready(function() {
+ tableSorter('userList');
+ selection.setListenerFunction(orgUnitSelected, true);
+
+ dhis2.contextmenu.makeContextMenu({
+ menuId: 'contextMenu',
+ menuItemActiveClass: 'contextMenuItemActive'
+ });
+});
+
+function orgUnitSelected( orgUnitIds ) {
+ window.location.href = "user.action";
+}
+
+function showUpdateUserForm( context ) {
+ location.href = 'showUpdateUserForm.action?id=' + context.id;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/user.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/user.vm 2012-11-23 08:27:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/user.vm 2013-12-04 14:39:36 +0000
@@ -15,6 +15,29 @@
<h3>$i18n.getString( "user_management" ) #openHelp( "user_by_org_unit" )</h3>
+<!--
+<td>$encoder.htmlEncode( $userCredentials.username )</td>
+<td>$encoder.htmlEncode( $userCredentials.user.surname ), $encoder.htmlEncode( $userCredentials.user.firstName )</td>
+<td style="text-align:right">
+<a href="showUpdateUserForm.action?id=$userCredentials.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>
+#if($currentUserName != $userCredentials.username)
+<a href="javascript:removeUser( $userCredentials.id, '$encoder.jsEncode( $userCredentials.username )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a>
+#else
+<img src="../images/delete-denied.png" alt="$i18n.getString( 'remove' )"/>
+#end
+<a href="javascript:showUserDetails( $userCredentials.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a>
+</td>
+</tr>
+-->
+
+<div id="contextMenu" class="contextMenu">
+ <ul id="contextMenuItems" class="contextMenuItems">
+ <li><a data-target-fn="showUpdateUserForm"><i class="fa fa-edit"></i> $i18n.getString( "edit" )</a></li>
+ <li data-enabled="canDelete"><a data-target-fn="removeUser"><i class="fa fa-trash-o"></i> $i18n.getString( "remove" )</a></li>
+ <li><a data-target-fn="showUserDetails"><i class="fa fa-info-circle"></i> $i18n.getString( "show_details" )</a></li>
+ </ul>
+</div>
+
<table style="width:100%">
<tr>
<td style="vertical-align:top">
@@ -25,36 +48,21 @@
</tr>
</table>
<table class="listTable" id="userList" width='100%'>
- <col/>
- <col/>
- <thead>
+ <thead>
<tr>
<th>$i18n.getString( "username" )</th>
<th>$i18n.getString( "name" )</th>
- <th class="{sorter: false}" style="width:80px;">$i18n.getString( "operations" )</th>
</tr>
</thead>
<tbody id="list">
- #set( $mark = false )
#foreach( $userCredentials in $userCredentialsList )
- <tr id="tr${userCredentials.id}" #alternate( $mark )>
- <td>$encoder.htmlEncode( $userCredentials.username )</td>
- <td>$encoder.htmlEncode( $userCredentials.user.surname ), $encoder.htmlEncode( $userCredentials.user.firstName )</td>
- <td style="text-align:right">
- <a href="showUpdateUserForm.action?id=$userCredentials.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>
- #if($currentUserName != $userCredentials.username)
- <a href="javascript:removeUser( $userCredentials.id, '$encoder.jsEncode( $userCredentials.username )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a>
- #else
- <img src="../images/delete-denied.png" alt="$i18n.getString( 'remove' )"/>
- #end
- <a href="javascript:showUserDetails( $userCredentials.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a>
- </td>
+ <tr id="tr${userCredentials.id}" data-id="$!userCredentials.id" data-uid="$!userCredentials.uid" data-type="UserCredentials" data-name="$encoder.htmlEncode( $!userCredentials.displayName )"
+ data-can-manage="$security.canManage( $userCredentials )"
+ data-can-update="$security.canUpdate( $userCredentials )"
+ data-can-delete="#if( $currentUserName != $userCredentials.username )true#{else}false#end">
+ <td>$encoder.htmlEncode( $!userCredentials.username )</td>
+ <td>$encoder.htmlEncode( $!userCredentials.displayName )</td>
</tr>
- #if( $mark )
- #set( $mark = false )
- #else
- #set( $mark = true )
- #end
#end
</tbody>
</table>
@@ -63,7 +71,8 @@
#parse( "/dhis-web-commons/paging/paging.vm" )
</div>
</td>
- <td style="width:20em; padding-left:2em; vertical-align:top">
+
+ <td id="detailsData">
<div id="detailsArea" style="display:none">
<div style="float:right">
@@ -73,7 +82,7 @@
<p><label>$i18n.getString( "surname" ):</label><br/><span id="surnameField"></span></p>
<p><label>$i18n.getString( "firstName" ):</label><br/><span id="firstNameField"></span></p>
<p><label>$i18n.getString( "email" ):</label><br/><span id="emailField"></span></p>
- <p><label>$i18n.getString( "phone_number" ):</label><br/><span id="phoneNumberField"></span></p>
+ <p><label>$i18n.getString( "phone_number" ):</label><br/><span id="phoneNumberField"></span></p>
<p><label>$i18n.getString( "last_login"):</label><br/><span id="lastLoginField"></span></p>
<p><label>$i18n.getString( "organisation_units" ):</label><br/><span id="assignedOrgunitField"></span></p>
<p><label>$i18n.getString( "roles" ):</label><br/><span id="roleField"></span></p>