JavaScript Extension Development API for Oracle Visual Builder Cloud Service - Classic Applications

Class: components.dt/js/spi/deleters/Deleter

A deleter is used to cleanup artifacts generated by Creator. It is plugged-in into the Abcs system using the registration API (ComponentProviderRegistry).

The deleter by default doesn't raise any UI dialog for confirming the component deletion. In order to bring-up any confirmation you need to implement that into the cleanup method and fullfil the Promise with the result of the user decision then. See example below.

Don’t care about the deletion of the view from its parent. That is the responsibility of the Abcs infractructure itself and is done automatically.

In order to add a deleter for a new component type create an object with methods described by Deleter. The object must implement Deleter.cleanup method to clean the page or confirm the deletion process and Deleter.getType to specify the type of the deleter.

Version:
  • 16.3.5
Source:
See:
Example

Example of a view's deleter with confirmation dialog

define([
    'components.dt/js/spi/deleters/DeleterType'
], function (DeleterType) {

    'use strict';

    var MyDeleter = function () {
    };

    MyDeleter.prototype.cleanup = function (view, page) {
        var self = this;
        return new Promise(function(fulfil) {
            var dialogClosedListener = ko.observable(false);
            var confirmation = MyDeleter.createConfirmationDialog(dialogClosedListener);
            dialogClosedListener.subscribe(function() {
                var accepted = confirmation.isAccepted();

                if (accepted) {
                    // deletion is accepted, perform the cleanup
                    self._cleanArtefacts();
                }

                fulfil(accepted);
            });
            confirmation.showDialog();
        });
    };

    MyDeleter.prototype.getType = function () {
        return DeleterType.CLEANUP;
    };

    MyDeleter.prototype._cleanArtefacts = function () {
        // do all clean-up work
    };

    MyDeleter.createConfirmationDialog = function (dialogClosedListener) {
        return {
            isAccepted: function() {
                // implement the method and return the user answer to deletion dialog
            },
            showDialog: function() {
                // invoke the the confirmation dialog
                // call "dialogClosedListener(true);" once the dialog is closed
            }
        }
    };

    ...

    return MyDeleter;

});

Methods

cleanup(view, page) → {Promise.<Boolean>}

stable API

Cleans the View and the Page of artefacts generated originally by the component's Creator.

Parameters:
Name Type Description
view pages.dt/js/api/View

top view container to be deleted

page pages.dt/js/api/Page

the page owning the view in its hierarchy

Version:
  • 16.3.5
Source:
See:
  • Deleter for an example on how to implement the method
Returns:

Promise which fulfills before the view deletion is called; if the Promise fulfills with another value than true, the deletion process is interrupted and the view remains. The same happens if the Promise is rejected (in that case the reject's argument is printed as warning into the console).

Type
Promise.<Boolean>

getType() → {components.dt/js/spi/deleters/DeleterType}

stable API

Specifies the type of the deleter.

Every deleter must specify its type. The only publicly supported deleter is the DeleterType.CLEANUP now. Any custom deleter must return DeleterType.CLEANUP type.

Version:
  • 16.3.5
Source:
Returns:

deleter type

Type
components.dt/js/spi/deleters/DeleterType