From 4a97a053c190627cb6d65ff84b63537ecc399f49 Mon Sep 17 00:00:00 2001 From: Bao Chau Date: Thu, 9 Mar 2017 14:56:34 -0800 Subject: [PATCH 1/5] create new route print-header --- app/admin/print-header/controller.js | 9 ++++++++ app/admin/print-header/route.js | 31 ++++++++++++++++++++++++++++ app/admin/print-header/template.hbs | 16 ++++++++++++++ app/router.js | 1 + 4 files changed, 57 insertions(+) create mode 100644 app/admin/print-header/controller.js create mode 100644 app/admin/print-header/route.js create mode 100644 app/admin/print-header/template.hbs diff --git a/app/admin/print-header/controller.js b/app/admin/print-header/controller.js new file mode 100644 index 0000000000..c3c1fcbe7a --- /dev/null +++ b/app/admin/print-header/controller.js @@ -0,0 +1,9 @@ +import AbstractEditController from 'hospitalrun/controllers/abstract-edit-controller'; +export default AbstractEditController.extend({ + hideCancelButton: true, + updateCapability: 'update_config', + + afterUpdate() { + this.displayAlert(this.get('i18n').t('admin.address.titles.optionsSaved'), this.get('i18n').t('admin.address.messages.addressSaved')); + } +}); diff --git a/app/admin/print-header/route.js b/app/admin/print-header/route.js new file mode 100644 index 0000000000..f1fe6c8dcd --- /dev/null +++ b/app/admin/print-header/route.js @@ -0,0 +1,31 @@ +import AbstractEditRoute from 'hospitalrun/routes/abstract-edit-route'; +import Ember from 'ember'; +import { translationMacro as t } from 'ember-i18n'; +import UnauthorizedError from 'hospitalrun/utils/unauthorized-error'; + +export default AbstractEditRoute.extend({ + hideNewButton: true, + newTitle: t('admin.address.newTitle'), + editTitle: t('admin.address.editTitle'), + model() { + return new Ember.RSVP.Promise((resolve, reject) => { + this.get('store').find('option', 'address_options').then((addressOptions) => { + resolve(addressOptions); + }, (err) => { + if (err instanceof UnauthorizedError) { + reject(err); + } else { + let store = this.get('store'); + let newConfig = store.push(store.normalize('option', { + id: 'address_options', + value: { + address1Label: this.get('i18n').t('admin.address.addressLabel'), + address1Include: true + } + })); + resolve(newConfig); + } + }); + }); + } +}); diff --git a/app/admin/print-header/template.hbs b/app/admin/print-header/template.hbs new file mode 100644 index 0000000000..c3e480d506 --- /dev/null +++ b/app/admin/print-header/template.hbs @@ -0,0 +1,16 @@ +{{#edit-panel editPanelProps=editPanelProps}} +
+
+ {{#em-form model=model submitButton=false }} + {{em-input label=(t 'admin.address.address1Label') property="value.address1Label"}} + {{em-checkbox label=(t 'admin.address.include1Label') property="value.address1Include"}} + {{em-input label=(t 'admin.address.address2Label') property="value.address2Label"}} + {{em-checkbox label=(t 'admin.address.include2Label') property="value.address2Include"}} + {{em-input label=(t 'admin.address.address3Label') property="value.address3Label"}} + {{em-checkbox label=(t 'admin.address.include3Label') property="value.address3Include"}} + {{em-input label=(t 'admin.address.address4Label') property="value.address4Label"}} + {{em-checkbox label=(t 'admin.address.include4Label') property="value.address4Include"}} + {{/em-form}} +
+
+{{/edit-panel}} diff --git a/app/router.js b/app/router.js index 64fa5d3d12..38e0f18a99 100755 --- a/app/router.js +++ b/app/router.js @@ -9,6 +9,7 @@ const Router = Ember.Router.extend({ Router.map(function() { this.route('admin', function() { this.route('address'); + this.route('print-header'); this.route('custom-forms', function() { this.route('edit', { path: '/edit/:custom-form_id' }); }); From 53fe177d8df239e4d0c9eb185d024e073640a643 Mon Sep 17 00:00:00 2001 From: Bao Chau Date: Thu, 9 Mar 2017 23:26:19 -0800 Subject: [PATCH 2/5] update navigation bar with print header nav --- app/admin/print-header/route.js | 8 ++++---- app/mixins/navigation.js | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/admin/print-header/route.js b/app/admin/print-header/route.js index f1fe6c8dcd..d1b878fee2 100644 --- a/app/admin/print-header/route.js +++ b/app/admin/print-header/route.js @@ -9,7 +9,7 @@ export default AbstractEditRoute.extend({ editTitle: t('admin.address.editTitle'), model() { return new Ember.RSVP.Promise((resolve, reject) => { - this.get('store').find('option', 'address_options').then((addressOptions) => { + this.get('store').find('option', 'print_header').then((addressOptions) => { resolve(addressOptions); }, (err) => { if (err instanceof UnauthorizedError) { @@ -17,10 +17,10 @@ export default AbstractEditRoute.extend({ } else { let store = this.get('store'); let newConfig = store.push(store.normalize('option', { - id: 'address_options', + id: 'print_header', value: { - address1Label: this.get('i18n').t('admin.address.addressLabel'), - address1Include: true + facilityName: this.get('i18n').t('admin.printHeader.facilityName'), + headerLine1: this.get('i18n').t('admin.printHeader.headerLine1') } })); resolve(newConfig); diff --git a/app/mixins/navigation.js b/app/mixins/navigation.js index b6c7380402..909100d031 100644 --- a/app/mixins/navigation.js +++ b/app/mixins/navigation.js @@ -274,6 +274,12 @@ export default Ember.Mixin.create({ route: 'admin.address', capability: 'update_config' }, + { + title: 'Print Header', + iconClass: 'octicon-chevron-right', + route: 'admin.print-header', + capability: 'update_config' + }, { title: 'Custom Forms', iconClass: 'octicon-chevron-right', From 44cd98049b4e9176cc98bde8288c488d60b3997b Mon Sep 17 00:00:00 2001 From: Bao Chau Date: Sat, 11 Mar 2017 10:47:33 -0800 Subject: [PATCH 3/5] adding translation for print header options. complete print header configuration screen --- app/admin/print-header/controller.js | 2 +- app/admin/print-header/route.js | 8 ++++---- app/admin/print-header/template.hbs | 18 ++++++++++-------- app/locales/en/translations.js | 21 +++++++++++++++++++++ 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/app/admin/print-header/controller.js b/app/admin/print-header/controller.js index c3c1fcbe7a..160c3423a7 100644 --- a/app/admin/print-header/controller.js +++ b/app/admin/print-header/controller.js @@ -4,6 +4,6 @@ export default AbstractEditController.extend({ updateCapability: 'update_config', afterUpdate() { - this.displayAlert(this.get('i18n').t('admin.address.titles.optionsSaved'), this.get('i18n').t('admin.address.messages.addressSaved')); + this.displayAlert(this.get('i18n').t('admin.header.titles.optionsSaved'), this.get('i18n').t('admin.header.messages.headerSaved')); } }); diff --git a/app/admin/print-header/route.js b/app/admin/print-header/route.js index d1b878fee2..c747e55133 100644 --- a/app/admin/print-header/route.js +++ b/app/admin/print-header/route.js @@ -5,8 +5,8 @@ import UnauthorizedError from 'hospitalrun/utils/unauthorized-error'; export default AbstractEditRoute.extend({ hideNewButton: true, - newTitle: t('admin.address.newTitle'), - editTitle: t('admin.address.editTitle'), + newTitle: t('admin.header.newTitle'), + editTitle: t('admin.header.editTitle'), model() { return new Ember.RSVP.Promise((resolve, reject) => { this.get('store').find('option', 'print_header').then((addressOptions) => { @@ -19,8 +19,8 @@ export default AbstractEditRoute.extend({ let newConfig = store.push(store.normalize('option', { id: 'print_header', value: { - facilityName: this.get('i18n').t('admin.printHeader.facilityName'), - headerLine1: this.get('i18n').t('admin.printHeader.headerLine1') + facilityName: this.get('i18n').t('admin.header.facilityName'), + headerLine1: this.get('i18n').t('admin.header.headerLine1') } })); resolve(newConfig); diff --git a/app/admin/print-header/template.hbs b/app/admin/print-header/template.hbs index c3e480d506..bea6145530 100644 --- a/app/admin/print-header/template.hbs +++ b/app/admin/print-header/template.hbs @@ -2,14 +2,16 @@
{{#em-form model=model submitButton=false }} - {{em-input label=(t 'admin.address.address1Label') property="value.address1Label"}} - {{em-checkbox label=(t 'admin.address.include1Label') property="value.address1Include"}} - {{em-input label=(t 'admin.address.address2Label') property="value.address2Label"}} - {{em-checkbox label=(t 'admin.address.include2Label') property="value.address2Include"}} - {{em-input label=(t 'admin.address.address3Label') property="value.address3Label"}} - {{em-checkbox label=(t 'admin.address.include3Label') property="value.address3Include"}} - {{em-input label=(t 'admin.address.address4Label') property="value.address4Label"}} - {{em-checkbox label=(t 'admin.address.include4Label') property="value.address4Include"}} + {{em-input label=(t 'admin.header.facilityName') property="value.facilityName"}} + {{em-checkbox label=(t 'admin.header.includeFacilityName') property="value.facilityNameInclude"}} + {{em-input label=(t 'admin.header.headerLine1') property="value.headerLine1"}} + {{em-checkbox label=(t 'admin.header.includeHeaderLine1') property="value.headerLine1Include"}} + {{em-input label=(t 'admin.header.headerLine2') property="value.headerLine2"}} + {{em-checkbox label=(t 'admin.header.includeHeaderLine2') property="value.headerLine2Include"}} + {{em-input label=(t 'admin.header.headerLine3') property="value.headerLine3"}} + {{em-checkbox label=(t 'admin.header.includeHeaderLine3') property="value.headerLine3Include"}} + {{em-input label=(t 'admin.header.logoURL') property="value.logoURL"}} + {{em-checkbox label=(t 'admin.header.includeLogoURL') property="value.logoURLInclude"}} {{/em-form}}
diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index c6ef2d7eb1..698db8c77a 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -117,6 +117,27 @@ export default { editTitle: 'Address Options', addressLabel: 'Address' }, + header: { + facilityName: 'Facility Name', + headerLine1: 'Header Line 1', + headerLine2: 'Header Line 2', + headerLine3: 'Header Line 3', + logoURL: 'Logo URL', + includeFacilityName: 'Include Facility Name', + includeHeaderLine1: 'Include Header Line 1', + includeHeaderLine2: 'Include Header Line 2', + includeHeaderLine3: 'Include Header Line 3', + includeLogoURL: 'Include Logo URL', + titles: { + optionsSaved: 'Options Saved' + }, + messages: { + headerSaved: 'The header options have been saved' + }, + newTitle: 'Header Options', + editTitle: 'Header Options', + headerLabel: 'Header' + }, customForms: { buttons: { addField: 'Add Field', From 7fb068bb9b904e1282f377aed3f7723ea04bf9a3 Mon Sep 17 00:00:00 2001 From: Bao Chau Date: Sat, 11 Mar 2017 14:11:54 -0800 Subject: [PATCH 4/5] add translation for print header hav --- app/locales/en/translations.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 698db8c77a..5388764ebe 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -79,7 +79,8 @@ export default { customForms: 'Custom Forms', appointmentsCalendar: 'Appointments Calendar', theaterSchedule: 'Theater Schedule', - scheduleSurgery: 'Schedule Surgery' + scheduleSurgery: 'Schedule Surgery', + printHeader: 'Print Header' }, actions: { logout: 'Logout', From 5d818470bd1c64dc4d4b68d87a324e4f5f2c3001 Mon Sep 17 00:00:00 2001 From: Bao Chau Date: Mon, 13 Mar 2017 08:14:00 -0700 Subject: [PATCH 5/5] add unit test for print header screen --- app/admin/print-header/route.js | 4 ++-- tests/acceptance/admin-test.js | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/admin/print-header/route.js b/app/admin/print-header/route.js index c747e55133..500808311a 100644 --- a/app/admin/print-header/route.js +++ b/app/admin/print-header/route.js @@ -9,8 +9,8 @@ export default AbstractEditRoute.extend({ editTitle: t('admin.header.editTitle'), model() { return new Ember.RSVP.Promise((resolve, reject) => { - this.get('store').find('option', 'print_header').then((addressOptions) => { - resolve(addressOptions); + this.get('store').find('option', 'print_header').then((headerOptions) => { + resolve(headerOptions); }, (err) => { if (err instanceof UnauthorizedError) { reject(err); diff --git a/tests/acceptance/admin-test.js b/tests/acceptance/admin-test.js index e723cd9db9..849b7e54b0 100644 --- a/tests/acceptance/admin-test.js +++ b/tests/acceptance/admin-test.js @@ -97,6 +97,24 @@ test('Update address options', function(assert) { }); }); +test('Update header options', function(assert) { + runWithPouchDump('admin', function() { + authenticateUser(); + visit('/admin/print-header'); + andThen(function() { + assert.equal(currentURL(), '/admin/print-header'); + fillIn('input', 'Print Header Label'); + click('button:contains(Update)'); + andThen(() => { + waitToAppear('.modal-dialog'); + andThen(() => { + assert.equal(find('.modal-title').text(), 'Options Saved', 'Header Options Saved'); + }); + }); + }); + }); +}); + test('Update workflow options', function(assert) { let selector = 'input[type=checkbox]';