123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- // Licensed Materials - Property of IBM
- //
- // IBM Cognos Products: cogadmin
- //
- // (C) Copyright IBM Corp. 2005, 2010
- //
- // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- //
- //
- // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- //----------------------------------------------------------
- com.cognos.admin.ObjectFactory("com.cognos.admin.extension");
- /* This is a implementation of the extensive event handler. The impl need to have a method named "doAction" to
- * work as a mapping.
- * @param: env, context of the behaviour controller framework.
- *
- */
- com.cognos.admin.extension.Suspend = function (env) {
- this.fragment = env.fragment;
- this.context = env.context;
- this.scheduleEndDateId = this.fragment.id+"endDate";
- this.scheduleEndTimeId = this.fragment.id+"endTime";
- this.i18n = env.i18n
- var self = this;
-
- //register for shedule prompt notifications to provide an event to rectify schedule selection popup appearing behind this dialog
- this.scheduleDialogListener = function() {
- this.notify = function(iState, oNotifier) {
- //Because the compiled (ie. obfuscated) js version of the prompting libs are being used, we'll need to introspect (ie. loop thru) the oNotifier object to find the scheduler prompt
- for (name in oNotifier) {
- o = oNotifier[name];
- if (o && (o.id == 'dialogDatePicker'+self.fragment.id+'endDate')) {
- _o = o;
- setTimeout('_o.style.zIndex="9999"',1);
- return;
- }
- }
- }
- };
-
- this.onDialogOK = function(evt) {
- var frag = evt.source;
- var finite = $(frag.id+'suspend_finite').checked;
- var selections = document.pform[frag.id+"suspend_period"];
- var requestParms = ("finite="+encodeURIComponent(finite));
- if (finite) {
- if (!self.getDateControl().isValid()) {
- alert(self.i18n.IDS_FLT_MSG_INVALID_DATE);
- evt.preventDefault();
- return false;
- }
- if (!self.getTimeControl().isValid()) {
- alert(self.i18n.IDS_FLT_MSG_INVALID_TIME);
- evt.preventDefault();
- return false;
- }
- var date = self.getDateControl().sGetValue();
- var time = self.getTimeControl().sGetValue();
- requestParms+=("&release="+encodeURIComponent(date+"T"+time));
- }
- for (var name in self.context) {
- requestParms+=("&"+name+"="+self.context[name]);
- }
- requestParms+="&userClickedOk=true";
- frag.retrieve(requestParms);
- return true;
- };
-
- this.unload = function(evt) {
- self.fragment.removeEventListener("cognos.ui.dialog.show", self.onDialogShow);
- self.fragment.removeEventListener("fragment.unload", self.destroy);
- self.fragment.removeEventListener("cognos.ui.dialog.ok", self.onDialogOK);
- //clean up Prompting Date/Time instances
- var schedulePopup = $("dialogDatePicker"+this.scheduleEndDateId);
- while (schedulePopup) {
- var parent = schedulePopup.parentNode
- parent.removeChild(schedulePopup);
- schedulePopup = $("dialogDatePicker"+this.scheduleEndDateId);
- }
- var controlArray = getPreProcessControlArray();
- _F_Array.remove(controlArray,"pickerControl"+this.scheduleEndDateId);
- _F_Array.remove(controlArray,"timePicker"+this.scheduleEndTimeId);
- _F_Array.remove(datePickerObserverArray,"pickerControl"+this.scheduleEndDateId);
- };
-
- this.onDialogShow = function(evt) {
- var frag = evt.target;
- var scheduleEndDateId = self.scheduleEndDateId;
- var scheduleEndTimeId = self.scheduleEndTimeId
- var now = new Date();
- var firstDate = now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
- var defaultDate = now;
- var dateArgs = {formName:"pform",parameterName:"sched_"+scheduleEndDateId,submitType:"",prmtDefaultDate:defaultDate.toUTCString(),defaultValue:defaultDate,startOfWeek:"Sunday",calendar:"Gregorian",selectUI:"editBox",selectDateUI:"editBox",inputOrder:"YMD",firstDate:firstDate,lastDate:"",dateTime:1,initialState:RANGE_NO_VALUE,required:true,suppressDisabled:true,hideAdornments:true,suppressExtraPromptNames:false,multi:false,range:false,style:"",selectDateEditBoxStyle:"",selectDateYearsStyle:"",selectDateMonthsStyle:"",selectDateDaysOfWeekStyle:"",selectDateDaysStyle:"",CVId:frag.id,id:scheduleEndDateId};
- var defaultTimeValue = defaultDate.getHours()+":"+defaultDate.getMinutes()+":"+defaultDate.getSeconds();
- var timeArgs = {formName:"pform",parameterName:"sched_"+scheduleEndTimeId,submitType:"",defaultValue:defaultTimeValue,selectUI:"editBox",timeZone:"",hourFormat:"hh",minuteFormat:"mm",secondFormat:"ss",display:2,mode:0,initialState:RANGE_NO_VALUE,required:true,suppressDisabled:true,hideAdornments:true,suppressExtraPromptNames:false,multi:false,range:false,style:"",style:"",CVId:frag.id,id:scheduleEndTimeId}
- genSelectDateHTML(dateArgs);
- genSelectTimeHTML(timeArgs);
- var parent = frag.parent;
- if (null == parent) {
- parent = window; //default
- }
- if (null == parent.listenerRegistered) {
- parent.listenerRegistered = true;
- registerForNotications(new self.scheduleDialogListener());
- }
- };
- this.fragment.addEventListener("cognos.ui.dialog.show", this.onDialogShow);
- this.fragment.addEventListener("fragment.unload", this.unload);
- this.fragment.addEventListener("cognos.ui.dialog.ok", this.onDialogOK);
-
- };
- com.cognos.admin.extension.Suspend.VERSION = "0.1.0";
- com.cognos.admin.extension.Suspend.prototype = {
- getPromptControl : function(type, id) {
- return window[type+id]
- },
-
- getDateControl : function() {
- return this.getPromptControl("pickerControl",this.scheduleEndDateId);
- },
-
- getTimeControl : function() {
- return this.getPromptControl("timePicker",this.scheduleEndTimeId);
- }
- }
|