Table Of Contents

Application Packaging Standard

Last updated 18-Mar-2019

aps/confirm

Creates popup window to confirm an action.

The popup window allows a user to confirm or cancel an action. Since it returns a promise, use the ``then(function(response){})`` method to process the response.

Return: dojo/deferred instance

Overview

The APS confirmation popup container is called by the aps/confirm method. The method allows you to specify a title and description of what you need to confirm or reject.

The popup container provides the OK and Cancel buttons to confirm or reject the displayed contents respectively. It is possible to redefine the labels of these buttons.

require([
    "aps/confirm",
    ...
], function(confirm,...) {

   // ...

   /*  The method returns a promise that can be processed by the call-back function */
   confirm({
      title: <string>,
      size: <string: either "lg", or "md", or "sm">,
      description: <string>,
      submitLabel: <string>,
      submitType: <string>,
      submitIcon: <string>,
      cancelLabel: <string>,
      cancelType: <string>,
      cancelIcon: <string>
   })
   /* Call-back function */
   .then(
       /* Success callback */
       function(response) {
         if(response === true) {
           //... do something on the `OK` response
           //...
         }
         else {
           //... do something on the `Cancel` response
           //...
         }
       },
       /* Error callback */
       function() {
           //... do something on Error
       }
   );

The submitType or cancelType and submitIcon or cancelIcon are similar respectively to the type and iconClass properties of the aps/button widget.

The size property is a string that specifies the pop-up window size:

  • “lg” - large, default value
  • “md” - middle
  • “sm” - small

Since the aps/confirm method returns a Dojo Promise object, the returned value should be processed using the asynchronous then method. The submitLabel and cancelLabel arguments are optional. Default values are: “OK” and “Cancel”.

Example

The following steps let you test the aps/confirm method.

  1. Download the basic sample package and unpack it.

  2. Open the ui/server.new-last.js file in a text editor.

  3. Add "aps/confirm" to the require method and the confirm argument to the main call-back function.

  4. Replace the onSubmit handler with the following code that calls a confirmation popup widget:

    self.onSubmit = function() {
        confirm({title: "Save Configuration",
             description: "Are you sure the Server configuration is ready to save?"})
        .then(function(response) {
             if(response === true) {
                 when(store.put(getPlainValue(model.newVPS)),
                    function() {
                       aps.apsc.gotoView("servers");
                    },
                    displayError
                 );
             }
             else aps.apsc.cancelProcessing();
        });
    };
    
  5. Deploy the package and provision the application.

  6. In the customer control panel, start creating a VPS. On the Servers / Review page, when you click the Finish button, the request for confirmation must pop up.

    ../../../../../_images/confirm.png
  7. Test both buttons, Cancel and Ok, in sequence.

Parameters

ARGUMENT TYPE DESCRIPTION
params
__params