1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- *
- * IBM Cognos Products: BI UI Commons
- *
- * Copyright IBM Corp. 2017, 2018
- *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['bacontentnav/ui/dialogs/SaveAsDialog', 'storytelling/nls/StringResources', './ExportView', 'underscore'], function (BaseDialog, StringResources, ExportView, _) {
- /**
- * Create an export dialog that will be used to select a folder and a file name.
- * A service object can be passed to the dialog in order to implement the saving process and returns a Promise.
- * Doing so will show an overwrite dialog if the promise returns an error.
- * Note: If passing a service, onSave won't be called.
- *
- * @param - options
- * {
- * glassContext: <glassContextObject>, // Glass context object.
- * defaultFileName: "some name", // Default file name to be used in the save dialog.
- * onHide: function() {} // Callback when dialog is hidden.
- * viewOptions.url String , viewOptions.selfUrl String and viewOptions.ancestors Array of objects are three parameters
- * to customize the initial folder when dialog opens
- *
- * service: {
- * export: function (service, selection, filename, overwrite, loadAfterSave) // export function returning a promise.
- * : Promise() // The promise should be resolved when the save succeed, or can reject
- * // with the following object: { isDuplicate: true }
- * }
- *
- * }
- *
- */
- var ExportToStoryDialog = BaseDialog.extend({
- init: function init(options) {
- this.options = options;
- this.options.service = this.options.service || {};
- this.options.service.save = this.onSave.bind(this);
- var dialogOptions = _.defaults(this.options, {
- 'buttons': [{
- 'text': StringResources.get('exportLabel'),
- 'handler': this.ok.bind(this),
- 'type': 'primary',
- 'defaultId': 'save_button'
- }, 'cancel'],
- 'viewClass': ExportView,
- 'className': 'exportToStoryDialog',
- 'id': 'exportDialogTitle',
- 'title': StringResources.get('exportDialogTitle')
- });
- ExportToStoryDialog.inherited('init', this, [dialogOptions]);
- },
- /**
- * Called when the dialog is opened
- */
- onOpen: function onOpen() {
- ExportToStoryDialog.inherited('onOpen', this);
- var container = this._container();
- container.find('footer').attr('role', 'contentinfo').attr('aria-label', StringResources.get('exportDialogFooter'));
- },
- /**
- * Called when the export button is clicked
- */
- onSave: function onSave(service, selection, filename, overwrite) {
- return this.options.service.export(service, selection, filename, overwrite, this.view.getLoadAfterExport());
- }
- });
- return ExportToStoryDialog;
- });
- //# sourceMappingURL=ExportToStoryDialog.js.map
|