Skip to content

Commit

Permalink
Add data entry events to approvals app
Browse files Browse the repository at this point in the history
  • Loading branch information
Markionium committed Nov 7, 2016
1 parent bb6aa29 commit 7eadb02
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"sinon": "^1.14.1"
},
"scripts": {
"build": "gulp build-prod",
"test": "gulp test",
"validate": "gulp git:pre-commit"
},
Expand Down
36 changes: 36 additions & 0 deletions src/main/datasets/datasetview-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@
function datasetViewDirective(AppManifest, $translate, dataSetGroupService, $log) {
var dataSetReportWrapSelector = '.dataset-report-wrap';

/**
* Creates the events as they exist in data entry so they can be subscribed to.
* This is needed so that subscriptions to these events in custom forms do not cause the
* form to behave differently between reports and approvals.
*/
(function createDataEntryEvents() {
window.dhis2 = window.dhis2 || {};
dhis2.de = dhis2.de || {};

dhis2.de.event = {
// Fired
formLoaded : "dhis2.de.event.formLoaded",
dataValuesLoaded : "dhis2.de.event.dataValuesLoaded",
formReady : "dhis2.de.event.formReady",
// Never fired in approvals (but can be subscribed to in custom form)
dataValueSaved : "dhis2.de.event.dataValueSaved",
completed : "dhis2.de.event.completed",
uncompleted : "dhis2.de.event.uncompleted",
validationSucces : "dhis2.de.event.validationSuccess",
validationError : "dhis2.de.event.validationError"
};
}());

/**
* Fire a subset of the data entry events, just like in Data Set Report.
*/
function fireDataEntryEvents() {
var $document = $(document);

$document.trigger(dhis2.de.event.formLoaded);
$document.trigger(dhis2.de.event.dataValuesLoaded);
$document.trigger(dhis2.de.event.formReady);
}

function loadDataSetReport(details, ds, element, scope) {
var dataSetReportUrl = AppManifest.activities.dhis.href + '/dhis-web-reporting/generateDataSetReport.action';
var params = {
Expand Down Expand Up @@ -254,6 +288,8 @@ function datasetViewDirective(AppManifest, $translate, dataSetGroupService, $log
} else {
element.find(dataSetReportWrapSelector).append(scope.reportView[$item.id].content);
}

fireDataEntryEvents();
}
} catch (e) {
if (window.console && window.console.error) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/manifest.webapp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"0.4.10","name":"Data Approval","description":"Approvals app for PEPFAR","icons":{"48":"img/icons/dataapproval.png"},"developer":{"url":"http://www.dhis2.org","name":"Mark Polak","company":"DHIS2 Core Team","email":"[email protected]"},"launch_path":"index.html?v=0.4.10","default_locale":"en","activities":{"dhis":{"href":"*"}}}
{"version":"0.5.0","name":"Data Approval","description":"Approvals app for PEPFAR","icons":{"48":"img/icons/dataapproval.png"},"developer":{"url":"http://www.dhis2.org","name":"Mark Polak","company":"DHIS2 Core Team","email":"[email protected]"},"launch_path":"index.html?v=0.5.0","default_locale":"en","activities":{"dhis":{"href":"*"}}}

0 comments on commit 7eadb02

Please sign in to comment.