dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13351
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4262: ouwt: made first steps in having a offline ouwt, still some bugs to be sorted out. This demands a...
------------------------------------------------------------
revno: 4262
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-08-08 17:09:46 +0200
message:
ouwt: made first steps in having a offline ouwt, still some bugs to be sorted out. This demands a web storage compatible web browser.
added:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/json2.js
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/ClearSelectedOrganisationUnitsAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetSelectedOrganisationUnitsAction.java
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.array.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/orgunittree.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.html
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/loginfailed.html
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/menu.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnitSearch.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnitSearch.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/ajax/jsonOrganisationUnitTree.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm 2011-07-25 11:07:38 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm 2011-08-08 15:09:46 +0000
@@ -2,22 +2,18 @@
#macro( expandOrganisationUnit $organisationUnit )
{
"id": $!{organisationUnit.id},
- "name": "$!encoder.jsonEncode( ${organisationUnit.name} )",
- "hasChildren": #if( $organisationUnit.children.size() > 0 )true,#{else}false#end
- #if( $organisationUnit.children.size() > 0 )
+ #if( $organisationUnit.parent )"parentId": $!{organisationUnit.parent.id},#end
+ "name": "$!encoder.jsonEncode( ${organisationUnit.name} )"#if( $organisationUnit.children.size() > 0 ),
"children": [
- #foreach ( $child in $organisationUnit.sortedChildren )
- #expandOrganisationUnit( $child )#if( $velocityCount < $organisationUnit.children.size() ),#end
- #end
- ]
- #end
+ #foreach ( $child in $organisationUnit.sortedChildren )
+ #expandOrganisationUnit( $child )#if( $velocityCount < $organisationUnit.children.size() ),#end
+ #end]#end
}
#end
{ "organisationUnits": [
#foreach ( $organisationUnit in $organisationUnits )
- #expandOrganisationUnit( $organisationUnit )
- #if( $velocityCount < $organisationUnits.size() ),#end
+ #expandOrganisationUnit( $organisationUnit )#if( $velocityCount < $organisationUnits.size() ),#end
#end
]
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.array.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.array.js 2011-06-19 17:25:08 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.array.js 2011-08-08 15:09:46 +0000
@@ -34,7 +34,7 @@
* @param from {Number} Start index
* @param to {Number} End index
*
- * @returns {Array}Â Array without the removed parts
+ * @returns {Array} Array without the removed parts
*/
dhis2.array.remove = function( array, from, to )
{
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/json2.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/json2.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/json2.js 2011-08-08 15:09:46 +0000
@@ -0,0 +1,480 @@
+/*
+ http://www.JSON.org/json2.js
+ 2011-02-23
+
+ Public Domain.
+
+ NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+
+ See http://www.JSON.org/js.html
+
+
+ This code should be minified before deployment.
+ See http://javascript.crockford.com/jsmin.html
+
+ USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+ NOT CONTROL.
+
+
+ This file creates a global JSON object containing two methods: stringify
+ and parse.
+
+ JSON.stringify(value, replacer, space)
+ value any JavaScript value, usually an object or array.
+
+ replacer an optional parameter that determines how object
+ values are stringified for objects. It can be a
+ function or an array of strings.
+
+ space an optional parameter that specifies the indentation
+ of nested structures. If it is omitted, the text will
+ be packed without extra whitespace. If it is a number,
+ it will specify the number of spaces to indent at each
+ level. If it is a string (such as '\t' or ' '),
+ it contains the characters used to indent at each level.
+
+ This method produces a JSON text from a JavaScript value.
+
+ When an object value is found, if the object contains a toJSON
+ method, its toJSON method will be called and the result will be
+ stringified. A toJSON method does not serialize: it returns the
+ value represented by the name/value pair that should be serialized,
+ or undefined if nothing should be serialized. The toJSON method
+ will be passed the key associated with the value, and this will be
+ bound to the value
+
+ For example, this would serialize Dates as ISO strings.
+
+ Date.prototype.toJSON = function (key) {
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ return this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z';
+ };
+
+ You can provide an optional replacer method. It will be passed the
+ key and value of each member, with this bound to the containing
+ object. The value that is returned from your method will be
+ serialized. If your method returns undefined, then the member will
+ be excluded from the serialization.
+
+ If the replacer parameter is an array of strings, then it will be
+ used to select the members to be serialized. It filters the results
+ such that only members with keys listed in the replacer array are
+ stringified.
+
+ Values that do not have JSON representations, such as undefined or
+ functions, will not be serialized. Such values in objects will be
+ dropped; in arrays they will be replaced with null. You can use
+ a replacer function to replace those with JSON values.
+ JSON.stringify(undefined) returns undefined.
+
+ The optional space parameter produces a stringification of the
+ value that is filled with line breaks and indentation to make it
+ easier to read.
+
+ If the space parameter is a non-empty string, then that string will
+ be used for indentation. If the space parameter is a number, then
+ the indentation will be that many spaces.
+
+ Example:
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}]);
+ // text is '["e",{"pluribus":"unum"}]'
+
+
+ text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+ // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+ text = JSON.stringify([new Date()], function (key, value) {
+ return this[key] instanceof Date ?
+ 'Date(' + this[key] + ')' : value;
+ });
+ // text is '["Date(---current time---)"]'
+
+
+ JSON.parse(text, reviver)
+ This method parses a JSON text to produce an object or array.
+ It can throw a SyntaxError exception.
+
+ The optional reviver parameter is a function that can filter and
+ transform the results. It receives each of the keys and values,
+ and its return value is used instead of the original value.
+ If it returns what it received, then the structure is not modified.
+ If it returns undefined then the member is deleted.
+
+ Example:
+
+ // Parse the text. Values that look like ISO date strings will
+ // be converted to Date objects.
+
+ myData = JSON.parse(text, function (key, value) {
+ var a;
+ if (typeof value === 'string') {
+ a =
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+ if (a) {
+ return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+ +a[5], +a[6]));
+ }
+ }
+ return value;
+ });
+
+ myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+ var d;
+ if (typeof value === 'string' &&
+ value.slice(0, 5) === 'Date(' &&
+ value.slice(-1) === ')') {
+ d = new Date(value.slice(5, -1));
+ if (d) {
+ return d;
+ }
+ }
+ return value;
+ });
+
+
+ This is a reference implementation. You are free to copy, modify, or
+ redistribute.
+*/
+
+/*jslint evil: true, strict: false, regexp: false */
+
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
+ call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+ getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+ lastIndex, length, parse, prototype, push, replace, slice, stringify,
+ test, toJSON, toString, valueOf
+*/
+
+
+// Create a JSON object only if one does not already exist. We create the
+// methods in a closure to avoid creating global variables.
+
+var JSON;
+if (!JSON) {
+ JSON = {};
+}
+
+(function () {
+ "use strict";
+
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ if (typeof Date.prototype.toJSON !== 'function') {
+
+ Date.prototype.toJSON = function (key) {
+
+ return isFinite(this.valueOf()) ?
+ this.getUTCFullYear() + '-' +
+ f(this.getUTCMonth() + 1) + '-' +
+ f(this.getUTCDate()) + 'T' +
+ f(this.getUTCHours()) + ':' +
+ f(this.getUTCMinutes()) + ':' +
+ f(this.getUTCSeconds()) + 'Z' : null;
+ };
+
+ String.prototype.toJSON =
+ Number.prototype.toJSON =
+ Boolean.prototype.toJSON = function (key) {
+ return this.valueOf();
+ };
+ }
+
+ var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+ gap,
+ indent,
+ meta = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+
+ function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+ escapable.lastIndex = 0;
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string' ? c :
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' : '"' + string + '"';
+ }
+
+
+ function str(key, holder) {
+
+// Produce a string from holder[key].
+
+ var i, // The loop counter.
+ k, // The member key.
+ v, // The member value.
+ length,
+ mind = gap,
+ partial,
+ value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+ if (value && typeof value === 'object' &&
+ typeof value.toJSON === 'function') {
+ value = value.toJSON(key);
+ }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+
+// What happens next depends on the value's type.
+
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+
+ case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+ return isFinite(value) ? String(value) : 'null';
+
+ case 'boolean':
+ case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+ return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+ case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+ if (!value) {
+ return 'null';
+ }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+ gap += indent;
+ partial = [];
+
+// Is the value an array?
+
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+ v = partial.length === 0 ? '[]' : gap ?
+ '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
+ '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ if (typeof rep[i] === 'string') {
+ k = rep[i];
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+ v = partial.length === 0 ? '{}' : gap ?
+ '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
+ '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
+ }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+ if (typeof JSON.stringify !== 'function') {
+ JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+ var i;
+ gap = '';
+ indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+ } else if (typeof space === 'string') {
+ indent = space;
+ }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function' &&
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+ return str('', {'': value});
+ };
+ }
+
+
+// If the JSON object does not yet have a parse method, give it one.
+
+ if (typeof JSON.parse !== 'function') {
+ JSON.parse = function (text, reviver) {
+
+// The parse method takes a text and an optional reviver function, and returns
+// a JavaScript value if the text is a valid JSON text.
+
+ var j;
+
+ function walk(holder, key) {
+
+// The walk method is used to recursively walk the resulting structure so
+// that modifications can be made.
+
+ var k, v, value = holder[key];
+ if (value && typeof value === 'object') {
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = walk(value, k);
+ if (v !== undefined) {
+ value[k] = v;
+ } else {
+ delete value[k];
+ }
+ }
+ }
+ }
+ return reviver.call(holder, key, value);
+ }
+
+
+// Parsing happens in four stages. In the first stage, we replace certain
+// Unicode characters with escape sequences. JavaScript handles many characters
+// incorrectly, either silently deleting them, or treating them as line endings.
+
+ text = String(text);
+ cx.lastIndex = 0;
+ if (cx.test(text)) {
+ text = text.replace(cx, function (a) {
+ return '\\u' +
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ });
+ }
+
+// In the second stage, we run the text against regular expressions that look
+// for non-JSON patterns. We are especially concerned with '()' and 'new'
+// because they can cause invocation, and '=' because it can cause mutation.
+// But just to be safe, we want to reject all unexpected forms.
+
+// We split the second stage into 4 regexp operations in order to work around
+// crippling inefficiencies in IE's and Safari's regexp engines. First we
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+// replace all simple value tokens with ']' characters. Third, we delete all
+// open brackets that follow a colon or comma or that begin the text. Finally,
+// we look to see that the remaining characters are only whitespace or ']' or
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+ if (/^[\],:{}\s]*$/
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+// In the third stage we use the eval function to compile the text into a
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+// in JavaScript: it can begin a block or an object literal. We wrap the text
+// in parens to eliminate the ambiguity.
+
+ j = eval('(' + text + ')');
+
+// In the optional fourth stage, we recursively walk the new structure, passing
+// each name/value pair to a reviver function for possible transformation.
+
+ return typeof reviver === 'function' ?
+ walk({'': j}, '') : j;
+ }
+
+// If the text is not JSON parseable, then a SyntaxError is thrown.
+
+ throw new SyntaxError('JSON.parse');
+ };
+ }
+}());
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/orgunittree.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/orgunittree.vm 2010-11-29 13:06:19 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/orgunittree.vm 2011-08-08 15:09:46 +0000
@@ -1,4 +1,13 @@
+<div id="orgUnitTree">
+ <ul>
+ </ul>
+</div>
+
+<img id="ouwt_loader" src="../images/ajax-loader-bar.gif"/>
+
+
+#*
#macro( parseNode $node )
#if( $node.hasChildren )
#if( $node.children )
@@ -28,11 +37,8 @@
#end
#if( $organisationUnitTree )
- <div id="orgUnitTree">
- <ul>
- #foreach( $root in $organisationUnitTree )
- #parseNode( $root )
- #end
- </ul>
- </div>
+ #foreach( $root in $organisationUnitTree )
+ #parseNode( $root )
+ #end
#end
+*#
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2011-07-22 09:17:04 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2011-08-08 15:09:46 +0000
@@ -18,6 +18,11 @@
var subtree = new Subtree();
var organisationUnitTreePath = '../dhis-web-commons/ouwt/';
+$( document ).ready( function()
+{
+ selection.load();
+} );
+
// -----------------------------------------------------------------------------
// Selection
// -----------------------------------------------------------------------------
@@ -43,25 +48,223 @@
unselectAllowed = allowed;
}
+ this.load = function()
+ {
+ $.get( '../dhis-web-commons-ajax-json/getOrganisationUnitTree.action', function( data, textStatus, jqXHR )
+ {
+ var roots = [];
+
+ for ( var i in data["organisationUnits"] )
+ {
+ var ou = data["organisationUnits"][i];
+ roots.push( ou.id );
+ store_ou( ou );
+ }
+
+ localStorage[getTagId( "Roots" )] = JSON.stringify( roots );
+
+ if ( sessionStorage[getTagId( "Selected" )] === undefined )
+ {
+ if ( multipleSelectionAllowed )
+ {
+ sessionStorage[getTagId( "Selected" )] = roots;
+ }
+ else
+ {
+ sessionStorage[getTagId( "Selected" )] = roots[0];
+ }
+
+ this.sync();
+ }
+
+ if ( data["organisationUnits"].length > 0 )
+ {
+ subtree.reloadTree();
+ }
+
+ $( "#ouwt_loader" ).hide();
+ } );
+ }
+
+ // server = true : sync from server
+ // server = false : sync to server
+ this.sync = function( server )
+ {
+ if ( server )
+ {
+ sessionStorage.removeItem( getTagId( "Selected" ) );
+
+ $.post( organisationUnitTreePath + "getselected.action", function( data )
+ {
+ if ( multipleSelectionAllowed )
+ {
+ $.each( data, function( i, item )
+ {
+ console.log( "multiSelecting " + item.id );
+ } )
+ }
+ else
+ {
+ console.log( "singleSelecting " + data[0].id );
+ }
+ } );
+ }
+ else
+ {
+ $.post( organisationUnitTreePath + "clearselected.action", this.responseReceived );
+
+ if ( sessionStorage[getTagId( "Selected" )] === undefined )
+ {
+ return;
+ }
+
+ var selected = JSON.parse( sessionStorage[getTagId( "Selected" )] );
+
+ if ( multipleSelectionAllowed )
+ {
+ if ( !$.isArray( selected ) )
+ {
+ selected = [ selected ];
+ }
+
+ $.each( selected, function( i, item )
+ {
+ $.post( organisationUnitTreePath + "addorgunit.action", {
+ id : item
+ } )
+ } );
+ }
+ else
+ {
+ if ( $.isArray( selected ) )
+ {
+ selected = selected[0];
+ }
+
+ $.post( organisationUnitTreePath + "setorgunit.action", {
+ id : selected
+ } );
+ }
+ }
+
+ subtree.reloadTree();
+ }
+
+ this.clear = function()
+ {
+ $.post( organisationUnitTreePath + "clearselected.action", this.responseReceived );
+ sessionStorage.removeItem( getTagId( "Selected" ) );
+
+ var roots = JSON.parse( localStorage[getTagId( "Roots" )] );
+
+ if ( roots.length > 1 )
+ {
+ sessionStorage[getTagId( "Selected" )] = roots;
+ }
+ else
+ {
+ sessionStorage[getTagId( "Selected" )] = roots[0];
+ }
+
+ subtree.reloadTree();
+ }
+
+ function store_ou( ou )
+ {
+ var output = {}
+ output.id = ou.id;
+ output.parentId = ou.parentId;
+ output.name = ou.name;
+ output.children = [];
+
+ for ( var i in ou.children )
+ {
+ output.children.push( ou.children[i].id );
+ store_ou( ou.children[i] );
+ }
+
+ localStorage[getTagId( ou.id )] = JSON.stringify( output );
+ }
+
this.select = function( unitId )
{
var $linkTag = $( "#" + getTagId( unitId ) ).find( "a" ).eq( 0 );
if ( $linkTag.hasClass( "selected" ) && unselectAllowed )
{
- $.post( organisationUnitTreePath + "removeorgunit.action", { id : unitId }, responseReceived );
-
+ var selected = JSON.parse( sessionStorage[getTagId( "Selected" )] );
+
+ if ( !!selected && $.isArray( selected ) )
+ {
+ var idx;
+
+ $.each( selected, function( i, item )
+ {
+ if ( +item === unitId )
+ {
+ idx = i;
+ }
+ } );
+
+ if ( idx !== undefined )
+ {
+ dhis2.array.remove( selected, idx, idx );
+ }
+
+ sessionStorage[getTagId( "Selected" )] = JSON.stringify( selected );
+ }
+ else
+ {
+ sessionStorage.removeItem( getTagId( "Selected" ) );
+ }
+
+ $.post( organisationUnitTreePath + "removeorgunit.action", {
+ id : unitId
+ }, this.responseReceived );
+
$linkTag.removeClass( "selected" );
- } else
+ }
+ else
{
if ( multipleSelectionAllowed )
{
- $.post( organisationUnitTreePath + "addorgunit.action", { id : unitId }, responseReceived );
+ var selected = sessionStorage[getTagId( "Selected" )];
+
+ if ( selected )
+ {
+ selected = JSON.parse( selected );
+
+ if ( !$.isArray( selected ) )
+ {
+ selected = [ selected ];
+ }
+ }
+ else
+ {
+ selected = [];
+ }
+
+ if ( selected.indexOf( unitId ) !== -1 )
+ {
+ return;
+ }
+
+ selected.push( unitId );
+ sessionStorage[getTagId( "Selected" )] = JSON.stringify( selected );
+
+ $.post( organisationUnitTreePath + "addorgunit.action", {
+ id : unitId
+ }, this.responseReceived );
$linkTag.addClass( "selected" );
- } else
+ }
+ else
{
- $.post( organisationUnitTreePath + "setorgunit.action", { id : unitId }, responseReceived );
+ sessionStorage[getTagId( "Selected" )] = unitId;
+
+ $.post( organisationUnitTreePath + "setorgunit.action", {
+ id : unitId
+ }, this.responseReceived );
$( "#orgUnitTree" ).find( "a" ).removeClass( "selected" );
$linkTag.addClass( "selected" );
@@ -69,23 +272,40 @@
}
};
- function responseReceived( json )
+ this.responseReceived = function()
{
if ( !listenerFunction )
{
return;
}
- var unitIds = [];
- var unitNames = [];
-
- for ( i in json.selectedUnits )
- {
- unitIds[i] = json.selectedUnits[i].id;
- unitNames[i] = json.selectedUnits[i].name;
- }
-
- listenerFunction( unitIds, unitNames );
+ var selected = []
+
+ if ( sessionStorage[getTagId( "Selected" )] !== undefined )
+ {
+ selected = JSON.parse( sessionStorage[getTagId( "Selected" )] );
+ }
+
+ var ids = [];
+ var names = [];
+
+ if ( $.isArray( selected ) )
+ {
+ $.each( selected, function( i, item )
+ {
+ var name = JSON.parse( localStorage[getTagId( item )] ).name;
+ ids.push( item );
+ names.push( name );
+ } );
+ }
+ else
+ {
+ var name = JSON.parse( localStorage[getTagId( selected )] ).name;
+ ids.push( +selected );
+ names.push( name );
+ }
+
+ listenerFunction( ids, names );
}
function getTagId( unitId )
@@ -95,24 +315,27 @@
this.findByCode = function()
{
- $.getJSON( organisationUnitTreePath + 'getOrganisationUnitByCode.action?code='
- + encodeURI( $( '#searchField' ).val() ), function( data )
+ var name = $( '#searchField' ).val()
+
+ $.getJSON( organisationUnitTreePath + 'getOrganisationUnitByCode.action?code=' + encodeURI( name ), function(
+ data )
{
- var unitId = data.message;
if ( data.response == "success" )
{
+ var unitId = data.message;
+
$( '#orgUnitTreeContainer' ).load( organisationUnitTreePath + 'loadOrganisationUnitTree.action',
function()
{
-
if ( !listenerFunction )
{
return false;
}
- var unitIds = [ unitId ];
- listenerFunction( unitIds );
+
+ listenerFunction( [ unitId ] );
} );
- } else
+ }
+ else
{
$( '#searchField' ).css( 'background-color', '#ffc5c5' );
}
@@ -132,94 +355,158 @@
if ( children.length < 1 || !isVisible( children[0] ) )
{
- $.ajax( {
- url : organisationUnitTreePath + 'expandSubtree.action',
- data : {
- 'parentId' : unitId
- },
- success : processExpand
- } );
- } else
- {
- $.ajax( {
- url : organisationUnitTreePath + 'collapseSubtree.action',
- data : {
- 'parentId' : unitId
- },
- success : processCollapse
- } );
+ var ou = JSON.parse( localStorage[getTagId( unitId )] );
+ processExpand( ou );
+ }
+ else
+ {
+ var ou = JSON.parse( localStorage[getTagId( unitId )] );
+ processCollapse( ou );
+ }
+ };
+
+ selectOrgUnits = function( ous )
+ {
+ $.each( ous, function( i, item )
+ {
+ selectOrgUnit( item );
+ } );
+ }
+
+ selectOrgUnit = function( ou )
+ {
+ $( "#" + getTagId( ou ) + " > a" ).addClass( "selected" );
+ }
+
+ expandTreeAtOrgUnits = function( ous )
+ {
+ $.each( ous, function( i, item )
+ {
+ expandTreeAtOrgUnit( item );
+ } );
+ }
+
+ expandTreeAtOrgUnit = function( ou )
+ {
+ if ( localStorage[getTagId( ou )] === undefined )
+ {
+ return;
+ }
+
+ var ouEl = JSON.parse( localStorage[getTagId( ou )] );
+
+ var $rootsTag = $( "#orgUnitTree > ul" );
+
+ if ( $rootsTag.length < 1 )
+ {
+ $( "#orgUnitTree" ).append( "<ul/>" );
+ $rootsTag = $( "#orgUnitTree > ul" );
+ }
+
+ var array = [];
+
+ if ( ouEl.parentId !== undefined )
+ {
+ while ( ouEl.parentId !== undefined )
+ {
+ if ( localStorage[getTagId( ouEl.parentId )] !== undefined )
+ {
+ array.push( ouEl.parentId );
+ }
+ else
+ {
+ break;
+ }
+
+ ouEl = JSON.parse( localStorage[getTagId( ouEl.parentId )] );
+ }
+
+ array.reverse();
+ }
+
+ var rootId = array.length < 1 ? ou : array[0];
+
+ if ( $( "#" + getTagId( rootId ) ).length < 1 )
+ {
+ var expand = JSON.parse( localStorage[getTagId( rootId )] );
+ var $parentTag = $( "#" + getTagId( rootId ) );
+ $rootsTag.append( createTreeElementTag( expand ) );
+ }
+
+ $.each( array, function( i, item )
+ {
+ var expand = JSON.parse( localStorage[getTagId( item )] );
+ processExpand( expand );
+ } );
+ }
+
+ this.reloadTree = function()
+ {
+ var $treeTag = $( "#orgUnitTree" );
+ $treeTag.children().eq( 0 ).remove();
+
+ if ( sessionStorage[getTagId( "Selected" )] === undefined )
+ {
+ var roots = JSON.parse( localStorage[getTagId( "Roots" )] );
+
+ expandTreeAtOrgUnits( roots );
+ }
+ else
+ {
+ var selected = JSON.parse( sessionStorage[getTagId( "Selected" )] );
+
+ if ( $.isArray( selected ) )
+ {
+ expandTreeAtOrgUnits( selected );
+ }
+ else
+ {
+ expandTreeAtOrgUnit( selected );
+ selected = [ selected ];
+ }
+
+ selectOrgUnits( selected );
}
};
this.refreshTree = function()
{
- var $treeTag = $( "#orgUnitTree" );
- $treeTag.children().eq( 0 ).remove();
-
- $.get( organisationUnitTreePath + "getExpandedTree.action", treeReceived );
- };
-
- function processCollapse( rootElement )
- {
- $( rootElement ).find( "unit" ).each( function( i, item )
- {
- var parentId = $( item ).eq( 0 ).text();
- var $parentTag = $( "#" + getTagId( parentId ) );
- var child = $parentTag.find( "ul" ).eq( 0 );
-
- setVisible( child, false );
- setToggle( $parentTag, false );
- } );
- }
-
- function processExpand( rootElement )
- {
- $( rootElement ).find( "parent" ).each( function( i, item )
- {
- var parentId = $( item ).attr( "parentId" );
- var $parentTag = $( "#" + getTagId( parentId ) );
- var $children = $parentTag.find( "ul" );
-
- if ( $children.length < 1 )
- {
- createChildren( $parentTag, item );
- } else
- {
- setVisible( $children.eq( 0 ), true );
- setToggle( $parentTag, true );
- }
- } );
- }
-
- function treeReceived( rootElement )
- {
- var $treeTag = $( "#orgUnitTree" );
- var $rootsTag = $( "<ul/>" );
-
- $( rootElement ).find( "roots > unit" ).each( function( i, item )
- {
- $rootsTag.append( createTreeElementTag( item ) );
- } );
-
- $treeTag.append( $rootsTag );
-
- $( rootElement ).find( "children > parent" ).each( function( i, item )
- {
- var parentId = $( item ).attr( "parentId" );
- var $parentTag = $( "#" + getTagId( parentId ) );
-
- createChildren( $parentTag, item );
- } );
- }
-
- function createChildren( parentTag, parentElement )
+ selection.load();
+ }
+
+ function processCollapse( parent )
+ {
+ var $parentTag = $( "#" + getTagId( parent.id ) );
+ var child = $parentTag.find( "ul" ).eq( 0 );
+ setVisible( child, false );
+ setToggle( $parentTag, false );
+ }
+
+ function processExpand( parent )
+ {
+ var $parentTag = $( "#" + getTagId( parent.id ) );
+ var $children = $parentTag.find( "ul" );
+
+ if ( $children.length < 1 )
+ {
+ createChildren( $parentTag, parent );
+ }
+ else
+ {
+ setVisible( $children.eq( 0 ), true );
+ setToggle( $parentTag, true );
+ }
+ }
+
+ function createChildren( parentTag, parent )
{
var $childrenTag = $( "<ul/>" );
- $( parentElement ).find( "child" ).each( function( i, item )
+ $.each( parent.children, function( i, item )
{
- $childrenTag.append( createTreeElementTag( item ) );
- } )
+ var ou = JSON.parse( localStorage[getTagId( item )] );
+ $childrenTag.append( createTreeElementTag( ou ) );
+ } );
setVisible( $childrenTag, true );
setToggle( parentTag, true );
@@ -227,35 +514,28 @@
$( parentTag ).append( $childrenTag );
}
- function createTreeElementTag( child )
+ function createTreeElementTag( ou )
{
- var $child = $( child );
- var childId = $child.attr( "id" );
- var hasChildren = $child.attr( "hasChildren" ) != 0;
-
var $toggleTag = $( "<span/>" );
$toggleTag.addClass( "toggle" );
- if ( hasChildren )
+ if ( ou.children.length > 0 )
{
- $toggleTag.bind( "click", new Function( 'subtree.toggle( ' + childId + ' )' ) );
+ $toggleTag.bind( "click", new Function( 'subtree.toggle( ' + ou.id + ' )' ) );
$toggleTag.append( getToggleExpand() );
- } else
+ }
+ else
{
$toggleTag.append( getToggleBlank() );
}
var $linkTag = $( "<a/>" );
- $linkTag.attr( "href", "javascript:void selection.select( " + childId + ")" );
- $linkTag.append( $child.eq( 0 ).text() );
-
- if ( $child.attr( "select" ) )
- {
- $linkTag.addClass( "selected" );
- }
+ $linkTag.attr( "href", "javascript:void selection.select( " + ou.id + ")" );
+ $linkTag.append( ou.name );
var $childTag = $( "<li/>" );
- $childTag.attr( "id", getTagId( childId ) );
+
+ $childTag.attr( "id", getTagId( ou.id ) );
$childTag.append( " " );
$childTag.append( $toggleTag )
$childTag.append( " " );
@@ -272,7 +552,8 @@
if ( $toggleTag.children().eq( 0 ) )
{
$toggleTag.children().eq( 0 ).replaceWith( toggleImg );
- } else
+ }
+ else
{
$toggleTag.append( toggleImg );
}
@@ -283,7 +564,8 @@
if ( visible )
{
$( tag ).show();
- } else
+ }
+ else
{
$( tag ).hide();
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.html'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.html 2011-05-20 09:00:48 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/login.html 2011-08-08 15:09:46 +0000
@@ -6,6 +6,13 @@
<script type="text/javascript">
$(document).ready(function() {
$('#j_username').focus();
+
+ $('#loginForm').bind('submit', function() {
+ $('#submit').attr('disabled', 'disabled');
+ $('#reset').attr('disabled', 'disabled');
+
+ sessionStorage.removeItem( 'orgUnitSelected' );
+ });
});
</script>
<link type="text/css" rel="stylesheet" media="screen" href="../css/login.css">
@@ -16,20 +23,22 @@
<div><img alt="" src="logo_banner.png"></div>
<div style="margin-top:2%">
- <form action="../../dhis-web-commons-security/login.action" method="post">
+ <form id='loginForm' action="../../dhis-web-commons-security/login.action" method="post">
<table>
<tr>
<td><label for="j_username">Username</label></td>
- <td><input type="text" id="j_username" name="j_username" style="width:240px;height:20px;"></td>
+ <td><input type="text" id="j_username" name="j_username" style="width:240px; height:20px;"></td>
</tr>
<tr>
<td><label for="j_password">Password</label></td>
- <td><input type="password" id="j_password" name="j_password" style="width:240px;height:20px;"></td>
+ <td><input type="password" id="j_password" name="j_password" style="width:240px; height:20px;"></td>
</tr>
<tr>
<td></td>
- <td><input type="submit" value="Login" style="width:120px; height:26px;">
- <input type="reset" value="Clear" style="width:120px; height:26px;"></td>
+ <td>
+ <input id='submit' type="submit" value="Login" style="width:120px; height:26px;">
+ <input id='reset' type="reset" value="Clear" style="width:120px; height:26px;">
+ </td>
</tr>
</table>
</form>
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/loginfailed.html'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/loginfailed.html 2011-03-23 18:29:28 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/security/loginfailed.html 2011-08-08 15:09:46 +0000
@@ -2,10 +2,15 @@
<html>
<head>
<title>DHIS 2</title>
- <script type="text/javascript" src="../javascripts/jQuery/jquery.min.js"></script>
+ <script type="text/javascript" src="../javascripts/jQuery/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#j_username').focus();
+
+ $('#loginForm').bind('submit', function() {
+ $('#submit').attr('disabled', 'disabled');
+ $('#reset').attr('disabled', 'disabled');
+ });
});
</script>
<link type="text/css" rel="stylesheet" media="screen" href="../css/login.css">
@@ -16,20 +21,22 @@
<div><img alt="" src="logo_banner.png"></div>
<div style="margin-top:2%">
- <form action="../../dhis-web-commons-security/login.action" method="post">
+ <form id='loginForm' action="../../dhis-web-commons-security/login.action" method="post">
<table>
<tr>
<td><label for="j_username">Username</label></td>
- <td><input type="text" id="j_username" name="j_username" style="width:240px;height:20px;"></td>
+ <td><input type="text" id="j_username" name="j_username" style="width:240px; height:20px;"></td>
</tr>
<tr>
<td><label for="j_password">Password</label></td>
- <td><input type="password" id="j_password" name="j_password" style="width:240px;height:20px;"></td>
+ <td><input type="password" id="j_password" name="j_password" style="width:240px; height:20px;"></td>
</tr>
<tr>
<td></td>
- <td><input type="submit" value="Login" style="width:120px; height:26px;">
- <input type="reset" value="Clear" style="width:120px; height:26px;"></td>
+ <td>
+ <input id='submit' type="submit" value="Login" style="width:120px; height:26px;">
+ <input id='reset' type="reset" value="Clear" style="width:120px; height:26px;">
+ </td>
</tr>
</table>
</form>
=== 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 2011-07-21 11:52:46 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm 2011-08-08 15:09:46 +0000
@@ -17,9 +17,11 @@
#end
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
<script type="text/javascript">
var dateFormat = '$encoder.jsEscape($i18n.getString( 'format.date.label.jquery' ) , "'")';
</script>
+
<script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.ext.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.metadata.js"></script>
@@ -43,6 +45,7 @@
<script type="text/javascript" src="../dhis-web-commons/javascripts/lists.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/periodType.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/date.js"></script>
+ <script type="text/javascript" src="../dhis-web-commons/javascripts/json2.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/validationRules.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.util.js"></script>
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java 2011-07-25 16:37:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java 2011-08-08 15:09:46 +0000
@@ -33,7 +33,8 @@
import java.util.List;
import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
import com.opensymphony.xwork2.Action;
@@ -43,17 +44,15 @@
public class GetOrganisationUnitTreeAction
implements Action
{
- private final static int ALL = 0;
-
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
- private OrganisationUnitService organisationUnitService;
+ private CurrentUserService currentUserService;
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ public void setCurrentUserService( CurrentUserService currentUserService )
{
- this.organisationUnitService = organisationUnitService;
+ this.currentUserService = currentUserService;
}
// -------------------------------------------------------------------------
@@ -71,13 +70,6 @@
// Input & Output
// -------------------------------------------------------------------------
- private Integer level;
-
- public void setLevel( Integer level )
- {
- this.level = level;
- }
-
private List<OrganisationUnit> organisationUnits;
public List<OrganisationUnit> getOrganisationUnits()
@@ -92,15 +84,15 @@
public String execute()
throws Exception
{
- if ( level == null || level == ALL )
+ User user = currentUserService.getCurrentUser();
+
+ if ( user.getOrganisationUnits() != null )
{
- organisationUnits = new ArrayList<OrganisationUnit>(
- organisationUnitService.getOrganisationUnitsAtLevel( 1 ) );
+ organisationUnits = new ArrayList<OrganisationUnit>( user.getOrganisationUnits() );
}
else
{
- organisationUnits = new ArrayList<OrganisationUnit>(
- organisationUnitService.getOrganisationUnitsAtLevel( level ) );
+ organisationUnits = new ArrayList<OrganisationUnit>();
}
Collections.sort( organisationUnits, organisationUnitComparator );
=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/ClearSelectedOrganisationUnitsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/ClearSelectedOrganisationUnitsAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/ClearSelectedOrganisationUnitsAction.java 2011-08-08 15:09:46 +0000
@@ -0,0 +1,62 @@
+package org.hisp.dhis.ouwt.action;
+
+/*
+ * Copyright (c) 2004-2010, 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.ouwt.manager.OrganisationUnitSelectionManager;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author mortenoh
+ */
+public class ClearSelectedOrganisationUnitsAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private OrganisationUnitSelectionManager selectionManager;
+
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+ {
+ this.selectionManager = selectionManager;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ selectionManager.clearSelectedOrganisationUnits();
+
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetSelectedOrganisationUnitsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetSelectedOrganisationUnitsAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/ouwt/action/GetSelectedOrganisationUnitsAction.java 2011-08-08 15:09:46 +0000
@@ -0,0 +1,76 @@
+package org.hisp.dhis.ouwt.action;
+
+/*
+ * Copyright (c) 2004-2010, 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 java.util.Collection;
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author mortenoh
+ */
+public class GetSelectedOrganisationUnitsAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private OrganisationUnitSelectionManager selectionManager;
+
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+ {
+ this.selectionManager = selectionManager;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input/output
+ // -------------------------------------------------------------------------
+
+ private Collection<OrganisationUnit> selectedUnits;
+
+ public Collection<OrganisationUnit> getSelectedUnits()
+ {
+ return selectedUnits;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ selectedUnits = selectionManager.getSelectedOrganisationUnits();
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2011-07-21 15:16:53 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2011-08-08 15:09:46 +0000
@@ -144,6 +144,11 @@
</property>
</bean>
+ <bean id="org.hisp.dhis.ouwt.action.ClearSelectedOrganisationUnitsAction" class="org.hisp.dhis.ouwt.action.ClearSelectedOrganisationUnitsAction"
+ scope="prototype">
+ <property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+ </bean>
+
<bean id="org.hisp.dhis.ouwt.action.SetSelectedOrganisationUnitAction" class="org.hisp.dhis.ouwt.action.SetSelectedOrganisationUnitAction"
scope="prototype">
<property name="organisationUnitService">
@@ -154,6 +159,11 @@
</property>
</bean>
+ <bean id="org.hisp.dhis.ouwt.action.GetSelectedOrganisationUnitsAction" class="org.hisp.dhis.ouwt.action.GetSelectedOrganisationUnitsAction"
+ scope="prototype">
+ <property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+ </bean>
+
<bean id="org.hisp.dhis.ouwt.action.AddSelectedOrganisationUnitAction" class="org.hisp.dhis.ouwt.action.AddSelectedOrganisationUnitAction"
scope="prototype">
<property name="organisationUnitService">
@@ -513,7 +523,7 @@
<bean id="org.hisp.dhis.commons.action.GetOrganisationUnitTreeAction" class="org.hisp.dhis.commons.action.GetOrganisationUnitTreeAction"
scope="prototype">
- <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
<bean id="org.hisp.dhis.commons.action.GetPeriodAction" class="org.hisp.dhis.commons.action.GetPeriodAction"
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2011-07-22 09:17:04 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2011-08-08 15:09:46 +0000
@@ -112,45 +112,53 @@
<action name="expandSubtree" class="org.hisp.dhis.oust.action.ExpandSubtreeAction">
<result name="success" type="velocity">
- /dhis-web-commons/ouwt/responseExpand.vm</result>
+ /dhis-web-commons/ouwt/responseExpand.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getExpandedTree" class="org.hisp.dhis.oust.action.GetExpandedTreeAction">
<result name="success" type="velocity">
- /dhis-web-commons/ouwt/responseTree.vm</result>
+ /dhis-web-commons/ouwt/responseTree.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="setorgunit" class="org.hisp.dhis.oust.action.SetSelectedOrganisationUnitAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ouwt/responseSelect.vm</result>
+ /dhis-web-commons/ouwt/responseSelect.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="addorgunit" class="org.hisp.dhis.oust.action.AddSelectedOrganisationUnitAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ouwt/responseSelect.vm</result>
+ /dhis-web-commons/ouwt/responseSelect.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="removeorgunit" class="org.hisp.dhis.oust.action.RemoveSelectedOrganisationUnitAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ouwt/responseSelect.vm</result>
+ /dhis-web-commons/ouwt/responseSelect.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="clearSelectedOrganisationUnits" class="org.hisp.dhis.oust.action.ClearSelectedOrganisationUnitsAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ouwt/responseSuccess.vm</result>
+ /dhis-web-commons/ouwt/responseSuccess.vm
+ </result>
<result name="error" type="velocity-xml">
- /dhis-web-commons/ouwt/responseError.vm</result>
+ /dhis-web-commons/ouwt/responseError.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="selectallorgunit" class="org.hisp.dhis.oust.action.SelectAllOrganisationUnitAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ouwt/responseSelect.vm</result>
+ /dhis-web-commons/ouwt/responseSelect.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
@@ -162,45 +170,70 @@
<action name="expandSubtree" class="org.hisp.dhis.ouwt.action.ExpandSubtreeAction">
<result name="success" type="velocity">
- /dhis-web-commons/ouwt/responseExpand.vm</result>
+ /dhis-web-commons/ouwt/responseExpand.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="collapseSubtree" class="org.hisp.dhis.ouwt.action.CollapseSubtreeAction">
<result name="success" type="velocity">
- /dhis-web-commons/ouwt/responseCollapse.vm</result>
+ /dhis-web-commons/ouwt/responseCollapse.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getExpandedTree" class="org.hisp.dhis.ouwt.action.GetExpandedTreeAction">
<result name="success" type="velocity">
- /dhis-web-commons/ouwt/responseTree.vm</result>
+ /dhis-web-commons/ouwt/responseTree.vm
+ </result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <action name="clearselected" class="org.hisp.dhis.ouwt.action.ClearSelectedOrganisationUnitsAction">
+ <result name="success" type="velocity-xml">
+ /dhis-web-commons/ouwt/responseSuccess.vm
+ </result>
+ <result name="error" type="velocity-xml">
+ /dhis-web-commons/ouwt/responseError.vm
+ </result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <action name="getselected" class="org.hisp.dhis.ouwt.action.GetSelectedOrganisationUnitsAction">
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ouwt/responseSelect.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="setorgunit" class="org.hisp.dhis.ouwt.action.SetSelectedOrganisationUnitAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ouwt/responseSelect.vm</result>
+ /dhis-web-commons/ouwt/responseSelect.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="addorgunit" class="org.hisp.dhis.ouwt.action.AddSelectedOrganisationUnitAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ouwt/responseSelect.vm</result>
+ /dhis-web-commons/ouwt/responseSelect.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="removeorgunit" class="org.hisp.dhis.ouwt.action.RemoveSelectedOrganisationUnitAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ouwt/responseSelect.vm</result>
+ /dhis-web-commons/ouwt/responseSelect.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOrganisationUnitByCode" class="org.hisp.dhis.ouwt.action.GetOrganisationUnitByCodeAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm
+ </result>
<result name="input" type="velocity-json">
- /dhis-web-commons/ajax/jsonResponseInput.vm</result>
+ /dhis-web-commons/ajax/jsonResponseInput.vm
+ </result>
</action>
<action name="loadOrganisationUnitTree" class="org.hisp.dhis.commons.action.NoAction">
@@ -242,7 +275,7 @@
<action name="translate" class="org.hisp.dhis.i18n.action.TranslateAction">
<result name="success" type="velocity">/dhis-web-commons/i18n/goback.vm
- </result>
+ </result>
<result name="input" type="redirect">
<param name="location">i18n.action</param>
<param name="className">${className}</param>
@@ -255,21 +288,22 @@
<action name="validateAddDuplicatedTranslation" class="org.hisp.dhis.i18n.action.ValidateAddDuplicatedTranslationAction">
<result name="success" type="velocity-xml">/dhis-web-commons/i18n/responseTranslationSuccess.vm
- </result>
+ </result>
<result name="input" type="velocity-xml">/dhis-web-commons/i18n/responseTranslationInput.vm
- </result>
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getTranslations" class="org.hisp.dhis.i18n.action.GetTranslationsAction">
<result name="success" type="velocity">
- /dhis-web-commons/i18n/responseTranslations.vm</result>
+ /dhis-web-commons/i18n/responseTranslations.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="i18nJavaScriptSupport" class="org.hisp.dhis.commons.action.NoAction">
<result name="success" type="velocity-javascript">/dhis-web-commons/i18n/i18n.vm
- </result>
+ </result>
</action>
</package>
@@ -280,115 +314,134 @@
<action name="getCategoryOptionCombos" class="org.hisp.dhis.commons.action.GetCategoryOptionCombosAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlCategoryOptionCombos.vm</result>
+ /dhis-web-commons/ajax/xmlCategoryOptionCombos.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElement" class="org.hisp.dhis.commons.action.GetDataElementAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlDataElement.vm</result>
+ /dhis-web-commons/ajax/xmlDataElement.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElementGroup" class="org.hisp.dhis.commons.action.GetDataElementGroupAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlDataElementGroup.vm</result>
+ /dhis-web-commons/ajax/xmlDataElementGroup.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElementGroups" class="org.hisp.dhis.commons.action.GetDataElementGroupsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/xmlDataElementGroups.vm</result>
+ /dhis-web-commons/ajax/xmlDataElementGroups.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElementGroupSet" class="org.hisp.dhis.commons.action.GetDataElementGroupSetAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/xmlDataElementGroupSet.vm</result>
+ /dhis-web-commons/ajax/xmlDataElementGroupSet.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElements" class="org.hisp.dhis.commons.action.GetDataElementsAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlDataElements.vm</result>
+ /dhis-web-commons/ajax/xmlDataElements.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataSet" class="org.hisp.dhis.commons.action.GetDataSetAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlDataSet.vm</result>
+ /dhis-web-commons/ajax/xmlDataSet.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataSets" class="org.hisp.dhis.commons.action.GetDataSetsAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlDataSets.vm</result>
+ /dhis-web-commons/ajax/xmlDataSets.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getIndicator" class="org.hisp.dhis.commons.action.GetIndicatorAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlIndicator.vm</result>
+ /dhis-web-commons/ajax/xmlIndicator.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getIndicatorGroup" class="org.hisp.dhis.commons.action.GetIndicatorGroupAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlIndicatorGroup.vm</result>
+ /dhis-web-commons/ajax/xmlIndicatorGroup.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getIndicatorGroups" class="org.hisp.dhis.commons.action.GetIndicatorGroupsAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlIndicatorGroups.vm</result>
+ /dhis-web-commons/ajax/xmlIndicatorGroups.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getIndicatorGroupSet" class="org.hisp.dhis.commons.action.GetIndicatorGroupSetAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlIndicatorGroupSet.vm</result>
+ /dhis-web-commons/ajax/xmlIndicatorGroupSet.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getIndicators" class="org.hisp.dhis.commons.action.GetIndicatorsAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlIndicators.vm</result>
+ /dhis-web-commons/ajax/xmlIndicators.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOperands" class="org.hisp.dhis.commons.action.GetOperandsAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlOperands.vm</result>
+ /dhis-web-commons/ajax/xmlOperands.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOrganisationUnit" class="org.hisp.dhis.commons.action.GetOrganisationUnitAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlOrganisationUnit.vm</result>
+ /dhis-web-commons/ajax/xmlOrganisationUnit.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOrganisationUnits" class="org.hisp.dhis.commons.action.GetOrganisationUnitsAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlOrganisationUnits.vm</result>
+ /dhis-web-commons/ajax/xmlOrganisationUnits.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOrganisationUnitChildren" class="org.hisp.dhis.commons.action.GetOrganisationUnitChildrenAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlOrganisationUnits.vm</result>
+ /dhis-web-commons/ajax/xmlOrganisationUnits.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getPeriod" class="org.hisp.dhis.commons.action.GetPeriodAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlPeriod.vm</result>
+ /dhis-web-commons/ajax/xmlPeriod.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getPeriods" class="org.hisp.dhis.commons.action.GetPeriodsAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlPeriods.vm</result>
+ /dhis-web-commons/ajax/xmlPeriods.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
@@ -400,237 +453,277 @@
<action name="getUser" class="org.hisp.dhis.commons.action.GetUserAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonUser.vm</result>
+ /dhis-web-commons/ajax/jsonUser.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getUserRoles" class="org.hisp.dhis.commons.action.GetUserRolesAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonUserRoles.vm</result>
+ /dhis-web-commons/ajax/jsonUserRoles.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getUsers" class="org.hisp.dhis.commons.action.GetUsersAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonUsers.vm</result>
+ /dhis-web-commons/ajax/jsonUsers.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getUserGroups" class="org.hisp.dhis.commons.action.GetUserGroupsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonUserGroups.vm</result>
+ /dhis-web-commons/ajax/jsonUserGroups.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getValidationRules" class="org.hisp.dhis.commons.action.GetValidationRulesAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonValidationRules.vm</result>
+ /dhis-web-commons/ajax/jsonValidationRules.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getCategoryOptionCombos" class="org.hisp.dhis.commons.action.GetCategoryOptionCombosAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonCategoryOptionCombos.vm</result>
+ /dhis-web-commons/ajax/jsonCategoryOptionCombos.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElement" class="org.hisp.dhis.commons.action.GetDataElementAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonDataElement.vm</result>
+ /dhis-web-commons/ajax/jsonDataElement.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElementGroup" class="org.hisp.dhis.commons.action.GetDataElementGroupAction">
<result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/jsonDataElementGroup.vm</result>
+ /dhis-web-commons/ajax/jsonDataElementGroup.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElementGroups" class="org.hisp.dhis.commons.action.GetDataElementGroupsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonDataElementGroups.vm</result>
+ /dhis-web-commons/ajax/jsonDataElementGroups.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElementGroupSets" class="org.hisp.dhis.commons.action.GetDataElementGroupSetsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonDataElementGroupSets.vm</result>
+ /dhis-web-commons/ajax/jsonDataElementGroupSets.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElementsNotInGroup" class="org.hisp.dhis.commons.action.GetDataElementsNotInGroupAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonDataElements.vm</result>
+ /dhis-web-commons/ajax/jsonDataElements.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElementName" class="org.hisp.dhis.commons.action.GetDataElementNameAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonDataElementName.vm</result>
+ /dhis-web-commons/ajax/jsonDataElementName.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElements" class="org.hisp.dhis.commons.action.GetDataElementsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonDataElements.vm</result>
+ /dhis-web-commons/ajax/jsonDataElements.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getSectionDataElements" class="org.hisp.dhis.commons.action.GetSectionDataElementsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonDataElements.vm</result>
+ /dhis-web-commons/ajax/jsonDataElements.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElementCategories" class="org.hisp.dhis.commons.action.GetDataElementCategoriesAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonDataElementCategories.vm</result>
+ /dhis-web-commons/ajax/jsonDataElementCategories.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataSet" class="org.hisp.dhis.commons.action.GetDataSetAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonDataSet.vm</result>
+ /dhis-web-commons/ajax/jsonDataSet.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataSets" class="org.hisp.dhis.commons.action.GetDataSetsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonDataSets.vm</result>
+ /dhis-web-commons/ajax/jsonDataSets.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getIndicator" class="org.hisp.dhis.commons.action.GetIndicatorAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonIndicator.vm</result>
+ /dhis-web-commons/ajax/jsonIndicator.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getIndicatorGroup" class="org.hisp.dhis.commons.action.GetIndicatorGroupAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonIndicatorGroup.vm</result>
+ /dhis-web-commons/ajax/jsonIndicatorGroup.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getIndicatorGroups" class="org.hisp.dhis.commons.action.GetIndicatorGroupsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonIndicatorGroups.vm</result>
+ /dhis-web-commons/ajax/jsonIndicatorGroups.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getIndicatorGroupSet" class="org.hisp.dhis.commons.action.GetIndicatorGroupSetAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonIndicatorGroupSet.vm</result>
+ /dhis-web-commons/ajax/jsonIndicatorGroupSet.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getIndicatorGroupSets" class="org.hisp.dhis.commons.action.GetIndicatorGroupSetsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonIndicatorGroupSets.vm</result>
+ /dhis-web-commons/ajax/jsonIndicatorGroupSets.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getIndicators" class="org.hisp.dhis.commons.action.GetIndicatorsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonIndicators.vm</result>
+ /dhis-web-commons/ajax/jsonIndicators.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getDataElementOperands" class="org.hisp.dhis.commons.action.GetDataElementOperandsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonDataElementOperands.vm</result>
+ /dhis-web-commons/ajax/jsonDataElementOperands.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOperands" class="org.hisp.dhis.commons.action.GetOperandsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonOperands.vm</result>
+ /dhis-web-commons/ajax/jsonOperands.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOrganisationUnit" class="org.hisp.dhis.commons.action.GetOrganisationUnitAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonOrganisationUnit.vm</result>
+ /dhis-web-commons/ajax/jsonOrganisationUnit.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOrganisationUnitGroups" class="org.hisp.dhis.commons.action.GetOrganisationUnitGroupsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonOrganisationUnitGroups.vm</result>
+ /dhis-web-commons/ajax/jsonOrganisationUnitGroups.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOrganisationUnitGroupsByGroupSet" class="org.hisp.dhis.commons.action.GetOrganisationUnitGroupsByGroupSetAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonOrganisationUnitGroups.vm</result>
+ /dhis-web-commons/ajax/jsonOrganisationUnitGroups.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOrganisationUnitGroupSets" class="org.hisp.dhis.commons.action.GetOrganisationUnitGroupSetsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonOrganisationUnitGroupSets.vm</result>
+ /dhis-web-commons/ajax/jsonOrganisationUnitGroupSets.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOrganisationUnitChildren" class="org.hisp.dhis.commons.action.GetOrganisationUnitChildrenAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonOrganisationUnits.vm</result>
+ /dhis-web-commons/ajax/jsonOrganisationUnits.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOrganisationUnitLevels" class="org.hisp.dhis.commons.action.GetOrganisationUnitLevelsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonOrganisationUnitLevels.vm</result>
+ /dhis-web-commons/ajax/jsonOrganisationUnitLevels.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOrganisationUnits" class="org.hisp.dhis.commons.action.GetOrganisationUnitsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonOrganisationUnits.vm</result>
+ /dhis-web-commons/ajax/jsonOrganisationUnits.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getOrganisationUnitTree" class="org.hisp.dhis.commons.action.GetOrganisationUnitTreeAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonOrganisationUnitTree.vm</result>
+ /dhis-web-commons/ajax/jsonOrganisationUnitTree.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getPeriod" class="org.hisp.dhis.commons.action.GetPeriodAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonPeriod.vm</result>
+ /dhis-web-commons/ajax/jsonPeriod.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getPeriods" class="org.hisp.dhis.commons.action.GetPeriodsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonPeriods.vm</result>
+ /dhis-web-commons/ajax/jsonPeriods.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getAvailablePeriods" class="org.hisp.dhis.commons.action.GetAvailablePeriodsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonPeriods.vm</result>
+ /dhis-web-commons/ajax/jsonPeriods.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getConstants" class="org.hisp.dhis.commons.action.GetConstantsAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonConstants.vm</result>
+ /dhis-web-commons/ajax/jsonConstants.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="getExpressionText" class="org.hisp.dhis.commons.action.GetExpressionTextAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm
+ </result>
<result name="error" type="velocity-json">
- /dhis-web-commons/ajax/jsonResponseError.vm</result>
+ /dhis-web-commons/ajax/jsonResponseError.vm
+ </result>
<param name="onExceptionReturn">plainTextError</param>
</action>
<action name="ping" class="org.hisp.dhis.commons.action.NoAction">
<result name="success" type="velocity-json">
- /dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm
+ </result>
</action>
</package>
@@ -695,9 +788,11 @@
<action name="updateUserAccount" class="org.hisp.dhis.useraccount.action.UpdateUserAccountAction">
<result name="success" type="velocity">
- /dhis-web-commons/useraccount/updateUserSuccess.vm</result>
+ /dhis-web-commons/useraccount/updateUserSuccess.vm
+ </result>
<result name="input" type="velocity">
- /dhis-web-commons/useraccount/updateUserInput.vm</result>
+ /dhis-web-commons/useraccount/updateUserInput.vm
+ </result>
</action>
</package>
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/menu.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/menu.vm 2010-11-30 08:54:17 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/menu.vm 2011-08-08 15:09:46 +0000
@@ -1,6 +1,15 @@
+<script type="text/javascript">
+ jQuery(document).ready(function() {
+ selection.setListenerFunction( organisationUnitSelected );
+
+ jQuery("body").bind("ajaxSuccess", function(e, xhr, settings) {
+ if(settings.url.indexOf("getOrganisationUnitTree")) {
+ selection.responseReceived();
+ jQuery("body").unbind("ajaxSuccess");
+ }
+ });
+ });
+</script>
+
<br>
#parse( "/dhis-web-commons/ouwt/orgunittreesearch.vm" )
-
-<script>
-selection.setListenerFunction( organisationUnitSelected );
-</script>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.js 2011-06-14 16:13:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.js 2011-08-08 15:09:46 +0000
@@ -2,13 +2,16 @@
// Organisation unit selection listener
// -----------------------------------------------------------------------------
+$( document ).ready( function()
+{
+ selection.setListenerFunction( organisationUnitSelected );
+} )
+
function organisationUnitSelected( orgUnitIds )
{
window.location.href = 'organisationUnit.action';
}
-selection.setListenerFunction( organisationUnitSelected );
-
// -----------------------------------------------------------------------------
// View details
// -----------------------------------------------------------------------------
@@ -26,25 +29,25 @@
setInnerHTML( 'nameField', getElementValue( unitElement, 'name' ) );
setInnerHTML( 'shortNameField', getElementValue( unitElement, 'shortName' ) );
setInnerHTML( 'openingDateField', getElementValue( unitElement, 'openingDate' ) );
-
+
var orgUnitCode = getElementValue( unitElement, 'code' );
setInnerHTML( 'codeField', orgUnitCode ? orgUnitCode : '[' + none + ']' );
-
- var closedDate = getElementValue( unitElement, 'closedDate' );
+
+ var closedDate = getElementValue( unitElement, 'closedDate' );
setInnerHTML( 'closedDateField', closedDate ? closedDate : '[' + none + ']' );
var commentValue = getElementValue( unitElement, 'comment' );
setInnerHTML( 'commentField', commentValue ? commentValue.replace( /\n/g, '<br>' ) : '[' + none + ']' );
-
+
var active = getElementValue( unitElement, 'active' );
setInnerHTML( 'activeField', active == 'true' ? yes : no );
-
+
var url = getElementValue( unitElement, 'url' );
setInnerHTML( 'urlField', url ? '<a href="' + url + '">' + url + '</a>' : '[' + none + ']' );
-
+
var lastUpdated = getElementValue( unitElement, 'lastUpdated' );
setInnerHTML( 'lastUpdatedField', lastUpdated ? lastUpdated : '[' + none + ']' );
-
+
showDetails();
}
@@ -54,5 +57,5 @@
function removeOrganisationUnit( unitId, unitName )
{
- removeItem( unitId, unitName, confirm_to_delete_org_unit, 'removeOrganisationUnit.action', subtree.refreshTree );
+ removeItem( unitId, unitName, confirm_to_delete_org_unit, 'removeOrganisationUnit.action', subtree.refreshTree );
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnitSearch.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnitSearch.js 2011-03-20 22:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnitSearch.js 2011-08-08 15:09:46 +0000
@@ -1,47 +1,57 @@
+$( document ).ready( function()
+{
+ tableSorter( 'listTable' );
+ initOrgUnitDetails();
+
+ selection.setListenerFunction( organisationUnitSelected );
+ selection.responseReceived();
+} );
function organisationUnitSelected( orgUnitIds )
{
- if ( orgUnitIds[0] && orgUnitIds[0] > 0 ) {
- $.getJSON( "../dhis-web-commons-ajax-json/getOrganisationUnit.action?id=" + orgUnitIds[0], function( data ) {
- $( "#selectedOrganisationUnit" ).val( "[ " + data.organisationUnit.name + " ]" );
- } );
- }
- else {
- $( "#selectedOrganisationUnit" ).val( "[ " + i18n_all + " ]" );
- }
+ if ( orgUnitIds[0] && orgUnitIds[0] > 0 )
+ {
+ $.getJSON( "../dhis-web-commons-ajax-json/getOrganisationUnit.action?id=" + orgUnitIds[0], function( data )
+ {
+ $( "#selectedOrganisationUnit" ).val( "[ " + data.organisationUnit.name + " ]" );
+ } );
+ }
+ else
+ {
+ $( "#selectedOrganisationUnit" ).val( "[ " + i18n_all + " ]" );
+ }
}
-selection.setListenerFunction( organisationUnitSelected );
-
function initOrgUnitDetails()
{
- $( "#organisationUnitDetails" ).dialog( {
- modal:true,
- autoOpen:false,
- width:600,
- height:600
- } );
+ $( "#organisationUnitDetails" ).dialog( {
+ modal : true,
+ autoOpen : false,
+ width : 600,
+ height : 600
+ } );
}
function showOrgUnitDetails( id )
{
- $( "#organisationUnitDetails" ).load( "getOrganisationUnitDetails.action?id=" + id, function() {
- $( "#organisationUnitDetails" ).dialog( "open" );
- } );
+ $( "#organisationUnitDetails" ).load( "getOrganisationUnitDetails.action?id=" + id, function()
+ {
+ $( "#organisationUnitDetails" ).dialog( "open" );
+ } );
}
function download( type )
{
- if ( type != null && type != "" )
- {
- setHeaderWaitDelayMessage( i18n_please_wait_while_downloading );
- }
- else
- {
- setWaitMessage( i18n_please_wait_while_searching );
- }
-
- $( "#type" ).val( type );
-
- document.getElementById( "searchForm" ).submit();
-}
\ No newline at end of file
+ if ( type != null && type != "" )
+ {
+ setHeaderWaitDelayMessage( i18n_please_wait_while_downloading );
+ }
+ else
+ {
+ setWaitMessage( i18n_please_wait_while_searching );
+ }
+
+ $( "#type" ).val( type );
+
+ document.getElementById( "searchForm" ).submit();
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnitSearch.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnitSearch.vm 2011-03-18 14:24:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnitSearch.vm 2011-08-08 15:09:46 +0000
@@ -1,9 +1,4 @@
<script type="text/javascript">
- jQuery( document ).ready( function() {
- tableSorter( 'listTable' );
- initOrgUnitDetails();
- } );
-
var i18n_all = '$encoder.jsEscape( $i18n.getString( "all" ) , "'" )';
var i18n_please_wait_while_downloading = '$encoder.jsEscape( $i18n.getString( "please_wait_while_downloading" ) , "'" )';
var i18n_please_wait_while_searching = '$encoder.jsEscape( $i18n.getString( "please_wait_while_searching" ) , "'" )';