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

webapp.pdf-exporter-admin.js.css.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
SbbCommon.init({
    extension: 'pdf-exporter',
    setting: 'css',
    scope: SbbCommon.getValueById('scope'),
    initCodeInput: true
});
Configurations.init({
    setConfigurationContentCallback: setCss
});

function saveCss() {
    SbbCommon.hideActionAlerts();

    SbbCommon.callAsync({
        method: 'PUT',
        url: `/polarion/${SbbCommon.extension}/rest/internal/settings/${SbbCommon.setting}/names/${Configurations.getSelectedConfiguration()}/content?scope=${SbbCommon.scope}`,
        contentType: 'application/json',
        body: JSON.stringify({
            'css': SbbCommon.getValueById('css-input')
        }),
        onOk: () => {
            SbbCommon.showSaveSuccessAlert();
            SbbCommon.setNewerVersionNotificationVisible(false);
            Configurations.loadConfigurationNames();
        },
        onError: () => SbbCommon.showSaveErrorAlert()
    });
}

function revertToDefault() {
    if (confirm("Are you sure you want to return the default value?")) {
        loadDefaultContent()
            .then((responseText) => {
                setCss(responseText);
                SbbCommon.showRevertedToDefaultAlert();
            })
    }
}

function setCss(text) {
    const cssModel = JSON.parse(text);
    SbbCommon.setValueById('css-input', cssModel.css);
    if (cssModel.bundleTimestamp !== SbbCommon.getValueById('bundle-timestamp')) {
        loadDefaultContent()
            .then((responseText) => {
                const defaultCssModel = JSON.parse(responseText);
                SbbCommon.setNewerVersionNotificationVisible(cssModel.css && defaultCssModel.css
                    && (cssModel.css.length !== defaultCssModel.css.length || cssModel.css !== defaultCssModel.css));
            })
    }
}

function loadDefaultContent() {
    return new Promise((resolve, reject) => {
        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) => resolve(responseText),
            onError: () => {
                SbbCommon.setLoadingErrorNotificationVisible(true);
                reject();
            }
        });
    });
}

Configurations.loadConfigurationNames();




© 2015 - 2024 Weber Informatics LLC | Privacy Policy