'Are you sure?' action

Hey Matt,

I’ve done popups just in Javascript without a template component. Try this, it’s my working code with your text inserted. I think the main difference is in the first line.

$('<div />').html('The following fields are empty: ' + emptyFields.join(', ') + '. Are you sure you want to continue?').dialog({
       title: 'Warning: Fields Are Empty',
        modal: true,
        resizable: false,
        width: 450,
        height: 180,
        buttons: [{
            text: 'Continue with empty fields',
            click: function () {
                $(this).dialog("close");
                dfd.resolve();                
            },
        }, {
            text: 'Cancel',
            class: 'nx-button-secondary',
            click: function () {
                $(this).dialog("close");
                dfd.reject();                
            },
        }]
    });
}

Thanks, Pablo! That worked.

you are welcome ,

@ryan using $(‘

’) didn’t work for me, I don’t remember why right now

Here’s a generalised confirmation popup function that can be added to inline Javascript and then called from snippets or inline Javascript. I’m using this routinely now.

function popupConfirmation(dfd, title, text, confirmButtonText, cancelButtonText) {
    var $ = skuid.$;
    $('<div />').html(text).dialog({
        title: title,
        modal: true,
        resizable: false,
        width: 450,
        height: 200,
        buttons: [{
            text: confirmButtonText,
            click: function () {
                $(this).dialog("close");
                dfd.resolve();                
            },
        }, {
            text: cancelButtonText,
            class: 'nx-button-secondary',
            click: function () {
                $(this).dialog("close");
                dfd.reject();                
            },
        }]
    });
}

For those interested in how custom action support might work for this particular use case, check out https://community.skuid.com/t/custom-action-support?rfm=1&topic_submit=true.

Why isn’t this under consideration? Strange no?

Yes. Even with workarounds in javascript, a stock ‘Confirmation popup’ action would still be really useful. I would use it a lot more often than I do the workaround now (and my users would end up making fewer mistakes that I have to unravel).

How would you call the popupConfirmation from a snippet?

I want to use this so that once the field update happens on the model then I want to prompt the user if they are sure they want to make that change.  

Here’s how the popupConfirmation method I gave above can be called from a snippet:

var $ = skuid&#46;$;<br />var dfd = $&#46;Deferred();<br />popupConfirmation(dfd, 'Continue', 'Are you sure you want to continue?','Continue','Cancel');<br />return dfd&#46;promise();

You can call it in a snippet that is called from a Multiple Action item. If the deferred variable is rejected, the Multiple Action items after the snippet call will not be executed.

Thank you … I got this working and it was a huge help.

For V2 equivalent, something like this should work:

function popupConfirmation(dfd, title, text, confirmButtonText, cancelButtonText) {

const modal = skuid.utils.createModal({

title: title,

width: “450px”,

height: “200px”,

components: [

{

componentType: "skuid__text",

contents: text,

},

],

buttons: [{

label: confirmButtonText,

onClick: function() {

modal.cpi.close();

dfd.resolve();

},

}, {

label: cancelButtonText,

onClick: function() {

modal.cpi.close();

dfd.reject();

},

}],

});

}