=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java 2013-03-22 06:46:45 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java 2013-05-23 14:28:28 +0000 @@ -34,6 +34,8 @@ import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.indicator.IndicatorGroup; import org.hisp.dhis.indicator.IndicatorGroupSet; +import org.hisp.dhis.patientreport.PatientAggregateReport; +import org.hisp.dhis.patientreport.PatientTabularReport; import org.hisp.dhis.program.Program; import org.hisp.dhis.report.Report; import org.hisp.dhis.reporttable.ReportTable; @@ -104,6 +106,12 @@ SUPPORTED_TYPES.put( "chart", Chart.class ); PUBLIC_AUTHORITIES.put( Chart.class, "F_CHART_PUBLIC_ADD" ); + + SUPPORTED_TYPES.put( "patientTabularReport", PatientTabularReport.class ); + PUBLIC_AUTHORITIES.put( PatientTabularReport.class, "F_PATIENT_TABULAR_REPORT_PUBLIC_ADD" ); + + SUPPORTED_TYPES.put( "patientAggregateReport", PatientAggregateReport.class ); + PUBLIC_AUTHORITIES.put( PatientAggregateReport.class, "F_PATIENT_TABULAR_REPORT_PUBLIC_ADD" ); } public static boolean isSupported( String type ) === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientreport/hibernate/HibernatePatientTabularReportStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientreport/hibernate/HibernatePatientTabularReportStore.java 2013-04-02 04:33:34 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientreport/hibernate/HibernatePatientTabularReportStore.java 2013-05-23 14:28:28 +0000 @@ -27,11 +27,16 @@ package org.hisp.dhis.patientreport.hibernate; +import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; import org.hibernate.Criteria; import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; +import org.hisp.dhis.common.SharingUtils; import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore; import org.hisp.dhis.patientreport.PatientTabularReport; import org.hisp.dhis.patientreport.PatientTabularReportStore; @@ -51,15 +56,60 @@ @Override public Collection get( User user, String query, Integer min, Integer max ) { - return search( user, query, min, max ).list(); + Criteria criteria = getCriteria(); + + if ( query != null ) + { + criteria.add( Restrictions.ilike( "name", "%" + query + "%" ) ); + } + + List result = new ArrayList(); + Collection reports = criteria.list(); + + for ( PatientTabularReport report : reports ) + { + if ( SharingUtils.canRead( user, report ) ) + { + result.add( report ); + } + } + + if( min > result.size() ) + { + min = result.size(); + } + + if( max > result.size() ) + { + max = result.size(); + } + + return result.subList( min, max ); } @Override public int countList( User user, String query ) { - Number rs = (Number) search( user, query, null, null ).setProjection( Projections.rowCount() ).uniqueResult(); - - return rs != null ? rs.intValue() : 0; + Criteria criteria = getCriteria(); + + if ( query != null ) + { + criteria.add( Restrictions.ilike( "name", "%" + query + "%" ) ); + } + + int result = 0; + @SuppressWarnings( "unchecked" ) + Collection reports = criteria.list(); + + for ( PatientTabularReport report : reports ) + { + if ( SharingUtils.canRead( user, report ) ) + { + result++; + } + } + + return result; } // ------------------------------------------------------------------------- @@ -68,18 +118,23 @@ private Criteria search( User user, String query, Integer min, Integer max ) { - Criteria criteria = getCriteria( Restrictions.eq( "user", user ) ); + Criteria criteria = getCriteria(); if ( query != null ) { criteria.add( Restrictions.ilike( "name", "%" + query + "%" ) ); } - if ( min != null && max != null ) + Iterator iterReports = criteria.list().iterator(); + + while ( iterReports.hasNext() ) { - criteria.setFirstResult( min ).setMaxResults( max ); + if ( !SharingUtils.canRead( user, iterReports.next() ) ) + { + iterReports.remove(); + } } - + return criteria; } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientAggregateReport.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientAggregateReport.hbm.xml 2013-02-07 10:25:34 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientAggregateReport.hbm.xml 2013-05-23 14:28:28 +0000 @@ -67,9 +67,6 @@ - - @@ -79,5 +76,18 @@ + + + + + + + + + + + + === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml 2013-05-19 08:24:25 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml 2013-05-23 14:28:28 +0000 @@ -36,9 +36,6 @@ - - @@ -51,6 +48,19 @@ + + + + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-05-21 10:08:44 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-05-23 14:28:28 +0000 @@ -905,7 +905,7 @@ /dhis-web-commons/ajax/jsonResponseSuccess.vm - F_GENERATE_BENEFICIARY_TABULAR_REPORT + F_PATIENT_TABULAR_REPORT_PUBLIC_ADD,F_PATIENT_TABULAR_REPORT_PRIVATE_ADD /dhis-web-commons/ajax/jsonResponseSuccess.vm - F_GENERATE_BENEFICIARY_TABULAR_REPORT + F_PATIENT_AGGREGATE_REPORT_PUBLIC_ADD,F_PATIENT_AGGREGATE_REPORT_PRIVATE_ADD 1) { + body.object.userGroupAccesses = []; + for (var i = 1, item; i < userGroupRowContainer.items.items.length; i++) { + item = userGroupRowContainer.items.items[i]; + body.object.userGroupAccesses.push(item.getAccess()); + } + } + + return body; + }; + + // Initialize + userGroupStore = Ext.create('Ext.data.Store', { + fields: ['id', 'name'], + proxy: { + type: 'ajax', + url: TR.init.path_api + '/sharing/search', + reader: { + type: 'json', + root: 'userGroups' + } + } + }); + + userGroupField = Ext.create('Ext.form.field.ComboBox', { + valueField: 'id', + displayField: 'name', + emptyText: 'Search for user groups', //i18n + queryParam: 'key', + queryDelay: 200, + minChars: 1, + hideTrigger: true, + fieldStyle: 'height:26px; padding-left:6px; border-radius:1px; font-size:11px', + style: 'margin-bottom:5px', + width: 380, + store: userGroupStore, + listeners: { + beforeselect: function(cb) { // beforeselect instead of select, fires regardless of currently selected item + userGroupButton.enable(); + }, + afterrender: function(cb) { + cb.inputEl.on('keyup', function() { + userGroupButton.disable(); + }); + } + } + }); + + userGroupButton = Ext.create('Ext.button.Button', { + text: '+', + style: 'margin-left:2px; padding-right:4px; padding-left:4px; border-radius:1px', + disabled: true, + height: 26, + handler: function(b) { + userGroupRowContainer.add(UserGroupRow({ + id: userGroupField.getValue(), + name: userGroupField.getRawValue(), + access: 'r-------' + })); + + userGroupField.clearValue(); + b.disable(); + } + }); + + userGroupRowContainer = Ext.create('Ext.container.Container', { + bodyStyle: 'border:0 none' + }); + + publicGroup = userGroupRowContainer.add(UserGroupRow({ + id: sharing.object.id, + name: sharing.object.name, + access: sharing.object.publicAccess + }, true, !sharing.meta.allowPublicAccess)); + + if (Ext.isArray(sharing.object.userGroupAccesses)) { + for (var i = 0, userGroupRow; i < sharing.object.userGroupAccesses.length; i++) { + userGroupRow = UserGroupRow(sharing.object.userGroupAccesses[i]); + userGroupRowContainer.add(userGroupRow); + } + } + + window = Ext.create('Ext.window.Window', { + title: 'Sharing layout', + bodyStyle: 'padding:6px 6px 0px; background-color:#fff', + resizable: false, + modal: true, + destroyOnBlur: true, + items: [ + { + html: sharing.object.name, + bodyStyle: 'border:0 none; font-weight:bold; color:#333', + style: 'margin-bottom:8px' + }, + { + xtype: 'container', + layout: 'column', + bodyStyle: 'border:0 none', + items: [ + userGroupField, + userGroupButton + ] + }, + userGroupRowContainer + ], + bbar: [ + '->', + { + text: 'Save', + handler: function() { + Ext.Ajax.request({ + url: TR.conf.finals.ajax.path_api + 'sharing?type=patientTabularReport&id=' + sharing.object.id, + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + params: Ext.encode(getBody()) + }); + + window.destroy(); + } + } + ], + listeners: { + show: function(w) { + var pos = TR.cmp.caseBasedFavorite.window.getPosition(); + w.setPosition(pos[0] + 5, pos[1] + 5); + TR.cmp.caseBasedFavorite.window.destroyOnBlur = false; + }, + destroy: function() { + TR.cmp.caseBasedFavorite.window.destroyOnBlur = true; + } + } + }); + + return window; + }; + TR.viewport = Ext.create('Ext.container.Viewport', { layout: 'border', === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm 2013-05-23 05:47:24 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm 2013-05-23 14:28:28 +0000 @@ -189,5 +189,8 @@ aggregate_options: '$encoder.jsEscape($i18n.getString( 'aggregate_options' ) , "'")', display_totals: '$encoder.jsEscape($i18n.getString( 'display_totals' ) , "'")', options: '$encoder.jsEscape($i18n.getString( 'options' ) , "'")', -hide: '$encoder.jsEscape($i18n.getString( 'hide' ) , "'")' +hide: '$encoder.jsEscape($i18n.getString( 'hide' ) , "'")', +can_view: '$encoder.jsEscape($i18n.getString( 'can_view' ) , "'")', +can_edit_and_view: '$encoder.jsEscape($i18n.getString( 'can_edit_and_view' ) , "'")', +public_access: '$encoder.jsEscape($i18n.getString( 'public_access' ) , "'")' }; \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm 2013-05-19 08:24:25 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm 2013-05-23 14:28:28 +0000 @@ -2,6 +2,7 @@ "user": { "id":"$!currentUser.id", + "name":"$!currentUser.name", "accessPatientAttributes":$auth.hasAccess( "dhis-web-caseentry", "accessPatientAttributes" ), "isAdmin":$!currentUser.userCredentials.isSuper(), "ous":[ === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportList.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportList.vm 2013-04-02 04:33:34 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportList.vm 2013-05-23 14:28:28 +0000 @@ -3,8 +3,17 @@ #foreach( ${tabularReport} in $!{reports} ) { "id": "${tabularReport.id}", + "uid": "${tabularReport.uid}", "name": "$!encoder.jsonEncode( ${tabularReport.name} )", - "lastUpdated": "${tabularReport.lastUpdated}" + "lastUpdated": "${tabularReport.lastUpdated}", + "access": + { + "manage":$security.canManage( $tabularReport ), + "write":$security.canWrite( $tabularReport ), + "read":$security.canRead( $tabularReport ), + "update":$security.canUpdate( $tabularReport ), + "delete":$security.canDelete( $tabularReport ) + } }#if( $velocityCount < $size ),#end #end ], === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties 2013-05-06 06:48:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/resources/org/hisp/dhis/user/i18n_module.properties 2013-05-23 14:28:28 +0000 @@ -181,6 +181,10 @@ F_PATIENT_DASHBOARD = Person Dashboard F_PATIENT_COMMENT_ADD = Add Person Comment F_PATIENT_COMMENT_DELETE = Delete Person Comment +F_PATIENT_AGGREGATE_REPORT_PUBLIC_ADD = Add Public Person Aggregate Report +F_PATIENT_AGGREGATE_REPORT_PRIVATE_ADD = Add Private Person Aggregate Report +F_PATIENT_TABULAR_REPORT_PUBLIC_ADD = Add Public Cased based Report +F_PATIENT_TABULAR_REPORT_PRIVATE_ADD = Add Private Person Aggregate Report F_SCHEDULING_SEND_MESSAGE = Scheduling send messages F_SCHEDULING_CASE_AGGREGATE_QUERY_BUILDER = Scheduling case aggregate query builder F_ACTIVITY_PLAN = Search Activity Plan