New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #3279 warning closing form #3303
Fix #3279 warning closing form #3303
Conversation
Hello @bradymiller @stephenwaite @sjpadgett @tywrenn Please review this PR, and give me feedback or suggestion about this dialog style. |
Hi Cliff, while the workflow is correct for the alert, we don't want user having to do this for every tab closure. You think providers are stressed now, wait til we give them this:) These type alerts should happen in forms where if content changed to trigger alert occurs. |
Hi @sjpadgett Thanks for your reply, If have any request changed Please let me know. |
Well if I understand @stephenwaite original issue, he was concern that a modified SOAP could be canceled w/o a second chance for user to reconsider. This is common in UX and should somehow extend to all our encounter forms. I see two places to trigger the alert.
My first thought is a javascript function, maybe even one placed in our JS utility.js that monitors for content changes and sets a flag that is exposed globally to parent tabs or form(perhaps a session variable) that can be checked by alert before popping up. Set the context for the changes also. |
Hi @sjpadgett @stephenwaite and @bradymiller I try to in Also, I've tried in |
hi @stu01509 , not really sure, would you like to push you're best effort so can take a look at the code? |
Hi @sjpadgett @stephenwaite and @bradymiller Finally, I used local storage to record Please review it again, Thanks. |
nice @stu01509 , that fixes when you click to close the tab but not the cancel button, thank you |
In form cancel will require you to create a doCancel() function to replace the window.location redirect in the cancel button. The check you onchange flag and act accordingly. Just saying:) |
Thanks for @stephenwaite and @sjpadgett review and suggestion, |
src/Tabs/TabsWrapper.php
Outdated
const panelId = self.parent().attr("href").substring(1); | ||
top.restoreSession(); | ||
twCloseTab(tabsid, panelId); | ||
localStorage.removeItem('isSoapEdit'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't need to use localStorage. would be more straightforward to just store it in top.* . See here for example of things that are stored there:
https://github.com/openemr/openemr/blob/master/interface/main/tabs/main.php#L157-L164
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, Thanks for your instruction, It's very useful to me,
I will try it! 😁
Now, I still use localstorage to record the Any suggestions or feedback to improve it? |
hi @stu01509 , To store the variable in
|
Oh my! It's working. |
hi @stu01509 , the alert works great when you try to close the tab but there's still no alert for clicking the |
if (top.isSoapEdit === true) { | ||
dlgopen('', '', 450, 125, '', '<div class="text-danger">Warning</div>', { | ||
type: 'Alert', | ||
html: '<p>Do you want to close the tabs?</p>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translate (using the above xla construct)
html: '<p>Do you want to close the tabs?</p>', | ||
buttons: [ | ||
{text: 'Cancel', close: true, style: 'default btn-sm'}, | ||
{text: 'Close', close: true, style: 'danger btn-sm', click: closeSoap}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translate above 2 labels (using the above xla construct)
src/Tabs/TabsWrapper.php
Outdated
} | ||
|
||
if (self[0].id === 'SOAP' && top.isSoapEdit === true) { | ||
dlgopen('', '', 450, 125, '', '<div class="text-danger">Warning</div>', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translate (note this is different than in above smarty context):
dlgopen('', '', 450, 125, '', '<div class="text-danger"><?php echo xla("Warning"); ?></div>', {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
man, EOD...
your gonna have to look up how to call php functions in EOD (there may be examples of this in OpenEMR codebase, but not sure)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a huge project 🤣, I will try to fix it.
Thank you.
src/Tabs/TabsWrapper.php
Outdated
if (self[0].id === 'SOAP' && top.isSoapEdit === true) { | ||
dlgopen('', '', 450, 125, '', '<div class="text-danger">Warning</div>', { | ||
type: 'Alert', | ||
html: '<p>Do you want to close the tabs?</p>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translate (using the above xla function)
src/Tabs/TabsWrapper.php
Outdated
html: '<p>Do you want to close the tabs?</p>', | ||
buttons: [ | ||
{text: 'Cancel', close: true, style: 'default btn-sm'}, | ||
{text: 'Close', close: true, style: 'danger btn-sm', click: closeSoap}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
translate above 2 labels (using the above xla function)
Hi @bradymiller I try to change 'general_new.html' But it looks like have some problem, I guessing maybe is {literal} tag effect? |
think so @stu01509 , try the |
Hi @stephenwaite |
Hi @bradymiller and @stephenwaite Updated this commit, I used variables to save translate content. |
hi @stu01509 , nice work! guess this can be extended to other forms which would build on this and be a larger project? would you like to create the parent project and reference this? thank you |
src/Tabs/TabsWrapper.php
Outdated
@@ -113,9 +113,13 @@ public static function genJavaScript() | |||
$s = ''; | |||
if (!defined('INCLUDED_TW_ONETIME_JS')) { | |||
define('INCLUDED_TW_ONETIME_JS', true); | |||
$modalTitle = xla("Warning"); | |||
$modalContent = xla("Do you want to close the tabs"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
place the punctuation (?
) within the constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Please review it again :)
hi @stu01509 , What will happen here if a user opens up two SOAP forms at the same time and works on them? |
Hello @bradymiller If a user opens up two SOAP forms, and just edit one of form when it closes the anyone form, just show modal dialog. |
Hello @stephenwaite Sounds good ideas, I would like to build on this project after this PR merged, Can you open a new issue and assign me? Thanks 😁 |
This is why that global js should be array that includes context. This makes life so much easier. then universal function to deal. Just saying one var should handle all edits and just a suggestion from the busy body that is me:) |
Hi @sjpadgett Thanks for your suggestion 👍, It's a good idea to deal with all the encounter form status, I will plan it in the next feature. |
Okay but I collect royalties! $9.99 ought to do it:) |
Okay, Let me use PR to instead of royalties 😁 |
hi @stu01509 , Testing well and bringing into codebase. Great job persevering on this one and agree that a generic mechanism that leverages this (ie. any form can plug into it) would be very nice. Thanks for the improvement! -brady |
Hello @bradymiller Let me planing a pretty plan for implementation about this feature, and that can easily to use in any form and show the dialog 😃 |
Fixes #3279
Short description of what this resolves:
Added warning dialog to show when the user closes the tabs.