dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17737
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7180: Implemented option for various styles (css) for custom data entry forms
------------------------------------------------------------
revno: 7180
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-06-04 18:20:41 +0200
message:
Implemented option for various styles (css) for custom data entry forms
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataentryform/hibernate/DataEntryForm.hbm.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartPluginController.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/customForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/AutoSaveDataEntryFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.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-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java 2012-03-27 20:10:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryForm.java 2012-06-04 16:20:41 +0000
@@ -48,6 +48,11 @@
public class DataEntryForm
implements Serializable, ImportableObject
{
+ public static final String STYLE_COMFORTABLE = "comfortable";
+ public static final String STYLE_REGULAR = "regular";
+ public static final String STYLE_COMPACT = "compact";
+ public static final String STYLE_NONE = "none";
+
/**
* Determines if a de-serialized file is compatible with this class.
*/
@@ -65,6 +70,11 @@
* Name of DataEntryForm. Required and unique.
*/
private String name;
+
+ /**
+ * The display style to use to render the form.
+ */
+ private String style;
/**
* HTML Code of DataEntryForm
@@ -90,6 +100,13 @@
this.htmlCode = htmlCode;
}
+ public DataEntryForm( String name, String style, String htmlCode )
+ {
+ this.name = name;
+ this.style = style;
+ this.htmlCode = htmlCode;
+ }
+
// -------------------------------------------------------------------------
// Logic
// -------------------------------------------------------------------------
@@ -141,7 +158,7 @@
throw new IllegalArgumentException( message );
}
}
-
+
// -------------------------------------------------------------------------
// hashCode and equals
// -------------------------------------------------------------------------
@@ -205,6 +222,19 @@
@JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
+ public String getStyle()
+ {
+ return style;
+ }
+
+ public void setStyle( String style )
+ {
+ this.style = style;
+ }
+
+ @JsonProperty
+ @JsonView( {DetailedView.class, ExportView.class} )
+ @JacksonXmlProperty( namespace = Dxf2Namespace.NAMESPACE )
public String getHtmlCode()
{
return htmlCode;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataentryform/hibernate/DataEntryForm.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataentryform/hibernate/DataEntryForm.hbm.xml 2011-05-28 21:25:46 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataentryform/hibernate/DataEntryForm.hbm.xml 2012-06-04 16:20:41 +0000
@@ -12,6 +12,8 @@
<property name="name" not-null="true" unique="true" length="160" />
+ <property name="style" length="40" />
+
<property name="htmlCode" column="htmlcode" type="text" />
</class>
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartPluginController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartPluginController.java 2012-05-28 14:25:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartPluginController.java 2012-06-04 16:20:41 +0000
@@ -141,7 +141,6 @@
.getOrganisationUnit().getChildren() ) );
}
}
-
else
{
organisationUnits = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitsByUid( organisationUnitIds ) );
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css 2012-06-04 12:27:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css 2012-06-04 16:20:41 +0000
@@ -538,31 +538,41 @@
}
/*----------------------------------------------------------------------------*/
-/* Custom forms, put a <div id="cde-comfy"></div> around form to use */
+/* Custom forms dynamic style */
/*----------------------------------------------------------------------------*/
-#cde-comfy table
+.cde table
{
border-collapse: collapse;
}
-#cde-comfy table, #cde-comfy th, #cde-comfy td
-{
- border: 1px solid #c0c0c0;
-}
-
-#cde-comfy td, #cde-comfy th
-{
- height: 30px;
- padding: 10px;
- margin: 10px;
-}
-
.cde-greyfield
{
background-color: #e0e0e0;
}
+.cde-regular td, .cde-regular th
+{
+ padding: 12px;
+ border: 1px solid #c0c0c0;
+}
+
+.cde-comfortable td, .cde-comfortable th
+{
+ padding: 18px;
+ border: 1px solid #c0c0c0;
+}
+
+.cde-compact td, .cde-compact th
+{
+ padding: 5px;
+ border: 1px solid #c0c0c0;
+}
+
+.cde-none
+{
+}
+
/*----------------------------------------------------------------------------*/
/* jQuery overrides */
/*----------------------------------------------------------------------------*/
@@ -585,3 +595,11 @@
font-weight: normal;
font-size: 10pt;
}
+
+.ui-button-text
+{
+ font-family: LiberationSansBold, arial, sans-serif;
+ font-weight: normal;
+ font-size: 9pt;
+}
+
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2012-05-16 19:30:54 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2012-06-04 16:20:41 +0000
@@ -574,7 +574,7 @@
window.clearTimeout( headerMessageTimeout );
- headerMessageTimeout = window.setTimeout( "hideHeaderMessage();", 8000 );
+ headerMessageTimeout = window.setTimeout( "hideHeaderMessage();", 7000 );
}
/**
@@ -586,7 +586,7 @@
window.clearTimeout( headerMessageTimeout );
- headerMessageTimeout = window.setTimeout( "hideHeaderMessage();", 8000 );
+ headerMessageTimeout = window.setTimeout( "hideHeaderMessage();", 7000 );
}
/**
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2012-02-16 19:58:55 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2012-06-04 16:20:41 +0000
@@ -117,6 +117,13 @@
{
return this.customDataEntryFormCode;
}
+
+ private DataEntryForm dataEntryForm;
+
+ public DataEntryForm getDataEntryForm()
+ {
+ return dataEntryForm;
+ }
private List<Section> sections;
@@ -312,7 +319,7 @@
private void getOtherDataEntryForm( List<DataElement> dataElements, DataSet dataSet )
{
- DataEntryForm dataEntryForm = dataSet.getDataEntryForm();
+ dataEntryForm = dataSet.getDataEntryForm();
if ( dataEntryForm != null )
{
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/customForm.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/customForm.vm 2011-08-27 11:43:07 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/customForm.vm 2012-06-04 16:20:41 +0000
@@ -1,1 +1,5 @@
+
+#set( $css = "cde cde-${dataEntryForm.style}" )
+<div class="${css}">
$customDataEntryFormCode
+</div>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/AutoSaveDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/AutoSaveDataEntryFormAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/AutoSaveDataEntryFormAction.java 2012-06-04 16:20:41 +0000
@@ -77,6 +77,13 @@
this.nameField = nameField;
}
+ private String style;
+
+ public void setStyle( String style )
+ {
+ this.style = style;
+ }
+
private String designTextarea;
public void setDesignTextarea( String designTextarea )
@@ -100,23 +107,24 @@
{
DataSet dataset = dataSetService.getDataSet( dataSetIdField );
- DataEntryForm dataEntryForm = dataset.getDataEntryForm();
+ DataEntryForm form = dataset.getDataEntryForm();
- if ( dataEntryForm == null )
+ if ( form == null )
{
- dataEntryForm = new DataEntryForm( nameField, dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
- int id = dataEntryFormService.addDataEntryForm( dataEntryForm );
+ form = new DataEntryForm( nameField, style, dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
+ int id = dataEntryFormService.addDataEntryForm( form );
message = String.valueOf( id );
- dataset.setDataEntryForm( dataEntryForm );
+ dataset.setDataEntryForm( form );
dataSetService.updateDataSet( dataset );
}
else
{
- dataEntryForm.setName( nameField );
- dataEntryForm.setHtmlCode( dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
- dataEntryFormService.updateDataEntryForm( dataEntryForm );
- message = String.valueOf( dataEntryForm.getId() );
+ form.setName( nameField );
+ form.setStyle( style );
+ form.setHtmlCode( dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
+ dataEntryFormService.updateDataEntryForm( form );
+ message = String.valueOf( form.getId() );
}
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/SaveDataEntryFormAction.java 2012-06-04 16:20:41 +0000
@@ -77,6 +77,13 @@
this.nameField = nameField;
}
+ private String style;
+
+ public void setStyle( String style )
+ {
+ this.style = style;
+ }
+
private String designTextarea;
public void setDesignTextarea( String designTextarea )
@@ -95,24 +102,26 @@
designTextarea = dataEntryFormService.prepareDataEntryFormForSave( designTextarea );
- DataEntryForm dataEntryForm = dataset.getDataEntryForm();
+ DataEntryForm form = dataset.getDataEntryForm();
- if ( !( dataEntryForm != null && dataEntryForm.getHtmlCode().equals( designTextarea ) ) )
+ if ( ( form != null && form.getStyle() != null && !form.getStyle().equals( style ) ) ||
+ ( form != null && form.getHtmlCode() != null && !form.getHtmlCode().equals( designTextarea ) ) )
{
dataset.increaseVersion(); // Check if version must be updated
}
- if ( dataEntryForm == null )
+ if ( form == null )
{
- dataEntryForm = new DataEntryForm( nameField, dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
- dataEntryFormService.addDataEntryForm( dataEntryForm );
- dataset.setDataEntryForm( dataEntryForm );
+ form = new DataEntryForm( nameField, style, dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
+ dataEntryFormService.addDataEntryForm( form );
+ dataset.setDataEntryForm( form );
}
else
{
- dataEntryForm.setName( nameField );
- dataEntryForm.setHtmlCode( dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
- dataEntryFormService.updateDataEntryForm( dataEntryForm );
+ form.setName( nameField );
+ form.setStyle( style );
+ form.setHtmlCode( dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
+ dataEntryFormService.updateDataEntryForm( form );
}
dataSetService.updateDataSet( dataset );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties 2012-05-22 12:31:44 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties 2012-06-04 16:20:41 +0000
@@ -81,3 +81,9 @@
grey_field=Grey field
totals=Totals
expiry_days=Expiry Days
+insert_data_elements_totals_indicators=Insert data elements, totals and indicators
+style=Style
+comfortable=Comfortable
+regular=Regular
+compact=Compact
+none=None
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js 2012-04-23 20:19:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/dataEntryForm.js 2012-06-04 16:20:41 +0000
@@ -47,12 +47,14 @@
function saveDataEntryForm()
{
+ var style = $("#style").val();
var field = $("#designTextarea").ckeditorGet();
var designTextarea = field.getData();
$.postUTF8( 'autoSaveDataEntryForm.action',
{
nameField: getFieldValue('nameField'),
+ style: style,
designTextarea: designTextarea,
dataSetIdField: getFieldValue('dataSetIdField'),
dataEntryFormId: dataEntryFormId
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js 2012-04-23 13:42:38 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js 2012-06-04 16:20:41 +0000
@@ -188,15 +188,6 @@
$sorted.appendTo( select_selector );
}
-function showThenFadeOutMessage( message )
-{
- $("#message_").html(message);
- $("#message_").fadeOut(3000, function() {
- $("#message_").html("");
- $("#message_").show();
- });
-}
-
function insertDataElement() {
var oEditor = $("#designTextarea").ckeditorGet();
var $option = $("#dataElementSelector option:selected");
@@ -232,10 +223,10 @@
if (!checkExisted(dataEntryId)) {
oEditor.insertHtml(html);
} else {
- showThenFadeOutMessage( "<b>" + i18n_dataelement_already_inserted + "</b>" );
+ setHeaderDelayMessage( i18n_dataelement_already_inserted );
}
} else {
- showThenFadeOutMessage( "<b>" + i18n_no_dataelement_was_selected + "</b>" );
+ setHeaderDelayMessage( i18n_no_dataelement_was_selected );
}
}
@@ -253,10 +244,10 @@
if(!checkExisted(dataEntryId)) {
oEditor.insertHtml( template );
} else {
- showThenFadeOutMessage( "<b>" + i18n_dataelement_already_inserted + "</b>" );
+ setHeaderDelayMessage( i18n_dataelement_already_inserted );
}
} else {
- showThenFadeOutMessage( "<b>" + i18n_no_dataelement_was_selected + "</b>" );
+ setHeaderDelayMessage( i18n_no_dataelement_was_selected );
}
}
@@ -272,10 +263,10 @@
if(!checkExisted("indicator" + id)) {
oEditor.insertHtml( template );
} else {
- showThenFadeOutMessage( "<b>" + i18n_indicator_already_inserted + "</b>" );
+ setHeaderDelayMessage( i18n_indicator_already_inserted );
}
} else {
- showThenFadeOutMessage( "<b>" + i18n_no_indicator_was_selected + "</b>" );
+ setHeaderDelayMessage( i18n_no_indicator_was_selected );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm 2012-04-23 20:19:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/viewDataEntryForm.vm 2012-06-04 16:20:41 +0000
@@ -82,11 +82,6 @@
</script>
<style type="text/css">
-#message_{
- display:block;
- color:red;
-}
-
.ui-state-active2, .ui-widget-content .ui-state-active2, .ui-widget-header .ui-state-active2 {
border: 1px solid #79b7e7;
background: #f5f8f9;
@@ -124,6 +119,17 @@
<td><input type="text" value="$dataSet.name" style="width:20em" disabled /></td>
</tr>
<tr>
+ <td><label>$i18n.getString( "style" )</label></td>
+ <td>
+ <select id="style" name="style" style="width:20em">
+ <option value="regular"#if( !$dataEntryForm.style || "regular" == $dataEntryForm.style ) selected=selected#end>$i18n.getString( "regular" )</option>
+ <option value="comfortable"#if( "comfortable" == $dataEntryForm.style ) selected=selected#end>$i18n.getString( "comfortable" )</option>
+ <option value="compact"#if( "compact" == $dataEntryForm.style ) selected=selected#end>$i18n.getString( "compact" )</option>
+ <option value="none"#if( "none" == $dataEntryForm.style ) selected=selected#end>$i18n.getString( "none" )</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
<td colspan="2"> </td>
</tr>
</tbody>
@@ -159,35 +165,32 @@
<input type="hidden" name="dataSetIdField" id="dataSetIdField" value="${dataSet.id}" />
</form>
-<div id="selectionDialog" title="Selection Box">
+<div id="selectionDialog" title="$i18n.getString( 'insert_data_elements_totals_indicators' )">
<div id="tabs">
<table style="width: 100%;">
<tr id="dataElementsTab">
- <td colspan="2">
+ <td>
<select id="dataElementSelector" multiple="multiple" style="height: 200px; width: 100%;"></select>
</td>
</tr>
<tr id="totalsTab">
- <td colspan="2">
+ <td>
<select id="totalSelector" multiple="multiple" style="height: 200px; width: 100%;"></select>
</td>
</tr>
<tr id="indicatorsTab">
- <td colspan="2">
+ <td>
<select id="indicatorSelector" multiple="multiple" style="height: 200px; width: 100%;"></select>
</td>
</tr>
<tr>
- <td>
+ <td style="height: 45px">
<button type="button" id="dataElementsButton">$i18n.getString( "data_elements" )</button>
<button type="button" id="totalsButton">$i18n.getString( "totals" )</button>
<button type="button" id="indicatorsButton">$i18n.getString( "indicators" )</button> <span style="color:#606060">|</span>
<button type="button" id="insertButton">$i18n.getString( "insert" )</button>
<input type="checkbox" id="greyedField"><label for="greyedField">$i18n.getString( "grey_field" )</label>
</td>
- <td style="width:145px">
- <span id="message_"></span>
- </td>
</tr>
</table>
</div>