Example of Creating the MetabaseSaveDialog Component

Before executing the example, study recommendations to code writing. Make sure that repository contains an express report with the 88665 key.

To create the MetabaseSaveDialog component, use HTML code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>MetabaseSaveDialog</title>
    <script src="../build/PP.js" type="text/javascript"></script>
    <script src="../build/PP.Metabase.js" type="text/javascript"></script>
    <script src="../build/PP.Express.js" type="text/javascript"></script>
    <script src="../build/PP.Navigator.js" type="text/javascript"></script>
    <script type="text/javascript" src="../resources/Metabase.resources.ru.js"></script>
    <script type="text/javascript" src="../resources/Express.resources.ru.js"></script>
    <script type="text/javascript" src="../resources/Navigator.resources.ru.js"></script>
    <link href="../build/PP.css" rel="stylesheet" type="text/css" />
    <link href="../build/PP.Metabase.css" rel="stylesheet" type="text/css" />
    <link href="../build/PP.Express.css" rel="stylesheet" type="text/css" />
 
    <script type="text/javascript">
        var metabase, eaxMdService, eaxAnalyzer, saveDialog;
        // Function executed on loading HTML document
        function onLoad() {
            // Specify path to root folder with resources files
            PP.resourceManager.setRootResourcesFolder("../../resources/");
            // Determine language settings for resources
            PP.setCurrentCulture(PP.Cultures.ru);
            // Create a repository connection
            metabase = new PP.Mb.Metabase({
                // Set PP.SOM web service URL in the format:
                // <http://<ServerName | IP-address>[:<Port>][/<VirtualCatalog>]/axis2/services/PP.SOM.Som>
                PPServiceUrl: "http://localhost/FPBI_App_v9.2x64/axis2/services/PP.SOM.Som",
                Id: "Repository",
                UserCreds: {
                    UserName: "user",
                    Password: "password"
                }
            });
            // Open repository connection
            metabase.open();
            // Create a service for working with express reports
            eaxMdService = new PP.Exp.EaxMdService({
                Metabase: metabase
            });
            // Open express report with the 88665 key
            eaxAnalyzer = eaxMdService.editDocument(88665);
            // Determine filters array for dialog box
            var filters = [{
                Filters: [2561, 0],
                ResourceKey: "openDialogExpressReports",
                iconIndex: 16
            }];
            // Determine languages array to translate saved object name
            var displayLanguages = [];
            displayLanguages.push(PP.Cultures.ru.LCID); // Russian
            displayLanguages.push(PP.Cultures.en.LCID); // English
            // Create an object save dialog box
            saveDialog = new PP.Navigator.MetabaseSaveDialog({
                DefaultId: "EXP_REPORT", // Saved object identifier
                /* Determine saved object name */
                DefaultName: "Dynamics of indicators by region",
                Metabase: metabase,
                FiltersSet: filters, // Filters array for dialog box
                CurrentFilter: filters[1], // Current filter
                ImagePath: "../build/img/",
                OpenToKey: parseInt(eaxAnalyzer.getParentKey() || 0),
                // Determine translations of saved object name in Russian and English
                Names: [{
                    locale: PP.Cultures.ru.LCID,
                    name: "Dynamics of indicators by region"
                }, {
                    locale: PP.Cultures.en.LCID,
                    name: "Dynamics indicators by region"
                }],
                ShowTranslateButton: true, // Show button to display object name translations
                // Set dialog box to translate saved object name into different languages.
                TranslateDialog: new PP.Mb.Ui.TranslateDialog({
                    DisplayLanguages: displayLanguages
                }),
                SaveAsObject: function (sender, args) { // Handle the SaveAsObject event
                    console.log("Saved object name in different languages:");
                    var names = args.Names;
                    for (var i in names) {
                        var n = names[i];
                        console.log("Language code: " + n.locale + ", name: " + n.name);
                    }
                }
            });
            saveDialog.show(); // Display object save dialog box
        }
    </script>
</head>
<body onload="onLoad();">
</body>
</html>

After executing the example the HTML page will contain the MetabaseSaveDialog component:

Clicking the OK button generates the SaveAsObject event and displays the message to the browser console:

Name of the saved object in different languages:
Language code: 1033, Name: Dynamics indicators by region
Language code: 1049, Name: Dynamics of indicators by region

See also:

MetabaseSaveDialog