All Downloads are FREE. Search and download functionalities are using the official Maven repository.

webapp.pdf-exporter-admin.js.filename-template.js Maven / Gradle / Ivy

Go to download

This Polarion extension provides possibility to convert Polarion Documents to PDF files. This is an alternative to native Polarion's solution.

There is a newer version: 7.0.1
Show newest version
const DEFAULT_SETTING_NAME = "Default";

SbbCommon.init({
    extension: 'pdf-exporter',
    setting: 'filename-template',
    scope: SbbCommon.getValueById('scope'),
    initCodeInput: true
});

function saveSettings() {
    SbbCommon.hideActionAlerts();

    SbbCommon.callAsync({
        method: 'PUT',
        url: `/polarion/${SbbCommon.extension}/rest/internal/settings/${SbbCommon.setting}/names/${DEFAULT_SETTING_NAME}/content?scope=${SbbCommon.scope}`,
        contentType: 'application/json',
        body: JSON.stringify({
            'documentNameTemplate': SbbCommon.getValueById('document-name-template'),
            'reportNameTemplate': SbbCommon.getValueById('report-name-template'),
            'testRunNameTemplate': SbbCommon.getValueById('testrun-name-template')
        }),
        onOk: () => {
            SbbCommon.showSaveSuccessAlert();
            SbbCommon.setNewerVersionNotificationVisible(false);
            Configurations.loadConfigurationNames();
        },
        onError: () => SbbCommon.showSaveErrorAlert()
    });
}

function revertToDefault() {
    if (confirm("Are you sure you want to return the default values?")) {
        SbbCommon.setLoadingErrorNotificationVisible(false);
        SbbCommon.hideActionAlerts();

        SbbCommon.callAsync({
            method: 'GET',
            url: `/polarion/${SbbCommon.extension}/rest/internal/settings/${SbbCommon.setting}/default-content`,
            contentType: 'application/json',
            onOk: (responseText) => {
                SbbCommon.showRevertedToDefaultAlert();
                setSettings(responseText);
            },
            onError: () => SbbCommon.setLoadingErrorNotificationVisible(true)
        });
    }
}

function setSettings(content) {
    const settings = JSON.parse(content);
    SbbCommon.setValueById('document-name-template', settings.documentNameTemplate);
    SbbCommon.setValueById('report-name-template', settings.reportNameTemplate);
    SbbCommon.setValueById('testrun-name-template', settings.testRunNameTemplate);

    if (settings.bundleTimestamp !== SbbCommon.getValueById('bundle-timestamp')) {
        SbbCommon.setNewerVersionNotificationVisible(true);
    }
}

function readSettings() {
    SbbCommon.callAsync({
        method: 'GET',
        url: `/polarion/${SbbCommon.extension}/rest/internal/settings/${SbbCommon.setting}/names/${DEFAULT_SETTING_NAME}/content?scope=${SbbCommon.scope}`,
        contentType: 'application/json',
        onOk: (responseText) => {
            setSettings(responseText)
        },
        onError: () => SbbCommon.setLoadingErrorNotificationVisible(true)
    });
}

readSettings();




© 2015 - 2024 Weber Informatics LLC | Privacy Policy