dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17679
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7127: (patient) Add filter functionality into columns of Tabular report.
------------------------------------------------------------
revno: 7127
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-06-01 11:31:00 +0700
message:
(patient) Add filter functionality into columns of Tabular report.
added:
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/equals.png
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/greater_than.png
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/less_than.png
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.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-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-06-01 02:04:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-06-01 04:31:00 +0000
@@ -349,4 +349,8 @@
view = View
start_date_must_be_less_then_or_equals_to_end_date = Start date must be less then or equals to end date
is_not_valid = is not valid
-the_date_is_not_valid = The date is not valid
\ No newline at end of file
+the_date_is_not_valid = The date is not valid
+before = Before
+after = After
+on = On
+clear_filter = Clear filter
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2012-05-31 10:17:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2012-06-01 04:31:00 +0000
@@ -706,7 +706,7 @@
orderByOrgunitAsc: true,
orderByExecutionDateByAsc: true,
orgunitId: 0,
- generateReport: function( type ) {
+ generateReport: function( type, isFilter ) {
// Validation
if( !this.validation.objects() )
{
@@ -749,7 +749,6 @@
TR.datatable.getDataTable();
TR.datatable.setPagingToolbarStatus();
- Ext.getCmp('btnFilter').enable();
Ext.getCmp('btnClean').enable();
Ext.getCmp('btnSortBy').enable();
@@ -765,6 +764,32 @@
}
TR.util.notification.ok();
},
+ filterReport: function() {
+ TR.util.mask.showMask(TR.cmp.region.center, TR.i18n.loading);
+ var url = TR.conf.finals.ajax.path_root + TR.conf.finals.ajax.generatetabularreport_get;
+ Ext.Ajax.request({
+ url: url,
+ method: "POST",
+ scope: this,
+ params: this.getParams(),
+ success: function(r) {
+ var json = Ext.JSON.decode(r.responseText);
+ if ( json.items.length > 1 )
+ {
+ TR.store.datatable.loadData(json.items,false);
+ Ext.getCmp('btnClean').enable();
+ Ext.getCmp('btnSortBy').enable();
+ TR.util.notification.ok();
+ TR.util.mask.hideMask();
+ }
+ else
+ {
+ TR.util.mask.hideMask();
+ TR.util.notification.error(TR.i18n.et_no_data, TR.i18n.et_no_data);
+ }
+ }
+ })
+ },
getParams: function() {
var p = {};
p.startDate = TR.cmp.settings.startDate.rawValue;
@@ -930,6 +955,20 @@
return false;
}
+ if( !TR.cmp.settings.startDate.isValid() )
+ {
+ var message = TR.i18n.start_date + " " + TR.i18n.is_not_valid;
+ TR.util.notification.error( message, message);
+ return false;
+ }
+
+ if( !TR.cmp.settings.endDate.isValid() )
+ {
+ var message = TR.i18n.end_date + " " + TR.i18n.is_not_valid;
+ TR.util.notification.error( message, message);
+ return false;
+ }
+
if( TR.cmp.settings.startDate.getValue() > TR.cmp.settings.endDate.getValue() )
{
TR.util.notification.error(TR.i18n.start_date_must_be_less_then_or_equals_to_end_date, TR.i18n.start_date_must_be_less_then_or_equals_to_end_date);
@@ -974,7 +1013,7 @@
covertValueType: function( type )
{
type = type.toLowerCase();
- if( type == 'date' || type == 'list')
+ if( type == 'date' )
{
return type;
}
@@ -1153,69 +1192,7 @@
// Data element columns
TR.cmp.params.dataelement.selected.store.each( function(r) {
- if( r.data.valueType.toLowerCase() == 'date' )
- {
- cols[++index] = {
- header: TR.value.columns[index].name,
- dataIndex: 'col' + index,
- height: TR.conf.layout.east_gridcolumn_height,
- name: r.data.id,
- hidden: eval(TR.value.columns[index].hidden ),
- sortable: false,
- draggable: true,
- isEditAllowed: true,
- emptyText: TR.i18n.et_no_data,
- renderer: Ext.util.Format.dateRenderer( TR.i18n.format_date ),
- filterable: true,
- filter: {
- type:TR.value.covertValueType( r.data.valueType )
- },
- editor: {
- xtype: TR.value.covertXType( r.data.valueType ),
- format: TR.i18n.format_date,
- queryMode: 'local',
- editable: true,
- valueField: 'name',
- displayField: 'name',
- allowBlank: true,
- store: new Ext.data.ArrayStore({
- fields: ['name'],
- data: TR.value.columns[index].suggested
- })
- }
- }
- }
- else
- {
- cols[++index] = {
- header: TR.value.columns[index].name,
- dataIndex: 'col' + index,
- height: TR.conf.layout.east_gridcolumn_height,
- name: r.data.id,
- hidden: eval(TR.value.columns[index].hidden ),
- sortable: false,
- draggable: true,
- isEditAllowed: true,
- emptyText: TR.i18n.et_no_data,
- filterable: true,
- filter: {
- type:TR.value.covertValueType( r.data.valueType ),
- options: TR.value.columns[index].suggested
- },
- editor: {
- xtype: TR.value.covertXType( r.data.valueType ),
- queryMode: 'local',
- editable: true,
- valueField: 'name',
- displayField: 'name',
- allowBlank: true,
- store: new Ext.data.ArrayStore({
- fields: ['name'],
- data: TR.value.columns[index].suggested
- })
- }
- }
- }
+ cols[++index] = TR.datatable.createColumn( r.data.valueType, r.data.id, cols, index );
});
cols[++index]={
@@ -1243,50 +1220,7 @@
}]
}
- this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
- clicksToEdit: 1,
- autoScroll: true,
- errorSummary: true,
- listeners: {
- beforeedit: function( e, editor)
- {
- if( e.rowIdx > 0 && !e.column.isEditAllowed )
- {
- return false;
- }
- },
- edit: function( editor, e ){
- var grid = TR.datatable.datatable;
- grid.getView().getNode(e.rowIdx).classList.remove('hidden');
-
- var oldValue = e.originalValue;
- var newValue = editor.editors.items[0].field.rawValue;
- if( newValue != oldValue)
- {
- // filter
- if( e.rowIdx==0 ){
- TR.exe.execute();
- }
- // save data-value of data element
- else{
- var psiId = TR.store.datatable.getAt(e.rowIdx).data['id'];
- var deId = e.column.name.split('_')[1];
- TR.value.save( psiId, deId, newValue);
- }
- }
- },
- canceledit: function( grid, eOpts ){
- if( e.rowIdx == 0 ){
- var grid = TR.datatable.datatable;
- grid.getView().getNode(0).classList.add('hidden');
- }
- },
- validateedit: function( editor, e, eOpts )
- {
- return true;
- }
- }
- });
+ TR.datatable.initCellEditing();
// grid
this.datatable = Ext.create('Ext.grid.Panel', {
@@ -1298,6 +1232,28 @@
selType: 'cellmodel',
features: [{
ftype: 'filters',
+ autoReload: true,
+ encode: true,
+ local: false,
+ buildQuery : function (filters) {
+ for( var i=0;i<filters.length;i++)
+ {
+ var filter = filters[i];
+ var field = filter.field;
+ var compare = '=';
+ if( filter.data.comparison == 'lt')
+ compare = '<' ;
+ else ( filter.data.comparison == 'gt' )
+ compare = '>' ;
+
+ var value = compare + "'"+ filter.data.value + "'";
+
+ var grid = TR.datatable.datatable;
+ var record = grid.getView().getRecord( grid.getView().getNode(0) );
+ record.set(field, value);
+ }
+ TR.exe.filter();
+ },
filters: []
}],
viewConfig: {
@@ -1417,6 +1373,114 @@
return this.datatable;
},
+ initCellEditing: function(){
+ this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
+ clicksToEdit: 1,
+ autoScroll: true,
+ errorSummary: true,
+ listeners: {
+ beforeedit: function( e, editor)
+ {
+ if( e.rowIdx > 0 && !e.column.isEditAllowed )
+ {
+ return false;
+ }
+ },
+ edit: function( editor, e ){
+ var grid = TR.datatable.datatable;
+ grid.getView().getNode(e.rowIdx).classList.remove('hidden');
+
+ var oldValue = e.originalValue;
+ var newValue = editor.editors.items[0].field.rawValue;
+ if( newValue != oldValue)
+ {
+ // filter
+ if( e.rowIdx==0 ){
+ TR.exe.execute();
+ }
+ // save data-value of data element
+ else{
+ var psiId = TR.store.datatable.getAt(e.rowIdx).data['id'];
+ var deId = e.column.name.split('_')[1];
+ TR.value.save( psiId, deId, newValue);
+ }
+ }
+ },
+ canceledit: function( grid, eOpts ){
+ if( e.rowIdx == 0 ){
+ var grid = TR.datatable.datatable;
+ grid.getView().getNode(0).classList.add('hidden');
+ }
+ },
+ validateedit: function( editor, e, eOpts )
+ {
+ return true;
+ }
+ }
+ });
+ },
+ createColumn: function( type, id, cols, index )
+ {
+ if( type.toLowerCase() == 'date' )
+ {
+ return {
+ header: TR.value.columns[index].name,
+ dataIndex: 'col' + index,
+ name: id,
+ hidden: eval(TR.value.columns[index].hidden ),
+ sortable: false,
+ draggable: true,
+ isEditAllowed: true,
+ renderer: Ext.util.Format.dateRenderer( TR.i18n.format_date ),
+ filter: {
+ type:TR.value.covertValueType( type ),
+ dateFormat: TR.i18n.format_date,
+ beforeText: TR.i18n.before,
+ afterText: TR.i18n.after,
+ onText: TR.i18n.on
+ },
+ editor: {
+ xtype: TR.value.covertXType( type ),
+ format: TR.i18n.format_date,
+ queryMode: 'local',
+ editable: true,
+ valueField: 'name',
+ displayField: 'name',
+ allowBlank: true,
+ store: new Ext.data.ArrayStore({
+ fields: ['name'],
+ data: TR.value.columns[index].suggested
+ })
+ }
+ }
+ }
+
+ return {
+ header: TR.value.columns[index].name,
+ dataIndex: 'col' + index,
+ name: id,
+ hidden: eval(TR.value.columns[index].hidden ),
+ sortable: false,
+ draggable: true,
+ isEditAllowed: true,
+ filter: {
+ type:TR.value.covertValueType( type ),
+ options: TR.value.columns[index].suggested
+ },
+ editor: {
+ xtype: TR.value.covertXType( type ),
+ queryMode: 'local',
+ editable: true,
+ valueField: 'name',
+ displayField: 'name',
+ allowBlank: true,
+ store: new Ext.data.ArrayStore({
+ fields: ['name'],
+ data: TR.value.columns[index].suggested
+ })
+ }
+ }
+ },
setPagingToolbarStatus: function() {
if( TR.state.currentPage == TR.state.total
&& TR.state.total== 1 )
@@ -1452,7 +1516,10 @@
TR.exe = {
execute: function( type ) {
- TR.state.generateReport(type);
+ TR.state.generateReport( type );
+ },
+ filter: function() {
+ TR.state.filterReport();
},
paging: function( currentPage )
{
@@ -1560,7 +1627,9 @@
labelStyle: 'padding-left:3px; font-weight:bold',
labelAlign: 'top',
labelSeparator: '',
- editable: false,
+ editable: true,
+ allowBlank:false,
+ invalidText: TR.i18n.the_date_is_not_valid,
style: 'margin-right:8px',
width: TR.conf.layout.west_fieldset_width / 2 - 4,
format: TR.i18n.format_date,
@@ -1580,7 +1649,9 @@
labelWidth: TR.conf.layout.form_label_width,
labelAlign: 'top',
labelSeparator: '',
- editable: false,
+ editable: true,
+ allowBlank:false,
+ invalidText: TR.i18n.the_date_is_not_valid,
width: TR.conf.layout.west_fieldset_width / 2 - 4,
format: TR.i18n.format_date,
value: new Date(),
@@ -2175,28 +2246,9 @@
TR.exe.execute();
}
},
- {
- xtype: 'button',
- text: TR.i18n.filter,
- id: 'btnFilter',
- disabled: true,
- handler: function() {
- var grid = TR.datatable.datatable;
- var hidden = grid.getView().getNode(0).classList.contains('hidden');
- if( hidden )
- {
- grid.getView().getNode(0).classList.remove('hidden');
- var record = grid.getView().getRecord( grid.getView().getNode(0) );
- grid.getView().getSelectionModel().select(record, false, false);
- }
- else {
- grid.getView().getNode(0).classList.add('hidden');
- }
- }
- },
{
xtype: 'button',
- text: TR.i18n.clear,
+ text: TR.i18n.clear_filter,
id: 'btnClean',
disabled: true,
handler: function() {
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css 2012-05-31 07:17:15 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/css/style.css 2012-06-01 04:31:00 +0000
@@ -717,3 +717,52 @@
.tr-menu-item-desc {
background-image:url('../images/hmenu-desc.gif');
}
+
+/**
+ * GridFilters Styles
+ */
+
+.ux-filtered-column {
+ font-style: italic;
+ font-weight: bold;
+}
+
+.ux-gridfilter-text-icon {
+ background-image: url(../images/find.png) !important;
+}
+
+
+.x-grid3-row-body p {
+ margin:5px 5px 10px 5px !important;
+}
+
+.feature-list {
+ margin-bottom: 15px;
+}
+.feature-list li {
+ list-style: disc;
+ margin-left: 17px;
+ margin-bottom: 4px;
+}
+
+/**
+ * RangeMenu Styles
+ **/
+
+.ux-rangemenu-icon {
+ margin-top: 0;
+}
+
+.ux-rangemenu-gt {
+ background-image: url(../images/greater_than.png) !important;
+}
+
+.ux-rangemenu-lt {
+ background-image: url(../images/less_than.png) !important;
+}
+
+.ux-rangemenu-eq {
+ background-image: url(../images/equals.png) !important;
+}
+
+
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/equals.png'
Binary files dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/equals.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/equals.png 2012-06-01 04:31:00 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/greater_than.png'
Binary files dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/greater_than.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/greater_than.png 2012-06-01 04:31:00 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/less_than.png'
Binary files dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/less_than.png 1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/images/less_than.png 2012-06-01 04:31:00 +0000 differ
=== 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 2012-05-31 04:40:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm 2012-06-01 04:31:00 +0000
@@ -27,6 +27,7 @@
filter:'$encoder.jsEscape($i18n.getString( 'filter' ) , "'")',
cancel:'$encoder.jsEscape($i18n.getString( 'cancel' ) , "'")',
clear:'$encoder.jsEscape($i18n.getString( 'clear' ) , "'")',
+clear_filter:'$encoder.jsEscape($i18n.getString( 'clear_filter' ) , "'")',
show_hide_settings:'$encoder.jsEscape($i18n.getString( 'show_hide_settings' ) , "'")',
updating:'$encoder.jsEscape($i18n.getString( 'updating' ) , "'")',
data_table:'$encoder.jsEscape($i18n.getString( 'data_table' ) , "'")',
@@ -74,4 +75,9 @@
confirmation:'$encoder.jsEscape($i18n.getString( 'confirmation' ) , "'")',
data_entry_form:'$encoder.jsEscape($i18n.getString( 'data_entry_form' ) , "'")',
start_date_must_be_less_then_or_equals_to_end_date:'$encoder.jsEscape($i18n.getString( 'start_date_must_be_less_then_or_equals_to_end_date' ) , "'")',
+is_not_valid:'$encoder.jsEscape($i18n.getString( 'is_not_valid' ) , "'")',
+the_date_is_not_valid:'$encoder.jsEscape($i18n.getString( 'the_date_is_not_valid' ) , "'")',
+before:'$encoder.jsEscape($i18n.getString( 'before' ) , "'")',
+after:'$encoder.jsEscape($i18n.getString( 'after' ) , "'")',
+on:'$encoder.jsEscape($i18n.getString( 'on' ) , "'")'
};
\ No newline at end of file