dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29177
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14698: moved jqSelected html into macro, now used in add/edit user (for roles and user-groups)
------------------------------------------------------------
revno: 14698
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-06 19:57:33 +0700
message:
moved jqSelected html into macro, now used in add/edit user (for roles and user-groups)
removed:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/UserAuthorityGroupController.java
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/jqSelected.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.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
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/UserAuthorityGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/UserAuthorityGroupController.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/UserAuthorityGroupController.java 1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
-package org.hisp.dhis.api.controller.user;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.api.controller.AbstractCrudController;
-import org.hisp.dhis.user.UserAuthorityGroup;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-@Controller
-@RequestMapping( value = UserAuthorityGroupController.RESOURCE_PATH )
-public class UserAuthorityGroupController
- extends AbstractCrudController<UserAuthorityGroup>
-{
- public static final String RESOURCE_PATH = "/userRoles";
-}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2014-02-19 04:23:03 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2014-04-06 12:57:33 +0000
@@ -42,7 +42,7 @@
"phoneNumber" : {
"rangelength" : [ 0, 80 ]
},
- "roleValidator" : {
+ "urValidator" : {
"required" : true
}
},
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2014-01-05 18:03:32 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2014-04-06 12:57:33 +0000
@@ -1,3 +1,4 @@
+
#macro( objectList $objectName $objects )
<table class="objectListTable">
<col>
@@ -405,3 +406,60 @@
#end
#end
+
+#************************************************************************************
+ * Args:
+ * prefix: prefix to add before Available/Selected identifiers
+ * required: true/false (default false), selection is required
+ * i18n_available: i18n string for available part
+ * i18n_selected: i18n string for selected part
+ * objects: objects to add to selected, uses value=uid and name=displayName
+ ************************************************************************************#
+#macro( jqSelected $args )
+#if( "$!args.required" == "" ) #set( $required = false ) #else #set( $required = true ) #end
+
+<table style="margin-bottom: 20px">
+ <colgroup>
+ <col style="width: 500px;"/>
+ <col/>
+ <col style="width: 500px;"/>
+ </colgroup>
+ <thead>
+ <tr>
+ <th>$i18n.getString( $args.i18n_available )</th>
+ <th></th>
+ <th>$i18n.getString( $args.i18n_selected )
+ #if( $required )
+ <em title="$i18n.getString( 'required' )" class="required">*</em>
+ <select id="${args.prefix}Validator" style="display:none"></select>
+ #end
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><input id="${args.prefix}AvailableSearch}" type="text" placeholder=" Search.." style="width: 100%; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0;" /></td>
+ <td></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td>
+ <select id="${args.prefix}Available" name="${args.prefix}Available" multiple="multiple" style="height: 200px; width: 100%;"/>
+ </td>
+ <td>
+ <button type="button" style="width: 25px; text-align: center;" onclick="$.fn.selected.defaults.defaultMoveSelected('#${args.prefix}Available');"><span class="fa fa-angle-right"> </span></button><br />
+ <button type="button" style="width: 25px; text-align: center;" onclick="$.fn.selected.defaults.defaultMoveSelected('#${args.prefix}Selected');"><span class="fa fa-angle-left"> </span></button><br />
+ <button type="button" style="width: 25px; text-align: center;" onclick="$.fn.selected.defaults.defaultMoveAll('#${args.prefix}Available');"><span class="fa fa-angle-double-right"> </span></button><br />
+ <button type="button" style="width: 25px; text-align: center;" onclick="$.fn.selected.defaults.defaultMoveAll('#${args.prefix}Selected');"><span class="fa fa-angle-double-left"> </span></button><br />
+ </td>
+ <td>
+ <select id="${args.prefix}Selected" name="${args.prefix}Selected" multiple="multiple" style="height: 200px; width: 100%;">
+ #foreach ( $object in $args.objects )
+ <option value="$object.uid">$encoder.htmlEncode( $object.displayName )</option>
+ #end
+ </select>
+ </td>
+ </tr>
+ </tbody>
+</table>
+#end
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserAction.java 2014-04-05 20:08:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/AddUserAction.java 2014-04-06 12:57:33 +0000
@@ -28,12 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
+import com.google.common.collect.Lists;
+import com.opensymphony.xwork2.Action;
import org.apache.struts2.ServletActionContext;
import org.hisp.dhis.api.utils.ContextUtils;
import org.hisp.dhis.attribute.AttributeService;
@@ -56,8 +52,9 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
-import com.google.common.collect.Lists;
-import com.opensymphony.xwork2.Action;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
/**
* @author Torgeir Lorange Ostby
@@ -216,11 +213,11 @@
this.localeDb = localeDb;
}
- private Collection<String> selectedList = new ArrayList<String>();
+ private List<String> urSelected = Lists.newArrayList();
- public void setSelectedList( Collection<String> selectedList )
+ public void setUrSelected( List<String> urSelected )
{
- this.selectedList = selectedList;
+ this.urSelected = urSelected;
}
private List<String> ugSelected = Lists.newArrayList();
@@ -298,8 +295,8 @@
// ---------------------------------------------------------------------
Set<OrganisationUnit> dataCaptureOrgUnits = new HashSet<OrganisationUnit>( selectionManager.getSelectedOrganisationUnits() );
- user.updateOrganisationUnits( dataCaptureOrgUnits );
-
+ user.updateOrganisationUnits( dataCaptureOrgUnits );
+
Set<OrganisationUnit> dataViewOrgUnits = new HashSet<OrganisationUnit>( selectionTreeManager.getReloadedSelectedOrganisationUnits() );
user.setDataViewOrganisationUnits( dataViewOrgUnits );
@@ -309,9 +306,9 @@
Set<UserAuthorityGroup> userAuthorityGroups = new HashSet<UserAuthorityGroup>();
- for ( String id : selectedList )
+ for ( String id : urSelected )
{
- userAuthorityGroups.add( userService.getUserAuthorityGroup( Integer.parseInt( id ) ) );
+ userAuthorityGroups.add( userService.getUserAuthorityGroup( id ) );
}
userService.canIssueFilter( userAuthorityGroups );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserAction.java 2014-04-05 20:08:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserAction.java 2014-04-06 12:57:33 +0000
@@ -28,12 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
+import com.google.common.collect.Lists;
+import com.opensymphony.xwork2.Action;
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
@@ -53,8 +49,9 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
-import com.google.common.collect.Lists;
-import com.opensymphony.xwork2.Action;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
/**
* @author Torgeir Lorange Ostby
@@ -178,11 +175,11 @@
this.localeDb = localeDb;
}
- private Collection<String> selectedList = new ArrayList<String>();
+ private List<String> urSelected = Lists.newArrayList();
- public void setSelectedList( Collection<String> selectedList )
+ public void setUrSelected( List<String> urSelected )
{
- this.selectedList = selectedList;
+ this.urSelected = urSelected;
}
private List<String> ugSelected = Lists.newArrayList();
@@ -253,8 +250,8 @@
// ---------------------------------------------------------------------
Set<OrganisationUnit> dataCaptureOrgUnits = new HashSet<OrganisationUnit>( selectionManager.getSelectedOrganisationUnits() );
- user.updateOrganisationUnits( dataCaptureOrgUnits );
-
+ user.updateOrganisationUnits( dataCaptureOrgUnits );
+
Set<OrganisationUnit> dataViewOrgUnits = new HashSet<OrganisationUnit>( selectionTreeManager.getReloadedSelectedOrganisationUnits() );
user.setDataViewOrganisationUnits( dataViewOrgUnits );
@@ -264,9 +261,9 @@
Set<UserAuthorityGroup> userAuthorityGroups = new HashSet<UserAuthorityGroup>();
- for ( String id : selectedList )
+ for ( String id : urSelected )
{
- userAuthorityGroups.add( userService.getUserAuthorityGroup( Integer.parseInt( id ) ) );
+ userAuthorityGroups.add( userService.getUserAuthorityGroup( id ) );
}
userService.canIssueFilter( userAuthorityGroups );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserForm.vm 2014-04-05 20:08:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/addUserForm.vm 2014-04-06 12:57:33 +0000
@@ -1,47 +1,44 @@
<script src="javascript/jqSelected.js"></script>
<script type="text/javascript">
- jQuery(function()
- {
- validation2( 'addUserForm', function( form )
- {
- jQuery( "#selectedList" ).children().attr( "selected", "selected" );
- jQuery( "#ugSelected" ).children().attr( "selected", "selected" );
-
- if( $('#selectionTree').find('.selected').size() == 0 ) {
- setHeaderDelayMessage('$encoder.jsEncode( $i18n.getString( "organisation_unit_required_for_user" ) )');
- } else {
- form.submit();
- }
- }, {
- 'beforeValidateHandler' : function()
- {
- listValidator( 'roleValidator', 'selectedList' );
- #tblDynamicAttributesJavascript()
- },
- 'rules' : getValidationRules( "user" )
- } );
-
- checkValueIsExist( "username", "validateUser.action" );
- checkValueIsExist( "openId", "validateUser.action" );
-
- jQuery( "#cancel" ).click( function()
- {
- dhis2.commons.redirectCurrentPage( 'alluser.action' );
- } );
-
- jQuery("#availableList").dhisAjaxSelect({
- source: "../dhis-web-commons-ajax-json/getUserRoles.action",
- iterator: 'userRoles',
- connectedTo: 'selectedList',
- handler: function(item) {
- var option = jQuery("<option />");
- option.text( item.name );
- option.attr( "value", item.id );
-
- return option;
- }
- });
- });
+ jQuery(function() {
+ validation2('addUserForm', function( form ) {
+ jQuery("#urSelected").children().attr("selected", "selected");
+ jQuery("#ugSelected").children().attr("selected", "selected");
+
+ if( $('#selectionTree').find('.selected').size() == 0 ) {
+ setHeaderDelayMessage('$encoder.jsEncode( $i18n.getString( "organisation_unit_required_for_user" ) )');
+ } else {
+ form.submit();
+ }
+ }, {
+ 'beforeValidateHandler': function() {
+ listValidator('urValidator', 'urSelected');
+ #tblDynamicAttributesJavascript()
+ },
+ 'rules': getValidationRules("user")
+ });
+
+ checkValueIsExist("username", "validateUser.action");
+ checkValueIsExist("openId", "validateUser.action");
+
+ jQuery("#cancel").click(function() {
+ dhis2.commons.redirectCurrentPage('alluser.action');
+ });
+
+ $('#urAvailable').selected({
+ url: '../api/userRoles.json',
+ target: $('#urSelected'),
+ search: $('#urAvailableSearch'),
+ iterator: 'userRoles'
+ });
+
+ $('#ugAvailable').selected({
+ url: '../api/userGroups.json',
+ target: $('#ugSelected'),
+ search: $('#ugAvailableSearch'),
+ iterator: 'userGroups'
+ });
+ });
</script>
<style type="text/css">
@@ -149,74 +146,22 @@
</table>
-#tblDynamicAttributes( { "attributes": $attributes } )
-
-<table>
- <colgroup>
- <col style="width: 500px;"/>
- <col/>
- <col style="width: 500px;"/>
- </colgroup>
-
- <tr>
- <th>$i18n.getString( "available_roles" )</th>
- <th></th>
- <th>$i18n.getString( "selected_roles" )<select id="roleValidator" style="display:none"/></th>
- </tr>
-
- <tr style="margin-bottom: 15px;">
- <td>
- <select id="availableList" name="availableList" multiple="multiple" style="height: 200px; width: 100%;"></select>
- </td>
-
- <td style="text-align:center">
- <input type="button" value=">" title="$i18n.getString( 'move_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'availableList' );"/><br/>
- <input type="button" value="<" title="$i18n.getString( 'remove_selected' )" style="width:50px" onclick="dhisAjaxSelect_moveAllSelected( 'selectedList' );"/><br/>
- <input type="button" value=">>" title="$i18n.getString('move_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'availableList' );"/><br/>
- <input type="button" value="<<" title="$i18n.getString('remove_all')" style="width:50px" onclick="dhisAjaxSelect_moveAll( 'selectedList' );"/>
- </td>
-
- <td>
- <select id="selectedList" name="selectedList" multiple="multiple" style="height: 200px; width: 100%; margin-top: 22px;"></select>
- </td>
- </tr>
-</table>
-
-<table style="margin-bottom: 20px">
-<colgroup>
- <col style="width: 500px;"/>
- <col/>
- <col style="width: 500px;"/>
-</colgroup>
-<thead>
-<tr>
- <th>$i18n.getString( "available_user_groups" )</th>
- <th></th>
- <th>$i18n.getString( "selected_user_groups" )</th>
-</tr>
-</thead>
-<tbody>
-<tr>
- <td><input id="ugAvailableSearch" type="text" placeholder=" Search.." style="width: 100%; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0;" /></td>
- <td></td>
- <td></td>
-</tr>
-<tr>
- <td>
- <select id="ugAvailable" name="ugAvailable" multiple="multiple" style="height: 200px; width: 100%;"/>
- </td>
- <td>
- <button type="button" style="width: 25px; text-align: center;" onclick="$.fn.selected.defaults.defaultMoveSelected('#ugAvailable');"><span class="fa fa-angle-right"> </span></button><br />
- <button type="button" style="width: 25px; text-align: center;" onclick="$.fn.selected.defaults.defaultMoveSelected('#ugSelected');"><span class="fa fa-angle-left"> </span></button><br />
- <button type="button" style="width: 25px; text-align: center;" onclick="$.fn.selected.defaults.defaultMoveAll('#ugAvailable');"><span class="fa fa-angle-double-right"> </span></button><br />
- <button type="button" style="width: 25px; text-align: center;" onclick="$.fn.selected.defaults.defaultMoveAll('#ugSelected');"><span class="fa fa-angle-double-left"> </span></button><br />
- </td>
- <td>
- <select id="ugSelected" name="ugSelected" multiple="multiple" style="height: 200px; width: 100%;" />
- </td>
-</tr>
-</tbody>
-</table>
+#tblDynamicAttributes({
+ "attributes": $attributes
+})
+
+#jqSelected({
+ "prefix": "ur",
+ "required": true,
+ "i18n_available": "available_roles",
+ "i18n_selected": "selected_roles"
+})
+
+#jqSelected({
+ "prefix": "ug",
+ "i18n_available": "available_user_groups",
+ "i18n_selected": "selected_user_groups"
+})
<table>
<tr>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/jqSelected.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/jqSelected.js 2014-04-05 06:00:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/jqSelected.js 2014-04-06 12:57:33 +0000
@@ -2,18 +2,6 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
-$(function() {
- var $ugTarget = $('#ugSelected');
- var $ugAvailableSearch = $('#ugAvailableSearch');
-
- $('#ugAvailable').selected({
- url: '../api/userGroups.json',
- target: $ugTarget,
- search: $ugAvailableSearch,
- iterator: 'userGroups'
- });
-});
-
!(function( $, window, document, undefined ) {
var methods = {
create: function( options ) {
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm 2014-04-05 20:08:37 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/updateUserForm.vm 2014-04-06 12:57:33 +0000
@@ -1,53 +1,51 @@
<script src="javascript/jqSelected.js"></script>
<script type="text/javascript">
- jQuery(function() {
- var rules = getValidationRules( "user" );
- rules["rawPassword"].required = false;
- rules["retypePassword"].required = false;
- rules["inviteEmail"].required = false;
-
- validation2( 'updateUserForm', function( form )
- {
- jQuery( "#selectedList" ).children().attr( "selected", "selected" );
- jQuery( "#ugSelected" ).children().attr( "selected", "selected" );
-
- if( $('#selectionTree').find('.selected').size() == 0 ) {
- setHeaderDelayMessage('$i18n.getString( "organisation_unit_required_for_user" )');
- } else {
- form.submit();
- }
- }, {
- 'beforeValidateHandler' : function()
- {
- listValidator( 'roleValidator', 'selectedList' );
- #tblDynamicAttributesJavascript()
- },
- 'rules' : rules
- } );
-
- checkValueIsExist( "openId", "validateUser.action", { id : $userCredentials.id } );
-
- jQuery( "#cancel" ).click( function()
- {
- dhis2.commons.redirectCurrentPage( 'alluser.action' );
- } );
-
- jQuery("#availableList").dhisAjaxSelect({
- source: "../dhis-web-commons-ajax-json/getUserRoles.action",
- iterator: 'userRoles',
- connectedTo: 'selectedList',
- handler: function(item) {
- var option = jQuery("<option />");
- option.text( item.name );
- option.attr( "value", item.id );
-
- return option;
- }
- });
-
- selectionTreeSelection.setMultipleSelectionAllowed(true);
- selectionTree.buildSelectionTree();
- });
+ jQuery(function() {
+ var rules = getValidationRules("user");
+ rules["rawPassword"].required = false;
+ rules["retypePassword"].required = false;
+ rules["inviteEmail"].required = false;
+
+ validation2('updateUserForm', function( form ) {
+ jQuery("#urSelected").children().attr("selected", "selected");
+ jQuery("#ugSelected").children().attr("selected", "selected");
+
+ if( $('#selectionTree').find('.selected').size() == 0 ) {
+ setHeaderDelayMessage('$i18n.getString( "organisation_unit_required_for_user" )');
+ } else {
+ form.submit();
+ }
+ }, {
+ 'beforeValidateHandler': function() {
+ listValidator('urValidator', 'urSelected');
+ #tblDynamicAttributesJavascript()
+ },
+ 'rules': rules
+ });
+
+ checkValueIsExist("openId", "validateUser.action", { id: $userCredentials.id });
+
+ jQuery("#cancel").click(function() {
+ dhis2.commons.redirectCurrentPage('alluser.action');
+ });
+
+ selectionTreeSelection.setMultipleSelectionAllowed(true);
+ selectionTree.buildSelectionTree();
+
+ $('#urAvailable').selected({
+ url: '../api/userRoles.json',
+ target: $('#urSelected'),
+ search: $('#urAvailableSearch'),
+ iterator: 'userRoles'
+ });
+
+ $('#ugAvailable').selected({
+ url: '../api/userGroups.json',
+ target: $('#ugSelected'),
+ search: $('#ugAvailableSearch'),
+ iterator: 'userGroups'
+ });
+ });
</script>
<style type="text/css">
@@ -61,10 +59,7 @@
<h3>$i18n.getString( "edit_user" )</h3>
<form id="updateUserForm" action="updateUser.action" method="post" class="inputForm">
-
-<div>
- <input type="hidden" id="id" name="id" value="$userCredentials.id"/>
-</div>
+<div><input type="hidden" id="id" name="id" value="$userCredentials.id"/></div>
<table>
<col style="width: 120px"/>
@@ -141,8 +136,53 @@
</table>
-#tblDynamicAttributes( { "attributes": $attributes, "attributeValues": $attributeValues } )
-
+#tblDynamicAttributes( {
+ "attributes": $attributes,
+ "attributeValues": $attributeValues
+})
+
+#jqSelected({
+ "prefix": "ur",
+ "required": true,
+ "i18n_available": "available_roles",
+ "i18n_selected": "selected_roles",
+ "objects": $userCredentials.userAuthorityGroups
+})
+
+#jqSelected({
+ "prefix": "ug",
+ "i18n_available": "available_user_groups",
+ "i18n_selected": "selected_user_groups",
+ "objects": $user.groups
+})
+
+<table>
+ <tr>
+ <th>$i18n.getString( "data_capture_maintenance_org_units" )</th>
+ <th></th>
+ <th>$i18n.getString( "data_output_analysis_org_units" )</th>
+ </tr>
+ <tr>
+ <td>
+ #parse( "/dhis-web-commons/ouwt/orgunittree.vm" )
+ </td>
+ <td style="width: 26px"></td>
+ <td>
+ <div id="selectionTree"></div>
+ </td>
+ </tr>
+</table>
+
+<p>
+ <input type="submit" value="$i18n.getString( 'save' )" style="width:10em" />
+ <input type="button" id="cancel" value="$i18n.getString( 'cancel' )" style="width:10em" />
+</p>
+
+</form>
+
+
+
+<!--
<table>
<colgroup>
<col style="width: 500px;"/>
@@ -179,67 +219,4 @@
</td>
</tr>
</table>
-
-<table style="margin-bottom: 20px">
-<colgroup>
-<col style="width: 500px;"/>
-<col/>
-<col style="width: 500px;"/>
-</colgroup>
-<thead>
-<tr>
-<th>$i18n.getString( "available_user_groups" )</th>
-<th></th>
-<th>$i18n.getString( "selected_user_groups" )</th>
-</tr>
-</thead>
-<tbody>
-<tr>
-<td><input id="ugAvailableSearch" type="text" placeholder=" Search.." style="width: 100%; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0;" /></td>
-<td></td>
-<td></td>
-</tr>
-<tr>
-<td>
- <select id="ugAvailable" name="ugAvailable" multiple="multiple" style="height: 200px; width: 100%;"/>
-</td>
-<td>
- <button type="button" style="width: 25px; text-align: center;" onclick="$.fn.selected.defaults.defaultMoveSelected('#ugAvailable');"><span class="fa fa-angle-right"> </span></button><br />
- <button type="button" style="width: 25px; text-align: center;" onclick="$.fn.selected.defaults.defaultMoveSelected('#ugSelected');"><span class="fa fa-angle-left"> </span></button><br />
- <button type="button" style="width: 25px; text-align: center;" onclick="$.fn.selected.defaults.defaultMoveAll('#ugAvailable');"><span class="fa fa-angle-double-right"> </span></button><br />
- <button type="button" style="width: 25px; text-align: center;" onclick="$.fn.selected.defaults.defaultMoveAll('#ugSelected');"><span class="fa fa-angle-double-left"> </span></button><br />
-</td>
-<td>
- <select id="ugSelected" name="ugSelected" multiple="multiple" style="height: 200px; width: 100%;">
- #foreach ( $group in $user.groups )
- <option value="$group.uid">$encoder.htmlEncode( $group.name )</option>
- #end
- </select>
-</td>
-</tr>
-</tbody>
-</table>
-
-<table>
- <tr>
- <th>$i18n.getString( "data_capture_maintenance_org_units" )</th>
- <th></th>
- <th>$i18n.getString( "data_output_analysis_org_units" )</th>
- </tr>
- <tr>
- <td>
- #parse( "/dhis-web-commons/ouwt/orgunittree.vm" )
- </td>
- <td style="width: 26px"></td>
- <td>
- <div id="selectionTree"></div>
- </td>
- </tr>
-</table>
-
-<p>
- <input type="submit" value="$i18n.getString( 'save' )" style="width:10em" />
- <input type="button" id="cancel" value="$i18n.getString( 'cancel' )" style="width:10em" />
-</p>
-
-</form>
+-->