diff --git a/app/admin/print-header/controller.js b/app/admin/print-header/controller.js new file mode 100644 index 0000000000..160c3423a7 --- /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.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 new file mode 100644 index 0000000000..500808311a --- /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.header.newTitle'), + editTitle: t('admin.header.editTitle'), + model() { + return new Ember.RSVP.Promise((resolve, reject) => { + this.get('store').find('option', 'print_header').then((headerOptions) => { + resolve(headerOptions); + }, (err) => { + if (err instanceof UnauthorizedError) { + reject(err); + } else { + let store = this.get('store'); + let newConfig = store.push(store.normalize('option', { + id: 'print_header', + value: { + 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 new file mode 100644 index 0000000000..bea6145530 --- /dev/null +++ b/app/admin/print-header/template.hbs @@ -0,0 +1,18 @@ +{{#edit-panel editPanelProps=editPanelProps}} +
+
+ {{#em-form model=model submitButton=false }} + {{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}} +
+
+{{/edit-panel}} diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index c6ef2d7eb1..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', @@ -117,6 +118,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', 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', 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' }); }); 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]';