// Licensed Materials - Property of IBM // // IBM Cognos Products: ps // // (C) Copyright IBM Corp. 2013 // // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. function impersonateTenantSelector(context) { var _self = this; this.context = context; dojo.require("dijit.form.FilteringSelect"); dojo.require("dojo.data.ItemFileReadStore"); var id = 'impersonatedTenant'; var showTenantContentOnlyChkBoxId = 'showTenantContentOnly'; var ids = [id,showTenantContentOnlyChkBoxId]; dijit.registry.forEach(function(w){ if(dojo.indexOf(ids,w.id) >= 0){ w.destroyRecursive(true); } }); // create store instance referencing data from listTenants.xts var tenantStore = new dojo.data.ItemFileReadStore({ url: '?b_action=xts.run&m=portal/tenants/listTenants.xts&src=listTenants&isImpersonate=true' }); _self.filteringSelect = new dijit.form.FilteringSelect({ name: id, value: (_self.context.writeAs == "") ? " " : _self.context.writeAs, //filteringSelect doesn't behave well with empty value store: tenantStore, maxHeight: -1, searchAttr: "name", pageSize: this.context.listSize, onChange: function(state){ _self.context.onChange(dojo.byId(showTenantContentOnlyChkBoxId).checked ? 'read' : 'write', dojo.trim(new String(this.item.id))); } }, id); dojo.require("dijit.form.CheckBox"); var checkBox = new dijit.form.CheckBox({ name: "showTenantContentOnly", checked: context.readAs != null }, "showTenantContentOnly"); dojo.connect(dijit.byId("showTenantContentOnly"), "onChange", function(isChecked) { doImpersonateTenant(isChecked ? 'read' : 'write', dojo.trim(new String(_self.filteringSelect.item.id))); } ); _self.filteringSelect.startup(); } function impersonateTenant(fragment, table_name) { var checkboxes = getCheckboxCheckParams(table_name); impersonateTenantImpl(fragment, '','cancel'); } function impersonateTenantImpl(fragment, checkboxes, cmdType) { var params = checkboxes; params += '&ifrmcmd=impersonateTenant&cmdType='; params += cmdType; fragment.retrieve(encodeURI(params)); } function createFragment(fragID, divID, xtsTargetURL) { var frag = new fragment("/xts"+encodeURI(xtsTargetURL), fragID, divID); if (frag.parent && !document.getElementById(divID)) { var div = document.createElement('div'); div.id = divID; document.getElementById(frag.parent.div).appendChild(div); } return frag; }