"use strict"; /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: BI Dashboard *| (C) Copyright IBM Corp. 2015, 2017 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define(['../../../lib/@waca/core-client/js/core-client/ui/core/Class', 'bi/admin/nls/StringResource', 'ba-react-admin/ba-react-admin.min', 'bacontentnav/ui/dialogs/SaveAsDialog'], function (BaseClass, stringResources, AdminReact, SaveAsDialog) { 'use strict'; var ActionHandler = BaseClass.extend({ onPress: function onPress(context) { if (context.target.plugin.itemSpec.id === 'com.ibm.bi.job_mgt.saveMenu') { return this.doSave(context); } this.doClassicLink(context); }, closeAppAndLoadClassicUI: function closeAppAndLoadClassicUI(context) { var jobId = AdminReact.JobObjectStore.id; return context.glassContext.appController.closeAppView('job_mgt', '123').then(function () { var jPath = 'storeID("' + jobId + '")'; window.open('v1/disp?b_action=xts.run&m=portal/properties_job.xts&m_class=jobDefinition&m_obj=' + jPath + '&backURL=disp%3Fb_action%3Dxts.run%26m%3Dportal%2Fclose.xts%26ui.compid%3Dps', '_blank'); }); }, doClassicLink: function doClassicLink(context) { if (AdminReact.JobObjectStore.isDirty || AdminReact.JobObjectStore.isNew) { this.doSave(context).then(function (res) { console.log(res); this.closeAppAndLoadClassicUI(context); }.bind(this)); return; } this.closeAppAndLoadClassicUI(context); }, doSave: function doSave(context) { var glassContext = context.glassContext; if (AdminReact.JobObjectStore.isNew) { var pro = new Promise(function (resolve) { var dialog = new SaveAsDialog({ glassContext: glassContext, onSave: function (location, name) { this.respondToSave(glassContext, location, name, resolve); }.bind(this) }); dialog.title = stringResources.get('createNewJob'); dialog.open(); this.dialog = dialog; }.bind(this)); return pro; } else { AdminReact.JobObjectStore.save(glassContext); return Promise.resolve(); } }, isItemVisible: function isItemVisible() { return false; //return (AdminReact.JobObjectStore.canWrite); }, respondToSave: function respondToSave(glassContext, location, name, resFunction) { this.dialog.hide(); AdminReact.JobObjectStore.save(glassContext, location, name).then(function () { glassContext.appController.currentAppView.currentContentView.updateAfterSave(); if (resFunction) { resFunction(); } }); } }); return ActionHandler; });