Special XML conversion code for Firefox >= 20.0
[infodrom/rico3] / minsrc / ricoLiveGridForms.js
index 1721038..5ce18dd 100644 (file)
@@ -1,6 +1,6 @@
 /*
- *  (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
@@ -49,6 +49,8 @@ Rico.TableEdit.prototype = {
     this.buttonHover=new Rico.HoverSet();
     this.dateRegExp=/^\s*(\w+)(\W)(\w+)(\W)(\w+)/i;
     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'));
@@ -329,13 +331,15 @@ Rico.TableEdit.prototype = {
         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);
+        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);
         }
@@ -372,7 +376,7 @@ Rico.TableEdit.prototype = {
         break;
     }
     if (field && fmt.SelectCtl) {
-      Rico.EditControls.applyTo(column,field);
+      Rico.EditControls.applyTo(column,field,fmt.EntryType=='D');
     }
     var hdrSuffix='';
     hdr.className='ricoEditLabel';
@@ -440,8 +444,8 @@ Rico.TableEdit.prototype = {
       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);
@@ -564,12 +568,12 @@ Rico.TableEdit.prototype = {
           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);
           }
         }
@@ -754,7 +758,7 @@ Rico.TableEdit.prototype = {
       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);
         }
       }
@@ -840,13 +844,14 @@ Rico.TableEdit.prototype = {
         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(/&nbsp;/g,' ');
+          var value=Rico.trim(Rico.stripTags(this.grid.cell(this.rowIdx,i).innerHTML).replace(/&nbsp;/g,' '));
           if (desc) desc+=', ';
-          desc+=this.grid.columns[i].displayName+" "+value;
+          desc+=this.grid.columns[i].displayName + ' \"' + value + '\"';
         }
         break;
       default   :
@@ -910,8 +915,7 @@ Rico.TableEdit.prototype = {
       // 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) {
@@ -1028,7 +1032,7 @@ Rico.EditControls = {
     this.zIndex=Math.max(this.zIndex,z+10);
   },
 
-  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);
@@ -1049,7 +1053,11 @@ Rico.EditControls = {
     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'));