-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add "Patient Listing" button to patient update confirmation dialog #263
Conversation
HospitalRun#230 (comment) ~\app\patients\edit\controller.js Updated "afterUpdate" action to not use displayAlert. The display alert was a helper function that helped users quickly open a message dialog. Instead the "afterUpdate" action will now call a new dialog directly and bypass the displayAlert helper class. The new updated afterUpdate action specifies that the update button will call an action to bring the user back to the patient list. The action that the updateButtonAction is set to is called 'returnToPatient', this action has been added to the controller file and the route file. ~\app\patients\edit\route.js Added new action 'returnToPatient' points to the action in the controller file. ~\app\templates\components\modal-dialog.hbs Updated the model dialogue template to allow users to customize the cancel button. In order to customize the cancel button you must set the flag {{isCancelTextChanged}} to true and then set {{cancelButtonText}} to the text that you want to be displayed instead. If you do not have the flag set to true, then the template will render the default cancel button that has the text "Cancel" The reason for setting a flag is so that other dialogs that use this template can continue to work normally without having to go back to modify and set {{canceButtonText}} for every instance of the template. ~\app\components\modal-dialog.js Updated component to capture the custom text and flag if they wish to customize the text ~\app\dialog\template.hbs Updated the mapping to capture the user input.
removed commented out code and updated message to replace exclamation point with period.
1) added missing space before curly brackets. 2) updated patient record saved string to remove the extra space.
updated test case to click on the cancel button because there is no longer an 'Ok' button.
@capurp looks good, but I would make one small change. Instead of having an attribute <button class="btn btn-default warning" {{action "cancelAction"}}>{{cancelButtonText}}</button> @jglovier are you ok with the UI change here? |
@jkleinsc I like the idea but the issue that I ran into when I tried to set the default of the
would overwrite the value to an empty string if there was no |
@capurp you can use a computed property in the modal-dialog component by doing something like this: cancelBtnText: function() {
let cancelText = this.get('cancelButtonText');
if (Ember.isEmpty(cancelText) {
return 'Cancel';
} else {
return cancelText;
}
}.property('cancelButtonText'); <button class="btn btn-default warning" {{action "cancelAction"}}>{{cancelBtnText}}</button> |
@jkleinsc Thanks for the suggestion. What do you think about using setting the cancel text to a separate attribute ( let cancelText = this.get('cancelButtonText'); because the value of cancelButtonText was being set in ~\app\dialog\template.hbs and was overwriting the commuted property in modal-dialog.js. So in order to pass in the user custom text without overwriting the cancelButtonText commuted property function I created the Here are the changes I made. ~\app\templates\components\modal-dialog.hbs
~app/components/modal-dialog.js cancelButtonTextHelper: '',
cancelButtonText: function (){
let cancelText = this.get('cancelButtonTextHelper');
if (Ember.isEmpty(cancelText)) {
return 'Cancel';
} else {
return cancelText;
}
}.property('cancelButtonText'),
actions: {
cancelAction: function() {
this.sendAction('cancelAction');
},
updateAction: function() {
this.sendAction('updateButtonAction');
}
}, ~\app\dialog\template.hbscancelButtonTextHelper=model.cancelButtonTextHelper ~\app\patients\edit\controller.jshttps://guides.github.com/features/mastering-markdown/
afterUpdate: function(record) {
this.send('openModal', 'dialog', Ember.Object.create({
title: 'Patient Saved',
message: `The patient record for ${record.get('displayName')} has been saved.`,
updateButtonAction: 'returnToPatient',
updateButtonText: 'Back to Patient List',
cancelButtonTextHelper: 'Close'
}));
} |
@capurp if you look at the example I provided, I left the value being passed into the component as cancel**_Button**_Text, but the computed property is called cancel**_Btn**_Text. I would prefer to do something like this because a component is a public facing utility and should have easy to understand parameters. cancelButtonTextHelper doesn't make as much sense as cancelButtonText. If you are concerned about cancel**_Button**_Text and cancel**_Btn**_Text looking too similar, you could call the computed property something along the lines of Does that make sense? |
@jkleinsc https://github.com/jkleinsc Sounds good! Yes I agree - On Tue, Jan 19, 2016 at 10:01 AM, John Kleinschmidt <
|
@capurp awesome - thanks for tackling this one! From the design side it LGTM. 👍 |
removed isCancelTextChanged flag. use commuted property to set default value.
return cancel
Thanks @capurp for this PR! |
address #230
summary of solution:
To allow users the option of either navigating back to the patients list or to close the update notification
~\app\patients\edit\controller.js
Updated "afterUpdate" action to not use displayAlert. The display alert was a helper function that helped users quickly open a message dialog. Instead the "afterUpdate" action will now call a new dialog directly and bypass the displayAlert helper class. The new updated afterUpdate action specifies that the update button will call an action to bring the user back to the patient list. The action that the updateButtonAction is set to is called 'returnToPatient', this action has been added to the controller file and the route file.
~\app\patients\edit\route.js
Added new action 'returnToPatient' points to the action in the controller file.
~\app\templates\components\modal-dialog.hbs
Updated the model dialogue template to allow users to customize the cancel button. In order to customize the cancel button you must set the flag {{isCancelTextChanged}} to true and then set {{cancelButtonText}} to the text that you want to be displayed instead. If you do not have the flag set to true, then the template will render the default cancel button that has the text "Cancel" The reason for setting a flag is so that other dialogs that use this template can continue to work normally without having to go back to modify and set {{canceButtonText}} for every instance of the template.
~\app\components\modal-dialog.js
Updated component to capture the custom text and flag if they wish to customize the text
~\app\dialog\template.hbs
Updated the mapping
===== screenshot =====