Parcourir la source

Fixes gh-806 Optional default values not present in the environment are marked in different color

Optional default values not present in the environment are marked in red. A new context menu
item has been added for these items to write them to environment. Note that the environment
still needs to be saved after this action for it to be saved to the environment file. The tooltip
has been updated to reflect that this value is not present in the environment.


Signed-off-by: Sridhar Meda <sridhar.meda@lexisnexis.com>
Sridhar Meda il y a 13 ans
Parent
commit
9901090ccd

+ 9 - 0
esp/files/scripts/configmgr/common.js

@@ -342,3 +342,12 @@ function addUniqueToArray(arr, itm) {
     if (flag)
       arr[arr.length] = itm;
 }
+
+function isNotInEnv(notInEnvList, name)
+{
+  var tmp = ';@' + name + ';';
+  if (notInEnvList.indexOf(tmp) !== -1)
+    return true;
+  else
+    return false;
+}

+ 46 - 12
esp/files/scripts/configmgr/configmgr.js

@@ -68,8 +68,12 @@ var formatterDispatcher = function(elCell, oRecord, oColumn, oData) {
     default:
       YAHOO.widget.DataTable.formatText.call(this, elCell, oRecord, oColumn, oData);
       break;
-
   }
+
+  var notInEnv = oRecord.getData('_not_in_env');
+
+  if (notInEnv === 1)
+    YAHOO.util.Dom.addClass(elCell, 'not_in_env');
 };
 
 function createSubTable(rows, tabDivName, index, name) {
@@ -419,14 +423,18 @@ function createTable(rows, tabDivName, index, compName) {
       myDataTable.subscribe("cellMouseoverEvent", function(oArgs) {
         var target = oArgs.target;
         var record = this.getRecord(target);
-        var txt;
+        var txt = "";
+
+        if (record.getData('_not_in_env') === 1)
+          txt += "This default optional value is not present in the environment. Use context menu to write to environment.<br>";
+
         //firefox has option to control status bar msg writing that is off by default. 
         //need to doc this to let the user enable the setting.
         if (record.getData('_key')) {
           if (cS[record.getData('_key')].tip)
-            txt = cS[record.getData('_key')].tip;
+            txt += cS[record.getData('_key')].tip;
           else if (cS[record.getData('_key') + tabDivName].tip)
-            txt = cS[record.getData('_key') + tabDivName].tip;
+            txt += cS[record.getData('_key') + tabDivName].tip;
 
           if (cS[record.getData('_key')].defaultValue)
             txt += "<br>Default value = '" + cS[record.getData('_key')].defaultValue + "'";
@@ -440,7 +448,7 @@ function createTable(rows, tabDivName, index, compName) {
           if (tmp.length > 1)
             tmp1 = tmp[1].split("::");
           if (cS[cols.keys[target.cellIndex].key + tmp1[0]].tip)
-            txt = cS[cols.keys[target.cellIndex].key + tmp1[0]].tip;
+            txt += cS[cols.keys[target.cellIndex].key + tmp1[0]].tip;
 
           if (cS[cols.keys[target.cellIndex].key + tmp1[0]].defaultValue)
             txt += "<br>Default value = '" + cS[cols.keys[target.cellIndex].key + tmp1[0]].defaultValue + "'";
@@ -965,6 +973,10 @@ function handleConfigCellClickEvent(oArgs, caller, isComplex) {
             }
 
             callback(true, newValue);
+
+            if (record.getData("_not_in_env") === 1)
+              removeExtraClassFromCell(caller, record, column, "not_in_env");
+
             if (compName === "topology") {
               //refresh for topology to refresh the left hand side values
               top.document.navDT.clickCurrentSelOrName(top.document.navDT);
@@ -3054,7 +3066,8 @@ function onContextMenuBeforeShowRegular(p_sType, p_aArgs) {
                                 { text: "Add", onclick: { fn: onMenuItemClickGenericAddDelete} },
                                 { text: "Delete", onclick: { fn: onMenuItemClickGenericAddDelete} }
                                 ],
-      "ResetToDefault":         [ {text: "Reset to default", onclick: {fn: onMenuItemClickResetToDefault} }]
+      "ResetToDefault":         [ {text: "Reset to default", onclick: {fn: onMenuItemClickResetToDefault} }],
+      "WriteToEnvironment":     [ {text: "Write to environment", onclick: {fn: onMenuItemClickResetToDefault} }]
      };
   }
 
@@ -3099,21 +3112,25 @@ function onContextMenuBeforeShowRegular(p_sType, p_aArgs) {
     }
     this.clearContent();
     
-    this.addItems(aMenuItems);
+    if (aMenuItems)
+      this.addItems(aMenuItems);
         
     if (parentName === "RoxieFarmProcess" || parentName === "RoxieServerProcess" || parentName === "RoxieSlave")
       this.addItems(oContextMenuItems["Delete"], 2);
     else if (parentName === "GenericAddDelete" && recSet.getLength() === 0) {
       this.getItem(1).cfg.setProperty("disabled", true);
     }
-    
+
+    if( record && record.getData('_not_in_env') === 1 && record.getData(column.key + '_ctrlType') !== 0)
+      this.addItems(oContextMenuItems["WriteToEnvironment"]);
+
     if( record && record.getData(column.key + '_ctrlType') !== 0 ) {
         var defaultValue=dt.getDefault(oTarget, record);
         if( defaultValue !== '' && typeof(defaultValue) !== 'undefined' && defaultValue !== record.getData('value') )
            this.addItems(oContextMenuItems["ResetToDefault"]);
       }
-     
-      if (top.document.forms['treeForm'].isLocked.value === 'false') {
+
+    if (top.document.forms['treeForm'].isLocked.value === 'false') {
         var groups = this.getItemGroups();
         for (iGroup = 0; iGroup < groups.length; iGroup++) {
           if (typeof (groups[iGroup]) !== 'undefined')
@@ -3469,8 +3486,10 @@ function onMenuItemClickResetToDefault(p_sType, p_aArgs, p_oValue)
   var bldSet = top.document.navDT.getRecord(top.document.navDT.getSelectedRows()[0]).getData('BuildSet');
   var newValue = dt.getDefault(oTarget, record);
   var meta = record.getData(column.key + '_extra');
+  var menuItemName = this.cfg.getProperty("text");
+  var flag = (menuItemName === 'Write to environment');
   
-  if( newValue !== oldValue) {
+  if (flag || newValue !== oldValue) {
      var form = top.window.document.forms['treeForm'];
      top.document.startWait(document);
      var attrName = getAttrName(dt, column, record, false); // = record.getData('name');
@@ -3552,6 +3571,10 @@ function onMenuItemClickResetToDefault(p_sType, p_aArgs, p_oValue)
               }
 
               dt.updateCell(record, column, newValue);
+
+              if (flag)
+                removeExtraClassFromCell(dt, record, column, "not_in_env");
+
               if (compName === "topology") {
                 //refresh for topology to refresh the left hand side values
                 top.document.navDT.clickCurrentSelOrName(top.document.navDT);
@@ -3601,4 +3624,15 @@ function onMenuItemClickResetToDefault(p_sType, p_aArgs, p_oValue)
       },
       top.document.navDT.getFileName(true) + 'XmlArgs=' + xmlArgs);
   }
-}
+}
+
+function removeExtraClassFromCell(dt, record, column, classes)
+{
+  var Dom = YAHOO.util.Dom;
+  var elCell = dt.getTdEl({record:record, column:column});
+  var divEl = Dom.getChildren(elCell);
+  Dom.removeClass(divEl[0], classes);
+  var elPrevCell = dt.getPreviousTdEl(elCell);
+  divEl = Dom.getChildren(elPrevCell);
+  Dom.removeClass(divEl[0], classes);
+}

+ 21 - 0
esp/services/WsDeploy/WsDeployService.cpp

@@ -3018,7 +3018,18 @@ bool CWsDeployFileInfo::displaySettings(IEspContext &context, IEspDisplaySetting
           const char* attrName = iAttr->queryName();
 
           if (!pSrcTree->hasProp(attrName))
+          {
             pSrcTree->addProp(attrName, iAttr->queryValue());
+
+            const char* prop = "@_notInEnv";
+            StringBuffer sbVal;
+
+            if (pSrcTree->hasProp(prop))
+              sbVal.append(pSrcTree->queryProp(prop));
+
+            pSrcTree->setProp(prop, sbVal.append(";").append(attrName).append(";").str());
+
+          }
         }
 
           //Add subelements that occur only once
@@ -3038,7 +3049,17 @@ bool CWsDeployFileInfo::displaySettings(IEspContext &context, IEspDisplaySetting
               const char* attrName = iAttrElem->queryName();
 
               if (!pSrcElem->hasProp(attrName))
+              {
                 pSrcElem->addProp(attrName, iAttrElem->queryValue());
+
+                const char* prop = "@_notInEnv";
+                StringBuffer sbVal;
+
+                if (pSrcElem->hasProp(prop))
+                  sbVal.append(pSrcElem->queryProp(prop));
+
+                pSrcElem->setProp(prop, sbVal.append(";").append(attrName).append(";").str());
+              }
             }
 
             Owned<IPropertyTreeIterator> iterSubElems = pElem->getElements("*");

+ 5 - 0
esp/xslt/ui_configmgr.xslt

@@ -70,6 +70,8 @@
             <style type="text/css">
               /* custom styles for this example */
               .yui-skin-sam .yui-dt-liner { white-space:nowrap; }
+
+              .not_in_env  { color: #FF0000;}
             </style>
 
             <style type="text/css">
@@ -498,6 +500,7 @@
               <xsl:otherwise>
                 createRowArraysForComp('<xsl:value-of select="$Component"/>', rows);
                 var cN = '<xsl:value-of select="@name"/>';
+                var notInEnv = '<xsl:value-of select="@_notInEnv"/>';
                 var aS;
                 var tN;
                 <xsl:for-each select="@*">
@@ -525,6 +528,8 @@
                           i.value_onChange = aS.onChange;
                           i.value_onChangeMsg = aS.onChangeMsg;
                           i.params = "pcType=<xsl:value-of select="$Component"/>::pcName=" + cN;
+                          if (isNotInEnv(notInEnv, "<xsl:value-of select="name()"/>"))
+                            i._not_in_env = 1;
                           rows[tN][rows[tN].length] = i;
                         }
                       }