Changeset 8132
- Timestamp:
- Mar 24, 2023, 1:31:56 PM (2 months ago)
- Location:
- branches/3.19-stable/www
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.19-stable/www/common/plugin/parse_file.js
r7663 r8132 30 30 var columnHeaders; 31 31 var fuzzyMatches; 32 var currentMappingName; 32 33 33 34 /** … … 70 71 Events.addEventHandler(element, 'click', parse.clearColumnMapping); 71 72 } 72 else if (autoInit == 'column-mapping-preset') 73 { 74 Events.addEventHandler(element, 'change', parse.setPresetColumnMapping); 73 else if (autoInit == 'column-mapping-preset-menu') 74 { 75 Buttons.addClickHandler(element, parse.showColumnMappingPresets); 76 } 77 else if (autoInit == 'preset-column-mapping') 78 { 79 Events.addEventHandler(element, 'click', parse.setPresetColumnMapping); 75 80 } 76 81 else if (autoInit == 'column-mapping') … … 173 178 } 174 179 180 parse.showColumnMappingPresets = function(event) 181 { 182 currentMappingName = Data.get(event.currentTarget, 'mapping'); 183 var frm = document.forms['mappings']; 184 frm['mapping.'+currentMappingName+'.expression'].focus(); 185 186 var offsetLeft = event.clientX; 187 var offsetTop = event.clientY; 188 var offsetBottom = null; 189 // Open the menu at the mouse position 190 Menu.showTopMenu('predefinedColumnMappings', offsetLeft, offsetTop); 191 event.stopPropagation(); 192 193 // We may have to adjust depending on size of window 194 var winPos = App.getWindowPosition(); 195 var pcm = Doc.element('predefinedColumnMappings'); 196 pcm.style.bottom = 'auto'; // To ensure that the height is auto-calculated 197 198 // If the right side overflows we move the menu to the left 199 if (offsetLeft+pcm.offsetWidth+10 > winPos.width) 200 { 201 offsetLeft = winPos.width-pcm.offsetWidth-10; 202 } 203 // If the bottom side overflows we move up... 204 if (offsetTop+pcm.offsetHeight+10 > winPos.height) 205 { 206 offsetTop = winPos.height-pcm.offsetHeight-10; 207 // ... but then we may overflow the top so we need to 208 // limit the height 209 if (offsetTop < 5) 210 { 211 offsetTop = 5; 212 offsetBottom = 5; 213 offsetLeft -= 10; // make room for the scrollbar 214 } 215 } 216 pcm.style.left = (offsetLeft)+'px'; 217 pcm.style.top = (offsetTop)+'px'; 218 if (offsetBottom) pcm.style.bottom = (offsetBottom)+'px'; 219 } 220 175 221 parse.setPresetColumnMapping = function(event) 176 222 { 177 223 var target = event.currentTarget; 178 var mappingName = Data.get(target, 'mapping'); 179 180 var columnIndex = target.value; 181 target.selectedIndex = 0; 224 var columnIndex = Data.int(target, 'index'); 182 225 var expression = parse.getMappingExpressionForHeader(columnIndex); 183 184 parse.setColumnMapping(mappingName, expression, true); 226 parse.setColumnMapping(currentMappingName, expression, true); 185 227 } 186 228 -
branches/3.19-stable/www/common/plugin/parse_file.jsp
r7975 r8132 33 33 import="net.sf.basedb.core.Path" 34 34 import="net.sf.basedb.core.Location" 35 import="net.sf.basedb.core.StringUtil" 35 36 import="net.sf.basedb.core.PluginConfigurationRequest" 36 37 import="net.sf.basedb.core.plugin.Plugin" … … 78 79 FlatFileParser parser = null; 79 80 FlatFileParser.LineType lastLine = null; 81 FlatFileParser.Data firstDataLine = null; 80 82 Pattern splitter = null; 81 83 boolean dataIsFound = false; … … 231 233 { 232 234 color: #0000D0; 235 } 236 237 #predefinedColumnMappings 238 { 239 overflow-x: hidden; 240 overflow-y: auto; 241 } 242 243 .file-column 244 { 245 display: grid; 246 grid-template-columns: 1fr 1fr; 247 width: 32em; 248 padding: 0 !important; 249 } 250 251 .file-column > div 252 { 253 overflow: hidden; 254 padding: 3px 4px; 255 } 256 257 .file-column > div.example 258 { 259 background-color: #F8F8F8; 260 border-left-width: 1px; 261 border-left-style: dotted; 262 font-style: italic; 263 } 264 265 .interactable.file-column:hover > div:first-child 266 { 267 padding: 1px 4px 1px 2px; 268 } 269 .interactable.file-column:hover > div.example 270 { 271 padding: 1px 2px 1px 4px; 272 } 273 274 .index-only .file-column 275 { 276 width: 20em; 277 grid-template-columns: 5em 1fr; 278 } 279 280 .index-only .interactable.file-column:hover 281 { 282 grid-template-columns: calc(5em - 2px) 1fr; 233 283 } 234 284 </style> … … 360 410 if (currentLine < maxLines) 361 411 { 362 if (lastLine == FlatFileParser.LineType.DATA) parser.nextData(); 412 if (lastLine == FlatFileParser.LineType.DATA) 413 { 414 firstDataLine = parser.nextData(); 415 } 363 416 while (currentLine < maxLines && parser.hasMoreData()) 364 417 { 365 418 FlatFileParser.Data data = parser.nextData(); 419 if (firstDataLine == null) firstDataLine = data; 366 420 linePatterns.add(Pattern.quote(data.line())); 367 421 if (parser.getNumSkippedLines() > 0) … … 439 493 > 440 494 <% 441 StringBuilder sb = new StringBuilder();442 495 List<String> headers = parser.getColumnHeaders(); 496 //headers = null; 443 497 int index = 0; 444 if (headers != null) 445 { 446 for (String header : headers) 498 int maxDataColumns = headers != null ? headers.size() : firstDataLine.columns(); 499 %> 500 <div id="predefinedColumnMappings" class="menu vertical bg-filled-100 <%=headers==null?"index-only":"" %>" style="display: none;"> 501 <div class="menuitem file-column" style="font-weight: bold;"> 502 <div>Column</div> 503 <div class="example">Example</div> 504 </div> 505 <% 506 while (index < maxDataColumns) 447 507 { 448 sb.append("<option value=\"" + index + "\">" + HTML.encodeTags(header)); 508 String headerText = headers != null ? HTML.encodeTags(headers.get(index)) : ""; 509 String exampleText = HTML.encodeTags(firstDataLine.getString(index)); 510 %> 511 <div class="menuitem interactable file-column auto-init" 512 data-auto-init="preset-column-mapping" data-index="<%=index%>" 513 title="<%=headerText%> – <%=exampleText%>" 514 > 515 <div><%=Integer.toString(index+1)%>: <%=headerText%></div> 516 <div class="example"><%=exampleText%></div> 517 </div> 518 <% 449 519 index++; 450 520 } 451 } 452 else 453 { 454 int maxDataColumns = Values.getInt(request.getParameter("maxDataColumns"), -1); 455 while (index < maxDataColumns) 456 { 457 sb.append("<option value=\"" + index + "\">" + index); 458 index++; 459 } 460 } 461 String mappings = sb.toString(); 521 %> 522 </div> 523 <% 462 524 String[] mappingParameters = request.getParameter("mappingParameterNames").split(","); 463 525 if (headers != null) … … 568 630 569 631 <tbl:cell column="columns"> 570 <select name="list.<%=name%>" class="auto-init" 571 data-auto-init="column-mapping-preset" data-mapping="<%=name%>"> 572 <option value=""> 573 <%=mappings%> 574 </select> 632 <base:button 633 title="- select -" image="mini_scroll_down.png" 634 subclass="icon-to-right auto-init" style="font-style: italic;" 635 data-auto-init="column-mapping-preset-menu" 636 data-mapping="<%=name%>" 637 /> 575 638 </tbl:cell> 576 639 -
branches/3.19-stable/www/include/styles/main.css
r8065 r8132 283 283 { 284 284 padding-right: 2px; 285 } 286 287 .basicbutton.icon-to-right > img 288 { 289 float: right; 290 padding-left: 2px; 285 291 } 286 292
Note: See TracChangeset
for help on using the changeset viewer.