Changeset 5763


Ignore:
Timestamp:
Sep 27, 2011, 9:17:56 AM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #1604: Support for multiple files of the same type in a FileSet?

It was not possible to create platform variants due to compilation errors in the JSP. The edit dialog was missing options for setting "allow multiple files" of a a file type.

Location:
trunk/www/admin/platforms/variants
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/admin/platforms/variants/edit_variant.jsp

    r5574 r5763  
    189189          DataFileType dft = ft.getDataFileType();
    190190          boolean required = ft.isRequired();
     191          boolean multiple = ft.getAllowMultiple();
     192          int value = 0;
     193          if (required) value += 1;
     194          if (multiple) value += 2;
    191195          %>
    192           Link.addNewItem(fileTypes, new Item('F', <%=dft.getId()%>, '<%=HTML.javaScriptEncode(dft.getName())%> <%=required ? "[×]" : "[-]"%>', '<%=required ? "1" : "0"%>'));
     196          Link.addNewItem(fileTypes, new Item('F', <%=dft.getId()%>, '<%=HTML.javaScriptEncode(dft.getName())%> <%=required ? "[×]" : "[-]"%>', <%=value%>));
    193197          <%
    194198        }
     
    206210      var frm = document.forms['variant'];
    207211      var required = frm.required.checked;
    208       if (!item) item = new Item('F', fileTypeId, name+(required ? '[×]' : '[-]'), required ? '1' : '0', '');
     212      var multiple = frm.multiple.checked;
     213      var newValue = 0;
     214      if (required) newValue += 1;
     215      if (multiple) newValue += 2;
     216      if (!item) item = new Item('F', fileTypeId, name+(required ? '[×]' : '[-]'), newValue, '');
    209217      Link.addItem(frm.fileTypes, item);
    210218    }
     
    219227      if (item && item.id)
    220228      {
    221         frm.required.checked = item.value != '0';
     229        frm.required.checked = (item.value & 1) > 0;
     230        frm.multiple.checked = (item.value & 2) > 0;
    222231      }
    223232      else
    224233      {
    225234        frm.required.checked = false;
     235        frm.multiple.checked = false;
    226236      }
    227237    }
     
    230240      var frm = document.forms['variant'];
    231241      var required = frm.required.checked;
     242      var multiple = frm.multiple.checked;
     243      var newValue = 0;
     244      if (required) newValue += 1;
     245      if (multiple) newValue += 2;
    232246      for (var i = 0; i < frm.fileTypes.length; i++)  // >
    233247      {
     
    235249        if (option.selected && option.item.id)
    236250        {
    237           option.item.value = required ? '1' : '0';
     251          option.item.value = newValue;
    238252          var text = option.text.replace(/\[.*\]/, '['+(required ? '×' : '-') +']');
    239253          option.text = text;
    240254        }
    241255      }
     256    }
     257    function multipleOnClick()
     258    {
     259      requiredOnClick();
    242260    }
    243261    </script>
     
    347365        <select name="fileTypes" size="10" multiple style="width: 20em;"
    348366          onchange="fileTypesOnChange()">
    349         </select>&nbsp;<br>
    350         × = Required
    351         <input type="checkbox" name="required" value="1" onchange="requiredOnClick()">
     367        </select>
    352368        <input type="hidden" name="modifiedFileTypes" value="">
    353369        <input type="hidden" name="removedFileTypes" value="">
     
    367383        /></td></tr>
    368384        </table>
     385        <input type="checkbox" id="required" name="required" value="1" onchange="requiredOnClick()">
     386          <label for="required">Required</label><br>
     387        <input type="checkbox" id="multiple" name="multiple" value="1" onchange="multipleOnClick()">
     388          <label for="multiple">Allow multiple files</label>
    369389      </td>
    370390      </tr>     
  • trunk/www/admin/platforms/variants/index.jsp

    r5590 r5763  
    3030  import="net.sf.basedb.core.Platform"
    3131  import="net.sf.basedb.core.PlatformVariant"
     32  import="net.sf.basedb.core.PlatformFileType"
    3233  import="net.sf.basedb.core.DataFileType"
    3334  import="net.sf.basedb.core.RawDataType"
     
    173174        {
    174175          DataFileType dft = DataFileType.getById(dc, ftId);
    175           boolean required = Values.getBoolean(request.getParameter("F"+ftId));
    176           platform.addFileType(dft, required, variant);
     176          int options = Values.getInt(request.getParameter("F"+ftId));
     177          PlatformFileType pft = platform.getFileType(dft, variant, true);
     178          pft.setRequired((options & 1) > 0);
     179          pft.setAllowMultiple((options & 2) > 0);
    177180        }
    178181      }
  • trunk/www/admin/platforms/variants/view_variant.jsp

    r5509 r5763  
    294294          />
    295295          <tbl:columndef
     296            id="multiple"
     297            title="Multiple files"
     298          />
     299          <tbl:columndef
    296300            id="genericType"
    297301            title="Generic type"
     
    323327                  /><%=Base.getLinkedName(ID, dft, false, true)%></tbl:cell>
    324328                <tbl:cell column="required"><%=fileType.isRequired() ? "yes" : "no"%></tbl:cell>
     329                <tbl:cell column="multiple"><%=fileType.getAllowMultiple() ? "yes" : "no"%></tbl:cell>
    325330                <tbl:cell column="genericType"><base:propertyvalue item="<%=dft%>" property="genericType" /></tbl:cell>
    326331                <tbl:cell column="description"><%=HTML.niceFormat(dft.getDescription())%></tbl:cell>
Note: See TracChangeset for help on using the changeset viewer.