Changeset 7663


Ignore:
Timestamp:
Mar 20, 2019, 9:25:41 AM (3 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #2166: Add a button that remove all column mappings to the "Test with file" function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/common/plugin/parse_file.js

    r7662 r7663  
    4242    Buttons.addClickHandler('btnFuzzyMatches', parse.setFuzzyMatches);
    4343    Events.addEventHandler('similarityScore', 'keypress', Events.numberOnly);
     44   
     45    var mappingHeader = Doc.element('col-mappings.expression');
     46    if (mappingHeader != null)
     47    {
     48      var html = mappingHeader.innerHTML;
     49      html += '<img class="link" id="clearAllMappings" src="../../images/clear_down.png" title="Clear all mappings" style="margin-left: 2em;">';
     50      mappingHeader.innerHTML = html;
     51      Buttons.addClickHandler('clearAllMappings', parse.clearAllColumnMappings);
     52    }
    4453  }
    4554
     
    100109  {
    101110    var frm = document.forms['mappings'];
    102     var field = 'mapping.'+mappingName+'.expression';
     111    var extendName = (mappingName.indexOf('mapping.') == -1);
     112    var field = extendName ? 'mapping.'+mappingName+'.expression' : mappingName;
    103113    if (overwrite || frm[field].value == '')
    104114    {
     
    143153  }
    144154 
     155  parse.clearAllColumnMappings = function(event)
     156  {
     157    var frm = document.forms['mappings'];
     158    for (var i = 0; i < frm.elements.length; i++)
     159    {
     160      var e = frm.elements[i];
     161      if (e.name.indexOf('mapping.') == 0)
     162      {
     163        parse.setColumnMapping(e.name, '', true);
     164      }
     165    }
     166  }
     167
    145168  parse.clearColumnMapping = function(event)
    146169  {
Note: See TracChangeset for help on using the changeset viewer.