Using javascript dialog instead of confirm

I can share code if it helps but I am not sure in this case it will. Let me know if you think differently.

I am on SuiteCRM v 7.12 and 7.13 (different test installations) running on Debian 11 with PHP 7.4

I am trying to trigger a javascript dialog modal window when a user selects a (new, custom) menu item from the “Bulk Action” dropdown options.

Has anyone been able to create a javascript dialog modal window from a menu selection and if so, how?

I have the menu item working with great thanks to John Mertic’s post at

and @pgr 's notes at

The issue is when I try to create a javascript dialog modal window to have the user confirm they really want to do this. I want a user confirmation since if they choose (and confirm) their menu selection, they will be editing many records in the database, not just displaying the contents of the database. I am restricting the option to people in a role which allows editing, but still want a confirmation.

I can accomplish this using the built-in javascript confirm method, but the confirm method can be disabled by the user (after a couple of popup’s the user is presented with a checkbox to disable the modal window) and if disabled, the default return of what would have been a popup is “Cancel”, which defeats the whole purpose of asking the user to confirm their menu selection.

So I wanted to create my own modal window using javascript dialog element (vanilla javascript, not jquery) and I have that working perfectly outside of SuiteCRM, but when I put the same code into SuiteCRM, the system does not bring up a modal window, it freezes the screen and the page must be refreshed to get it active again.

I did alos try using jquery and again, got it working perfectly outside of SuiteCRM but not once the same code was put into SuiteCRM.

Has anyone been able to succesfully create a javascript dialog modal window from a menu selection and if so, how?

You need to use YUI, the Yahoo “framework” that V7 uses.

Have a look at something similar I made in this PR

@pgr

Thank you for the quick reply .

I did not try the YAHOO route because of the statment:

SuiteCRM deprecated and totally removed YUI library with version 7.11.16

in the following post

Has Yahoo YUI been taken out of SuiteCRM or was the person who posted that incorrect?

I have not yet tried the Yahoo YUI method - see my previous response to your post - but I did look at your code.

I looks like the Yahoo YUI is allowing me to customize the look of the popup, but it then calls the “alert” dialog.

If this is what it is doing, then I’m back at the issue of the alert/confirm popup being something the user can disable future popups by checking the box that is presented after a few uses of the alert/confirm built-in function.

Is there a way to disable the disable? Can I prevent the checkbox/label from appearing in the alert/confirm dialog box?

Sorry about the multiple posts

I did check the code in my current (7.13) version of SuiteCRM in
[modules/OutboundEmailAccounts/OutboundEmailAccounts.php
and it still does use the YAHOO.SUGAR.MessageBox functionality

I can dig into that some more but before doing that, I would want to know that SuiteCRM is not deprecating Yahoo YUI. If it is being deprecated then my solution, if put into production, would not last long.

Do you know anything about Yahoo YUI being deprecated in SuiteCRM?

You’re right about that deprecation, maybe this is just a matter of names, but if it’s no longer YUI, it’s certainly something, because those modal dialogs are still there! :slight_smile: There are over a hundred references to yahoo.sugar in the code base. I guess some version of YUI was deprecated, some other bits are still in there.

I would be very sure that all of that is not going anywhere in v7.x, because it would be a lot of work, really a lot, and it’s totally not worth it.

On the other hand, nothing that you have in v7 front-end will apply to v8 front-end (Angular). If you’re doing developments for both versions, you will really have to come up with two completely different things, there’s no getting around that.

OK, I get that point

Now the question: Is yahoo.message launching the alert/confirm modal window (after using the yahoo.message setup to format the window)?

If so, I am back where I started with the risk of a user disabling the popup by slecting the “Disable …?” option presented by the alert/confirm popup after a few uses of the popup.

Question re the vy → v8 transition:

I did not know all front-end customizations in v8 would be incompatible with v7 but now that you say it, I guess it makes sense, given that jquery is no longer the framework.

But if I write my front-end customizations using vanilla javascript and avoiding jquery altogether, will they still work when/(now if) I go to v8 ?

I don’t believe that the browser will interfere with the modal opened by those functions. I don’t think your users will get a way to disable it. But you’ll have to try it.

About the custom work, The whole idea of injecting JS is going against the grain of the Angular framework. I don’t believe there will be any good way forward except learning Angular and rewriting custom stuff to Angular.

I have that drama myself and I take comfort from the fact that learning Angular will make me a better programmer, not just for learning one other thing, but because these modern frameworks actually teach you architecture and good app design; they are very well thought out and designed.

Note that, apart from the initial learning curve (which is significant) eventually the front-end development gets a lot better with a proper framework. Injected messy JS over messy JS is a ton of problems, as I’m sure you know already…

You are a better man than me @pgr:slight_smile:

I am not sure if this means I will leave my system at v7 (upgraded to php v8) or take the plunge and move it to v8. There is a lot of customization in this particular system and I did it for free since it is my Rotary and I want tto be able to use the funds we raise for our charitable projects, not paying me.

However, that altruism (on this project) only goes so far … :frowning:

Thanks for your help on this you are a star sir

1 Like

Wow,

I just took the Angular tutorial, and it pretty much confirms my prior statement.

After over an hour of just following their “simple” example, just copying/pasting what they told me to do - and not really learning how to do this on my own even for a “simple” example - I did conclude one thing.

With SuiteCRM going with Angular, I expect most casual programmers (read people like me who learned the coding game on Assembler, Fortran and Cobol and who want to keep somewhat current on programming) will no longer be active participants in debugging or code enhancement for SuiteCRM.

Angualr is just too much of a learning curve for a hobbyist.

I get that SuiteCRM wants to make the underlying code more structured, consistent and maintainable, enabling fewer bugs and easier future development. All to be applauded.

But I’ll be sticking with SuiteCRM v7 for now, and maybe ongoing. Once I get SuiteCRM v7 onto Php v8, that will likely be my LTS version.

My curiosity may get the better of me at some point in the future and I may take another shot at Angular, but with the skyrocketing popularity of React and Node.js, especially for smaller projects, I am more likely going to go that route.

I appreciate all the help you - and others - have provided on this forum over the years. And based on your suggestion, I did hire Andre Lopes at Lamapada Global for some really tricky work on my Rotary project and he has been great, thank you.