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

Commit

Permalink
Merge pull request #1 from HospitalRun/master
Browse files Browse the repository at this point in the history
Update my fork from upstream repo.
  • Loading branch information
MatthewDorner authored Apr 2, 2018
2 parents c68eaec + c5098af commit 615b8f1
Show file tree
Hide file tree
Showing 370 changed files with 4,277 additions and 33,939 deletions.
39 changes: 34 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 6,
ecmaVersion: 2017,
sourceType: 'module'
},

plugins: [
'ember'
],
extends: [
'eslint:recommended',
'plugin:ember-suave/recommended'
],

env: {
'browser': true
browser: true
},

globals: {
Expand All @@ -32,5 +33,33 @@ module.exports = {
'ember-suave/no-direct-property-access': 0,
'ember-suave/require-access-in-comments': 0,
'no-console': 0
}
},
overrides: [
// node files
{
files: [
'testem.js',
'ember-cli-build.js',
'config/**/*.js',
'lib/*/index.js'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
},
env: {
browser: false,
node: true
}
},

// test files
{
files: ['tests/**/*.js'],
excludedFiles: ['tests/dummy/**/*.js'],
env: {
embertest: true
}
}
]
};
46 changes: 22 additions & 24 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { copy } from '@ember/object/internals';
import { Promise as EmberPromise } from 'rsvp';
import { A, isArray } from '@ember/array';
import { isEmpty } from '@ember/utils';
import { inject as service } from '@ember/service';
import { reads } from '@ember/object/computed';
import { get } from '@ember/object';
import { bind } from '@ember/runloop';
import CheckForErrors from 'hospitalrun/mixins/check-for-errors';
import Ember from 'ember';
import uuid from 'npm:uuid';
import withTestWaiter from 'ember-concurrency-test-waiter/with-test-waiter';
import { Adapter } from 'ember-pouch';
import { task } from 'ember-concurrency';

const {
computed: {
reads
},
get,
run: {
bind
}
} = Ember;
import { pluralize } from 'ember-inflector';

