Changeset 3913


Ignore:
Timestamp:
Nov 6, 2007, 10:42:09 AM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #778: Add expression to formula

Location:
trunk/www
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/common/expression_builder.jsp

    r3675 r3913  
    5757  String form = request.getParameter("form");
    5858  String textarea = request.getParameter("textarea");
     59  String callback = request.getParameter("callback");
    5960  Formula.Type formulaType = Formula.Type.valueOf(request.getParameter("formulatype"));
    6061  RawDataType rawDataType = RawDataTypes.getRawDataType(request.getParameter("rawdatatype"));
     
    9798    function setExpressionAndClose()
    9899    {
    99       var textElement = window.opener.document.forms['<%=form%>'].elements['<%=textarea%>'];
    100100      var value = document.forms['expression'].expression.value;
    101       if (textElement.type == 'text') value = value.replace(/\n/g, '');
    102       textElement.value = value;
     101      <%
     102      if (callback != null)
     103      {
     104        StringBuilder sb = new StringBuilder();
     105        sb.append("window.opener.");
     106        sb.append(callback).append("(");
     107        if (form != null) sb.append("'").append(form).append("',");
     108        if (textarea != null) sb.append("'").append(textarea).append("',");
     109        sb.append("value)");
     110        %>
     111        <%=sb.toString()%>
     112        <%
     113      }
     114      else
     115      {
     116        %>
     117        var textElement = window.opener.document.forms['<%=form%>'].elements['<%=textarea%>'];
     118        if (textElement.type == 'text') value = value.replace(/\n/g, '');
     119        textElement.value = value;
     120        <%
     121      }
     122      %>
    103123      window.close();
    104124    }
  • trunk/www/include/scripts/main.js

    r3890 r3913  
    114114  }
    115115 
    116   this.expressionBuilder = function(ID, title, form, textarea, formulaType, rawDataType, channels, restrictions, bioAssaySetId)
    117   {
    118     var url = getRoot()+'common/expression_builder.jsp?ID='+ID+'&title='+title+'&form='+form+'&textarea='+textarea;
     116  this.expressionBuilder = function(ID, title, form, textarea, formulaType, rawDataType, channels, restrictions, bioAssaySetId, callback)
     117  {
     118    var url = getRoot()+'common/expression_builder.jsp?ID='+ID+'&title='+title;
     119    if (form) url += '&form='+form;
     120    if (textarea) url += '&textarea='+textarea;
     121    if (callback) url += '&callback='+callback;
    119122    url += '&formulatype='+formulaType;
    120123    url += '&rawdatatype='+rawDataType;
  • trunk/www/views/formulas/edit_formula.jsp

    r3679 r3913  
    302302      var channels = frm.channels.value;
    303303      var restrictions = formulaType == '<%=Formula.Type.COLUMN_RESTRICTION.name()%>';
    304       Main.expressionBuilder('<%=ID%>', 'Expression', 'formula', 'expression', formulaType, rdt, channels, restrictions);
     304      Main.expressionBuilder('<%=ID%>', 'Expression', 'formula', 'expression', formulaType, rdt, channels, restrictions, null, 'setExpressionFromBuilder');
     305    }
     306 
     307    function setExpressionFromBuilder(form, textarea, value)
     308    {
     309      var frm = document.forms['formula'];
     310      frm[textarea].value = value;
     311      if (frm.expressions.length == 0)
     312      {
     313        addOnClick();
     314      }
     315      else
     316      {
     317        expressionOnBlur();
     318      }
    305319    }
    306320 
Note: See TracChangeset for help on using the changeset viewer.