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

Customizable print header #985

Merged
merged 6 commits into from
Mar 13, 2017
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
9 changes: 9 additions & 0 deletions app/admin/print-header/controller.js
Original file line number Diff line number Diff line change
@@ -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'));
}
});
31 changes: 31 additions & 0 deletions app/admin/print-header/route.js
Original file line number Diff line number Diff line change
@@ -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);
}
});
});
}
});
18 changes: 18 additions & 0 deletions app/admin/print-header/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{#edit-panel editPanelProps=editPanelProps}}
<div class="panel panel-primary">
<div class="panel-body">
{{#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}}
</div>
</div>
{{/edit-panel}}
24 changes: 23 additions & 1 deletion app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions app/mixins/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
});
Expand Down
18 changes: 18 additions & 0 deletions tests/acceptance/admin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]';

Expand Down