Skip to content

Commit

Permalink
BAH-3049| Deepti,Sweety | Fix start date undefined value
Browse files Browse the repository at this point in the history
  • Loading branch information
deeptirawat1510 committed Nov 29, 2023
1 parent c5beb59 commit 061b404
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion ui/app/i18n/reports/locale_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
"CHOOSE_ANSWER_FROM_DROPDOWN_LABEL": "Choose Answer",
"DELETE_LABEL": "Delete",
"EDIT_LABEL": "Edit",
"REPORT_DATE_RANGE": "Select Date Range"
"REPORT_DATE_RANGE": "Select Date Range",
"START_DATE_CANNOT_LATER_THAN_STOP_DATE": "start date can not be later than stop date"
}
10 changes: 9 additions & 1 deletion ui/app/reports/controllers/reportsController.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
'use strict';

angular.module('bahmni.reports')
.controller('ReportsController', ['$scope', 'appService', 'reportService', 'FileUploader', 'messagingService', 'spinner', '$rootScope', 'auditLogService', function ($scope, appService, reportService, FileUploader, messagingService, spinner, $rootScope, auditLogService) {
.controller('ReportsController', ['$scope', 'appService', 'reportService', 'FileUploader', 'messagingService', 'spinner', '$rootScope', '$translate', 'auditLogService', function ($scope, appService, reportService, FileUploader, messagingService, spinner, $rootScope, $translate, auditLogService) {
const format = _.values(reportService.getAvailableFormats());
const dateRange = _.values(reportService.getAvailableDateRange());

var getTranslatedMessage = function (key) {
return $translate.instant(key);
};

$scope.uploader = new FileUploader({
url: Bahmni.Common.Constants.uploadReportTemplateUrl,
removeAfterUpload: true,
Expand Down Expand Up @@ -38,6 +42,7 @@ angular.module('bahmni.reports')
report['stopDate'] = isPreviousMonth($rootScope.default[header][item]) ? getPreviousMonthEndDate() : dateRange[0];
}
else if ($rootScope.default[header][item] === undefined) {
$rootScope.default.reportsRequiringDateRange.startDate = dateRange[0];
$rootScope.reportsRequiringDateRange.forEach(function (report) {
report.startDate = dateRange[0];
report.stopDate = isPreviousMonth(dateRange[0]) ? getPreviousMonthEndDate() : dateRange[0];
Expand Down Expand Up @@ -85,6 +90,9 @@ angular.module('bahmni.reports')
if (!report.stopDate) {
msg.push("end date");
}
if ((report.startDate > report.stopDate)) {
msg.push(getTranslatedMessage("START_DATE_CANNOT_LATER_THAN_STOP_DATE"));
}
messagingService.showMessage("error", "Please select the " + msg.join(" and "));
return false;
}
Expand Down
8 changes: 3 additions & 5 deletions ui/app/reports/views/reports.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h2 class="section-title">{{::'REPORTS_TITLE_KEY' | translate}}</h2>
<th class="reports-stop-date">{{::'REPORTS_END_DATE_HEADER_KEY' |translate}}
<span class="asterick">*</span>
<input ng-model="default.reportsRequiringDateRange.stopDate" date-converter
class="form-field start-date" type="date" min="{{default.reportsRequiringDateRange.startDate | date:'yyyy-MM-dd'}}"
class="form-field stop-date" type="date" min="{{default.reportsRequiringDateRange.startDate | date:'yyyy-MM-dd'}}"
ng-change="setDefault('stopDate', 'reportsRequiringDateRange')">
</th>
<th class="reports-format">
Expand All @@ -45,12 +45,10 @@ <h2 class="section-title">{{::'REPORTS_TITLE_KEY' | translate}}</h2>
<tr ng-repeat="report in ::reportsRequiringDateRange" show-if-privilege="{{:: report.requiredPrivilege}}">
<td>{{:: report.name |translate }}</td>
<td class="reports-start-date">
<input date-converter class="form-field start-date" type="date" max="{{report.stopDate + 1 | date:'yyyy-MM-dd'}}"
ng-model="report.startDate">
<input date-converter class="form-field start-date" type="date" ng-model="report.startDate">
</td>
<td class="reports-stop-date">
<input date-converter class="form-field stop-date" type="date" min="{{report.startDate | date:'yyyy-MM-dd'}}"
ng-model="report.stopDate">
<input date-converter class="form-field stop-date" type="date" min="{{report.startDate | date:'yyyy-MM-dd'}}" ng-model="report.stopDate">
</td>
<td class="reports-format">
<select ng-model="report.responseType" ng-options="type as label for (label , type) in ::formats">
Expand Down

0 comments on commit 061b404

Please sign in to comment.