/* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| BI and PM: prmt *| (C) Copyright IBM Corp. 2002, 2016 *| *| US Government Users Restricted Rights - Use, duplication or *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *| *+------------------------------------------------------------------------+ */ //////////////////////////////////////////////////////////////////// // SelectValue HTML generation functions //////////////////////////////////////////////////////////////////// // Function to create a select prompt control // sPromptId: The id of the prompt control (String) // sFormName: Name of form control to submit selections to the server (String) // sParameterName: Name of control element to be submitted to report server (String) // sSubmitType: 'default' will submit as a standard form (String) // 'XML' will convert the submission to XML and submit // sAutoSubmitType: specify whether the autosubmit should stay on the same page (reprompt) // or move to the next prompt page (prompt) // ['prompt'|'reprompt'] (String) // sSelectUI: UI of control ['listbox'|'checkboxGroup'|'radioGroup'|'dropdown'] // sColumnName: Column name which control is a prompt of (String) // iInitialState: Range controls only. Controls whether to check radio buttons (Integer) // RANGE_NO_VALUE will select lowest to highest // RANGE_START_VALUE will select from a particular value to highest // RANGE_END_VALUE will select from lowest to a particular value // RANGE_BOUND_VALUE will select a range // RANGE_EQUAL_VALUE will select a single value // bDisabled: If control is disabled from user input (Boolean) // bRequired: If the control is a required field. (Boolean) // bAutoSubmit: If the control is submitted as soon as user selects a value (Boolean) // bHideAdornments: Hide icons (e.g. star icon for required controls) (Boolean) // bSuppressExtraPromptNames: Force report server to handle multiple prompt controls as a single entity (Boolean) // e.g. treat datetime control as a single date time, as opposed to treating date and time independntly // bMulti: If control can accomodate more than one value. (Boolean) // bRange: If control is a range. (Boolean) // sStyle: Style of prompt control. (String) // bShowParentDetails: ? // iNumSelectOptions: The number of selectOptions known of ahead of time function genSelectValueHTML(sPromptId, sFormName, sParameterName, sSubmitType, sAutoSubmitType, sSelectUI, sColumnName, iInitialState, bDisabled, bRequired, bAutoSubmit, bHideAdornments, bSuppressExtraPromptNames, bMulti, bRange, sStyle, bShowParentDetails, iNumSelectOptions, bShowGroupingBox) { var oProperties = sPromptId; if (arguments.length > 1 || typeof oProperties != K_PRMT_sOBJECT) { oProperties = { id: sPromptId, formName: sFormName, parameterName: sParameterName, submitType: sSubmitType, autoSubmitType: sAutoSubmitType, selectUI: sSelectUI, columnName: sColumnName, initialState: iInitialState, disabled: bDisabled, required: bRequired, autoSubmit: bAutoSubmit, hideAdornments: bHideAdornments, supressExtraPromptNames: bSuppressExtraPromptNames, multi: bMulti, range: bRange, style: sStyle, showParentDetails: bShowParentDetails, numSelectOptions: iNumSelectOptions, alwaysShowGroupingBox: bShowGroupingBox }; } if (oProperties.multi && oProperties.range) { genSelectValueRangeMultipleHTML(oProperties); } else { if (oProperties.range) { genSelectValueRangeHTML(oProperties); } else { genSelectValueSMHTML(oProperties); } } } function cancelScroll() { window.event.cancelBubble = true; window.event.returnValue = false; } function genSelectValueSMHTML(s_PromptId, s_FormName, s_ParameterName, s_SubmitType, s_AutoSubmitType, s_SelectUI, s_ColumnName, b_Disabled, b_Required, b_AutoSubmit, b_MultiSelect, b_HideAdornments, b_SuppressExtraPromptNames, s_Style, b_ShowParentDetails, i_NumSelectOptions, b_alwaysShowGroupingBox) { var oProperties = s_PromptId; if (arguments.length > 1 || typeof oProperties != K_PRMT_sOBJECT) { oProperties = { id: s_PromptId, formName: s_FormName, parameterName: s_ParameterName, submitType: s_SubmitType, autoSubmitType: s_AutoSubmitType, selectUI: s_SelectUI, columnName: s_ColumnName, disabled: b_Disabled, required: b_Required, autoSubmit: b_AutoSubmit, multi: b_MultiSelect, hideAdornments: b_HideAdornments, supressExtraPromptNames: b_SuppressExtraPromptNames, style: s_Style, showParentDetails: b_ShowParentDetails, numSelectOptions: i_NumSelectOptions, alwaysShowGroupingBox: b_alwaysShowGroupingBox}; } var sPromptId = oProperties.id; var sParamName = "_" + oProperties.parameterName; if (!oProperties.supressExtraPromptNames) { sParamName = "p" + sParamName; } if (!verifyPromptId(sPromptId) || !verifyPromptId(sParamName)) { return; } //skin folder var sSkin = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN); var sFormName = oProperties.formName; if (!sFormName) { sFormName = "forms[0]"; } var sErrorImg = null; if (!oProperties.hideAdornments) { sErrorImg = "document." + sFormName + ".imgTest" + sPromptId; } var sFormElementName = sParamName; var sStyle = oProperties.style; if (typeof sStyle != K_PRMT_sSTRING) { sStyle = K_PRMT_sEMPTY; } if (oProperties.submitType == K_PRMT_sXML) { sFormElementName = "_oLstChoices" + sPromptId; } sFormElementName = jsEncodeStr(sFormElementName); var sAutoSubmitBehavior = "setTimeout('listBox" + sPromptId + ".checkData()', 100);"; if (oProperties.autoSubmit) { sAutoSubmitBehavior = "setTimeout('listBox" + sPromptId + ".autoSubmit()', 100);"; } var sWidth = cssParser( oProperties.style, "width" ); if( sWidth != K_PRMT_sEMPTY && sWidth.match( /\s*width\s*:\s*\d+%/gi ) ) { sWidth = "width:100%;"; } else { sWidth = K_PRMT_sEMPTY; } var HTMLOut = K_PRMT_sEMPTY, JSOut = K_PRMT_sEMPTY; if (oProperties.submitType == K_PRMT_sXML) { HTMLOut += genHiddenInputHTML(sFormName, jsEncodeStr(sParamName), K_PRMT_sEMPTY); } HTMLOut += "
"; renderPromptControlHTML("selectValue" + sPromptId, HTMLOut); executePromptControlJS(JSOut); } function genSelectValueRangeHTML(s_PromptId, s_FormName, s_ParameterName, s_SubmitType, s_AutoSubmitType, s_SelectUI, s_ColumnName, i_InitialState, b_Disabled, b_Required, b_AutoSubmit, b_MultiSelect, b_HideAdornments, b_SuppressExtraPromptNames, s_Style) { var oProperties = s_PromptId; if (arguments.length > 1 || typeof oProperties != K_PRMT_sOBJECT) { oProperties = { id: s_PromptId, formName: s_FormName, parameterName: s_ParameterName, submitType: s_SubmitType, autoSubmitType: s_AutoSubmitType, selectUI: s_SelectUI, columnName: s_ColumnName, initialState: i_InitialState, disabled: b_Disabled, required: b_Required, autoSubmit: b_AutoSubmit, multi: b_MultiSelect, hideAdornments: b_HideAdornments, supressExtraPromptNames: b_SuppressExtraPromptNames, style: s_Style }; } var sPromptId = oProperties.id; if (!verifyPromptId(sPromptId)) { return; } //skin folder var sSkin = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN); var sFormName = oProperties.formName; if (!sFormName) { sFormName = "forms[0]"; } var sParamName = "_" + oProperties.parameterName; if (!oProperties.supressExtraPromptNames) { sParamName = "p" + sParamName; } if (!verifyPromptId(sParamName)) { return; } var sWidth = K_PRMT_sEMPTY; if( cssParser( oProperties.style, 'width' ) != K_PRMT_sEMPTY ) { sWidth = 'width:100%;'; } var HTMLOut = K_PRMT_sEMPTY; if (oProperties.submitType == K_PRMT_sXML) { HTMLOut += genHiddenInputHTML(sFormName, jsEncodeStr(sParamName), K_PRMT_sEMPTY); } HTMLOut += ""; renderPromptControlHTML("selectValue" + sPromptId, HTMLOut); var JSOut = "genSelectValueSMHTML(" + generatePromptProperties(oProperties, { id: "range_from" + sPromptId, formName: sFormName, parameterName: "range_from" + oProperties.parameterName, hideAdornments: (oProperties.required==true)?false:true, autoSubmitType: K_PRMT_sEMPTY, selectUI: 'dropdown', autoSubmit: false, style: cssParser(oProperties.style, 'background-color,color,font,text') + sWidth, suppressExtraPromptNames: true}) + ");" + "genSelectValueSMHTML(" + generatePromptProperties(oProperties, { id: "range_to" + sPromptId, formName: sFormName, parameterName: "range_to" + oProperties.parameterName, autoSubmitType: K_PRMT_sEMPTY, hideAdornments: (oProperties.required==true)?false:true, selectUI: 'dropdown', autoSubmit: false, style: cssParser(oProperties.style, 'background-color,color,font,text') + sWidth, suppressExtraPromptNames: true}) + ");"; if (oProperties.required) { JSOut += "this.range" + sPromptId + " = new CRange(document.forms['" + sFormName + "'].elements[" + '"' + jsEncodeStr(sParamName) + '"' + "], null, listBoxrange_from" + sPromptId + ", null, null, listBoxrange_to" + sPromptId + ", null, null, true, '" + oProperties.submitType + "', null, '" + getCVId(oProperties) + "');"; } else { JSOut += "this.range" + sPromptId + " = new CRange(document.forms['" + sFormName + "'].elements[" + '"' + jsEncodeStr(sParamName) + '"' + "], document.forms['" + sFormName + "'].elements['fromValue" + sPromptId + "'][0], listBoxrange_from" + sPromptId + ", null, document.forms['" + sFormName + "'].elements['toValue" + sPromptId + "'][0], listBoxrange_to" + sPromptId + ", null, null, false, '" + oProperties.submitType + "', " + oProperties.initialState + ", '" + getCVId(oProperties) + "');"; } var sCVObj = getCVInstance(oProperties); JSOut += sCVObj + "preProcessControlArray = " + sCVObj + "preProcessControlArray.concat('range" + sPromptId + "');" + sCVObj + "rangeObserverArray = " + sCVObj + "rangeObserverArray.concat('range" + sPromptId + "');"; executePromptControlJS(JSOut); } function genSelectValueRangeMultipleHTML(s_PromptId, s_FormName, s_ParameterName, s_SubmitType, s_AutoSubmitType, s_SelectUI, s_ColumnName, i_InitialState, b_Disabled, b_Required, b_AutoSubmit, b_MultiSelect, b_HideAdornments, b_SuppressExtraPromptNames, s_Style, i_NumSelectOptions, b_alwayShowGroupingBox) { var oProperties = s_PromptId; if (arguments.length > 1 || typeof oProperties != K_PRMT_sOBJECT) { oProperties = { id: s_PromptId, formName: s_FormName, parameterName: s_ParameterName, submitType: s_SubmitType, autoSubmitType: s_AutoSubmitType, selectUI: s_SelectUI, columnName: s_ColumnName, initialState: i_InitialState, disabled: b_Disabled, required: b_Required, autoSubmit: b_AutoSubmit, hideAdornments: b_HideAdornments, supressExtraPromptNames: b_SuppressExtraPromptNames, multi: b_MultiSelect, style: s_Style, numSelectOptions: i_NumSelectOptions, alwayShowGroupingBox: b_ShowGroupingBox}; } var sPromptId = oProperties.id; if (!verifyPromptId(sPromptId)) { return; } //skin folder var sSkin = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN); var sFormName = oProperties.formName; if (!sFormName) { sFormName = "forms[0]"; } var sParamName = "_" + oProperties.parameterName; if (!oProperties.supressExtraPromptNames) { sParamName = "p" + sParamName; } if (!verifyPromptId(sParamName)) { return; } var sWidth = K_PRMT_sEMPTY; if( cssParser( oProperties.style, 'width' ) != K_PRMT_sEMPTY ) { sWidth = 'width:100%;'; } var sHTMLOut = K_PRMT_sEMPTY; if (oProperties.submitType == K_PRMT_sXML) { sHTMLOut += genHiddenInputHTML(sFormName, jsEncodeStr(sParamName), K_PRMT_sEMPTY); } sHTMLOut += ""; renderPromptControlHTML("selectValue" + sPromptId, sHTMLOut); var sCVObj = getCVInstance(oProperties); var JSOut = "genSelectValueRangeHTML(" + generatePromptProperties(oProperties, { id: "r_" + sPromptId, formName: sFormName, parameterName: "r_" + oProperties.parameterName, autoSubmitType: K_PRMT_sEMPTY, selectUI: 'dropdown', required: false, style: cssParser(oProperties.style, 'background,color,font,text') + sWidth, suppressExtraPromptNames: true}) + ");" + "genInsertButtonHTML('" + sPromptId + "', 'multipleRange" + sPromptId + ".insertChoiceList()', 'insertButton" + sPromptId + "');" + "genRemoveButtonHTML('" + sPromptId + "', 'multipleRange" + sPromptId + ".removeChoiceList()', 'removeButton" + sPromptId + "');" + "this.multipleRange" + sPromptId + " = new CMultipleRange(ranger_" + sPromptId + ", document.forms['" + sFormName + "'].elements['_oLstChoices" + sPromptId + "'], document.forms['" + sFormName + "'].elements[" + '"' + jsEncodeStr(sParamName) + '"' + "], " + oProperties.required + ", '" + oProperties.submitType + "', document.getElementById('multipleRangeFeedback" + sPromptId + "'), document.sizer" + sPromptId + ", '" + sPromptId + "', document.getElementById('insertButton" + sPromptId + "'), document.getElementById('removeButton" + sPromptId + "'), '" + getCVId(oProperties) + "');" + sCVObj + "preProcessControlArray = " + sCVObj + "preProcessControlArray.concat('multipleRange" + sPromptId + "');" + sCVObj + "multipleObserverArray = " + sCVObj + "multipleObserverArray.concat('multipleRange" + sPromptId + "');" + "multipleRange" + sPromptId + ".initChoiceList();"; executePromptControlJS(JSOut); } //////////////////////////////////////////////////////////////////// // SelectWithSearch HTML generation functions //////////////////////////////////////////////////////////////////// // Function to create a select with search prompt control // // s_PromptId: The id of the prompt control (String) // s_FormName: Name of form control to submit selections to the server (String) // s_ParamName: (String) // s_SubmitType: 'default' will submit as a standard form (String) // 'XML' will convert the submission to XML and submit // s_SearchValue: String to search for (String) // s_MatchAnywhere: Match string anywhere ['true'] (String) // s_MatchAll: Match all of string ['true'] (String) // b_MultiSelect: If control can accomodate more than one value. (Boolean) // b_Required: If the control is a required field. (Boolean) // b_ShowOptions: Show search options (radio buttons) (Boolean) // b_NoResultsFound: If no results found (Boolean) // b_HideAdornments: Hide icons (e.g. star icon for required controls) (Boolean) // s_Style: Style of prompt control (String) // s_EditBoxStyle: Style of control edit box (String) // s_SearchButtonStyle: Style of control button (String) // s_OptionsStyle: Style of control search options (radio buttons) (String) // s_ResultsHeaderStyle: Style of search results header (String) // s_ResultsListboxStyle: Style of search results list box (String) // s_ChoicesHeaderStyle: Style of choices header (String) // s_ChoicesListboxStyle: Style of choices list box (String) // s_SearchFunction: Allow overriding of default search functionality (String) // b_Disabled: Disable controls (Boolean) // b_CaseInsensitive: Set search case insensitive or not (Boolean) // b_ShowCondition: If the condition drop down is to be shown in the UI (Boolean) function genSelectSearchHTML (s_PromptId, s_FormName, s_ParameterName, s_SubmitType, s_SearchValue, s_MatchAnywhere, s_MatchAll, b_MultiSelect, b_Required, b_ShowOptions, b_NoResultsFound, b_HideAdornments, s_Style, s_EditBoxStyle, s_SearchButtonStyle, s_OptionsStyle, s_ResultsHeaderStyle, s_ResultsListboxStyle, s_ChoicesHeaderStyle, s_ChoicesListboxStyle, s_SearchFunction, b_Disabled, b_CaseInsensitive, b_UsePromptIdForName, b_ShowCondition) { var oProperties = s_PromptId; if (arguments.length > 1 || typeof oProperties != K_PRMT_sOBJECT) { oProperties = { id: s_PromptId, formName: s_FormName, parameterName: s_ParameterName, submitType: s_SubmitType, multi: b_MultiSelect, required: b_Required, showOptions: b_ShowOptions, disabled: b_Disabled, hideAdornments: b_HideAdornments, usePromptIdForName: b_UsePromptIdForName, search_caseInsensitive: b_CaseInsensitive, search_criteria: s_SearchValue, search_function: s_SearchFunction, search_matchAnywhere: s_MatchAnywhere, search_matchAll: s_MatchAll, search_showCondition: b_ShowCondition, search_showNoResultFoundString: b_NoResultsFound, style: s_Style, style_choicesHeader: s_ChoicesHeaderStyle, style_choicesListBox: s_ChoicesListboxStyle, style_editBox: s_EditBoxStyle, style_options: s_OptionsStyle, style_resultsHeader: s_ResultsHeaderStyle, style_resultsListBox: s_ResultsListboxStyle, style_searchButton: s_SearchButtonStyle }; } var sPromptId = oProperties.id; var sParamName = oProperties.parameterName; if (!verifyPromptId(sPromptId) || !verifyPromptId(sParamName)) { return; } var sPromptVariablePrefix = "_sws_" + jsEncodeStr(oProperties.usePromptIdForName ? sPromptId : sParamName); //skin folder var sSkin = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN); var sFormName = oProperties.formName; if (!sFormName) { sFormName = "forms[0]"; } var sFormElementName = "p_" + sParamName; if (oProperties.submitType == K_PRMT_sXML) { sFormElementName = "_sws_" + sParamName + "_selectChoices" + sPromptId; } sFormElementName = jsEncodeStr(sFormElementName); var sStyleShowOptions = "display:none;"; if (oProperties.showOptions) { sStyleShowOptions = "display:inline;"; } var submitElementName = jsEncodeStr("p_" + sParamName); var sSearchValue = sDecodeU003( oProperties.search_criteria ); var HTMLOut = ""; renderPromptControlHTML("selectSearch" + sPromptId, HTMLOut); var JSOut = K_PRMT_sEMPTY; if (oProperties.multi) { JSOut += "genInsertButtonHTML('" + sPromptId + "', 'search" + sPromptId + ".insert(search" + sPromptId + ".m_oLstResults, search" + sPromptId + ".m_oLstChoices)', 'insertButton" + sPromptId + "');"; JSOut += "genRemoveButtonHTML('" + sPromptId + "', 'search" + sPromptId + ".remove(search" + sPromptId + ".m_oLstChoices)', 'removeButton" + sPromptId + "');"; } JSOut += "this.search" + sPromptId + " = new CSearch(document.forms['" + sFormName + "'].elements[" + '"' + submitElementName + '"' + "],"; if (oProperties.multi) { JSOut += " document.forms['" + sFormName + "'].elements['_searchResults" + sPromptId + "'],"; } else { JSOut += " document.forms['" + sFormName + "'].elements[" + '"' + sFormElementName + '"' + "],"; } JSOut += " document.forms['" + sFormName + "'].elements[" + '"' + sFormElementName + '"' + "]," + " document.forms['" + sFormName + "']," + " document.forms['" + sFormName + "'].elements['" + sPromptVariablePrefix + "_searchValue']," + " document.images['imgBusy" + sPromptId + "']," + " '" + sPromptId + "'," + " document.forms['" + sFormName + "'].elements['" + sPromptVariablePrefix + "_showOptions']," + " document.forms['" + sFormName + "'].elements['" + sPromptVariablePrefix + "_matchAnywhere']," + " document.forms['" + sFormName + "'].elements['" + sPromptVariablePrefix + "_matchAll']," + " " + oProperties.required + "," + " '" + oProperties.submitType + "'," + " document.getElementById('feedback" + sPromptId + "')," + ( oProperties.multi ? "true" : "false" ) + "," + " document.forms['" + sFormName + "'].elements['" + sPromptVariablePrefix + "_submit']," + " document.forms['" + sFormName + "'].elements['" + sPromptVariablePrefix + "_selectOptions']," + " document.sizerResults" + sPromptId + "," + ( oProperties.multi ? " document.sizerChoices" + sPromptId : "null" ) + "," + " document.getElementById('searchButton" + sPromptId + "')," + ( oProperties.multi ? " document.getElementById('insertButton" + sPromptId + "')" : "''" ) + "," + ( oProperties.multi ? " document.getElementById('removeButton" + sPromptId + "')" : "''" ) + "," + " '" + oProperties.search_function + "', '" + jsEncodeStr(sParamName) +"', '" + getCVId(oProperties) + "');"; var sCVObj = getCVInstance(oProperties); JSOut += sCVObj + "preProcessControlArray = " + sCVObj + "preProcessControlArray.concat('search" + sPromptId + "');"; executePromptControlJS(JSOut); }