export default Adapter.extend(CheckForErrors, {
ajax: Ember.inject.service(),
database: Ember.inject.service(),
ajax: service(),
database: service(),
db: reads('database.mainDB'),
usePouchFind: reads('database.usePouchFind'),

Expand All @@ -38,7 +36,7 @@ export default Adapter.extend(CheckForErrors, {
if (query.containsValue && query.containsValue.value) {
let queryString = '';
query.containsValue.keys.forEach((key) => {
if (!Ember.isEmpty(queryString)) {
if (!isEmpty(queryString)) {
queryString = `${queryString} OR `;
}
let queryValue = query.containsValue.value;
Expand All @@ -55,7 +53,7 @@ export default Adapter.extend(CheckForErrors, {
queryString = `${queryString}data.${key.name}:${queryValue}`;
});
let ajax = get(this, 'ajax');
if (Ember.isEmpty(query.size)) {
if (isEmpty(query.size)) {
query.size = this.get('_esDefaultSize');
}

Expand All @@ -67,7 +65,7 @@ export default Adapter.extend(CheckForErrors, {
}
}).then((results) => {
if (results && results.hits && results.hits.hits) {
let resultDocs = Ember.A(results.hits.hits).map((hit) => {
let resultDocs = A(results.hits.hits).map((hit) => {
let mappedResult = hit._source;
mappedResult.id = hit._id;
return mappedResult;
Expand Down Expand Up @@ -115,13 +113,13 @@ export default Adapter.extend(CheckForErrors, {

_handleQueryResponse(response, store, type) {
let database = this.get('database');
return new Ember.RSVP.Promise((resolve, reject) => {
return new EmberPromise((resolve, reject) => {
if (response.rows.length > 0) {
let ids = response.rows.map((row) => {
return database.getEmberId(row.id);
});
this.findRecord(store, type, ids).then((findResponse) => {
let primaryRecordName = type.modelName.camelize().pluralize();
let primaryRecordName = pluralize(type.modelName.camelize());
let sortedValues = [];
// Sort response in order of ids
ids.forEach((id) => {
Expand All @@ -146,7 +144,7 @@ export default Adapter.extend(CheckForErrors, {
_doesStartKeyContainSpecialCharacters(startkey) {
let haveSpecialCharacters = false;
let maxValue = this.get('maxValue');
if (!Ember.isEmpty(startkey) && Ember.isArray(startkey)) {
if (!isEmpty(startkey) && isArray(startkey)) {
startkey.forEach((keyvalue) => {
if (keyvalue === null || keyvalue === maxValue) {
haveSpecialCharacters = true;
Expand All @@ -164,7 +162,7 @@ export default Adapter.extend(CheckForErrors, {
live: true,
returnDocs: false
}).on('change', bind(this, 'onChange')
).on('error', Ember.K); // Change sometimes throws weird 500 errors that we can ignore
).on('error', function() {}); // Change sometimes throws weird 500 errors that we can ignore
db.changesListener = this.changes;
}
},
Expand All @@ -176,7 +174,7 @@ export default Adapter.extend(CheckForErrors, {
query(store, type, query, options) {
let specialQuery = false;
for (let i = 0; i < this._specialQueries.length; i++) {
if (Ember.get(query, this._specialQueries[i])) {
if (get(query, this._specialQueries[i])) {
specialQuery = true;
break;
}
Expand All @@ -194,7 +192,7 @@ export default Adapter.extend(CheckForErrors, {
let mapReduce = null;
let queryParams = {};
if (query.options) {
queryParams = Ember.copy(query.options);
queryParams = copy(query.options);
if (query.sortKey || query.filterBy) {
if (query.sortDesc) {
queryParams.sortDesc = query.sortDesc;
Expand Down Expand Up @@ -227,7 +225,7 @@ export default Adapter.extend(CheckForErrors, {
return this._executeContainsSearch(store, type, query);
}
let database = get(this, 'database');
return new Ember.RSVP.Promise((resolve, reject) => {
return new EmberPromise((resolve, reject) => {
let db = this.get('db');
try {
if (mapReduce) {
Expand Down Expand Up @@ -298,7 +296,7 @@ export default Adapter.extend(CheckForErrors, {
},

checkForErrorsTask: withTestWaiter(task(function* (callPromise) {
return yield new Ember.RSVP.Promise((resolve, reject) => {
return yield new EmberPromise((resolve, reject) => {
callPromise.then(resolve, (err) => {
let database = get(this, 'database');
reject(database.handleErrorResponse(err));
Expand Down
32 changes: 14 additions & 18 deletions app/adapters/user.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import Ember from 'ember';
import { inject as service } from '@ember/service';
import { Promise as EmberPromise } from 'rsvp';
import $ from 'jquery';
import { isEmpty } from '@ember/utils';
import { alias } from '@ember/object/computed';
import { get, computed } from '@ember/object';
import CheckForErrors from 'hospitalrun/mixins/check-for-errors';
import DS from 'ember-data';
import UserSession from 'hospitalrun/mixins/user-session';
Expand All @@ -9,29 +14,20 @@ const {
RESTAdapter
} = DS;

const {
computed,
computed: {
alias
},
get,
inject
} = Ember;

export default RESTAdapter.extend(CheckForErrors, UserSession, {
defaultSerializer: 'couchdb',

config: inject.service(),
database: inject.service(),
session: inject.service(),
config: service(),
database: service(),
session: service(),

oauthHeaders: alias('database.oauthHeaders'),
standAlone: alias('config.standAlone'),
usersDB: alias('database.usersDB'),

headers: computed('oauthHeaders', function() {
let oauthHeaders = get(this, 'oauthHeaders');
if (Ember.isEmpty(oauthHeaders)) {
if (isEmpty(oauthHeaders)) {
return {};
} else {
return oauthHeaders;
Expand All @@ -41,7 +37,7 @@ export default RESTAdapter.extend(CheckForErrors, UserSession, {
ajaxError(jqXHR) {
let error = this._super(jqXHR);
if (jqXHR && jqXHR.status === 401) {
let jsonErrors = Ember.$.parseJSON(jqXHR.responseText);
let jsonErrors = $.parseJSON(jqXHR.responseText);
window.Hospitalrun.__container__.lookup('controller:application').transitionToRoute('login');
return new DS.InvalidError(jsonErrors);
} else {
Expand Down Expand Up @@ -173,7 +169,7 @@ export default RESTAdapter.extend(CheckForErrors, UserSession, {
delete data.oauth;
data.roles = ['deleted'];
}
if (Ember.isEmpty(data._rev)) {
if (isEmpty(data._rev)) {
delete data._rev;
}
data = this._cleanPasswordAttrs(data);
Expand Down Expand Up @@ -241,7 +237,7 @@ export default RESTAdapter.extend(CheckForErrors, UserSession, {
'iterations'
];
attrsToCheck.forEach(function(attr) {
if (Ember.isEmpty(data[attr])) {
if (isEmpty(data[attr])) {
delete data[attr];
}
});
Expand All @@ -256,7 +252,7 @@ export default RESTAdapter.extend(CheckForErrors, UserSession, {
*/
_offlineFind(id) {
let usersDB = get(this, 'database.usersDB');
return new Ember.RSVP.Promise((resolve, reject) => {
return new EmberPromise((resolve, reject) => {
usersDB.get(id).then(resolve).catch((err) => {
let database = get(this, 'database');
reject(database.handleErrorResponse(err));
Expand Down
4 changes: 1 addition & 3 deletions app/admin/address/route.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import Ember from 'ember';
import { computed } from '@ember/object';
import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route';
import { task } from 'ember-concurrency';
import { translationMacro as t } from 'ember-i18n';
import UnauthorizedError from 'hospitalrun/utils/unauthorized-error';

const { computed } = Ember;

export default AbstractEditRoute.extend({
hideNewButton: true,
newTitle: t('admin.address.newTitle'),
Expand Down
12 changes: 4 additions & 8 deletions app/admin/custom-forms/edit/controller.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import EmberObject, { computed } from '@ember/object';
import { isEmpty, compare } from '@ember/utils';
import AbstractEditController from 'hospitalrun/controllers/abstract-edit-controller';
import Ember from 'ember';
import uuid from 'npm:uuid';

const {
computed,
isEmpty
} = Ember;

export default AbstractEditController.extend({
preview: false,
previewModel: Ember.Object.create(),
previewModel: EmberObject.create(),
updateCapability: 'update_config',

afterUpdate() {
Expand Down Expand Up @@ -90,7 +86,7 @@ export default AbstractEditController.extend({
value: i18n.t(`admin.customForms.labels.${formTypeId}FormType`)
};
}).sort(function(a, b) {
return Ember.compare(a.value.toString(), b.value.toString());
return compare(a.value.toString(), b.value.toString());
});
}),

Expand Down
18 changes: 8 additions & 10 deletions app/admin/custom-forms/field-edit/controller.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { inject as service } from '@ember/service';
import { inject as controller } from '@ember/controller';
import EmberObject, { computed } from '@ember/object';
import { isEmpty, compare } from '@ember/utils';
import AbstractEditController from 'hospitalrun/controllers/abstract-edit-controller';
import Ember from 'ember';

const {
computed,
isEmpty
} = Ember;

export default AbstractEditController.extend({
editController: Ember.inject.controller('admin/custom-forms/edit'),
editController: controller('admin/custom-forms/edit'),
cancelAction: 'closeModal',
i18n: Ember.inject.service(),
i18n: service(),

actions: {
addValue() {
Expand All @@ -21,7 +19,7 @@ export default AbstractEditController.extend({
model.set('values', fieldValues);
}
if (fieldType === 'header' && fieldValues.length < 1 || fieldType != 'header') {
fieldValues.addObject(Ember.Object.create());
fieldValues.addObject(EmberObject.create());
}
},

Expand Down Expand Up @@ -58,7 +56,7 @@ export default AbstractEditController.extend({
value: i18n.t(`admin.customForms.labels.${fieldTypeId}`)
};
}).sort(function(a, b) {
return Ember.compare(a.value.toString(), b.value.toString());
return compare(a.value.toString(), b.value.toString());
});
}),

Expand Down
6 changes: 2 additions & 4 deletions app/admin/custom-forms/index/route.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import EmberObject, { computed } from '@ember/object';
import AbstractIndexRoute from 'hospitalrun/routes/abstract-index-route';
import Ember from 'ember';
import ModalHelper from 'hospitalrun/mixins/modal-helper';
import UserSession from 'hospitalrun/mixins/user-session';
import { translationMacro as t } from 'ember-i18n';

const { computed } = Ember;

export default AbstractIndexRoute.extend(ModalHelper, UserSession, {
newButtonAction: computed(function() {
if (this.currentUserCan('update_config')) {
Expand All @@ -27,7 +25,7 @@ export default AbstractIndexRoute.extend(ModalHelper, UserSession, {
actions: {
deleteItem(item) {
let i18n = this.get('i18n');
let model = Ember.Object.create({
let model = EmberObject.create({
itemToDelete: item
});
let message = i18n.t('messages.delete', { name: item.get('name') });
Expand Down
9 changes: 5 additions & 4 deletions app/admin/loaddb/controller.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import Ember from 'ember';
import { inject as service } from '@ember/service';
import Controller from '@ember/controller';
import { translationMacro as t } from 'ember-i18n';
import ModalHelper from 'hospitalrun/mixins/modal-helper';
import ProgressDialog from 'hospitalrun/mixins/progress-dialog';
export default Ember.Controller.extend(ModalHelper, ProgressDialog, {
database: Ember.inject.service(),
fileSystem: Ember.inject.service('filesystem'),
export default Controller.extend(ModalHelper, ProgressDialog, {
database: service(),
fileSystem: service('filesystem'),
progressMessage: t('admin.loaddb.progressMessage'),
progressTitle: t('admin.loaddb.progressTitle'),
syncResults: null,
Expand Down
Loading

0 comments on commit 615b8f1

Please sign in to comment.