dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14805
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5128: local vn - Fixed problem in previewing file and allow to print the draft file with the applied st...
------------------------------------------------------------
revno: 5128
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-11-09 14:34:53 +0700
message:
local vn - Fixed problem in previewing file and allow to print the draft file with the applied style.
added:
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/jQuery/
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/jQuery/jquery.jqprint.0.3.js
modified:
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java
local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/generateReportForm.vm
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/style/previewStyle.css
--
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 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java 2011-11-03 04:26:28 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportNormalAction.java 2011-11-09 07:34:53 +0000
@@ -32,8 +32,8 @@
import org.apache.poi.ss.usermodel.Sheet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.reportsheet.ExportItem;
import org.hisp.dhis.reportsheet.ExportReport;
-import org.hisp.dhis.reportsheet.ExportItem;
import org.hisp.dhis.reportsheet.ExportReportNormal;
import org.hisp.dhis.reportsheet.exporting.AbstractGenerateExcelReportSupport;
import org.hisp.dhis.reportsheet.utils.ExcelUtils;
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java 2011-11-03 04:26:28 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java 2011-11-09 07:34:53 +0000
@@ -41,8 +41,8 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.reportsheet.ExportItem;
import org.hisp.dhis.reportsheet.ExportReport;
-import org.hisp.dhis.reportsheet.ExportItem;
import org.hisp.dhis.reportsheet.ExportReportOganiztionGroupListing;
import org.hisp.dhis.reportsheet.exporting.AbstractGenerateExcelReportSupport;
import org.hisp.dhis.reportsheet.utils.ExcelUtils;
@@ -218,5 +218,4 @@
}
}
}
-
}
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java 2011-11-03 04:26:28 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java 2011-11-09 07:34:53 +0000
@@ -294,6 +294,8 @@
if ( format != null )
{
xml.append( "<format align='" + convertAlignmentString( format.getAlignment() ) + "'" );
+ xml.append( " border='" + format.getBorderBottom() + format.getBorderLeft() + format.getBorderRight()
+ + format.getBorderTop() + "'" );
Font font = WORKBOOK.getFontAt( format.getFontIndex() );
@@ -301,11 +303,11 @@
{
xml.append( " valign='" + convertVerticalString( format.getVerticalAlignment() ) + "'>" );
- xml.append( "<font point_size='" + font.getFontHeightInPoints() + "'" );
- xml.append( " bold_weight='" + font.getBoldweight() + "'" );
+ xml.append( "<font size='" + font.getFontHeightInPoints() + "'" );
+ xml.append( " bold='" + font.getBoldweight() + "'" );
xml.append( " italic='" + font.getItalic() + "'" );
xml.append( " underline='" + UnderlinePatterns.valueOf( font.getUnderline() ).name() + "'" );
- xml.append( " colour='" + font.getColor() + "'" );
+ xml.append( " color='" + font.getColor() + "'" );
xml.append( " />" );
// The cell background information
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 2011-10-13 03:03:58 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 2011-11-09 07:34:53 +0000
@@ -476,7 +476,7 @@
<param name="stylesheets">style/previewStyle.css</param>
<param name="javascripts">
../dhis-web-commons/ouwt/ouwt.js,
- ../dhis-web-commons/javascripts/jQuery/jquery.jqprint.0.3.js,
+ javascript/jQuery/jquery.jqprint.0.3.js,
javascript/export.js,
javascript/preview.js
</param>
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/generateReportForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/generateReportForm.vm 2011-10-13 03:03:58 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/generateReportForm.vm 2011-11-09 07:34:53 +0000
@@ -31,27 +31,27 @@
</tr>
</table>
</div>
+
<hr/>
+
<p>
-<input type="button" id="previewButton" value="$i18n.getString( 'preview_report' )" onclick="validatePreviewReport();" style="width:150px"/>
-<input type="button" id="generateExportReport" value='$i18n.getString( "generate_export_report" )' onclick="validateGenerateReport();" style="width:150px"/>
-<input type="button" id="printExcelReportButton" value='$i18n.getString("print")' onclick='printExportReport()' disabled style="width:150px"/>
+ <input type="button" id="previewButton" value="$i18n.getString( 'preview_report' )" onclick="validatePreviewReport();" style="width:150px"/>
+ <input type="button" id="generateExportReport" value='$i18n.getString( "generate_export_report" )' onclick="validateGenerateReport();" style="width:150px"/>
+ <input type="button" id="printExcelReportButton" value='$i18n.getString("print")' onclick='printExportReport()' style="width:150px"/>
</p>
+
<div id="previewDiv"></div>
<script>
-
var i18n_select_period = '$encoder.jsEscape( $i18n.getString( "select_period" ) , "'")';
var i18n_value_rounded = '$encoder.jsEscape( $i18n.getString("value_rounded"), "'" )';
var i18n_specify_export_report = '$encoder.jsEscape( $i18n.getString("specify_export_report"), "'" )';
#if ( $organisationUnit )
-
$(document).ready(function()
{
- getExportReportsByGroup();
+ getExportReportsByGroup( '$organisationUnit.name' );
});
-
#else
disable("group");
disable("exportReport");
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js 2011-10-13 03:03:58 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/export.js 2011-11-09 07:34:53 +0000
@@ -9,34 +9,33 @@
var currentPeriodTypeName = '';
// Functions
-function organisationUnitSelected( orgUnits )
-{
- getExportReportsByGroup();
+function organisationUnitSelected( orgUnits, orgUnitNames )
+{
+ getExportReportsByGroup( orgUnitNames[0] );
}
selection.setListenerFunction( organisationUnitSelected );
-function getExportReportsByGroup() {
+function getExportReportsByGroup( selectedOrgUnitName ) {
- jQuery.postJSON( 'getExportReportsByGroup.action',
- {
- group: getFieldValue( 'group' )
- },
- function ( json )
- {
- jQuery('#exportReport').empty();
- jQuery.each( json.exportReports, function(i, item){
- addOptionById( 'exportReport', item.id + '_' + item.flag, item.name );
- });
-
- currentPeriodOffset = 0;
- reportSelected();
- displayPeriodsInternal();
+ if ( selectedOrgUnitName )
+ {
+ setInnerHTML( "selectedOrganisationUnit", selectedOrgUnitName );
- var selectedOrganisationUnit = null;
+ jQuery.postJSON( 'getExportReportsByGroup.action',
+ {
+ group: getFieldValue( 'group' )
+ },
+ function ( json )
+ {
+ jQuery('#exportReport').empty();
+ jQuery.each( json.exportReports, function(i, item){
+ addOptionById( 'exportReport', item.id + '_' + item.flag, item.name );
+ });
- try {
- selectedOrganisationUnit = json.organisationUnit;
+ currentPeriodOffset = 0;
+ reportSelected();
+ displayPeriodsInternal();
enable("group");
enable("exportReport");
@@ -45,36 +44,42 @@
enable("previewButton");
enable("nextPeriod");
enable("lastPeriod");
- }catch(e){
- disable("group");
- disable("exportReport");
- disable("selectedPeriodId");
- disable("generateExportReport");
- disable("previewButton");
- disable("nextPeriod");
- disable("lastPeriod");
- }
-
- setInnerHTML( "selectedOrganisationUnit", selectedOrganisationUnit );
- });
+ });
+ } else {
+ disable("group");
+ disable("exportReport");
+ disable("selectedPeriodId");
+ disable("generateExportReport");
+ disable("previewButton");
+ disable("nextPeriod");
+ disable("lastPeriod");
+ }
}
function reportSelected()
{
- currentPeriodTypeName = (getFieldValue( 'exportReport' ).split( '_' )[1] == "true") ? 'Daily' : 'Monthly';
+ var value = getFieldValue( 'exportReport' );
+
+ if ( value && value != null )
+ {
+ currentPeriodTypeName = (value.split( '_' )[1] == "true") ? 'Daily' : 'Monthly';
+ }
}
function displayPeriodsInternal()
{
- var periods = periodTypeFactory.get( currentPeriodTypeName ).generatePeriods( currentPeriodOffset );
- periods = periodTypeFactory.filterFuturePeriods( periods );
-
- clearListById( 'selectedPeriodId' );
-
- for ( i in periods )
- {
- addOptionById( 'selectedPeriodId', periods[i].id, periods[i].name );
- }
+ if ( currentPeriodTypeName )
+ {
+ var periods = periodTypeFactory.get( currentPeriodTypeName ).generatePeriods( currentPeriodOffset );
+ periods = periodTypeFactory.filterFuturePeriods( periods );
+
+ clearListById( 'selectedPeriodId' );
+
+ for ( i in periods )
+ {
+ addOptionById( 'selectedPeriodId', periods[i].id, periods[i].name );
+ }
+ }
}
function getNextPeriod()
=== added directory 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/jQuery'
=== added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/jQuery/jquery.jqprint.0.3.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/jQuery/jquery.jqprint.0.3.js 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/jQuery/jquery.jqprint.0.3.js 2011-11-09 07:34:53 +0000
@@ -0,0 +1,76 @@
+// -----------------------------------------------------------------------
+// Eros Fratini - eros@xxxxxxxxxxx
+// jqprint 0.3
+//
+// - 19/06/2009 - some new implementations, added Opera support
+// - 11/05/2009 - first sketch
+//
+// Printing plug-in for jQuery, evolution of jPrintArea: http://plugins.jquery.com/project/jPrintArea
+// requires jQuery 1.3.x
+//
+// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
+//------------------------------------------------------------------------
+
+(function($) {
+ var opt;
+
+ $.fn.jqprint = function (options) {
+ opt = $.extend({}, $.fn.jqprint.defaults, options);
+
+ var $element = (this instanceof jQuery) ? this : $(this);
+
+ if (opt.operaSupport && $.browser.opera)
+ {
+ var tab = window.open("","jqPrint-preview");
+ tab.document.open();
+
+ var doc = tab.document;
+ }
+ else
+ {
+ var $iframe = $("<iframe />");
+
+ if (!opt.debug) { $iframe.css({ position: "absolute", width: "0px", height: "0px", left: "-600px", top: "-600px" }); }
+
+ $iframe.appendTo("body");
+ var doc = $iframe[0].contentWindow.document;
+ }
+
+ if (opt.importCSS)
+ {
+ if ($("link[media=print]").length > 0)
+ {
+ $("link[media=print]").each( function() {
+ doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' media='print' />");
+ });
+ }
+ else
+ {
+ $("link").each( function() {
+ doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' />");
+ });
+ }
+ }
+
+ if (opt.printContainer) { doc.write( opt.CSS + $element.outer() ); }
+ else { $element.each( function() { doc.write($(this).html()); }); }
+
+ doc.close();
+
+ (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).focus();
+ setTimeout( function() { (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).print(); if (tab) { tab.close(); } }, 1000);
+ }
+
+ $.fn.jqprint.defaults = {
+ debug: false,
+ importCSS: true,
+ CSS: '',
+ printContainer: true,
+ operaSupport: true
+ };
+
+ // Thanks to 9__, found at http://users.livejournal.com/9__/380664.html
+ jQuery.fn.outer = function() {
+ return $($('<div></div>').html(this.clone())).html();
+ }
+})(jQuery);
\ No newline at end of file
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js 2011-11-03 09:28:41 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/preview.js 2011-11-09 07:34:53 +0000
@@ -93,7 +93,7 @@
contentsHTML += '<div id="tabs-' + s + '">';
- _sHTML = "<table class='ui-widget-content'>";
+ _sHTML = "<table class='ui-preview-table'>";
for (var i = 0 ; i < _rows.length ; i ++)
{
@@ -110,13 +110,14 @@
// Printing out the unformatted cells
for (; _index < _number ; _index ++)
{
- _sHTML += "<td class='ui-widget-content'/>";
+ _sHTML += "<td/>";
}
if ( _index == _number )
{
var _sData = getElementValue( _cols[j], 'data' );
var _align = getElementAttribute( _cols[j], 'format', 'align' );
+ var _border = getElementAttribute( _cols[j], 'format', 'border' );
// If this cell is merged - Key's form: Sheet#Row#Col
_sPattern = _orderSheet + "#" + i + "#" + _number;
@@ -126,16 +127,18 @@
j = Number(j) + Number(_colspan);
_index = Number(_index) + Number(_colspan);
- _sHTML += "<td align='" + _align + "' colspan='" + _colspan + "' ";
- _sHTML += "class='ui-widget-content";
+ _sHTML += "<td align='" + _align + "' colspan='" + _colspan + "'";
+ _sHTML += " class='printclass";
+ _sHTML += _border > 0 ? " ui-widget-content" : "";
+ // Preview without importing
if ( keyId && keyId.length > 0 )
{
- _sHTML += " ui-unselected' id='" + keyId;
+ _sHTML += " ui-preview-unselected' id='" + keyId;
}
- else if ( !isImport && parseFloat(_sData) )
+ else if ( !isImport && isRealNumber(_sData) )
{
- _sHTML += " ui-normal";
+ _sHTML += " ui-preview-normal";
}
_sHTML += "'>" + _sData + "</td>";
@@ -163,18 +166,18 @@
function applyStyleIntoPreview()
{
- importlist = jQuery( 'table.ui-widget-content tr > td.ui-unselected' );
+ importlist = jQuery( 'table.ui-widget-content tr > td.ui-preview-unselected' );
if ( importlist.length > 0 )
{
importlist.mouseover(function()
{
- jQuery(this).addClass( 'ui-mouseover' );
+ jQuery(this).addClass( 'ui-preview-mouseover' );
});
importlist.mouseout(function()
{
- jQuery(this).removeClass( 'ui-mouseover' );
+ jQuery(this).removeClass( 'ui-preview-mouseover' );
});
importlist.click(function()
@@ -189,7 +192,7 @@
}
else importItemIds.push( idTemp );
- jQuery(this).toggleClass( 'ui-selected' );
+ jQuery(this).toggleClass( 'ui-preview-selected' );
});
}
}
@@ -208,6 +211,13 @@
function printExportReport()
{
+ var htmlStyle = "<style type='text/css'>";
+ htmlStyle += "td.printclass { font-size: 12px; }";
+ htmlStyle += ".ui-preview-table{ border-collapse: collapse; }";
+ htmlStyle += ".ui-preview-normal{ font-weight: bold; color: blue }";
+ htmlStyle += ".ui-widget-content { border: 1px solid #a6c9e2; background: #fcfdfd url(images/ui-bg_inset-hard_100_fcfdfd_1x100.png) 50% bottom repeat-x; color: #222222; }";
+ htmlStyle += "</style>";
+
var tab = jQuery('#tabs').tabs('option', 'selected');
- jQuery( "#tabs-" + tab ).jqprint();
+ jQuery( "#tabs-" + tab ).jqprint( {CSS : htmlStyle} );
}
\ No newline at end of file
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/style/previewStyle.css'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/style/previewStyle.css 2011-07-28 09:50:39 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/style/previewStyle.css 2011-11-09 07:34:53 +0000
@@ -1,4 +1,5 @@
-.ui-normal{ font-weight: bold; color: blue }
-.ui-unselected{ font-weight: bold; color: blue; cursor:pointer }
-.ui-selected{ background: #F39814; color: white; cursor:pointer }
-.ui-mouseover{ background: #FECA40; color: white; cursor:pointer }
+.ui-preview-table{ border-collapse: collapse; }
+.ui-preview-normal{ font-weight: bold; color: blue }
+.ui-preview-unselected{ font-weight: bold; color: blue; cursor:pointer }
+.ui-preview-selected{ background: #F39814; color: white; cursor:pointer }
+.ui-preview-mouseover{ background: #FECA40; color: white; cursor:pointer }