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

#1515: Update computed properties to avoid deprecated method #1519

Merged
merged 1 commit into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/admin/lookup/edit/controller.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { isEmpty } from '@ember/utils';
import Controller, { inject as controller } from '@ember/controller';
import IsUpdateDisabled from 'hospitalrun/mixins/is-update-disabled';
import { computed } from '@ember/object';

export default Controller.extend(IsUpdateDisabled, {
editController: controller('admin/lookup'),
showUpdateButton: true,

updateButtonAction: 'update',
updateButtonText: function() {
updateButtonText: computed('model.isNew', function() {
let i18n = this.get('i18n');
if (this.get('model.isNew')) {
return i18n.t('buttons.add');
} else {
return i18n.t('buttons.update');
}
}.property('model.isNew'),
}),

actions: {
cancel() {
Expand Down
10 changes: 6 additions & 4 deletions app/admin/route.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import AbstractModuleRoute from 'hospitalrun/routes/abstract-module-route';
import { computed } from '@ember/object';

export default AbstractModuleRoute.extend({
addCapability: 'add_user',
allowSearch: false,
moduleName: 'admin',
sectionTitle: 'Admin',

editPath: function() {
editPath: computed(function() {
return 'users.edit';
}.property(),
}),

deletePath: function() {
deletePath: computed(function() {
return 'users.delete';
}.property()
})
});
6 changes: 4 additions & 2 deletions app/appointments/delete/controller.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import AbstractDeleteController from 'hospitalrun/controllers/abstract-delete-controller';
import { computed } from '@ember/object';

export default AbstractDeleteController.extend({
title: 'Delete Appointment',

afterDeleteAction: function() {
afterDeleteAction: computed('model.deleteFromPatient', function() {
let deleteFromPatient = this.get('model.deleteFromPatient');
if (deleteFromPatient) {
return 'appointmentDeleted';
} else {
return 'closeModal';
}
}.property('model.deleteFromPatient')
})
});
14 changes: 8 additions & 6 deletions app/appointments/index/controller.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import AbstractPagedController from 'hospitalrun/controllers/abstract-paged-controller';
import UserSession from 'hospitalrun/mixins/user-session';
import { computed } from '@ember/object';

export default AbstractPagedController.extend(UserSession, {
startKey: [],
canAddVisit: function() {
canAddVisit: computed(function() {
return this.currentUserCan('add_visit');
}.property(),
}),

canEdit: function() {
canEdit: computed(function() {
// Add and edit are the same capability
return this.currentUserCan('add_appointment');
}.property(),
}),

canDelete: function() {
canDelete: computed(function() {
return this.currentUserCan('delete_appointment');
}.property(),
}),

sortProperties: ['startDate', 'endDate'],
sortAscending: true
Expand Down
7 changes: 5 additions & 2 deletions app/appointments/search/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import AppointmentIndexController from 'hospitalrun/appointments/index/controlle
import AppointmentStatuses from 'hospitalrun/mixins/appointment-statuses';
import SelectValues from 'hospitalrun/utils/select-values';
import VisitTypes from 'hospitalrun/mixins/visit-types';
import { computed } from '@ember/object';

export default AppointmentIndexController.extend(AppointmentStatuses, VisitTypes, {
appointmentsController: controller('appointments'),
appointmentType: null,
physicians: alias('appointmentsController.physicianList.value'),
physicianList: function() {

physicianList: computed('physicians', function() {
return SelectValues.selectValues(this.get('physicians'), true);
}.property('physicians'),
}),

provider: null,
queryParams: ['appointmentType', 'provider', 'status', 'startKey', 'startDate'],
Expand Down
6 changes: 4 additions & 2 deletions app/components/array-display.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { isArray } from '@ember/array';
import { computed } from '@ember/object';
import Component from '@ember/component';

export default Component.extend({
isArray: function() {
isArray: computed('content', function() {
let content = this.get('content');
return isArray(content);
}.property('content')
})
});
10 changes: 6 additions & 4 deletions app/components/charge-quantity.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { isEmpty } from '@ember/utils';
import { alias } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import Component from '@ember/component';
import { computed } from '@ember/object';

export default Component.extend({
i18n: service(),
classNames: ['col-xs-2', 'form-group'],
Expand All @@ -14,15 +16,15 @@ export default Component.extend({
this.quantitySelected = alias(`model.${this.get('pricingItem.id')}`);
},

hasError: function() {
hasError: computed('quantitySelected', function() {
let quantitySelected = this.get('quantitySelected');
return !isEmpty(quantitySelected) && isNaN(quantitySelected);
}.property('quantitySelected'),
}),

quantityHelp: function() {
quantityHelp: computed('hasError', function() {
if (this.get('hasError')) {
return this.get('i18n').t('errors.invalidNumber');
}
}.property('hasError')
})

});
14 changes: 8 additions & 6 deletions app/components/charges-by-type-tab.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Component from '@ember/component';
import { computed } from '@ember/object';

export default Component.extend({
attributeBindings: ['role'],
classNameBindings: ['active'],
Expand All @@ -7,17 +9,17 @@ export default Component.extend({
role: 'presentation',
tagName: 'li',

active: function() {
active: computed(function() {
let index = this.get('index');
return (index === 0);
}.property(),
}),

tabId: function() {
tabId: computed('pricingType', function() {
return this.get('pricingType').toLowerCase().dasherize();
}.property('pricingType'),
}),

tabHref: function() {
tabHref: computed('tabId', function() {
let tabId = this.get('tabId');
return `#${tabId}`;
}.property('tabId')
})
});
4 changes: 2 additions & 2 deletions app/components/checkbox-or-typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default SelectOrTypeahead.extend({
}));
}.on('init'),

checkboxRows: function() {
checkboxRows: computed('content', 'checkboxesPerRow', function() {
let checkboxRows = [];
let checkboxesPerRow = this.get('checkboxesPerRow');
let content = this.get('content');
Expand All @@ -44,7 +44,7 @@ export default SelectOrTypeahead.extend({
checkboxRows.push(checkBoxRowValues);
}
return checkboxRows;
}.property('content', 'checkboxesPerRow'),
}),

actions: {
checkboxChanged(value, checked) {
Expand Down
6 changes: 3 additions & 3 deletions app/components/date-input.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineProperty } from '@ember/object';
import { defineProperty, computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import { isEmpty } from '@ember/utils';
import EmInput from 'ember-rapid-forms/components/em-input';
Expand All @@ -19,14 +19,14 @@ export default EmInput.extend(PikadayComponent, {
}
},

format: function() {
format: computed('showTime', function() {
let showTime = this.get('showTime');
if (showTime) {
return 'l h:mm A';
} else {
return 'l';
}
}.property('showTime'),
}),

showTimeChanged: function() {
let picker = this.get('_picker');
Expand Down
10 changes: 6 additions & 4 deletions app/components/ext-radio.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { isEmpty } from '@ember/utils';
import Component from '@ember/component';
import { computed } from '@ember/object';

export default Component.extend({
includeOtherOption: false,
otherOptionLabel: null,
showInline: false,

haveLabel: function() {
haveLabel: computed('content', function() {
let firstRadio = this.get('content.firstObject');
return !isEmpty(firstRadio.label);
}.property('content'),
}),

radioClass: function() {
radioClass: computed('showInline', function() {
if (this.get('showInline')) {
return 'radio-inline';
} else {
return 'radio';
}
}.property('showInline')
})
});
6 changes: 3 additions & 3 deletions app/components/inventory-location-picker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { scheduleOnce } from '@ember/runloop';
import { alias } from '@ember/object/computed';
import EmberObject, { defineProperty } from '@ember/object';
import EmberObject, { defineProperty, computed } from '@ember/object';
import { isEmpty } from '@ember/utils';
import Component from '@ember/component';
import SelectValues from 'hospitalrun/utils/select-values';
Expand Down Expand Up @@ -71,7 +71,7 @@ export default Component.extend({
this.set('calculatedLocationPickers', locationPickers);
},

locationPickers: function() {
locationPickers: computed('calculatedLocationPickers', 'locationList', 'quantityRequested', function() {
let locationList = this.get('locationList');
let locationPickers = [];
let quantityRequested = this.get('quantityRequested');
Expand All @@ -90,5 +90,5 @@ export default Component.extend({
scheduleOnce('afterRender', this, this.locationChange);
this.set('doingSetup', false);
return this.get('calculatedLocationPickers');
}.property('calculatedLocationPickers', 'locationList', 'quantityRequested')
})
});
10 changes: 6 additions & 4 deletions app/components/inventory-typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { once } from '@ember/runloop';
import { isEmpty } from '@ember/utils';
import { inject as service } from '@ember/service';
import TypeAhead from 'hospitalrun/components/type-ahead';
import { computed } from '@ember/object';

export default TypeAhead.extend({
classNameBindings: ['haveInventoryItems'],
displayKey: 'name',
Expand All @@ -23,21 +25,21 @@ export default TypeAhead.extend({
return returnObj;
},

haveInventoryItems: function() {
haveInventoryItems: computed('content', function() {
let content = this.get('content');
if (!isEmpty(content) && content.length > 0) {
return 'have-inventory-items';
}
}.property('content'),
}),

mappedContent: function() {
mappedContent: computed('content', function() {
let content = this.get('content');
let mapped = [];
if (content) {
mapped = content.map(this._mapInventoryItems.bind(this));
}
return mapped;
}.property('content'),
}),

contentChanged: function() {
let bloodhound = this.get('bloodhound');
Expand Down
6 changes: 4 additions & 2 deletions app/components/modal-dialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { isEmpty } from '@ember/utils';
import { inject as service } from '@ember/service';
import Component from '@ember/component';
import { computed } from '@ember/object';

export default Component.extend({
i18n: service(),
cancelAction: 'cancel',
Expand All @@ -13,14 +15,14 @@ export default Component.extend({
updateButtonClass: '',
updateButtonText: '',
cancelButtonText: '',
cancelBtnText: function() {
cancelBtnText: computed('cancelButtonText', function() {
let cancelText = this.get('cancelButtonText');
if (isEmpty(cancelText)) {
return this.get('i18n').t('buttons.cancel');
} else {
return cancelText;
}
}.property('cancelButtonText'),
}),
actions: {
cancelAction() {
this.sendAction('cancelAction');
Expand Down
7 changes: 4 additions & 3 deletions app/components/patient-typeahead.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { isEmpty } from '@ember/utils';
import { computed } from '@ember/object';
import PatientName from 'hospitalrun/mixins/patient-name';
import TypeAhead from 'hospitalrun/components/type-ahead';

export default TypeAhead.extend(PatientName, {
displayKey: 'name',
selectedAction: 'selectedPatientChanged',
Expand All @@ -24,13 +26,12 @@ export default TypeAhead.extend(PatientName, {
}
}.observes('content.[]'),

mappedContent: function() {
mappedContent: computed('content', function() {
let content = this.get('content');
let mapped = [];
if (content) {
mapped = content.map(this._mapPatient.bind(this));
}
return mapped;
}.property('content')

})
});
6 changes: 4 additions & 2 deletions app/components/photo-display.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { isEmpty } from '@ember/utils';
import { alias } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import Component from '@ember/component';

export default Component.extend({
computedPhotoUrl: null,
filesystem: service(),
Expand All @@ -10,7 +12,7 @@ export default Component.extend({
photo: null,
url: alias('photo.url'),

photoUrl: function() {
photoUrl: computed('computedPhotoUrl', 'fileName', 'url', function() {
let computedPhotoUrl = this.get('computedPhotoUrl');
let fileName = this.get('fileName');
let filesystem = this.get('filesystem');
Expand All @@ -26,5 +28,5 @@ export default Component.extend({
}.bind(this));
}
return url;
}.property('computedPhotoUrl', 'fileName', 'url')
})
});
Loading