123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- var SWAP_ERROR_NEED_XTAB = 100;
- var SWAP_ERROR_NEED_MORE = 101;
- function CSwap()
- {
- this.m_aExecParams = new Array();
- };
- CSwap.prototype = new AFeatureObject();
- CSwap.prototype.processErrorState = function ()
- {
- if (this.m_iErrorState === FEATURE_OBJECT_NO_ERROR)
- {
- return false;
- }
- else if (this.m_iErrorState === SWAP_ERROR_NEED_XTAB)
- {
- dlgShowMessage("SWAP_TITLE", "", "SWAP_ERROR_NEED_XTAB");
- return true;
- }
- else if (this.m_iErrorState === SWAP_ERROR_NEED_MORE)
- {
- dlgShowMessage("SWAP_TITLE", "", "SWAP_ERROR_NEED_MORE");
- return true;
- }
- };
- CSwap.prototype.proceedWithoutDialog = function ()
- {
- return this.execute();
- };
- CSwap.prototype.setup = function (aFeatureParams)
- {
- this.m_aParams = new Array();
- this.m_iErrorState = FEATURE_OBJECT_NO_ERROR;
- this.m_bRequiresDialog = false;
- this.m_aExecParams = new Array();
- var oMQMgr = goApplicationManager.getMiniQueryManager();
- if (oMQMgr.hasPivottedColumns())
- {
- var hasChart = false;
- var hasTable = true;
- var nonMeasureCount = 0;
- var chartType = "";
- var oChart = oMQMgr.getChart();
- if (typeof oChart == "object" && oChart.getAttribute("type") !== null)
- {
- chartType = oChart.getAttribute("type");
- if (oChart.getAttribute("showTable") == "false")
- {
- hasTable = false;
- }
- }
- var numMeasures = oMQMgr.getElementsByAttribute("usage", USAGE_VALUE_MEASURE).length;
- if (chartType !== "" && !(chartType == "pie" && numMeasures > 1) )
- {
- hasChart = true;
- for (var i = 0; i < oMQMgr.getAllColumns().length; i++)
- {
- if (oMQMgr.getHidden(i) == "none" && (!oMQMgr.isReportExpression(i)) && oMQMgr.isMeasure(i) === false && !(oMQMgr.getColumnRole(i) === MINI_QUERY_GROUP_SECTION))
- {
- nonMeasureCount++;
- }
- }
- }
- if (hasChart && (nonMeasureCount >= 2) && hasTable)
- {
-
- cfgSet("LAST_DIALOG", "swap");
- this.m_bRequiresDialog = true;
- this.m_aParams["m"] = "/" + qs_dir + "/swap.xts";
- }
- else if (hasChart && (nonMeasureCount < 2) && !hasTable)
- {
- this.m_iErrorState = SWAP_ERROR_NEED_MORE;
- }
- else if (hasChart && (nonMeasureCount >= 2))
- {
- this.m_aExecParams = ["chart"];
- }
- else
- {
- this.m_aExecParams = ["crosstab"];
- }
- }
- else
- {
- this.m_iErrorState = SWAP_ERROR_NEED_XTAB;
- }
- };
- CSwap.prototype.execute = function (aParameters)
- {
- var sCommand = "";
- if (this.m_aExecParams.length > 0)
- {
- if (this.m_aExecParams[0] == "crosstab")
- {
- sCommand = createCommand("M", "S", ['crosstab']);
- }
- else if (this.m_aExecParams[0] == "chart")
- {
- sCommand = createCommand("M", "S", ['chart']);
- }
- }
- else
- {
- try
- {
- var oDlgFrame = goApplicationManager.getDialogFrame();
- if (typeof oDlgFrame == "object")
- {
- if ((oDlgFrame.document.f.crosstab.checked === true)&&(oDlgFrame.document.f.chart.checked === true))
- {
- sCommand = createCommand("M", "S", ['all']);
- }
- else if (oDlgFrame.document.f.crosstab.checked === true)
- {
- sCommand = createCommand("M", "S", ['crosstab']);
- }
- else if (oDlgFrame.document.f.chart.checked === true)
- {
- sCommand = createCommand("M", "S", ['chart']);
- }
- }
- }
- catch (e)
- {
- }
- }
- if (sCommand !== "")
- {
- sendCmd(sCommand, "", true);
- }
- goApplicationManager.getWindowManager().hideDialogFrame();
- };
|