From 00a9620140594a770086c513a2a1b4d4b4ad2064 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Thu, 22 Oct 2015 12:00:55 -0400 Subject: [PATCH] Fixed dropdown values on appointment search --- app/appointments/search/route.js | 22 +++++++++++++++++++++- app/mixins/appointment-statuses.js | 6 +++++- app/mixins/visit-types.js | 12 ++++++++++-- app/utils/select-values.js | 18 ++++++++++++++---- config/deprecation-workflow.js | 18 ++++++++++++++++++ 5 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 config/deprecation-workflow.js diff --git a/app/appointments/search/route.js b/app/appointments/search/route.js index 1474b42087..d0ca6eb747 100644 --- a/app/appointments/search/route.js +++ b/app/appointments/search/route.js @@ -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', @@ -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)); } + }); diff --git a/app/mixins/appointment-statuses.js b/app/mixins/appointment-statuses.js index 1ae97021f3..3f6461963e 100644 --- a/app/mixins/appointment-statuses.js +++ b/app/mixins/appointment-statuses.js @@ -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() }); diff --git a/app/mixins/visit-types.js b/app/mixins/visit-types.js index 2460c090f5..69690a40a4 100644 --- a/app/mixins/visit-types.js +++ b/app/mixins/visit-types.js @@ -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; @@ -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') }); diff --git a/app/utils/select-values.js b/app/utils/select-values.js index 506bdefb80..cdfa6fc4ae 100644 --- a/app/utils/select-values.js +++ b/app/utils/select-values.js @@ -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); } } }; diff --git a/config/deprecation-workflow.js b/config/deprecation-workflow.js new file mode 100644 index 0000000000..3f11e0cae3 --- /dev/null +++ b/config/deprecation-workflow.js @@ -0,0 +1,18 @@ +window.deprecationWorkflow = window.deprecationWorkflow || {}; +window.deprecationWorkflow.config = { + workflow: [ + { handler: "silence", matchMessage: "Ember.create is deprecated in favor of Object.create" }, + { handler: "silence", matchMessage: "`lookup` was called on a Registry. The `initializer` API no longer receives a container, and you should use an `instanceInitializer` to look up objects from the container." }, + { handler: "silence", matchMessage: "The LoginControllerMixin is deprecated. Use the session's authenticate method directly instead." }, + { handler: "silence", matchMessage: "The AuthenticationControllerMixin is deprecated. Use the session's authenticate method directly instead." }, + { handler: "silence", matchMessage: "`Ember.ArrayController` is deprecated." }, + { handler: "silence", matchMessage: "ember-get-helper has been included in Ember 2.0. Use of this package is deprecated." }, + { handler: "silence", matchMessage: "Ember.ObjectController is deprecated, please use Ember.Controller and use `model.propertyName`." }, + { handler: "throw", matchMessage: "You attempted to access `patient` from ``, but object proxying is deprecated. Please use `model.patient` instead." }, + { handler: "throw", matchMessage: "You attempted to access `id` from ``, but object proxying is deprecated. Please use `model.id` instead." }, + { handler: "throw", matchMessage: "You attempted to access `isNew` from ``, but object proxying is deprecated. Please use `model.isNew` instead." }, + { handler: "silence", matchMessage: "You tried to look up 'store:main', but this has been deprecated in favor of 'service:store'." }, + { handler: "silence", matchMessage: "Using store.getById() has been deprecated. Use store.peekRecord to get a record by a given type and ID without triggering a fetch." }, + { handler: "silence", matchMessage: "DS.Model#isDirty has been deprecated please use hasDirtyAttributes instead" } + ] +};