1 | <!-- |
---|
2 | To change this template, choose Tools | Templates |
---|
3 | and open the template in the editor. |
---|
4 | --> |
---|
5 | |
---|
6 | <%@ page contentType="text/html;charset=UTF-8" %> |
---|
7 | |
---|
8 | <html> |
---|
9 | <head> |
---|
10 | <meta name="layout" content="main"/> |
---|
11 | <title>Importer wizard (simple)</title> |
---|
12 | <link rel="stylesheet" href="${resource(dir: 'css', file: 'importer.css')}"/> |
---|
13 | |
---|
14 | <g:if env="production"> |
---|
15 | <script type="text/javascript" src="${resource(dir: 'js', file: 'SelectAddMore.min.js')}"></script> |
---|
16 | </g:if><g:else> |
---|
17 | <script type="text/javascript" src="${resource(dir: 'js', file: 'SelectAddMore.js')}"></script> |
---|
18 | </g:else> |
---|
19 | |
---|
20 | <g:javascript> |
---|
21 | /** |
---|
22 | * Update one select based on another select |
---|
23 | * |
---|
24 | * @author |
---|
25 | * @see http://www.grails.org/Tag+-+remoteFunction |
---|
26 | * @param string select (form) name |
---|
27 | * @param string JSON data |
---|
28 | * @param boolean keep the first option |
---|
29 | * @param int selected option |
---|
30 | * @param string if null, show this as option instead |
---|
31 | * @void |
---|
32 | */ |
---|
33 | function updateSelect(name,data,keepFirstOption,selected,presentNullAsThis) { |
---|
34 | var rselect = $('#'+name).get(0) |
---|
35 | var items = data |
---|
36 | |
---|
37 | // If a study has been selected, don't show the "Choose study" field, otherwise do |
---|
38 | if ($('#'+'entity').val() == 'study') |
---|
39 | $('#studyfield').hide(); |
---|
40 | else $('#studyfield').show(); |
---|
41 | |
---|
42 | // set the entity name for the data template chooser |
---|
43 | //alert ( "das" + $('select[name=template_id]').attr('entity') ) |
---|
44 | |
---|
45 | //$('select[name=template_id]').attr('entity', $('#'+'entity').val()); |
---|
46 | |
---|
47 | if (items) { |
---|
48 | |
---|
49 | // remove old options |
---|
50 | var start = (keepFirstOption) ? 0 : -1; |
---|
51 | var i = rselect.length |
---|
52 | |
---|
53 | while (i > start) { |
---|
54 | rselect.remove(i) |
---|
55 | i-- |
---|
56 | } |
---|
57 | |
---|
58 | // add new options |
---|
59 | $.each(items,function() { |
---|
60 | var i = rselect.options.length |
---|
61 | |
---|
62 | rselect.options[i] = new Option( |
---|
63 | (presentNullAsThis && this.name == null) ? presentNullAsThis : this.name, |
---|
64 | this.id |
---|
65 | ); |
---|
66 | if (this.id == selected) rselect.options[i].selected = true |
---|
67 | }); |
---|
68 | } |
---|
69 | |
---|
70 | // handle template selects |
---|
71 | new SelectAddMore().init({ |
---|
72 | rel : 'typetemplate', |
---|
73 | url : '/gscf/templateEditor', |
---|
74 | vars : 'thentity', // can be a comma separated list of variable names to pass on |
---|
75 | label : 'add / modify ...', |
---|
76 | style : 'modify', |
---|
77 | onClose : function(scope) { |
---|
78 | //refreshWebFlow(); |
---|
79 | } |
---|
80 | }); |
---|
81 | } |
---|
82 | |
---|
83 | $(document).ready(function() { |
---|
84 | |
---|
85 | $('#simplewizardform').submit(function() { |
---|
86 | if ($('#file').val() == "") { |
---|
87 | alert ("Please choose your Excel file to import."); |
---|
88 | return false |
---|
89 | } else |
---|
90 | if ($('#entity').val() == "") { |
---|
91 | $('#datatemplate').addClass("validationfail"); |
---|
92 | return false |
---|
93 | } else |
---|
94 | $('#simplewizardform').submit(); |
---|
95 | |
---|
96 | return false; |
---|
97 | }); |
---|
98 | }); |
---|
99 | |
---|
100 | </g:javascript> |
---|
101 | |
---|
102 | <g:if env="production"> |
---|
103 | <script type="text/javascript" src="${resource(dir: 'js', file: 'SelectAddMore.min.js')}"></script> |
---|
104 | </g:if><g:else> |
---|
105 | <script type="text/javascript" src="${resource(dir: 'js', file: 'SelectAddMore.js')}"></script> |
---|
106 | </g:else> |
---|
107 | |
---|
108 | </head> |
---|
109 | <body> |
---|
110 | <h1>Importer wizard</h1> |
---|
111 | <p>You can import your Excel data to the server by choosing a file from your local harddisk in the form below.</p> |
---|
112 | <form id="simplewizardform" controller="importer" method="post" action="upload_simple" enctype="multipart/form-data"> |
---|
113 | <table border="0"> |
---|
114 | <tr> |
---|
115 | <td width="100px"> |
---|
116 | Choose your Excel file to import: |
---|
117 | </td> |
---|
118 | <td width="100px"> |
---|
119 | <input id="file" type="file" name="importfile"/> |
---|
120 | </td> |
---|
121 | </tr> |
---|
122 | <tr> |
---|
123 | <td width="100px"> |
---|
124 | Use data from sheet: |
---|
125 | </td> |
---|
126 | <td width="100px"> |
---|
127 | <g:select name="sheetindex" from="${1..25}"/> |
---|
128 | </td> |
---|
129 | </tr> |
---|
130 | <tr> |
---|
131 | <td width="100px"> |
---|
132 | Columnheader starts at row: |
---|
133 | </td> |
---|
134 | <td width="100px"> |
---|
135 | <g:select name="headerrow" from="${1..10}"/> |
---|
136 | </td> |
---|
137 | </tr> |
---|
138 | <tr> |
---|
139 | <td width="100px"> |
---|
140 | Data starts at row: |
---|
141 | </td> |
---|
142 | <td width="100px"> |
---|
143 | <g:select name="datamatrix_start" from="${2..10}"/> |
---|
144 | </td> |
---|
145 | </tr> |
---|
146 | <tr id="studyfield"> |
---|
147 | <td> |
---|
148 | Choose your study: |
---|
149 | </td> |
---|
150 | <td> |
---|
151 | <g:select name="study.id" from="${studies}" optionKey="id"/> |
---|
152 | </td> |
---|
153 | </tr> |
---|
154 | <tr> |
---|
155 | <td> |
---|
156 | Choose type of data: |
---|
157 | </td> |
---|
158 | <td> |
---|
159 | <g:select |
---|
160 | name="entity" |
---|
161 | id="entity" |
---|
162 | from="${entities}" |
---|
163 | optionValue="${{it.value.name}}" |
---|
164 | optionKey="key" |
---|
165 | noSelection="['':'-Choose type of data-']" |
---|
166 | onChange="${remoteFunction( controller: 'importer', |
---|
167 | action:'ajaxGetTemplatesByEntity', |
---|
168 | params: '\'entity=\'+escape(this.value)', |
---|
169 | onSuccess:'updateSelect(\'template_id\',data,false,false,\'default\')')}" /> |
---|
170 | </td> |
---|
171 | </tr> |
---|
172 | <tr> |
---|
173 | <td> |
---|
174 | <div id="datatemplate">Choose type of data template:</div> |
---|
175 | </td> |
---|
176 | <td> |
---|
177 | <g:select rel="typetemplate" entity="hoi" name="template_id" optionKey="id" optionValue="name" from="[]" /> |
---|
178 | </td> |
---|
179 | </tr> |
---|
180 | <tr> |
---|
181 | <td colspan="2"> |
---|
182 | <input type="submit" value="Next"/> |
---|
183 | </td> |
---|
184 | </tr> |
---|
185 | </table> |
---|
186 | </form> |
---|
187 | |
---|
188 | </body> |
---|
189 | </html> |
---|