var v = MVRZ.util.validation; var s = MVRZ.util.setInputDef; function datasetObject(datasetName, argArray){ msg('XX datasetObject:' + datasetName); this.datasetName = datasetName; this.argArray = argArray; if (typeof(MVRZ.data.object[datasetName]) != 'object') MVRZ.data.object[datasetName] = new Object(); //if (typeof(MVRZ.data.object[datasetName]) != 'undefined') this.dataset = MVRZ.data.object[datasetName]; this.loadStatus = LOAD_STATUS_UNLOADED; this.defaults = new Object(); this.defaults.idField = 'ID'; this.defaults.labelField = 'name'; // Set up the inputs this.inputs = new Object(); this.inputs.isValid = new Object(); this.inputs.fields = new Object(); this.inputs.style = new Object(); this.inputs.uniqueField = "ID"; this.inputs.selectOptionLabelField = "name"; // Default Select Field for this dataset this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this); this.inputs.selectField.styleWrapper = MY.defaults.selectStyle; this.inputs.selectField.sortByFieldName = 'name'; this.inputs.selectField.selectConfig = {sortByFieldName: 'ID'}; this.inputs.dataTableSubscribe = new Object(); //this.inputs.dataTableSubscribe['rowClickEvent'] = this.onEventSelectRow; this.inputs.dataTableSubscribe['cellClickEvent'] = this.onEventSelectCell; this.dataSource = new Object(); this.dataTables = new Object(); this.dataCharts = new Object(); this.oConfig = new Object(); this.oConfig.oFilter = new Object(); this.doSaveFor = new Object(); // Explicit array or ID's that should be saved rather than relying on ID==0 this.request = new Object(); this.request.argArray = new Object() this.request.saveArgArray = new Object() this.request.postArgArray = new Object() this.oRequestCallback = new Object(); this.renderSelectsList = []; // No addional selects to render this.localOnly = false; // Assume all data is on server by default this.event = { change: new YAHOO.util.CustomEvent("change", this) } this.successCallbackStack = new Object(); this.failureCallbackStack = new Object(); msg("Checking for fnInit()"); if (typeof(MY.fnInit[this.datasetName]) == 'function') { msg("Calling fnInit()"); this.fnInit = MY.fnInit[this.datasetName]; this.fnInit(argArray); } msg("Checking argArray for load()"); if (typeof(argArray) != 'undefined') { msg("Calling load()"); this.load(argArray); } msg("Done dataObject initialization"); } // Prototypes datasetObject.prototype.connect = connect; datasetObject.prototype._connect = _connect; datasetObject.prototype._load = _load; datasetObject.prototype.load = load; datasetObject.prototype.reload = reload; datasetObject.prototype.preload = preload; datasetObject.prototype.postload = postload; datasetObject.prototype.save = save; datasetObject.prototype.del = del; datasetObject.prototype.postConnect = postConnect; datasetObject.prototype.connectionParseResponse = connectionParseResponse; datasetObject.prototype._connectionHandleFailure = _connectionHandleFailure; datasetObject.prototype._connectionHandleSuccess = _connectionHandleSuccess; datasetObject.prototype._connectionHandleLoadFailure = _connectionHandleLoadFailure; datasetObject.prototype._connectionHandleLoadSuccess = _connectionHandleLoadSuccess; datasetObject.prototype._connectionHandleDelSuccess = _connectionHandleDelSuccess; datasetObject.prototype._connectionHandleDelFailure = _connectionHandleDelFailure; datasetObject.prototype._connectionHandleSaveInsert = _connectionHandleSaveInsert; datasetObject.prototype._connectionHandleSaveSuccess = _connectionHandleSaveSuccess; datasetObject.prototype._processCallbackStack = _processCallbackStack; datasetObject.prototype.setload = function setload(loadStatus) { msg("setload()"); this.loadStatus = loadStatus; } datasetObject.prototype.stopload = function stopload(stopNotice) { msg("stopload()"); this.loadStatus = LOAD_STATUS_STOP; if(typeof(stopNotice)!='undefined') this.stopNotice = stopNotice; } datasetObject.prototype.unload = function unload() { msg("unload()"); this.loadStatus = LOAD_STATUS_UNLOADED; } datasetObject.prototype.isLoaded = function isLoaded() { msg("isLoaded()"); return (this.loadStatus == LOAD_STATUS_LOADED ? true : false); } datasetObject.prototype.fnFireEventChange = function fnFireEventChange(obj) { // Scope is the html element that caused the event msg("fnFireEventChange()"); this.event.change.fire(obj); } datasetObject.prototype.handleDatatableAction = function handleDatatableAction(mvrzArgs){ function removeSelectedRows(oArgs) { //dbgp("Deleted " + id); var oDatatable = oArgs.oDatatable; var selectedRows = oArgs.selectedRows; // Redraw the table (or just delete the ones that were deleted) selectedRows = selectedRows.reverse(); // Reverse order so we get the right rows if(selectedRows.length) { for(var i in selectedRows) { oDatatable.deleteRow(parseInt(selectedRows[i])); } } } // Scope is clicked element - it has args in this.args if(typeof(mvrzArgs)!='object') { sysErr("Table action cannot be performed"); return; } var oDatatable = mvrzArgs.dataTable.oDataTable; var oDataset = mvrzArgs.dataTable.oDataset; var oRecordset = oDatatable.getRecordSet(); var action = mvrzArgs.onclick.action; if(typeof(action)=='undefined') { var action = mvrzArgs.dataTable.action; } if(typeof(action)=='undefined') { var actionId = mvrzArgs.dataTable.actionId; if(typeof(actionId)!='undefined') { var el = actionId; // Default if(!isElement(actionId)) { var el = document.getElementById(actionId); } action = el.value; } } // Find the selected rows var rows = oRecordset.getRecords(); //var selectedRows = oDatatable.getSelectedRows(); if(rows.length) { oDatatable.selectedRows = new Array(); oDatatable.localSelectedRows = new Array(); var idValueArray = new Array(); var idValueLocalArray = new Array(); var key = oDataset.inputs.uniqueField || 'ID'; var c=0, i=0; for(var r in rows) { var aInputs = YAHOO.util.Dom.getElementsByClassName( 'yui-dt-checkbox' , 'input' , rows[r]._sId); var record = oRecordset.getRecord(rows[r]); if(aInputs[0].checked) { c++; idValue = record.getData(key); if(idValue<0) { // Not saved to DB yet - local only so just delete recordset entry idValueLocalArray[i] = idValue; oDatatable.localSelectedRows.push(r); } else { idValueArray[i] = idValue; oDatatable.selectedRows.push(r); i++; } } } if(c>0) { if(idValueArray.length>0) { switch(action) { case(ACTION_TABLE_DELETE): // Send a delete request to the system var idList = idValueArray.join(":"); var argArray = new Object(); argArray[GET_ID] = idList; //dbgp("Deleting " + id); setActive("Deleting..."); oDataset.del(argArray, '', {oDatatable: oDatatable, selectedRows: oDatatable.selectedRows}, removeSelectedRows); break; default: // Send the action to the system var idList = idValueArray.join(":"); var argArray = new Object(); argArray[ARG_GETS] = new Object(); argArray[ARG_GETS][GET_ID] = idList; argArray[ARG_GETS][GET_NVPS] = DATASET_REQUEST_STATUS + '=' + action; setActive("Applying..."); oDataset.connect(YUI_ACTION_APPLY, argArray, '', {oDatatable: oDatatable, selectedRows: oDatatable.selectedRows}, removeSelectedRows); } } if(idValueLocalArray.length>0) { // This will get removed if other actions are taken setActive("Applying..."); removeSelectedRows({oDatatable: oDatatable, selectedRows: oDatatable.localSelectedRows}); } } else { popupInfo("Please select at least one row first"); } } else { popupInfo("No rows to delete!"); } //popupInfo('Delete '+this.datasetName + ', ' + selectedRows) } datasetObject.prototype.onEventSelectCell = function onEventSelectCell(oArgs) { // Scope is the datatable // Update the editable display with the new record msg(this.datasetName+': onEventSelectCell()'); var oRecord = this.getRecord(oArgs.target); //var idField = this.inputs.uniqueField; var idField = "ID"; var recordIndex = oRecord.getData(idField); //alert(idField + "=" + recordIndex); this.unselectAllRows(); this.selectRow(this.getRow(oArgs.target)); if(typeof(this.mvrz.datasetName)!='undefined' && this.mvrz.datasetName.length>0) { var oDataset = MY[this.mvrz.datasetName]; if(typeof(oDataset)=='object') { var classArray = oArgs.target.className.split(" "); var classBase = "yui-dt-col-"; var fieldName=null; for(var i in classArray) { if(classArray[i].substr(0, classBase.length) == classBase) { fieldName = classArray[i].substr(classBase.length); break; } } if(fieldName.length && typeof(oDataset.inputs.fields[fieldName])!='undefined' && oDataset.inputs.fields[fieldName].readonly) { oDataset.setDatasetId(recordIndex); msg(this.datasetName+': calling fnFireEventChange()'); oDataset.fnFireEventChange(this); } } } } datasetObject.prototype.onEventSelectRow = function onEventSelectRow(oArgs) { // Scope is the datatable // Update the editable display with the new record msg(this.datasetName+': onEventSelectRow()'); var oRecord = this.getRecord(oArgs.target); //var idField = this.inputs.uniqueField; var idField = "ID"; var recordIndex = oRecord.getData(idField); //alert(idField + "=" + recordIndex); this.unselectAllRows(); this.selectRow(this.getRow(oArgs.target)); if(typeof(this.mvrz.datasetName)!='undefined' && this.mvrz.datasetName.length>0) { var oDataset = MY[this.mvrz.datasetName]; if(typeof(oDataset)=='object') { oDataset.setDatasetId(recordIndex); msg(this.datasetName+': calling fnFireEventChange()'); oDataset.fnFireEventChange(this); } } ////renderQuotesPage('', PANE_QUOTES_LIST, {idValue: recordIndex}); } datasetObject.prototype.getActiveDataRow = function getActiveDataRow(){ if(this.currentDatasetIdValue) return this.getRow(this.getDatasetRowIndex(this.currentDatasetIdValue)); return null; } datasetObject.prototype.getSelectId = function getSelectId(){ var selectField = this.inputs.selectField; //var selectId = "select-" + this.datasetName + 'ID'; var selectId = MVRZ.util.encodeInputId(this.datasetName, '', '', 'select'); return selectId; } datasetObject.prototype.getSelectedId = function getSelectedId(){ var ret; var selectId = this.getSelectId(); var selectEl = document.getElementById(selectId); if (typeof(selectEl) != 'undefined' && selectEl != null) ret = selectEl.value; /* if(typeof(ret) == 'undefined' || ret==null) ret = this.dataValue; if(typeof(ret) == 'undefined' || ret==null) ret = this.currentDatasetIdValue; */ //if(typeof(ret) == 'undefined' || ret==null) ret = null; msg("datasetObject.prototype.getSelectedId: " + ret); return ret; } datasetObject.prototype._getDatsetId = function _getDatsetId(oElInfo, doUpdate) { // Common function for select that are for different datasets //dbgp("datasetObject.prototype._getDatsetId(), doUpdate="+doUpdate); if (typeof(doUpdate) == 'undefined') doUpdate = false; var ret = this.currentDatasetId; if(typeof(oElInfo)!='object') { msg("datasetObject.prototype._getDatsetId() - no elementInfo"); } else { switch(oElInfo.datasetName) { case(DATASET_PROPERTY): // Lookup the ID for this property ID msg("datasetObject.prototype._getDatsetId() - getting localID for "+DATASET_PROPERTY+", value="+oElInfo.value); var localID = this.get(oElInfo.value, 'ID', 'propertyID'); if(localID.length>0) ret = localID; else ret = 0; // Update the othe dataset as needed if(doUpdate) { msg("datasetObject.prototype._getDatsetId() - getting localID for "+DATASET_PROPERTY+", doing update to ="+oElInfo.value); MY[oElInfo.datasetName].setDatasetId(oElInfo.value); } else { msg("datasetObject.prototype._getDatsetId() - getting localID for "+DATASET_PROPERTY+", NOT doing update to ="+oElInfo.value); } break; default: } } msg("datasetObject.prototype._getDatsetId() returning "+ret); return ret; } datasetObject.prototype.getLastDatasetId = function getLastDatasetId(elId){ return this.lastDatasetIdValue; } datasetObject.prototype.getDatasetId = function getDatasetId(elId, doUpdate){ var ret = this.currentDatasetIdValue; // Default // Check the dataset of the input - and find the dataset ID that corresponds to it if (typeof(elId) != 'undefined') { // Decode the input ID var oElInfo = MVRZ.util.decodeInputId(elId); if (oElInfo.datasetName !== this.datasetName) { //dbgp("datasetObject.prototype.getDatasetId(" + elId + ") - different datsetName (" + oElInfo.datasetName + "), try calling function"); // Call special function for this object if (typeof(this._getDatsetId) == 'function') { msg("datasetObject.prototype.getDatasetId(" + elId + ") - calling function, doUpdate="+doUpdate+", typeof="+typeof(this._getDatsetId)); ret = this._getDatsetId(oElInfo, doUpdate); msg("datasetObject.prototype.getDatasetId(" + elId + ") - function returned "+ret); } else { msg("datasetObject.prototype.getDatasetId(" + elId + ") - NO function"); } } else { //dbgp("datasetObject.prototype.getDatasetId(" + elId + ") - same dataset name"); if (typeof(oElInfo)=='object') ret = oElInfo.value; } } msg("datasetObject.prototype.getDatasetId() returning: "+ret); return ret; } datasetObject.prototype.isDatasetValid = function isDatasetValid(idValue){ if(typeof(idValue)=='undefined') idValue = this.getDatasetId(); var ret = false; if(typeof(idValue)!='undefined') { if(typeof(this.isValid[idValue])=='undefined') { ret = MVRZ.util.validation.datasetIsValid(this.datasetName, idValue); } else { ret = this.isValid[idValue]; } } else { ret = MVRZ.util.validation.datasetIsValid(this.datasetName); } return ret; } datasetObject.prototype.setDatasetId = function setDatasetId(dataValue){ this.lastDatasetIdValue = this.currentDatasetIdValue; if (typeof(dataValue) == 'undefined') dataValue = this.currentDatasetIdValue; if (typeof(dataValue) == 'undefined') dataValue = this.getSelectedId(); if (((typeof(dataValue) == 'undefined') || dataValue==null || dataValue.length==0) && !this.noFirstIfZero) { dataValue = 0; switch (this.inputs.whenIdNotSet) { case (INPUT_WHENIDNOTSET_PICKFIRST): if (typeof(this.datasetData) != 'undefined' && typeof(this.datasetData[0]) != 'undefined') { var dataValue = this.datasetData[0][this.inputs.uniqueField]; } break; case (INPUT_WHENIDNOTSET_CREATENEW): default: dataValue = 0; } } if (typeof(dataValue) == 'undefined' || dataValue == null || dataValue.length == 0) { dataValue = 0; } msg('datasetObject.prototype.setDatasetId LAST dataValue:' + dataValue); this.currentDatasetIdValue = this.dataValue = this.idValue = dataValue; // Used in preRender return dataValue; } datasetObject.prototype.getDatasetRowIndex = function getDatasetRowIndex(index, idField){ //msg('datasetObject.prototype.getDatasetRowIndex:' + this.datasetName); var ret = -1; if (typeof(idField) == 'undefined') idField = this.defaults.idField; if (typeof(index) == 'undefined') index = this.currentDatasetIdValue; if (typeof(index) == 'undefined') { msg('datasetObject.prototype.getDatasetRowIndex::index nor current index is set'); return ret; } ret = this._getDatasetRowIndex(index, idField); msg('datasetObject.prototype.getDatasetRowIndex:: ' + this.datasetName + 'returning:' + ret); return ret; } datasetObject.prototype._getDatasetRowIndex = function _getDatasetRowIndex(index, idField){ msg('datasetObject.prototype._getDatasetRowIndex:' + this.datasetName + '/' + index + '/' + idField); var ret = -1; if (typeof(this.dataset) != 'undefined') { this.datasetData = this.dataset.data; if (typeof(this.datasetData) != 'undefined') { // Create a row in the dataset for this? if (index == 0 && this.datasetData.length == 0) { dataRowIndex = 0; msg("_getDatasetRowIndex() setting new line and defaults"); //popup('', "_getDatasetRowIndex() setting new line and defaults"); this.append(dataRowIndex, this.inputs.fieldDefaults); ret = dataRowIndex; } else { if (idField.length) { // Use index as the data index for (dataRowIndex in this.datasetData) { //msg('datasetObject.prototype._getDatasetRowIndex::'+dataRowIndex+' checking ' + this.datasetData[dataRowIndex][idField]); if (this.datasetData[dataRowIndex][idField] == index) { ret = dataRowIndex; //msg('datasetObject.prototype._getDatasetRowIndex::Found index at dataRowIndex:' + ret); break; } } if (ret < 0) { msg('datasetObject.prototype._getDatasetRowIndex::index not found in dataset:' + index); } } else { msg('datasetObject.prototype._getDatasetRowIndex:: idField zero length:' + index); } } } else { msg('datasetObject.prototype._getDatasetRowIndex::dataset data not loaded:' + this.datasetName); } } else { msg('datasetObject.prototype._getDatasetRowIndex::dataset not defined:' + this.datasetName); } //if(ret<=0) ret = -1; // Ensure not null msg('datasetObject.prototype._getDatasetRowIndex:: returning:' + ret); return ret; } datasetObject.prototype.setByIdField = function setByIdField(idValue, field, value, idField){ msg('datasetObject.prototype.setByIdField:' + this.datasetName); var ret = ''; if (typeof(field) == 'undefined') { msg('datasetObject.prototype.get::field is not set'); return ret; } if (typeof(idValue) == 'undefined' || idValue.length == 0) idValue = this.currentDatasetIdValue; if (typeof(idValue) == 'undefined' || idValue.length == 0) { msg('datasetObject.prototype.get::index nor current index is set'); return ret; } if (typeof(idField) == 'undefined') idField = this.inputs.uniqueField; if (typeof(idField) == 'undefined') idField = this.defaults.idField; ret = this._setByIdField(idValue, field, value, idField); msg('datasetObject.prototype.set:: returning:' + ret); return ret; } datasetObject.prototype._setByIdField = function _setByIdField(idValue, field, value, idField){ if (typeof(idValue) == 'undefined' || idValue == null || idValue.length == 0) idValue = 0; var datasetRowIndex = this.getDatasetRowIndex(idValue, idField); //popupInfo("_setByIdField() "+idValue+', '+field+', '+value+', '+idField+', datasetRowIndex='+datasetRowIndex); if (datasetRowIndex < 0) { var oFields = new Object(); oFields[field] = value; this.append(idValue, oFields, idField); } else { this.set(datasetRowIndex, field, value); } //this.datasetData[datasetRowIndex][field] = value; return value; } datasetObject.prototype.set = function set(datasetRowIndex, field, value){ msg("set(" + datasetRowIndex + ", " + field + ", " + value + ")"); //var datasetRowIndex = this.getDatasetRowIndex(index, idField); if (typeof(this.datasetData) != 'object') { if (typeof(MVRZ.data.object[this.datasetName][JSON_RESPONSE_INDEX_DATA]) != 'object') MVRZ.data.object[this.datasetName][JSON_RESPONSE_INDEX_DATA] = new Array(); this.datasetData = MVRZ.data.object[this.datasetName][JSON_RESPONSE_INDEX_DATA]; } if (typeof(this.datasetData[datasetRowIndex]) == 'undefined') { this.datasetData[datasetRowIndex] = new Object(); } if (typeof(value) == 'undefined') value = ''; this.datasetData[datasetRowIndex][field] = value; return value; } datasetObject.prototype.setRow = function setRow(datasetRowIndex, oFields){ //var datasetRowIndex = this.getDatasetRowIndex(index, idField); if (typeof(oFields) != 'object') return false; this.datasetData[datasetRowIndex] = new Object(); for (oIndex in oFields) { msg(datasetRowIndex + ": Assigning "+oFields[oIndex]+' to '+oIndex) this.datasetData[datasetRowIndex][oIndex] = oFields[oIndex]; // Copy not assign } return true; } datasetObject.prototype.append = function append(idValue, oFields, idField){ msg("append(" + idValue + ", oFields, " + idField + "): " + this.datasetName); if (this.datasetName === DATASET_NONE) return; if (typeof(idValue) == 'undefined' || idValue == null || idValue.length == 0) idValue = 0; if (typeof(idField) == 'undefined') idField = this.inputs.uniqueField; if (typeof(idField) == 'undefined') idField = this.defaults.idField; //popupInfo("append() checking datasetData for "+this.datasetName); if (typeof(this.datasetData) != 'object') { if (typeof(MVRZ.data.object[this.datasetName]) != 'object') MVRZ.data.object[this.datasetName] = new Array(); if (typeof(MVRZ.data.object[this.datasetName][JSON_RESPONSE_INDEX_DATA]) != 'object') MVRZ.data.object[this.datasetName][JSON_RESPONSE_INDEX_DATA] = new Array(); this.dataset = MVRZ.data.object[this.datasetName]; this.datasetData = MVRZ.data.object[this.datasetName][JSON_RESPONSE_INDEX_DATA]; } var newRowIndex = this.datasetData.length; // The next row this.datasetData[newRowIndex] = new Object(); //popupInfo("append(): "+this.datasetName + " :: idValue="+ idValue + " appending at index="+ newRowIndex + ", " + serializeArray(oFields)); //popup('', this.datasetName + " :: idValue="+ idValue + " appending at index="+ newRowIndex + ", " + serializeArray(oFields)); if (typeof(oFields) == 'object') this.setRow(newRowIndex, oFields); this.set(newRowIndex, idField, idValue); return newRowIndex; } datasetObject.prototype.remove = function remove(idValue, idField){ var ret = false; if(typeof(idValue)=='undefined') { // Delete whole dataset delete(this.dataset.data); delete(this.datasetData); ret = true; } else { // Find the dataset entry for this ID var datasetRowIndex = this.getDatasetRowIndex(idValue, idField); if(datasetRowIndex>=0) { //popupInfo("Deleting row index" + datasetRowIndex + " for idValue "+idValue); delete(this.dataset.data[datasetRowIndex]); delete(this.datasetData[datasetRowIndex]); ret = true; } else { //popupInfo("Could not delete row for idValue "+idValue); } } return ret; } datasetObject.prototype.getDatasetData = function getDatasetData(){ if(typeof(this.dataset[JSON_RESPONSE_INDEX_DATA])=='undefined') { this.dataset[JSON_RESPONSE_INDEX_DATA] = []; } return this.dataset[JSON_RESPONSE_INDEX_DATA]; } datasetObject.prototype.rows = function rows(match){ if(typeof(match)=='undefined') { var data = this.getDatasetData(); var count = 0; // Just taking the "length" doesn't work if an element has been deleted if(typeof(data)!='undefined') { var rows = this.getDatasetData(); for(var rIndex in rows) if(typeof(rows[rIndex])!='undefined') count++; } return count; } else { var ret = 0; var rows = this.getDatasetData(); for(var rIndex in rows) { var failed = false; for(var field in match) { // Test for matches var evalStr = "var pass = rows[rIndex]['"+field+"']"+match[field]; eval(evalStr); if(!pass) { failed = true; break; // Don't use this row } } if(!failed) ret++; } return ret; } } datasetObject.prototype.getRows = function getRows(match){ if(typeof(match)=='undefined') { return this.getDatasetData(); } else { var ret = new Array(); var rows = this.getDatasetData(); for(var rIndex in rows) { var failed = false; for(var field in match) { // Test for matches var evalStr = "var pass = rows[rIndex]['"+field+"']"+match[field]; eval(evalStr); if(!pass) { failed = true; break; // Don't use this row } } if(!failed) ret.push(rows[rIndex]); } return ret; } } datasetObject.prototype.getRow = function getRow(datasetRowIndex){ if (this.isRow(datasetRowIndex)) return this.getDatasetData()[datasetRowIndex]; return false; } datasetObject.prototype.isRow = function isRowSet(datasetRowIndex){ if (/*typeof(this.datasetData) == 'undefined' ||*/ typeof(this.getDatasetData()[datasetRowIndex]) == 'undefined') return false; return true; } datasetObject.prototype.getUniqueField = function getUniqueField() { var ret = 'ID'; // Default if(typeof(this.inputs.iniqueField)!='undefined') ret = this.inputs.iniqueField; return ret; } datasetObject.prototype.get = function get(indexOrArray, field, idField){ // Looks in the local dataset for a line where the value at idField is tha same as index and then returns the value at field in that line. // If idField is not specified then do a straight lookup using index as the index into the datset msg('datasetObject.prototype.get(' + indexOrArray + ', ' + field + ', ' + idField + ') :' + this.datasetName); var ret = ''; // Is is an array or dataset that needs to be looked up if(typeof(indexOrArray)=='object' && indexOrArray!=null) { var ret = indexOrArray[field]; } else { /* Needs to be left blank unless theres a different lookup field if(typeof(idField)=='undefined') idField = this.inputs.uniqueField; if(typeof(idField)=='undefined') idField = this.defaults.idField; */ if (typeof(field) == 'undefined') { msg('datasetObject.prototype.get::field is not set'); return ret; } if (typeof(idField) == 'undefined') idField = null; if (typeof(indexOrArray) == 'undefined' || indexOrArray==null || indexOrArray.length == 0) indexOrArray = this.currentDatasetIdValue; if (typeof(indexOrArray) == 'undefined' || indexOrArray == null || indexOrArray.length == 0) { msg('datasetObject.prototype.get::index nor current index is set'); return ret; } ret = this._get(indexOrArray, field, idField); } msg('datasetObject.prototype.get:: returning:' + ret); return ret; } datasetObject.prototype._get = function _get(index, field, idField){ // Looks in the local dataset for a line where the value at idField is tha same as index and then returns the value at field in that line. // If idField is not specified then do a straight lookup using index as the index into the datset msg('datasetObject.prototype._get:' + this.datasetName + '/' + index + '/' + field + '/' + idField); var ret = ''; if (typeof(index) == 'undefined' || index == null) { msg('datasetObject.prototype._get::index is not valid:' + this.datasetName); return ret; } if (typeof(this.dataset) != 'undefined') { this.datasetData = this.dataset.data; if (typeof(this.datasetData) != 'undefined') { if (idField == null || idField.length == 0) { // Use index as the data index as there's no field to look for the index value on if (typeof(this.datasetData[index]) != 'undefined') { ret = this.datasetData[index][field]; msg('datasetObject.prototype._get::using index as dataIndex as idField zero length:' + index); } else { msg('datasetObject.prototype._get::NO index, returing null string'); ret = ''; } } else { var found = false; for (var dataIndex in this.datasetData) { msg('datasetObject.prototype._get::' + dataIndex + ' checking ' + this.datasetData[dataIndex][idField]); if (this.datasetData[dataIndex][idField] == index) { ret = this.datasetData[dataIndex][field]; found = true; break; } } if (!found) { msg('datasetObject.prototype._get:' + this.datasetName + '/' + index + '/' + field + '/' + idField); msg('datasetObject.prototype._get::index not found in dataset:' + index); } } } else { msg('datasetObject.prototype._get::dataset data not loaded:' + this.datasetName); } } else { msg('datasetObject.prototype._get::dataset not defined:' + this.datasetName); } msg('datasetObject.prototype._get:: returning:' + field + '=' + ret); return ret; } datasetObject.prototype._setArgs = function _setArgs(action, oRequest){ msg('datasetObject.prototype._setArgs(' + action + '):' + this.datasetName); if (typeof(action) == 'undefined') action = YUI_ACTION_LOAD; //var request = new Object(); if(typeof(oRequest[ARG_GETS])=='undefined') oRequest[ARG_GETS] = new Object(); oRequest[ARG_GETS][GET_ACTION] = action; oRequest[ARG_GETS][GET_WHAT] = this.datasetName; oRequest[ARG_GETS][GET_RETURNFORMAT] = YUI_RETURNFORMAT_JSON; //return oRequest; //this.request.argArray = new Object(); ////this.request.argArray[GET_ACTION] = action; ////this.request.argArray[GET_WHAT] = this.datasetName; ////this.request.argArray[GET_RETURNFORMAT] = YUI_RETURNFORMAT_JSON; ////return this.request.argArray; } datasetObject.prototype.doPreRender = function doPreRender(idValue, elContent){ msg('datasetObject.prototype.doPreRender(' + idValue + ',' + elContent + '):' + this.datasetName); var ret = true; //var input = this.datasetName+'ID'; //var selectId = MVRZ.util.encodeSelectId(this.datasetName, input); //msg('datasetObject.prototype.doPreRender selectId:' + selectId); // - find the data row needed //var dataRowIndex = 0; // First one var dataArray = this.dataset[JSON_RESPONSE_INDEX_DATA]; if (typeof(idValue) == 'undefined') idValue = this.idValue; var dataValue = idValue; msg('datasetObject.prototype.doPreRender FIRST dataValue:' + dataValue); this.setDatasetId(dataValue); // Pre-render function? msg('doPreRender::Checking for preRender:' + typeof(this.preRender)); if (typeof(this.preRender) == 'function') { ret = this.preRender(idValue, elContent); } return ret; } datasetObject.prototype.renderSelects = function renderSelects(oAppendTo){ var el = MVRZ.util.getElObject(oAppendTo); msg('datasetObject.prototype.renderSelects:' + this.datasetName + ", id="+el.id); var el = MVRZ.util.getElObject(oAppendTo); if(el) { var selectsList = []; if(typeof(this.renderSelectsList)!='undefined' && this.renderSelectsList.length) { selectsList = MVRZ.util.clone(this.renderSelectsList); } else { //dbgp("selectsList::"+dump(selectsList)); if(typeof(this.inputs.selectField)!='undefined') { //dbgp("Adding Select() for this: "+this.datasetName); if(typeof(this.inputs.selectField) != "object") { // Reference to another dataset's selectfield var refDatasetName = this.inputs.selectField; } else { var refDatasetName = this.datasetName; } } if(!in_array(refDatasetName, selectsList)) { selectsList.push(this.datasetName); } } if (selectsList.length) { for (var selectIndex in selectsList) { var datasetName = selectsList[selectIndex]; //dbgp("Rendering "+this.datasetName+" select for selectIndex=" + selectIndex + ", datasetName=" + datasetName); if (typeof(MY[datasetName]) != 'object') { msg("No MY object for datasetName="+datasetName); continue; } if(typeof(MY[datasetName].inputs.selectField)=='undefined') { msg("No selectField for datasetName="+datasetName); continue; } MY[datasetName].inputs.selectField.noHandlers = false; MY[datasetName].inputs.selectField.onlyChangeHandler = true; MY[datasetName].inputs.selectField.fnOnChange = this.handleEditSelectChange; // TODO - just subscribe to any existing one to add a function call // TODO - make this use parameter instead of 'name' if (typeof(MY[datasetName].inputs.fields[MY[datasetName].inputs.selectFieldLabel]) != 'undefined') { MY[datasetName].inputs.fields['name'].fnOnSave = this.updateMainSelect; } //dbgp(selectIndex+": Calling renderSelect() for "+datasetName); //MY[datasetName].renderSelect(oAppendTo, MY[datasetName].getDatasetId(), MY[datasetName].inputs.selectField, false); var oInput = MVRZ.util.render.input(MY[datasetName].inputs.selectField, MY[datasetName].getSelectId(), MY[datasetName].dataValue, this); if(typeof(oInput)=='undefined' || oInput == null){ msg('renderForEdit('+this.datasetName+'):: Input select already present'); // No need to find input at this point } else { //c.innerHTML = ''; msg("Adding select id "+id+" to "+oAppendTo.id); oAppendTo.appendChild(oInput); } //dbgp("Done renderSelect()"); } } } } datasetObject.prototype.render = function render(pElContent, pArgArray, sLayoutContent, fnCallback){ msg('datasetObject.prototype.render:' + this.datasetName + '::' + serializeArray(pArgArray)); if (typeof(pArgArray) != 'object') { argArray = new Object(); } else { argArray = MVRZ.util.clone(pArgArray); } var oDataset = this; var elContent = pElContent; ////var elContent = ID_CONTENT_DIV; // Same every time if(typeof(elContent)!='object') { elContent = document.getElementById(pElContent); } if((typeof(elContent)=='undefined' || !elContent) && this.lastRenderContentId) { elContent = document.getElementById(this.lastRenderContentId); } if(typeof(elContent)=='undefined' || elContent == null) return; if(typeof(elContent.id)=='undefined' || elContent.id.length==0) elContent.id = YAHOO.util.Dom.generateId(); var elContentId = elContent.id; this.lastRenderContentId = elContentId; ////var renderInfoIndex = ID_GLOBAL_CONTENT_DIV; var renderInfoIndex = MVRZ.util.setChildId(elContentId, ID_CHILD_APPEND_CONTENT); if(typeof(sLayoutContent)=='undefined') sLayoutContent = ''; //popupInfo("render, elContent.id="+elContentId); var addSelect; if (typeof(argArray) != 'undefined') { var displayType = argArray[DISPLAY_TYPE]; var viewType = argArray[VIEW_TYPE]; addSelect = argArray['addSelect']; } if(typeof(addSelect)=='undefined') addSelect = false; // Default if (typeof(displayType) == 'undefined') displayType = argArray[DISPLAY_TYPE] = DISPLAY_TYPE_EDIT; if (typeof(viewType) == 'undefined') viewType = argArray[VIEW_TYPE] = VIEW_TYPE_DEFAULT; if (typeof(this.renderInfo) != 'object') this.renderInfo = new Object(); if (typeof(this.renderInfo[renderInfoIndex]) != 'object') this.renderInfo[renderInfoIndex] = new Object(); // Overwrite existing values if preset in arg list if (typeof(elContentId) != 'undefined') this.renderInfo[renderInfoIndex]['elContentBaseId'] = elContentId; if (typeof(argArray) != 'undefined') this.renderInfo[renderInfoIndex]['argArray'] = argArray; /* if(typeof(idValue)!='undefined') this.renderInfo['idValue'] = idValue; if(typeof(displayType)!='undefined') this.renderInfo['displayType'] = displayType; if(typeof(sIntroHtml)!='undefined') this.renderInfo['sIntroHtml'] = sIntroHtml; if(typeof(oSteps)!='undefined') this.renderInfo['oSteps'] = oSteps; */ //popupInfo('prototype.render renderInfoIndex=' + renderInfoIndex); //popupInfo('prototype.render argArray::' + serializeArray(argArray)); var renderFunctionName = 'renderFor' + displayType; /* if(this.datasetName == DATASET_PROPERTY) { msg('prototype.render() - stopping for dataset: '+this.datasetName); return; } */ // Set the layout /* var sLayout = '
' +'
' +'
'+sLayoutContent+'
' +'
' ; elContent.innerHTML = sLayout; */ var oContent = document.createElement("div"); oContent.id = renderInfoIndex; oContent.className = "mvrz-content-dataset-" + this.datasetName; oContent.innerHTML = sLayoutContent; var oIntro = document.createElement("div"); oIntro.id = MVRZ.util.setChildId(elContentId, ID_CHILD_APPEND_INTRO); var oSelect = document.createElement("div"); oSelect.id = MVRZ.util.setChildId(elContentId, ID_CHILD_APPEND_SELECT); var oControls = document.createElement("div"); oControls.id = MVRZ.util.setChildId(elContentId, ID_CHILD_APPEND_CONTROLS); //elContent.innerHTML = ''; elContent.appendChild(oIntro); elContent.appendChild(oSelect); elContent.appendChild(oContent); elContent.appendChild(oControls); if(addSelect || (typeof(this.renderSelectsList)!='undefined' && this.renderSelectsList.length)) { msg("Calling renderSelect()"); this.renderSelects(oSelect); } this['elContentIdLast'+displayType] = renderInfoIndex; //dbgp(this.datasetName + ":: SET editElContentIdLast="+renderInfoIndex); if (this.isLoaded()) { msg('prototype.render Already loaded, calling '+renderFunctionName); this[renderFunctionName](renderInfoIndex); if(typeof(fnCallback)=='function') { fnCallback(this.loadStatus); } } else { msg('prototype.render NOT already loaded, calling load() with callback='+renderFunctionName); //oContent.innerHTML = HTML_LOADING; if(this.loadStatus == LOAD_STATUS_STOP) { oContent.innerHTML = getStopNotice(this.stopNotice); if(typeof(fnCallback)=='function') { fnCallback(this.loadStatus); } } else { oContent.innerHTML = getLoadingNotice(this.loadingNotice); //Why no argArray?//this.load('', this, renderInfoIndex, renderFunctionName); ////this.load(argArray, this, renderInfoIndex, renderFunctionName); this.load(argArray, this, renderInfoIndex, function() { oContent.innerHTML = ''; oDataset[renderFunctionName](renderInfoIndex); if(typeof(fnCallback)=='function') { fnCallback(oDataset.loadStatus); } }); } } } datasetObject.prototype.handleEditSelectChange = function handleEditSelectChange(e, oDataSet) { //var oRequest = obj; if(typeof(oDataSet) != 'object') { //dbgp('renderEdit():: handleEditSelectChange: oDataset is not an object'); return false; } oDataset = this; var dataObjectIndex = oDataSet.datasetName; //dbgp('handleEditSelectChange('+dataObjectIndex+'):: currentDatasetIdValue='+oDataSet.currentDatasetIdValue); if(oDataSet.getDatasetId() != 0 && !MVRZ.util.validation.allInputsValidAndPresent(oDataSet.datasetName)) { msg('handleEditSelectChange('+dataObjectIndex+'):: INVALID dataset, not changing select: '+oDataSet.currentDatasetIdValue); MVRZ.Render.Feedback.Warn("Please ensure that all fields are completed correctly"); // Put the selection back oDataSet.updateMainSelect(e, oDataSet); return false; } if(typeof(e)!='undefined' && e != null) { var oTarget = YAHOO.util.Event.getTarget(e, 1); //var value = oTarget.value; var value = oDataSet.getDatasetId(oTarget.id, true); var isEvent = true; msg('handleEditSelectChange('+dataObjectIndex+'):: (event), value='+value); } else { var isEvent = false; var value = oDataSet.currentDatasetIdValue; msg('handleEditSelectChange('+dataObjectIndex+'):: (NO event) ('+typeof(e)+'), value='+value); } //dbgp('renderEdit('+dataObjectIndex+'):: handleEditSelectChange: value='+value); var elContent = oDataSet.renderEditId; //var c = document.getElementById(elContent); msg('handleEditSelectChange('+dataObjectIndex+'):: '+oTarget.id+' = '+oTarget.value+' ('+elContent+')'); // Render with a specific starting value oDataSet.currentDatasetIdValue = value; //MY[dataObjectIndex].renderEdit(elContent, value); oDataSet.idValue = value; //MY[dataObjectIndex].initRequest.handleLoadSuccess(obj); oDataSet.renderForEdit(null, value); //oDataSet.render(); ////oContent = MVRZ.util.render.inputs(gInputs[dataObjectIndex].inputs, oRequest, value); ////if(typeof(oContent)!='undefined') c.parentNode.replaceChild(oContent, c); } datasetObject.prototype.updateMainSelect = function updateMainSelect(e, oDataset) { //var oRequest = oConnection.argument; /* 2011-03-02 Seems silly to do this if(typeof(oDataset)=='undefined') { msg("renderEdit('+dataObjectIndex+'):: updateMainSelect - oDataSet not defined"); return; } */ oDataset = this; var dataObjectIndex = oDataset.datasetName; msg('updateMainSelect('+dataObjectIndex+'):: updateMainSelect: ' + dataObjectIndex); //if(typeof(oDataset.dataset)=='undefined') oDataset.dataset = var dataArray = oDataset.dataset[JSON_RESPONSE_INDEX_DATA]; // - Select box - indexed by row //oRequest.selectInput = new s(dataObjectIndex+'ID', "select", "", "ID", true, null, null, MVRZ.util.select[dataObjectIndex]); //var fieldsInput = new s(dataObjectIndex+'ID', "select", "", "ID", true, null, null, MVRZ.util.select[dataObjectIndex], this.handleEditSelectChange); var selectField = oDataset.inputs.selectField; //var input = dataObjectIndex+'ID'; /* if(typeof(oDataset.currentDatasetIdValue) != 'undefined') { var dataValue = oDataset.currentDatasetIdValue; } else { var dataValue = oDataset.currentSelectedId; } */ var dataValue = oDataset.getDatasetId(); var id = this.getSelectId(); oInput = MVRZ.util.render.input(selectField, id, dataValue, oDataset, true); if(typeof(oInput)=='undefined'){ msg('renderEdit('+dataObjectIndex+'):: No input select'); return; } } datasetObject.prototype.renderSelect = function renderSelect(oAppendTo, selectedId, selectField, postponeOptions){ msg('datasetObject.prototype.renderSelect:' + this.datasetName); if (typeof(postponeOptions) == 'undefined') postponeOptions = false; if (typeof(selectField) == 'undefined') { msg('datasetObject.prototype.renderSelect: using dataset default select field'); selectField = this.inputs.selectField; } else { msg('datasetObject.prototype.renderSelect: using argument select field, fnOnChange is ' + typeof(selectField.fnOnChange)); } //return; if (typeof(selectField) != 'undefined') { var input = this.datasetName + 'ID'; //var id = MVRZ.util.encodeSelectId(this.datasetName, input); var id = this.getSelectId(); this.selectId = id; //selectField.noHandlers = false; //selectField.onlyChangeHandler = true; //selectField.fnOnChange = this.handleEditSelectChange; // TODO - make this use parameter instead of 'name' /* if(typeof(this.inputs.fields['name'])!='undefined') { this.inputs.fields['name'].fnOnSave = this.updateMainSelect; } */ var oSelectWrapper = MVRZ.util.render.input(selectField, id, selectedId, this, false, postponeOptions); if (typeof(oSelectWrapper) == 'undefined' || oSelectWrapper == null) { msg('renderSelect(' + this.datasetName + '):: input already defined'); } else { oAppendTo.appendChild(oSelectWrapper); } oSelect = document.getElementById(id); return oSelect; //this.select(oSelect, selectedId); } } datasetObject.prototype.select = function select(oSelect, selectedId, fieldName, selectConfig){ msg('datasetObject.prototype.select:' + this.datasetName + ', selectedId=' + selectedId + ', fieldName=' + fieldName); //alert('datasetObject.prototype.select:' + this.datasetName + ', selectedId='+selectedId+', fieldName='+fieldName); if (typeof(selectedId) == 'undefined') selectedId = ''; if (typeof(this.selectInfo) == 'undefined') this.selectInfo = new Array(); var arrayIndex = this.selectInfo.length; this.selectInfo[arrayIndex] = new Object(); this.selectInfo[arrayIndex]['oSelectId'] = oSelect.id; this.selectInfo[arrayIndex]['selectedId'] = selectedId; this.selectInfo[arrayIndex]['oSelect'] = oSelect; this.selectInfo[arrayIndex]['selectedId'] = selectedId; var oRef = selectConfig; if (typeof(fieldName) == 'undefined' || fieldName.length == 0 || typeof(this.inputs.fields[fieldName]) == 'undefined') { if (typeof(oRef) == 'undefined') oRef = this.inputs.selectField.selectConfig; this.selectInfo[arrayIndex]['labelField'] = this.inputs.selectOptionLabelField; this.selectInfo[arrayIndex]['idField'] = this.inputs.selectField.selectOptionIdField; } else { if (typeof(oRef) == 'undefined') oRef = this.inputs.fields[fieldName].selectConfig; this.selectInfo[arrayIndex]['labelField'] = oRef.label; //alert('field selctInfo for '+ fieldName+', oRef.zeroSelect='+oRef.zeroSelect); //this.selectInfo['idField'] = oRef.id; } if (typeof(oRef) != 'undefined') { if(typeof(oRef.labelField)!='undefined') this.selectInfo[arrayIndex]['labelField'] = oRef.labelField; if(typeof(oRef.allowNew)!='undefined') this.selectInfo[arrayIndex]['allowNew'] = oRef.allowNew; if(typeof(oRef.newSelect)!='undefined') this.selectInfo[arrayIndex]['newSelect'] = oRef.newSelect; if(typeof(oRef.zeroSelect)!='undefined') this.selectInfo[arrayIndex]['zeroSelect'] = oRef.zeroSelect; if(typeof(oRef.removeCurrentId)!='undefined') this.selectInfo[arrayIndex]['removeCurrentId'] = oRef.removeCurrentId; if(typeof(oRef.sortByFieldName)!='undefined') this.selectInfo[arrayIndex]['sortByFieldName'] = oRef.sortByFieldName; if(typeof(oRef.parentField)!='undefined') this.selectInfo[arrayIndex]['parentField'] = oRef.parentField; if(typeof(oRef.matchArray)!='undefined') this.selectInfo[arrayIndex]['matchArray'] = oRef.matchArray; if(typeof(oRef.fnSkip)!='undefined') this.selectInfo[arrayIndex]['fnSkip'] = oRef.fnSkip; } msg('datasetObject.prototype.select:' + this.datasetName + '::' + fieldName + ':' + serializeArray(this.selectInfo)); if (this.isLoaded()) { this.renderSelectOptions(arrayIndex); } else { this.load('', this, arrayIndex, 'renderSelectOptions'); } } datasetObject.prototype.renderSelectOptions = function renderSelectOptions(arrayIndex){ msg('datasetObject.prototype.renderSelectOptions:' + this.datasetName + '::' + serializeArray(this.selectInfo[arrayIndex])); var oSelectId = this.selectInfo[arrayIndex]['oSelectId']; var selectedId = this.selectInfo[arrayIndex]['selectedId']; var oSelect = this.selectInfo[arrayIndex]['oSelect']; //var selectedId = this.selectInfo['selectedId']; var labelField = this.selectInfo[arrayIndex]['labelField']; var idField = this.selectInfo[arrayIndex]['idField']; var allowNew = this.selectInfo[arrayIndex]['allowNew']; var newSelect = this.selectInfo[arrayIndex]['newSelect']; var zeroSelect = this.selectInfo[arrayIndex]['zeroSelect']; var removeCurrentId = this.selectInfo[arrayIndex]['removeCurrentId']; var sortByFieldName = this.selectInfo[arrayIndex]['sortByFieldName']; var parentField = this.selectInfo[arrayIndex]['parentField']; var aMatch = this.selectInfo[arrayIndex]['matchArray']; var fnSkip = this.selectInfo[arrayIndex]['fnSkip']; if (typeof(labelField) == 'undefined') labelField = this.defaults['labelField']; if (typeof(idField) == 'undefined') idField = this.defaults['idField']; if (typeof(aMatch) == 'undefined') aMatch = new Array(); //popupInfo('selectInfo::'+oSelectId+'//'+selectedId+'/'+labelField+'/'+idField+'/removeCurrentId='+removeCurrentId+"fnSkip="+typeof(fnSkip)); /* var oList = new Object(); this.datasetData = this.dataset[JSON_RESPONSE_INDEX_DATA]; for(dataIndex in this.datasetData) { msg('selectInfo creating list::'+dataIndex+'/'+this.datasetData[dataIndex][labelField]+'/'+this.datasetData[dataIndex][idField]); oList[this.datasetData[dataIndex][labelField]] = this.datasetData[dataIndex][idField]; } msg('selectInfo oList.length::'+oList.length); */ msg('selectInfo dataset.length::' + this.dataset[JSON_RESPONSE_INDEX_DATA].length); this.datasetData = this.dataset[JSON_RESPONSE_INDEX_DATA]; var oOptions = new Object(); if (typeof(selectedId) == 'undefined' || selectedId.toString().length == 0) { //if(this.inputs.whenIdNotSet == INPUT_WHENIDNOTSET_PICKFIRST) { if (typeof(newSelect) != 'undefined' && newSelect.toString().length > 0) { //if(typeof(this.datasetData[0])=='object') selectedId = this.datasetData[0][idField]; if (typeof(this.datasetData[0]) == 'object') selectedId = this.get(0, idField); } } // Remove existing options if(typeof(oSelect.options)!='undefined') { for (i = oSelect.options.length - 1; i >= 0; i--) { oSelect.options[i] = null; } } // NEW entry? if (typeof(newSelect) != 'undefined' && newSelect.toString().length) { var oOption = document.createElement('option'); oOption.value = '0'; oOption.text = newSelect; try { oSelect.add(oOption, null); // standards compliant; doesn't work in IE } catch (ex) { oSelect.add(oOption); // IE only } } else { // Zero/First value? if (typeof(zeroSelect) != 'undefined' && zeroSelect.toString().length) { var oOption = document.createElement('option'); oOption.value = ''; oOption.text = zeroSelect; try { oSelect.add(oOption, null); // standards compliant; doesn't work in IE } catch (ex) { oSelect.add(oOption); // IE only } } } if (typeof(sortByFieldName) == 'undefined' || sortByFieldName.length == 0) { var oData = this.datasetData; } else { //var oData = getSortedDataObj(this.datasetData, sortByFieldName); var oData = this.datasetData; } // Data entries if (typeof(removeCurrentId) == 'undefined') removeCurrentId = false; var aRawOptionsValList = new Array(); var aRawOptionsTextList = new Array(); var iCount = 0, pCount = 0; var selectArray = new Array(); var prioritySelectArray = new Array(); //popupInfo('renderSelectOptions: '+this.datasetName+', oData length=' + oData.length); for (var dataIndex in oData) { if (typeof(labelField) == 'function') { var selectText = labelField(oData, dataIndex, this); } else { var selectText = oData[dataIndex][labelField]; } if (typeof(selectText) == 'undefined' || selectText==null || selectText.length == 0) continue; var selectVal = oData[dataIndex][idField]; if (removeCurrentId && this.currentDatasetIdValue === selectVal) { msg('datasetObject.prototype.renderSelectOptions: skipping currentId=' + selectVal); continue; } // Only items that match? var skip = false; //popupInfo('renderSelectOptions: '+this.datasetName+', match length=' + aMatch.length); if (aMatch.length) { for (var matchIndex in aMatch) { sEval = aMatch[matchIndex].eval; //popupInfo('renderSelectOptions: checking match for' + sEval); eval('var result = ' + sEval); if (!result) { //msg(' - skipping false match=' + selectVal); skip = true; continue; } } } if (!skip && typeof(fnSkip) == 'function') { skip = fnSkip(oData[dataIndex]); } //aRawOptionsValList[iCount] = selectVal; //aRawOptionsTextList[iCount] = selectText; if (skip) { //popupInfo(this.datasetName+':: renderSelectOptions: skipping dataIndex=' + dataIndex + "ID="+oData[dataIndex]['ID']); continue; } selectArray[iCount] = new Array(); selectArray[iCount][0] = selectText; selectArray[iCount][1] = selectVal; if(typeof(oData[dataIndex]['selectOrder'])!='undefined' && oData[dataIndex]['selectOrder']!=0) { prioritySelectArray[pCount] = selectArray[iCount]; pCount++; } iCount++; } //popupInfo('renderSelectOptions: '+this.datasetName+', selectArray length=' + selectArray.length); selectArray.sort(); // Check for sortOrder fields and add non-zero ones to the top of the list if(prioritySelectArray.length>0) { prioritySelectArray.reverse(); // As we insert at the top in the loop selectArray.unshift(["------------"]); // Spacer for(var i in prioritySelectArray) { selectArray.unshift(prioritySelectArray[i]); } } /* for (j = 0; j < selectBox.length; j++) { selectBox.options[j].text = selectArray[j][0]; selectBox.options[j].value = selectArray[j][1]; } if(typeof(sortByFieldName)!='undefined' && sortByFieldName.length>0) { //var oData = getSortedDataObj(this.datasetData, sortByFieldName); var oTmp = new Object(); var aTmp = aRawOptionsTextList.sort(); var aOptionsList = new Array(); iCount=0; for(index in aTmp) { aOptionsList[iCount] = aRawOptionsValList[iCount]; } } else { aOptionsList = aRawOptionsList; } XX // NEED TO SEPARATE INDEX AND VALUE FOR THE OPTION XX */ //popupInfo('datasetObject.prototype.select::setOptions: select.id=' + oSelect.id + ", entries= " + selectArray.length); for (var optionIndex in selectArray) { //msg('selectInfo list item::'+dataIndex+'/'+index+'/'+label); var oOption = document.createElement('option'); oOption.value = selectArray[optionIndex][1]; oOption.text = selectArray[optionIndex][0]; if (oOption.value == selectedId) oOption.selected = true; try { oSelect.add(oOption, null); // standards compliant; doesn't work in IE } catch (ex) { oSelect.add(oOption); // IE only } } this.currentSelectedId = selectedId; // Ensure that the dataset has this value - may be a default in the display that's not set for new entries var oId = MVRZ.util.decodeInputId(oSelect.id); if (oId.idValue == 0) { msg("render.input setting dataset value of " + oId.input + ' to ' + selectedId + ' at ID=' + oId.idValue); if (typeof(MY[oId.datasetName]) != 'undefined') { MY[oId.datasetName].setByIdField(oId.idValue, oId.input, selectedId); MVRZ.util.validation._validate(oId.datasetName, oId.input, selectedId, oSelect.id); } } /* this.selectList = new Object(); this.datasetData = this.dataset[JSON_RESPONSE_INDEX_DATA]; for(dataIndex in this.datasetData) { var label = this.datasetData[dataIndex][labelField]; var index = this.datasetData[dataIndex][idField]; msg('selectInfo creating list::'+dataIndex+'/'+index+'/'+label); this.selectList[index] = label; } msg('selectInfo this.selectList.length::'+this.selectList.length); // Create the options list var oOptions = new Object(); var count = 0; //if(oList.length) { for (item in this.selectList) { var selectVal = this.selectList[item]; var selectText = item; msg('datasetObject.prototype.select::setOptions: ' + item + " " + selectVal + " " + selectText + " selected=" + selectedId); var oOption = document.createElement('option'); oOption.value = selectVal; oOption.text = selectText; if (selectVal == selectedId) oOption.selected = true; try { oSelect.add(oOption, null); // standards compliant; doesn't work in IE } catch (ex) { oSelect.add(oOption); // IE only } } //} */ } datasetObject.prototype.edit = function(){ msg('datasetObject.prototype.edit:' + this.datasetName); } datasetObject.prototype.view = function(){ msg('datasetObject.prototype.view:' + this.datasetName); } function setRequest(obj, action){ msg('setRequest()'); if (typeof(action) == 'undefined') action = YUI_ACTION_LOAD; obj.initRequest = new Object(); //obj.initRequest.waitStack = new Object(); // Other objects waiting on the data obj.initRequest.args = new Object(); obj.initRequest.save = new Object(); obj.initRequest.args.what = obj.datasetName; obj.initRequest.args.load = { action: action, what: obj.dataObjectIndex, rf: YUI_RETURNFORMAT_JSON } } function renderView(elContent, oConfig, sIntroHtml, oSteps){ msg('renderView:: elContent = ' + elContent); if (typeof(oConfig) == 'undefined') oConfig = new Object(); if (typeof(oConfig.oFilter) == 'undefined') { oConfig.oFilter = new Object(); } this.initRequest.oConfig = oConfig; this.initRequest.elContent = elContent; this.initRequest.oSteps = oSteps; dataObjectIndex = this.dataObjectIndex; // Function to render the content this.initRequest.handleLoadSuccess = function(oConnection){ var oRequest = oConnection.argument; var dataObjectIndex = oRequest.args.what; msg('renderView(' + dataObjectIndex + '):: handleSuccess: ' + oRequest.args.what); var c = document.getElementById(oRequest.elContent); // Unparsed (error/warning) //if(typeof(MVRZ.data.object[dataObjectIndex][JSON_RESPONSE_INDEX_UNPARSED])!='undefined') { if (typeof(MY[dataObjectIndex].dataset[JSON_RESPONSE_INDEX_UNPARSED]) != 'undefined') { gRemoteInfoPanel.setBody(MY[dataObjectIndex].dataset[JSON_RESPONSE_INDEX_UNPARSED]); gRemoteInfoPanel.show(); } else { msg('renderView(' + dataObjectIndex + '):: handleSuccess RAW DATA :' + MY[dataObjectIndex].dataset[JSON_RESPONSE_INDEX_RAW]); //var jsonData = MVRZ.data.object[dataObjectIndex][JSON_RESPONSE_INDEX_RAW]; //var dataSource = new YAHOO.util.LocalDataSource(jsonData); //dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON; // Filter the data as needed var rowCount = 0; var jsonDataObj = MY[dataObjectIndex].dataset[JSON_RESPONSE_INDEX_DATA]; //oRequest.oFilter.featureID = '==1'; var jsonDataObjFiltered = new Array(); var oFilter = oConfig.oFilter; for (dataRowIndex in jsonDataObj) { var failed = false; for (filter in oFilter) { var evalStr = "var result = (" + jsonDataObj[dataRowIndex][filter] + oFilter[filter] + ")"; msg('zFILTERING: ' + dataRowIndex + ',' + filter + ':' + evalStr); eval(evalStr); if (!result) { msg(' - failed filter eval'); failed = true; break; } } if (failed) continue; // Next row // If we get here then the filter has passed msg('FILTERING: Adding row to filtered data: ' + dataRowIndex); jsonDataObjFiltered[rowCount++] = jsonDataObj[dataRowIndex]; //jsonDataObjFiltered[dataRowIndex] = jsonDataObj[dataRowIndex]; } // New rows? if (oRequest.oConfig.newRows) { for (var i = 0; i < oRequest.oConfig.newRows; i++) { msg('renderView(' + dataObjectIndex + '):: handleSuccess: Adding new row ' + i); jsonDataObjFiltered[rowCount] = new Object(); for (field in oRequest.oConfig.newRowPreset) { msg('renderView(' + dataObjectIndex + '):: handleSuccess: Presetting ' + field + ' to ' + oRequest.oConfig.newRowPreset[field]); jsonDataObjFiltered[rowCount][field] = oRequest.oConfig.newRowPreset[field]; } rowCount++; } } var dataSource = new YAHOO.util.LocalDataSource(jsonDataObjFiltered); //var dataSource = new YAHOO.util.LocalDataSource(jsonDataObj); dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSARRAY; // Set up the view table if (typeof([dataObjectIndex]) == 'undefined' || MY[dataObjectIndex].viewList.length == 0) { msg('renderView(' + dataObjectIndex + '):: handleSuccess: NO VIEW FIELDS'); return; } var colDefs = Array(); var schemaFields = Array(); var i = 0; for (input in MY[dataObjectIndex].viewList) { var inputName = MY[dataObjectIndex].viewList[input]; msg('renderView(' + dataObjectIndex + '):: handleSuccess: Field: ' + inputName + ' -- ' + typeof(oConfig.fnAfterTableSave)); colDefs[i] = { key: inputName, sortable: MY[dataObjectIndex].inputs.fields[inputName].sortable, formatter: MY[dataObjectIndex].inputs.fields[inputName].formatter, //formatter: function(elLiner, oRecord, oColumn, oData){msg("***** HELLO THERE ****** " + oData);}, label: MY[dataObjectIndex].inputs.fields[inputName].label, editor: MY[dataObjectIndex].inputs.fields[inputName].isNotEditable ? null : MVRZ.util.render.cellEditor(dataObjectIndex, MY[dataObjectIndex].inputs, inputName, oConfig.fnAfterTableSave) }; schemaFields[i] = { key: inputName, parser: MY[dataObjectIndex].inputs.fields[inputName].parser }; i++; } dataSource.responseSchema = { resultsList: JSON_RESPONSE_INDEX_DATA, fields: schemaFields }; //var colDefs = [{key:"featureID", label:"ID"},{key:"featureTypeID", label:"Type"},{key:"featureName", label:"Name"},{key:"releaseID", label:"Release"},{key:"featureNotes", label:"Notes"}]; var dataTable = new YAHOO.widget.DataTable(oRequest.elContent, colDefs, dataSource); dataTable.subscribe("cellClickEvent", dataTable.onEventShowCellEditor); } } MVRZ.util.remote.load(this.initRequest); } /* function renderEdit(elContent, idValue, displayType, sIntroHtml, oSteps){ // NOT USED this.initRequest.elContent = elContent; this.initRequest.oSteps = oSteps; this.initRequest.displayType = displayType; this.initRequest.idValue = idValue; this.initRequest.sIntroHtml = sIntroHtml; dataObjectIndex = this.dataObjectIndex; msg('renderEdit('+dataObjectIndex+'):: elContent = ' + elContent+', idValue = ' + idValue); //this.initRequest.selectInput = new s(dataObjectIndex+'ID', "select", "", "ID", true, null, null, MVRZ.util.select[dataObjectIndex]); // Function to render the content this.initRequest.handleLoadSuccess = function(oRequest){ //var oRequest = oConnectionCallback.argument; var dataObjectIndex = oRequest.args.what; var displayType = oRequest.displayType; msg('renderEdit('+dataObjectIndex+'):: handleLoadSuccess: ' + oRequest.args.what + ' // ' + oRequest.elContent); var c = document.getElementById(oRequest.elContent); this.handleEditSelectChange = function(e, obj) { var oRequest = obj; var dataObjectIndex = oRequest.args.what; msg('renderEdit('+dataObjectIndex+'):: handleEditSelectChange: '); if(typeof(e)!='undefined' && e != null) { msg('renderEdit('+dataObjectIndex+'):: handleEditSelectChange: (event) ' + oRequest.args.what); oTarget = YAHOO.util.Event.getTarget(e, 1); var value = oTarget.value; var isEvent = true; } else { msg('renderEdit('+dataObjectIndex+'):: handleEditSelectChange: (NO event) ('+typeof(e)+') ' + oRequest.args.what); var isEvent = false; var value = oRequest.currentDatasetIdValue; } msg('renderEdit('+dataObjectIndex+'):: handleEditSelectChange: ' + oRequest.args.what); var elContent = dataObjectIndex+":Edit"; //var c = document.getElementById(elContent); var dataObjectIndex = obj.args.what; msg('renderEdit('+dataObjectIndex+'):: handleEditSelectChange: '+oTarget.id+' = '+value+' ('+elContent+')'); // Render with a specific starting value oRequest.currentDatasetIdValue = value; //MY[dataObjectIndex].renderEdit(elContent, value); oRequest.idValue = value; MY[dataObjectIndex].initRequest.handleLoadSuccess(oRequest); ////oContent = MVRZ.util.render.inputs(gInputs[dataObjectIndex].inputs, oRequest, value); ////if(typeof(oContent)!='undefined') c.parentNode.replaceChild(oContent, c); } this.updateMainSelect = function(e, oRequest) { //var oRequest = oConnection.argument; if(typeof(oRequest)=='undefined') { msg("renderEdit('+dataObjectIndex+'):: updateMainSelect - oRequest not defined"); return; } var dataObjectIndex = oRequest.args.what; msg('renderEdit('+dataObjectIndex+'):: updateMainSelect: ' + dataObjectIndex); var dataArray = MVRZ.data.object[dataObjectIndex][JSON_RESPONSE_INDEX_DATA]; // - Select box - indexed by row //oRequest.selectInput = new s(dataObjectIndex+'ID', "select", "", "ID", true, null, null, MVRZ.util.select[dataObjectIndex]); //var fieldsInput = new s(dataObjectIndex+'ID', "select", "", "ID", true, null, null, MVRZ.util.select[dataObjectIndex], this.handleEditSelectChange); var selectField = gInputs[dataObjectIndex].inputs.selectField; var input = dataObjectIndex+'ID'; var dataValue = oRequest.currentDatasetIdValue; var id = MVRZ.util.encodeInputId(dataObjectIndex, 'select', input); oInput = MVRZ.util.render.input(selectField, id, dataValue, oRequest); if(typeof(oInput)=='undefined'){ msg('renderEdit('+dataObjectIndex+'):: No input select'); return; } } // Unparsed (error/warning) if(typeof(MVRZ.data.object[dataObjectIndex][JSON_RESPONSE_INDEX_UNPARSED])!='undefined') { gRemoteInfoPanel.setBody(MVRZ.data.object[dataObjectIndex][JSON_RESPONSE_INDEX_UNPARSED]); gRemoteInfoPanel.show(); } else { // - only render if not already present or the id is different var editIsPresent = false; if(document.getElementById(dataObjectIndex+":Edit")) editIsPresent = true; if(true || !document.getElementById(dataObjectIndex+":Edit")) { // The Text intro ////if(typeof(oRequest.sIntroHtml)!='undefined') c.innerHTML = oRequest.sIntroHtml; var input = dataObjectIndex+'ID'; var id = MVRZ.util.encodeSelectId(dataObjectIndex, input); // Content //var dataRowIndex = 0; // First one var dataArray = MVRZ.data.object[dataObjectIndex][JSON_RESPONSE_INDEX_DATA]; var dataValue = oRequest.idValue; if(typeof(dataValue)=='undefined' || dataValue==0) dataValue = oRequest.currentDatasetIdValue; if(typeof(dataValue)=='undefined' || dataValue==0) { var selectEl = document.getElementById(id); if(typeof(selectEl)!='undefined' && selectEl!=null) dataValue = selectEl.value; } if(typeof(dataValue)=='undefined' || (dataValue==0 && !this.noFirstIfZero)) { dataValue = dataArray[0]['ID']; } if(displayType==MVRZ_DISPLAY_TYPE_EDIT_MULTI) { // - Content for current selection gInputs[dataObjectIndex].inputs.doMulti = true; gInputs[dataObjectIndex].inputs.newRows = 1; oContent = MVRZ.util.render.inputs(gInputs[dataObjectIndex].inputs, oRequest); } else { if(editIsPresent) c.innerHTML = ''; if(typeof(oRequest.sIntroHtml)!='undefined') c.innerHTML = oRequest.sIntroHtml; //if(!editIsPresent) { // - Select box - indexed by row //oRequest.selectInput = new s(dataObjectIndex+'ID', "select", "", "ID", true, null, null, MVRZ.util.select[dataObjectIndex]); var selectField = gInputs[dataObjectIndex].inputs.selectField; selectField.noHandlers = false; selectField.onlyChangeHandler = true; selectField.fnOnChange = this.handleEditSelectChange; if(typeof(gInputs[dataObjectIndex].inputs.fields[dataObjectIndex+'Name'])!='undefined') { gInputs[dataObjectIndex].inputs.fields[dataObjectIndex+'Name'].fnOnSave = this.updateMainSelect; } //var dataValue = oRequest.currentDatasetIdValue; //var dataValue = oRequest.idValue; //var id = MVRZ.util.encodeInputId(dataObjectIndex, 'select', input); oInput = MVRZ.util.render.input(selectField, id, dataValue, oRequest); if(typeof(oInput)=='undefined'){ msg('renderEdit('+dataObjectIndex+'):: No input select'); return; } //c.innerHTML = ''; c.appendChild(oInput); //} // - Content for current selection oContent = MVRZ.util.render.inputs(gInputs[dataObjectIndex].inputs, oRequest, dataValue); } if(typeof(oContent)!='undefined') { c.appendChild(oContent); } // The Text outro if(typeof(oRequest.sOutroHtml)!='undefined') c.innerHTML += oRequest.sOutroHtml; } } } MVRZ.util.remote.load(this.initRequest); } */ function actionObject(action, what, argArray, callbackObj, callbackArg, successCallbackFunctionName, failureCallbackFunctionName){ msg('what:' + what); this.what = what; this.argArray = argArray; this.request = new Object(); this.request.argArray = new Object(); this.request.argArray[GET_ACTION] = action; this.request.argArray[GET_WHAT] = what; this.request.argArray[GET_RETURNFORMAT] = YUI_RETURNFORMAT_JSON; // TODO - add response handler //this._load(argArray); this.load(argArray, callbackObj, callbackArg, successCallbackFunctionName, failureCallbackFunctionName); } actionObject.prototype.load = load; actionObject.prototype._load = _load; SelectCountries = function(){ var dataObjectIndex = DATASET_SELECTCOUNTRIES; msg('Countries(' + dataObjectIndex + ')'); this.dataObjectIndex = dataObjectIndex; this.preload = preload; msg('Countries(' + dataObjectIndex + ') - calling set request'); setRequest(this); this.preload(); msg('Countries(' + dataObjectIndex + ') preloaded - DONE'); } function Contact(dataObjectIndex, forDisplay, type){ msg('Contact(' + dataObjectIndex + ')'); this.dataObjectIndex = dataObjectIndex; this.forDisplay = forDisplay; this.type = type; gInputs[dataObjectIndex] = new Object(); gInputs[dataObjectIndex].inputs = new Object(); this.inputs = gInputs[dataObjectIndex].inputs; this.isValid = function(){ msg('isValid:' + this.dataObjectIndex); var ret = MVRZ.util.validation.allInputsValid(this.dataObjectIndex); msg('isValid: returning ' + ret); return ret; } this.render = function(elContent, idValue, displayType, sIntroHtml, oSteps){ msg('renderContact: elContent = ' + elContent); this.initRequest.elContent = elContent; this.initRequest.oSteps = oSteps; // Function to render the content this.initRequest.handleLoadSuccess = function(oRequest /*oConnection*/){ //var oRequest = oConnection.argument; var dataObjectIndex = oRequest.args.what; msg('handleSuccess: ' + oRequest.args.what); var c = document.getElementById(oRequest.elContent); // The Text intro c.innerHTML = sIntroHtml; // The contact info ////oContent = _render(RENDER_FOR_EDIT, dataObjectIndex, oRequest) oContent = MVRZ.util.render.inputs(gInputs[dataObjectIndex].inputs, oRequest); c.appendChild(oContent); } MVRZ.util.remote.load(this.initRequest); } this.renderContactTelephoneTypeHelp = function(dataObject, dataRow, oInput, idField){ var input = oInput.name; var dataObjectIndex = dataObject.args.what; msg('renderContactTelephoneType(' + dataObjectIndex + ', ' + dataRow + ', ' + input + ', ' + idField + ')'); this.inputs = gInputs[dataObjectIndex].inputs; //var inputs = gInputs[dataObjectIndex].inputs; //var dataArrayRow = MVRZ.data.object[dataObjectIndex][JSON_RESPONSE_INDEX_DATA][dataRow]; var dataArrayRow = MY[dataObjectIndex].getRow(dataRow); var newInput = input + 'TypeID'; if (typeof(dataArrayRow) != 'undefined') { msg('dataRow:: ' + serializeArray(dataArrayRow)); var dataValue = typeof(dataArrayRow[newInput]) == 'undefined' ? null : dataArrayRow[newInput]; var idValue = dataArrayRow[idField]; msg('renderContactTelephoneType datarow is in data array ' + dataRow + ': (' + newInput + '):' + dataValue); } else { msg('renderContactTelephoneType datarow is NOT in data array ' + dataRow); var idValue = '0'; var dataValue = ''; } var id = dataRow + ":" + dataObjectIndex + ":" + idValue + ":" + newInput; msg('renderContactTelephoneType set id to ' + id); //var id = dataRow + ":" + idValue + ":" +newInput; var s = MVRZ.util.setInputDef; oInputTelType = new MVRZ.util.setInputDef(input + 'TypeID', "select", "Telephone Type", "Which telephone number is this", false, null, null, MVRZ.util.select.telephoneTypes); oInputTelType.style.width = "60px"; //this.inputs.fields[newInput] = oInputTelType; oContent = document.createElement("div"); if (oInput.isRequired) var sRequired = "Required: "; else var sRequired = "Optional: "; oText = document.createTextNode(" " + sRequired + oInputTelType.help); var oInput = MVRZ.util.render.input(oInputTelType, id, dataValue, dataObject); oContent.appendChild(oInput); oContent.appendChild(oText); return oContent; } msg('Contact(' + dataObjectIndex + ') - set request'); this.setRequest = function(){ msg('setRequest()'); this.initRequest = new Object(); this.initRequest.args = new Object(); this.initRequest.save = new Object(); this.initRequest.args.what = this.dataObjectIndex; this.initRequest.args.load = { action: YUI_ACTION_LOAD, what: this.dataObjectIndex, rf: YUI_RETURNFORMAT_JSON } //renderContact(elContent, initRequest, sIntroHtml); //contact = new Contact(this.dataObjectIndex, RENDER_FOR_EDIT); if (this.dataObjectIndex == DATASET_RESERVATIONSCONTACT) { for (field in this.inputs.fields) { this.inputs.fields[field].isRequired = false; } } } msg('Contact(' + dataObjectIndex + ') - DONE set request'); // Set up the inputs var v = MVRZ.util.validation; var s = MVRZ.util.setInputDef; // Define the contact fields //this.inputs.isValid = new Object(); this.inputs.forDisplay = this.forDisplay; this.inputs.ignoreRemoteIdField = true; this.inputs.fields = new Object(); this.inputs.fields['ID'] = new s('ID', "id"); if (dataObjectIndex == DATASET_RESERVATIONSCONTACT) { this.inputs.fields['firstName'] = new s('firstName', "text", "Reservations Name", "What to display to guests when referring to you/your properties (in conjunction with any company name in brackets). The name will be displayed for contact info on the Mini-site and in emails. Eg. 'Reservations' or 'Jim\'s Place'", true, v.isAlpha); } else { this.inputs.fields['firstName'] = new s('firstName', "text", "First Name", "Your first Name", true, v.isAlpha); this.inputs.fields['lastName'] = new s('lastName', "text", "Last Name", "Your last Name", true, v.isAlpha); } this.inputs.fields['companyName'] = new s('companyName', "text", "Company Name", "Your Company Name", false); this.inputs.fields['url'] = new s('url', "text", "Website", "Your website, if any", false, v.isUrl); this.inputs.fields['addressLine1'] = new s('addressLine1', "text", "Street Address", "The first line of your address", true); this.inputs.fields['addressLine2'] = new s('addressLine2', "text", "Street Address Line 2", "The second line of your address (if any)", false); this.inputs.fields['city'] = new s('city', "text", "City", "This is your postal city", true); this.inputs.fields['state'] = new s('state', "text", "State / Region", "The state or region within your country", true); this.inputs.fields['zip'] = new s('zip', "text", "Zip / Postal Code", "Enter the postal / zip code identifier here"); ////this.inputs.fields['countryID'] = new s('countryID', "select", "Country", "Select the country from the list.", true, null, null, MY[DATASET_SELECTCOUNTRIES].options ); this.inputs.fields['countryID'] = new s('countryID', "select", "Country", "Select the country from the list.", true, null, null, MY[DATASET_COUNTRY]); // Telephone numbers this.inputs.fields['telephone1'] = new s('telephone1', "text", "Telephone 1", this.renderContactTelephoneTypeHelp, true, v.isPhone); this.inputs.fields['telephone2'] = new s('telephone2', "text", "Telephone 2", this.renderContactTelephoneTypeHelp, false, v.isPhone); this.inputs.fields['telephone3'] = new s('telephone3', "text", "Telephone 3", this.renderContactTelephoneTypeHelp, false, v.isPhone); this.inputs.fields['telephone4'] = new s('telephone4', "text", "Telephone 4", this.renderContactTelephoneTypeHelp, false, v.isPhone); msg('Contact(' + dataObjectIndex + ') - calling set request'); this.setRequest(); msg('Contact(' + dataObjectIndex + ') - DONE'); } /* function renderContactTelephoneTypeHelp(dataObject, dataRow, oInput, idField) { var input = oInput.name; var dataObjectIndex = dataObject.args.what; msg('renderContactTelephoneType XX('+dataObjectIndex+', '+dataRow+', '+input+', '+idField+')'); var inputs = gInputs[dataObjectIndex].inputs; var dataArrayRow = MVRZ.data.object[dataObjectIndex][JSON_RESPONSE_INDEX_DATA][dataRow]; var newInput = input+'TypeID'; //if (MVRZ.data.object[dataObjectIndex][JSON_RESPONSE_INDEX_DATA].length) { var dataValue = typeof(dataArrayRow[newInput]=='undefined') ? null : dataArrayRow[newInput]; var idValue = dataArrayRow[idField]; //} else { // var dataValue = ''; // var idValue = '0'; //} var elemId = dataRow + ":" + dataObjectIndex + ":" + idValue + ":" +newInput; msg('renderContactTelephoneType set id to '+elemId); var s = MVRZ.util.setInputDef; oInputTelType = new MVRZ.util.setInputDef(input+'TypeID', "select", "Telephone Type", "Which telephone number is this", false, null, null, MVRZ.util.select.telephoneTypes); oInputTelType.style.width="60px"; inputs.fields[newInput] = oInputTelType; oContent = document.createElement("div"); if(oInput.isRequired) var sRequired = "Required: "; else var sRequired = "Optional: "; oText = document.createTextNode(" " + sRequired + oInputTelType.help); var oInput = MVRZ.util.render.input(oInputTelType, elemId, dataValue, dataObject); oContent.appendChild(oInput); oContent.appendChild(oText); return oContent; } */