123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- /*
- *+------------------------------------------------------------------------+
- *| 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.
- *|
- *+------------------------------------------------------------------------+
- */
- /**
- @class
- @private
- */
- cognos.Prompt.Control.SelectHTML5DateTime = cognos.Prompt.Control.f_extend({
- f_initialize: function( v_oProps )
- {
- this[K_PRMT_LABEL_RANGE_LOWEST] = PMT_RNG_EARLIEST_DATE;
- this[K_PRMT_LABEL_RANGE_HIGHEST] = PMT_RNG_LATEST_DATE;
- this._type_ = "cognos.Prompt.Control.SelectHTML5DateTime";
- this.f_parent( v_oProps ); // call parent's initialize()
- var v_oPropsComponent = Object.f_extend( {}, v_oProps );
- v_oPropsComponent["@required"] = true;
- v_oPropsComponent["@hideAdornments"] = true;
- v_oPropsComponent.m_bIsAComponent = true;
- this.m_oDate = new cognos.Prompt.Control.SelectHTML5Date( v_oPropsComponent );
- this.m_oTime = new cognos.Prompt.Control.SelectHTML5Time( v_oPropsComponent );
- this.m_oDate.m_oOwner = this;
- this.m_oTime.m_oOwner = this;
-
- this.m_bSkipAdornments = true;
- this.m_bDisabled = false;
- this.f_initCompleted();
-
- if (SYSTEMPROPERTY_TREE_CACHE_ENABLED)
- {
- this.cacheDateTimeControlName(this.getTracking());
- }
- },
- checkData: function()
- {
- // We keep a reference to the parent function
- // Calling this.m_oFrom functions seems to have a side effect on this.f_parent().
- var v_fnParent = this.f_parent;
-
- if ( ( this.isRequired() || !(this.m_bDisabled) ) && !(this.m_oDate.m_bValid && this.m_oTime.m_bValid) ) {
- this.m_bValid = false;
- } else {
- this.m_bValid = true;
- }
- this.f_parent = v_fnParent; // call parent's checkData using saved reference.
- this.f_parent(); // call parent's checkData using saved reference.
- return this.m_bValid;
- },
- clearValues: function()
- {
- this.f_parent();
- this.m_oDate.clearValues();
- this.m_oTime.clearValues();
- },
- f_drawCompleted: function()
- {
- // We keep a reference to the parent function
- // Calling this.m_oFrom.f_drawCompleted seems to have a side effect on this.f_parent().
- var v_fnParent = this.f_parent;
- var v_chk = $(this.f_getId( "chkAnyValue" ));
- if ( v_chk ) {
- PRMTUtils.f_addEvent( v_chk, "click", this.f_toggleDisable.bind(this) );
- }
- this.m_oDate.f_drawCompleted();
- this.m_oTime.f_drawCompleted();
- this.f_parent = v_fnParent; // call parent's f_drawCompleted using saved reference.
- this.f_parent(); // call parent's f_drawCompleted using saved reference.
- if ( this[K_PRMT_sATTR_DISABLED] ) {
- this.m_oDate.f_setEnabled( false );
- this.m_oTime.f_setEnabled( false );
- }
- }
- });
- /**
- Compare values. See {@link cognos.Prompt.Control#f_compare} for details.
- @see cognos.Prompt.Control#f_compare
- @private
- @return {Integer}
- */
- cognos.Prompt.Control.SelectHTML5DateTime.prototype.f_compare = function( v_oValue )
- {
- var v_iRetval = 1;
- if ( v_oValue ) {
- v_iRetval = this.m_oDate.f_compare( v_oValue.m_oDate );
- if ( v_iRetval === 0 ) {
- v_iRetval = this.m_oTime.f_compare( v_oValue.m_oTime );
- }
- }
- return v_iRetval;
- };
- /**
- @private
- @param {C_PromptElement} v_el Container.
- @return {void}
- */
- cognos.Prompt.Control.SelectHTML5DateTime.prototype.f_drawInput = function( v_el )
- {
- var v_tbl = $CE( "table", {
- "border": K_PRMT_DEBUG_TABLEBORDER, "cellPadding": 0, "cellSpacing": 0,
- "class": "clsPromptComponent",
- "style": cssParser( this["@style"], "visibility") }, v_el );
- var v_tbd = $CE( "tbody", {}, v_tbl );
- var v_tr = $CE( "tr", {}, v_tbd );
- var v_td = null;
- if ( !this.isRequired() && !this["@suppressDisabled"] && !(this.m_bIsAComponent || this["@multiSelect"]) ) {
- var v_bDisabled = ( this[K_PRMT_sATTR_DISABLED] === true );
- v_td = $CE( "td", {"vAlign": "top"}, v_tr );
- $CE( "input", {
- "type": "checkbox",
- "value": "anyValue",
- "id": this.f_getId( "chkAnyValue" ),
- "name": this.f_getId( "chkAnyValue" ),
- "checked": (v_bDisabled ? K_PRMT_sEMPTY : "checked") }, v_td );
- this.m_bDisabled = v_bDisabled;
- }
- v_td = $CE( "td", {"vAlign": "top"}, v_tr );
- v_tbl = $CE( "table", { "border": K_PRMT_DEBUG_TABLEBORDER, "cellPadding": 5, "cellSpacing": 0, "class": "clsBoundingBox pdt" }, v_td );
- if ( this.m_bIsAComponent ) {
- v_tbl.f_setProperty( "style", "margin-left:0px" );
- }
- v_tbd = $CE( "tbody", {}, v_tbl );
- v_tr = $CE( "tr", {}, v_tbd );
- v_td = $CE( "td", {"id": this.f_getId("selectDate"), "vAlign": "top"}, v_tr );
- this.m_oDate.f_drawInput( v_td );
- v_tr = $CE( "tr", {}, v_tbd );
- v_td = $CE( "td", {"id": this.f_getId("selectDate"), "vAlign": "top"}, v_tr );
- this.m_oTime.f_drawInput( v_td );
- };
- /**
- @private
- @return {void}
- */
- cognos.Prompt.Control.SelectHTML5DateTime.prototype.f_getDisplayValue = function()
- {
- return ( this.m_oDate.f_getDisplayValue() + K_PRMT_sSP + this.m_oTime.getTimeFormatForDisplay() );
- };
- /**
- @private
- @return {void}
- */
- cognos.Prompt.Control.SelectHTML5DateTime.prototype.f_getPV = function()
- {
- return (
- this.m_bDisabled ? null : { "use": this.f_getUseValue(), "display": this.f_getDisplayValue() }
- );
- };
- /**
- @private
- @return {String}
- */
- cognos.Prompt.Control.SelectHTML5DateTime.prototype.f_getUseValue = function() {
- return ( this.m_oDate.f_getUseValue() + "T" + this.m_oTime.getTimeInputValue() );
- };
- /**
- @private
- @return {void}
- */
- cognos.Prompt.Control.SelectHTML5DateTime.prototype.f_setPV = function( v_oPV )
- {
- var v_sValue = v_oPV["use"];
- if ( v_sValue ) {
- var v_aValues = v_sValue.split(new RegExp("[T\\s]"));
-
- if ( v_aValues.length > 2 ) {
- for ( var v_idx = 1; v_idx < v_aValues.length - 1; v_idx++ ) {
- // add all Date parts to the first element.
- v_aValues[0] += K_PRMT_sSP + (v_aValues[v_idx]).f_trim();
- }
- v_aValues[0] = v_aValues[0].f_trim();
-
- // move Time part (last value) in slot 1
- v_aValues[1] = v_aValues[ v_aValues.length - 1];
- }
-
- if ( v_aValues.length >= 1 ) {
- this.m_oDate.f_setDate( v_aValues[0] );
- if ( v_aValues.length >= 2 ) {
- this.m_oTime.f_setTime( v_aValues[1] );
- }
- }
- }
- };
- /**
- @private
- @return {void}
- */
- cognos.Prompt.Control.SelectHTML5DateTime.prototype.f_toggleDisable = function()
- {
- if ( !this.isRequired() ) {
- var v_bState = this.m_bDisabled;
- this.m_oDate.f_setEnabled( v_bState );
- this.m_oTime.f_setEnabled( v_bState );
- this.m_bDisabled = !v_bState;
- }
- this.checkData();
- };
- /**
- @private
- @return {boolean}
- */
- cognos.Prompt.Control.SelectHTML5DateTime.prototype.hasValue = function()
- {
- return (this.m_bValid);
- };
|