/*
- * (c) 2005-2009 Richard Cowin (http://openrico.org)
- * (c) 2005-2009 Matt Brown (http://dowdybrown.com)
+ * (c) 2005-2011 Richard Cowin (http://openrico.org)
+ * (c) 2005-2011 Matt Brown (http://dowdybrown.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
};
Rico.extend(this.options, liveGrid.options);
var self=this;
- this.hasWF2=(document.implementation && document.implementation.hasFeature && document.implementation.hasFeature('WebForms', '2.0'));
this.menu=liveGrid.menu;
this.menu.options.dataMenuHandler=function(grid,r,c,onBlankRow) { return self.editMenu(grid,r,c,onBlankRow); };
this.menu.ignoreClicks();
this.addText=Rico.getPhraseById("addRecord",this.options.RecordName);
this.buttonHover=new Rico.HoverSet();
this.dateRegExp=/^\s*(\w+)(\W)(\w+)(\W)(\w+)/i;
- Rico.EditControls.atLoad();
this.createKeyArray();
+ if (typeof(this.options.ConfirmDeleteCol) != 'number')
+ this.options.ConfirmDeleteCol=this.keys.length > 0 ? -2 : -1;
this.createEditDiv();
this.saveMsg=Rico.$(liveGrid.tableId+'_savemsg');
Rico.eventBind(document,"click", Rico.eventHandle(this,'clearSaveMsg'));
this.extraMenuItems=[];
- this.responseHandler=function() { self.processResponse(); };
- Rico.log("Rico.TableEdit.initialize complete, hasWF2="+this.hasWF2);
+ this.responseHandler=function(xhr) { self.processResponse(xhr); };
+ Rico.log("Rico.TableEdit.initialize complete");
},
createKeyArray: function() {
this.responseDialog.style.display='none';
var buttonOK = document.createElement('button');
- buttonOK.appendChild(document.createTextNode('OK'));
+ buttonOK.appendChild(document.createTextNode(Rico.getPhraseById("ok")));
Rico.eventBind(buttonOK,"click", Rico.eventHandle(this,'ackResponse'));
this.responseDialog.appendChild(buttonOK);
createWindow: function() {
var self=this;
- return new Rico.Window('', {closeFunc: function() { self.makeFormInvisible(); }, overflow: this.options.panels ? 'hidden' : 'auto'});
+ return new Rico.Window('', {closeFunc: function() { self.makeFormInvisible(); }, overflow: this.options.ColGroups ? 'hidden' : 'auto'});
},
initPanelGroup: function() {
this.options.bgColor = Rico.Color.createColorFromBackground(this.form).toString();
}
this.formPopup.container.style.display='none';
- //this.options.panelHdrWidth=(Math.floor(wi / this.options.panels.length)-20)+'px';
this.formPanels=new Rico.TabbedPanel(this.panelGroup, this.options);
},
if (!fldSpec.EntryType) continue;
if (fldSpec.EntryType=='H') continue;
if (fldSpec.FormView && fldSpec.FormView=="hidden") continue;
- var panelIdx=fldSpec.panelIdx || 0;
+ var panelIdx=fldSpec.ColGroupIdx || 0;
if (panelIdx==i) {
hasFields=true;
break;
}
if (!hasFields) return null;
this.panelHdr[i] = document.createElement('li');
- this.panelHdr[i].innerHTML=this.options.panels[i];
+ this.panelHdr[i].innerHTML=this.options.ColGroups[i];
this.panelHdrs.appendChild(this.panelHdr[i]);
this.panelContent[i] = document.createElement('div');
this.panelContents.appendChild(this.panelContent[i]);
this.panelCnt=0;
this.panelHdr=[];
this.panelContent=[];
- if (this.options.panels) {
+ if (this.options.ColGroups) {
this.panelGroup = document.createElement('div');
this.panelGroup.className='tabPanelGroup';
this.panelHdrs = document.createElement('ul');
this.panelActualIdx=[];
parentDiv.appendChild(this.panelGroup);
if (this.grid.direction=='rtl') {
- for (i=this.options.panels.length-1; i>=0; i--) {
+ for (i=this.options.ColGroups.length-1; i>=0; i--) {
tables[i]=this.createPanel(i);
}
} else {
- for (i=0; i<this.options.panels.length; i++) {
+ for (i=0; i<this.options.ColGroups.length; i++) {
tables[i]=this.createPanel(i);
}
}
for (i=0; i<this.grid.columns.length; i++) {
fldSpec=this.grid.columns[i].format;
if (!fldSpec) continue;
- panelIdx=fldSpec.panelIdx || 0;
+ panelIdx=fldSpec.ColGroupIdx || 0;
if (tables[panelIdx]) this.appendFormField(this.grid.columns[i],tables[panelIdx]);
if (typeof fldSpec.pattern=='string') {
switch (fldSpec.pattern) {
if (!fmt.Help) fmt.Help=fmt.dateFmt;
if (typeof fmt.min=='string') fmt.min=Rico.setISO8601(fmt.min) || new Date(fmt.min);
if (typeof fmt.max=='string') fmt.max=Rico.setISO8601(fmt.max) || new Date(fmt.max);
- if (this.hasWF2) {
+ fmt.Length=Math.max(fmt.dateFmt.length,10);
+ if (Rico.inputtypes.date) {
+ // use the WebForms calendar
field=Rico.createFormField(entry,'input','date',name,name);
field.required=fmt.required;
if (fmt.min) field.min=Rico.toISO8601String(fmt.min,3);
if (fmt.max) field.max=Rico.toISO8601String(fmt.max,3);
field.required=fmt.required;
- fmt.SelectCtl=null; // use the WebForms calendar instead of the Rico calendar
+ fmt.SelectCtl=null; // no need for Rico calendar control
} else {
field=Rico.createFormField(entry,'input','text',name,name);
}
case 'I':
if (!fmt.isNullable) fmt.required=true;
if (!fmt.pattern) fmt.pattern='int-signed';
- if (this.hasWF2) {
+ if (Rico.inputtypes.number) {
field=Rico.createFormField(entry,'input','number',name,name);
field.required=fmt.required;
field.min=fmt.min;
break;
}
if (field && fmt.SelectCtl) {
- Rico.EditControls.applyTo(column,field);
+ Rico.EditControls.applyTo(column,field,fmt.EntryType=='D');
}
var hdrSuffix='';
hdr.className='ricoEditLabel';
this.requestCount++;
var options={}, self=this;
Rico.extend(options, this.grid.buffer.ajaxOptions);
- options.parameters = {id: this.grid.tableId, offset: '0', page_size: '-1', edit: column.index};
- options.parameters[this.grid.actionId]="query";
+ options.parameters = this.grid.buffer.formQueryHashXML(0,-1);
+ options.parameters.edit = column.index;
options.onComplete = function(request) { self.selectValuesUpdate(elem,request); };
new Rico.ajaxRequest(this.grid.buffer.dataSource, options);
Rico.log("selectValuesRequest: "+fldSpec.FieldName);
elems[i].checked=o[elems[i].value]==1;
break;
case 'INPUT':
- if (fldSpec.EntryType=='D' && fldvalue!=fldSpec.ColData) {
+ if (fldSpec.EntryType=='D') {
// remove time data if it exists
a=fldvalue.split(/\s|T/);
fldvalue=a[0];
if (this.isTextInput(e)) {
- var d=Rico.setISO8601(fldvalue);
+ var d=fldvalue.toLowerCase() == 'today' ? new Date() : Rico.setISO8601(fldvalue);
if (d) fldvalue=Rico.formatDate(d,fldSpec.dateFmt);
}
}
processResponse: function(xhr) {
var responseText,success=true;
- Rico.log('Processing response from form submittal');
+ Rico.log('Processing response from form submittal: '+typeof(xhr));
this.responseDiv.innerHTML=xhr.responseText;
var respNodes=Rico.select('.ricoFormResponse',this.responseDiv);
if (respNodes) {
// generate a translated response
+ Rico.log('Found ricoFormResponse');
var phraseId=Rico.trim(respNodes[0].className).split(/\s+/)[1];
responseText=Rico.getPhraseById(phraseId,this.options.RecordName);
} else {
// present the response as sent from the server (untranslated)
+ Rico.log('Processing response text');
var ch=this.responseDiv.childNodes;
for (var i=ch.length-1; i>=0; i--) {
if (ch[i].nodeType==1 && ch[i].nodeName!='P' && ch[i].nodeName!='DIV' && ch[i].nodeName!='BR')
if (c.format) {
this.setField(i,c.format.ColData);
if (c.format.SelectCtl) {
- Rico.EditControls.resetValue(c);
+ if (c.format.EntryType != 'D') Rico.EditControls.resetValue(c);
Rico.EditControls.displayClrImg(c, !c.format.UpdateOnly);
}
}
desc=Rico.getPhraseById("thisRecord",this.options.RecordName);
break;
case -2 : // Use key/column header to identify the row
+ desc='';
for (var k=0; k<this.keys.length; k++) {
var i=this.keys[k].colidx;
var fmt=this.grid.columns[i].format;
if (fmt.EntryType.length>1 && fmt.EntryType.charAt(1)=='L') i++;
- var value=Rico.stripTags(this.grid.cell(rowIdx,i).innerHTML).replace(/ /g,' ');
+ var value=Rico.trim(Rico.stripTags(this.grid.cell(this.rowIdx,i).innerHTML).replace(/ /g,' '));
if (desc) desc+=', ';
- desc+=this.grid.columns[i].displayName+" "+value;
+ desc+=this.grid.columns[i].displayName + ' \"' + value + '\"';
}
break;
default :
validationMsg: function(elem,colnum,phraseId) {
var col=this.grid.columns[colnum];
- if (this.formPanels) this.formPanels.select(this.panelActualIdx[col.format.panelIdx]);
+ if (this.formPanels) this.formPanels.select(this.panelActualIdx[col.format.ColGroupIdx]);
var label=Rico.stripTags(col.formLabel.innerHTML).replace(/ /g,' ');
var msg=Rico.getPhraseById(phraseId," \"" + label + "\"");
Rico.log(' Validation error: '+msg);
// apply a century to 2-digit years
yy+=curyr - (curyr % 100);
}
- d.setFullYear(yy,mm,dd);
- return d;
+ return new Date(yy,mm,dd,0,0,0); // ensure time is midnight
},
TESubmit: function(e) {
this.zIndex=Math.max(this.zIndex,z+10);
},
- atLoad: function() {
- for (var id in this.widgetList) {
- var widget=this.widgetList[id].widget;
- if (widget.atLoad && !widget.atLoadComplete) {
- Rico.log("Rico.EditControls.atLoad: "+id);
- widget.atLoad();
- widget.atLoadComplete=true;
- }
- }
- },
-
- applyTo: function(column,inputCtl) {
+ applyTo: function(column,inputCtl,showInput) {
var wInfo=this.widgetList[column.format.SelectCtl];
if (!wInfo) return;
Rico.log('Rico.EditControls.applyTo: '+column.displayName+' : '+column.format.SelectCtl);
Rico.eventBind(newimg,"click", Rico.eventHandle(this,'processClick'));
inputCtl.parentNode.appendChild(descSpan);
inputCtl.parentNode.appendChild(newimg);
- inputCtl.style.display='none'; // comment out this line for debugging
+ if (showInput) {
+ descSpan.style.display='none';
+ } else {
+ inputCtl.style.display='none'; // comment out this line for debugging
+ }
var clr;
if (column.format.isNullable) {
clr=Rico.clearButton(Rico.eventHandle(this,'processClear'));