Changeset 6699


Ignore:
Timestamp:
Jan 30, 2015, 11:32:48 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

References #1912: Add more filter rows in list pages

Fixes a problem with using non-unique id for the 'Add filter row' icon when used on pages that has multiple lists. This caused the icon to not work or add rows to the incorrect list.

The add/remove icons are now based on class names instead which means we can target each icon within the table context it is defined in.

Location:
trunk/www
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/include/scripts/table.js

    r6697 r6699  
    107107   
    108108    // Add 'click' handler to the 'Add filter row' and 'Remove filter rows' icons
    109     Buttons.addClickHandler('table-add-filter-row', table.addFilterRowOnClick, attributes);
    110     var removeFilterRow = element.getElementsByClassName('table-remove-filter-row');
    111     for (var i = 0; i < removeFilterRow.length; i++)
    112     {
    113       Buttons.addClickHandler(removeFilterRow[i], table.removeFilterRowOnClick, attributes);
     109    var filterRowActions = element.getElementsByClassName('table-filter-row-action');
     110    for (var i = 0; i < filterRowActions.length; i++)
     111    {
     112      Buttons.addClickHandler(filterRowActions[i], table.filterRowActionOnClick, attributes);
    114113    }
    115114   
     
    288287 
    289288  /**
    290     Event handler for the 'Add filter row' icon that
    291     adds one more filter row to the table.
     289    Event handler for the 'Add filter row' and 'Remove filter row' icons
     290    that adds or remove filter rows to/from the table.
    292291    The element must have the table id stored in 'data-table-id'
    293     attribute.
    294   */
    295   table.addFilterRowOnClick = function(event)
     292    attribute. If 'remove-row' is set, a the given row is removed,
     293    otherwise a new row is added.
     294  */
     295  table.filterRowActionOnClick = function(event)
    296296  {
    297297    var target = event.currentTarget;
    298298    var tableId = Data.get(target, 'table-id');
    299     table.addFilterRow(tableId);
    300   }
    301  
    302   /**
    303     Event handler for a 'Remove filter row' icon that
    304     removes a filter row from the table. The element must
    305     have the table id stored in 'data-table-id' attribute
    306     and the filter index in 'data-filter-index' attribute.
    307     First row is 0.
    308   */
    309   table.removeFilterRowOnClick = function(event)
    310   {
    311     var target = event.currentTarget;
    312     var tableId = Data.get(target, 'table-id');
    313     var filterIndex = Data.get(target, 'filter-index');
    314     table.removeFilterRow(tableId, filterIndex);
     299    var removeRow = Data.get(target, 'remove-row');
     300    if (removeRow != null)
     301    {
     302      table.removeFilterRow(tableId, removeRow);
     303    }
     304    else
     305    {
     306      table.addFilterRow(tableId);
     307    }
    315308  }
    316309 
  • trunk/www/views/derivedbioassays/list_bioassays.jsp

    r6698 r6699  
    497497                >
    498498                <base:icon
    499                   id="table-add-filter-row"
     499                  subclass="link table-filter-row-action"
    500500                  image="add.png"
    501501                  tooltip="Add extra filter row"
    502502                  visible="<%=lastRow%>"
    503503                /><base:icon
    504                   id="<%="remove-filter-row-"+filterNo %>"
    505                   subclass="table-remove-filter-row"
     504                  subclass="link table-filter-row-action"
    506505                  image="remove.png"
    507506                  tooltip="Remove this filter row"
    508507                  visible="<%=numRows > 1 || numFilters > 0 %>"
    509                   data-filter-index="<%=filterNo%>"
     508                  data-remove-row="<%=filterNo%>"
    510509                />
    511510              </tbl:header>
  • trunk/www/views/experiments/list_experiments.jsp

    r6698 r6699  
    441441                >
    442442                <base:icon
    443                   id="table-add-filter-row"
     443                  subclass="link table-filter-row-action"
    444444                  image="add.png"
    445445                  tooltip="Add extra filter row"
    446446                  visible="<%=lastRow%>"
    447447                /><base:icon
    448                   id="<%="remove-filter-row-"+filterNo %>"
    449                   subclass="table-remove-filter-row"
     448                  subclass="link table-filter-row-action"
    450449                  image="remove.png"
    451450                  tooltip="Remove this filter row"
    452451                  visible="<%=numRows > 1 || numFilters > 0 %>"
    453                   data-filter-index="<%=filterNo%>"
     452                  data-remove-row="<%=filterNo%>"
    454453                />
    455454              </tbl:header>
  • trunk/www/views/formulas/list_formulas.jsp

    r6698 r6699  
    474474                >
    475475                <base:icon
    476                   id="table-add-filter-row"
     476                  subclass="link table-filter-row-action"
    477477                  image="add.png"
    478478                  tooltip="Add extra filter row"
    479479                  visible="<%=lastRow%>"
    480480                /><base:icon
    481                   id="<%="remove-filter-row-"+filterNo %>"
    482                   subclass="table-remove-filter-row"
     481                  subclass="link table-filter-row-action"
    483482                  image="remove.png"
    484483                  tooltip="Remove this filter row"
    485484                  visible="<%=numRows > 1 || numFilters > 0 %>"
    486                   data-filter-index="<%=filterNo%>"
     485                  data-remove-row="<%=filterNo%>"
    487486                />
    488487              </tbl:header>
  • trunk/www/views/physicalbioassays/list_bioassays.jsp

    r6698 r6699  
    478478                >
    479479                <base:icon
    480                   id="table-add-filter-row"
     480                  subclass="link table-filter-row-action"
    481481                  image="add.png"
    482482                  tooltip="Add extra filter row"
    483483                  visible="<%=lastRow%>"
    484484                /><base:icon
    485                   id="<%="remove-filter-row-"+filterNo %>"
    486                   subclass="table-remove-filter-row"
     485                  subclass="link table-filter-row-action"
    487486                  image="remove.png"
    488487                  tooltip="Remove this filter row"
    489488                  visible="<%=numRows > 1 || numFilters > 0 %>"
    490                   data-filter-index="<%=filterNo%>"
     489                  data-remove-row="<%=filterNo%>"
    491490                />
    492491              </tbl:header>
  • trunk/www/views/rawbioassays/list_rawbioassays.jsp

    r6698 r6699  
    579579                >
    580580                <base:icon
    581                   id="table-add-filter-row"
     581                  subclass="link table-filter-row-action"
    582582                  image="add.png"
    583583                  tooltip="Add extra filter row"
    584584                  visible="<%=lastRow%>"
    585585                /><base:icon
    586                   id="<%="remove-filter-row-"+filterNo %>"
    587                   subclass="table-remove-filter-row"
     586                  subclass="link table-filter-row-action"
    588587                  image="remove.png"
    589588                  tooltip="Remove this filter row"
    590589                  visible="<%=numRows > 1 || numFilters > 0 %>"
    591                   data-filter-index="<%=filterNo%>"
     590                  data-remove-row="<%=filterNo%>"
    592591                />
    593592              </tbl:header>
  • trunk/www/views/rawbioassays/rawdata/list_rawdata.jsp

    r6698 r6699  
    670670                >
    671671                <base:icon
    672                   id="table-add-filter-row"
     672                  subclass="link table-filter-row-action"
    673673                  image="add.png"
    674674                  tooltip="Add extra filter row"
    675675                  visible="<%=lastRow%>"
    676676                /><base:icon
    677                   id="<%="remove-filter-row-"+filterNo %>"
    678                   subclass="table-remove-filter-row"
     677                  subclass="link table-filter-row-action"
    679678                  image="remove.png"
    680679                  tooltip="Remove this filter row"
    681680                  visible="<%=numRows > 1 || numFilters > 0 %>"
    682                   data-filter-index="<%=filterNo%>"
     681                  data-remove-row="<%=filterNo%>"
    683682                />
    684683              </tbl:header>
  • trunk/www/views/reporterlists/list_reporterlists.jsp

    r6698 r6699  
    327327                >
    328328                <base:icon
    329                   id="table-add-filter-row"
     329                  subclass="link table-filter-row-action"
    330330                  image="add.png"
    331331                  tooltip="Add extra filter row"
    332332                  visible="<%=lastRow%>"
    333333                /><base:icon
    334                   id="<%="remove-filter-row-"+filterNo %>"
    335                   subclass="table-remove-filter-row"
     334                  subclass="link table-filter-row-action"
    336335                  image="remove.png"
    337336                  tooltip="Remove this filter row"
    338337                  visible="<%=numRows > 1 || numFilters > 0 %>"
    339                   data-filter-index="<%=filterNo%>"
     338                  data-remove-row="<%=filterNo%>"
    340339                />
    341340              </tbl:header>
  • trunk/www/views/reporterlists/reporters/list_reporters.jsp

    r6698 r6699  
    386386                >
    387387                <base:icon
    388                   id="table-add-filter-row"
     388                  subclass="link table-filter-row-action"
    389389                  image="add.png"
    390390                  tooltip="Add extra filter row"
    391391                  visible="<%=lastRow%>"
    392392                /><base:icon
    393                   id="<%="remove-filter-row-"+filterNo %>"
    394                   subclass="table-remove-filter-row"
     393                  subclass="link table-filter-row-action"
    395394                  image="remove.png"
    396395                  tooltip="Remove this filter row"
    397396                  visible="<%=numRows > 1 || numFilters > 0 %>"
    398                   data-filter-index="<%=filterNo%>"
     397                  data-remove-row="<%=filterNo%>"
    399398                />
    400399              </tbl:header>
  • trunk/www/views/reporters/list_reporters.jsp

    r6698 r6699  
    376376                >
    377377                <base:icon
    378                   id="table-add-filter-row"
     378                  subclass="link table-filter-row-action"
    379379                  image="add.png"
    380380                  tooltip="Add extra filter row"
    381381                  visible="<%=lastRow%>"
    382382                /><base:icon
    383                   id="<%="remove-filter-row-"+filterNo %>"
    384                   subclass="table-remove-filter-row"
     383                  subclass="link table-filter-row-action"
    385384                  image="remove.png"
    386385                  tooltip="Remove this filter row"
    387386                  visible="<%=numRows > 1 || numFilters > 0 %>"
    388                   data-filter-index="<%=filterNo%>"
     387                  data-remove-row="<%=filterNo%>"
    389388                />
    390389              </tbl:header>
Note: See TracChangeset for help on using the changeset viewer.