Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Fixed dropdown values on appointment search
Browse files Browse the repository at this point in the history
  • Loading branch information
jkleinsc committed Oct 22, 2015
1 parent cb3186e commit 00a9620
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 8 deletions.
22 changes: 21 additions & 1 deletion app/appointments/search/route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AppointmentIndexRoute from 'hospitalrun/appointments/index/route';
import DateFormat from 'hospitalrun/mixins/date-format';
import Ember from 'ember';
export default AppointmentIndexRoute.extend({
export default AppointmentIndexRoute.extend(DateFormat, {
editReturn: 'appointments.search',
filterParams: ['appointmentType', 'provider', 'status'],
modelName: 'appointment',
Expand Down Expand Up @@ -31,5 +32,24 @@ export default AppointmentIndexRoute.extend({
options: searchOptions,
mapReduce: 'appointments_by_date'
};
},

model: function(params) {
return this._super(params).then(function(model) {
model.setProperties({
selectedAppointmentType: params.appointmentType,
selectedProvider: params.provider,
selectedStatus: params.status
});
var startDate = params.startDate;
startDate = new Date();
if (!Ember.isEmpty(params.startDate)) {
startDate.setTime(params.startDate);
}
model.set('selectedStartingDate', startDate);
model.set('display_selectedStartingDate', this._dateFormat(startDate));
return model;
}.bind(this));
}

});
6 changes: 5 additions & 1 deletion app/mixins/appointment-statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ export default Ember.Mixin.create({
'Scheduled',
'Canceled'
],
appointmentStatuses: Ember.computed.map('appointmentStatusList', SelectValues.selectValuesMap)
appointmentStatuses: Ember.computed.map('appointmentStatusList', SelectValues.selectValuesMap),

appointmentStatusesWithEmpty: function() {
return SelectValues.selectValues(this.get('appointmentStatusList'), true);
}.property()
});
12 changes: 10 additions & 2 deletions app/mixins/visit-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default Ember.Mixin.create({
'Pharmacy'
],

visitTypes: function() {
_getVisitTypes: function(includeEmpty) {
var defaultVisitTypes = this.get('defaultVisitTypes'),
visitTypesList = this.get('visitTypesList'),
visitList;
Expand All @@ -19,7 +19,15 @@ export default Ember.Mixin.create({
} else {
visitList = visitTypesList.get('value');
}
visitList = SelectValues.selectValues(visitList);
visitList = SelectValues.selectValues(visitList, includeEmpty);
return visitList;
},

visitTypes: function() {
return this._getVisitTypes();
}.property('visitTypesList', 'defaultVisitTypes'),

visitTypesWithEmpty: function() {
return this._getVisitTypes(true);
}.property('visitTypesList', 'defaultVisitTypes')
});
18 changes: 14 additions & 4 deletions app/utils/select-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,23 @@ export default {
});
},

// Map an array of strings to objects with id and value set to the string values
// so that the array can be used for em-select
selectValuesMap: selectValuesMap,

selectValues: function(array) {
/** Map an array of strings to objects with id and value set to the string values
* so that the array can be used for em-select
* @param {Array} array to map.
* @param {boolean} includeEmpty if there should be an empty item added to the select list
*/
selectValues: function(array, includeEmpty) {
if (Ember.isArray(array)) {
return array.map(selectValuesMap);
var arrayToMap = new Array(array);
if (includeEmpty) {
arrayToMap = [''];
arrayToMap.addObjects(array);
} else {
arrayToMap = array;
}
return arrayToMap.map(selectValuesMap);
}
}
};
18 changes: 18 additions & 0 deletions config/deprecation-workflow.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 00a9620

Please sign in to comment.