Changeset 200

Show
Ignore:
Timestamp:
15-02-10 21:38:24 (4 years ago)
Author:
tabma
Message:

- properties template

Location:
trunk/grails-app
Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy

    r182 r200  
    3838    def upload = { 
    3939        def downloadedfile = request.getFile('importfile'); 
    40         def tempfile = new File(System.getProperty('java.io.tmpdir') + File.pathSeparator + System.currentTimeMillis() + ".nmcdsp") 
     40        def tempfile = new File(System.getProperty('java.io.tmpdir') + File.separatorChar + System.currentTimeMillis() + ".nmcdsp") 
    4141        downloadedfile.transferTo(tempfile) 
    4242         
     
    5050    } 
    5151 
    52     def accept = { 
    53          
     52    def savepreview = {  
     53        def entities  = request.getParameterValues("entity") 
     54 
     55        render(view:"step2", model:[entities:entities]) 
    5456    } 
    5557} 
  • trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy

    r173 r200  
    3737    } 
    3838 
    39     def createSelect(int selected, String name, ArrayList options) { 
     39    def entity = { attrs -> 
     40        out << entities[attrs['index']].name 
     41    } 
     42 
     43    /** 
     44     * @param entities array of entity:columnindex values 
     45     */ 
     46    def properties = { attrs -> 
     47        def ent = [] 
     48 
     49        attrs['entities'].each { e -> 
     50            def temp = e.split(":")          
     51            def entity = [type:temp[0],columnindex:temp[1]] 
     52            ent.add(entity) 
     53        } 
     54 
     55        out << render (template:"common/properties", model:[entities:ent]) 
     56    } 
     57 
     58    def createSelect(int selected, String name, ArrayList options, String customvalue) { 
    4059        def res = "<select style=\"font-size:10px\" name=\"${name}\">" 
    4160 
    4261        options.each { e -> 
    43             res += "<option value=\"${e.value}\"" 
     62            res += "<option value=\"${e.value}:${customvalue}\"" 
    4463            res += (e.value == selected) ? " selected" : "" 
    4564            res += ">${e.name}</option>" 
     
    5069    } 
    5170 
     71     
     72 
    5273    /** 
    5374     * @param selected selected entity 
     
    5677    def entitySelect = { attrs ->        
    5778        def selected = (attrs['selected']==null) ? -1 : attrs['selected'] 
    58         out << createSelect(selected, attrs['name'], entities) 
     79        def customvalue = (attrs['customvalue']==null) ? "" : attrs['customvalue'] 
     80        out << createSelect(selected, attrs['name'], entities, customvalue) 
    5981    } 
    6082 
     
    6789    def celltypeSelect = { attrs -> 
    6890        def selected = (attrs['selected']==null) ? -1 : attrs['selected'] 
    69         out << createSelect(selected, attrs['name'], celltypes) 
     91        def customvalue = (attrs['customvalue']==null) ? "" : attrs['customvalue'] 
     92        out << createSelect(selected, attrs['name'], celltypes, customvalue) 
    7093    } 
    7194} 
  • trunk/grails-app/views/importer/common/_preview.gsp

    r173 r200  
    1313         */ 
    1414%> 
    15 <g:form name="previewform" action="accept"> 
     15<g:form name="previewform" action="savepreview"> 
    1616    <table> 
    1717        <tr> 
     
    2828            <g:each var="column" in="${header}"> 
    2929                <td class="header"> 
    30                     <importer:celltypeSelect selected="${column.celltype}" name="celltype[${column.columnindex}]"/> 
     30                    <importer:celltypeSelect selected="${column.celltype}" name="celltype" customvalue="${column.columnindex.toString()}"/> 
    3131                </td> 
    3232            </g:each> 
     
    3737            <g:each var="column" in="${header}"> 
    3838                <td class="header"> 
    39                     <importer:entitySelect name="entity[${column.columnindex}]"/> 
     39                    <importer:entitySelect name="entity" customvalue="${column.columnindex.toString()}"/> 
    4040                </td> 
    4141            </g:each>