Changeset 6564


Ignore:
Timestamp:
Oct 15, 2014, 8:05:21 AM (9 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1869: Return selected items as a list

Implemented this in a different way. Instead of returning a list an extra field 'remaining' was added to the event.detail object which is a counter counting down to 0. When event.detail.remaining==0 the last selected item has been returned.

Location:
branches/3.3-stable/www
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-stable/www/biomaterials/extracts/extracts.js

    r6484 r6564  
    481481    event.detail.name += ' [-]';
    482482    Link.addItem('extracts', 'EXTRACT', event.detail);
    483     frm.parentType[0].checked = false;
    484     frm.parentType[1].checked = true;
    485     extracts.parentTypeOnClick();
     483    if (event.detail.remaining == 0)
     484    {
     485      frm.parentType[0].checked = false;
     486      frm.parentType[1].checked = true;
     487      extracts.parentTypeOnClick();
     488    }
    486489  }
    487490
  • branches/3.3-stable/www/biomaterials/samples/samples.js

    r6484 r6564  
    411411    event.detail.name += ' [-]';
    412412    Link.addItem('samples', 'SAMPLE', event.detail);
    413     frm.parentType[0].checked = false;
    414     frm.parentType[1].checked = true;
    415     samples.parentTypeOnClick();
     413    if (event.detail.remaining == 0)
     414    {
     415      frm.parentType[0].checked = false;
     416      frm.parentType[1].checked = true;
     417      samples.parentTypeOnClick();
     418    }
    416419  }
    417420
  • branches/3.3-stable/www/common/share/share.js

    r6412 r6564  
    144144   
    145145    Link.addItem('members', 'USER', event.detail);
    146     share.membersOnChange();
     146    if (event.detail.remaining == 0)
     147    {
     148      share.membersOnChange();
     149    }
    147150  }
    148151
     
    174177   
    175178    Link.addItem('members', 'GROUP', event.detail);
    176     share.membersOnChange();
     179    if (event.detail.remaining == 0)
     180    {
     181      share.membersOnChange();
     182    }
    177183  }
    178184
     
    199205   
    200206    Link.addItem('members', 'PROJECT', event.detail);
    201     share.membersOnChange();
     207    if (event.detail.remaining == 0)
     208    {
     209      share.membersOnChange();
     210    }
    202211  }
    203212 
     
    218227  {
    219228    Link.addItem('members', 'PERMISSIONTEMPLATE', event.detail);
    220     share.membersOnChange();
     229    if (event.detail.remaining == 0)
     230    {
     231      share.membersOnChange();
     232    }
    221233  }
    222234
  • branches/3.3-stable/www/filemanager/select_file.js

    r6400 r6564  
    3535  selectFile.setSelectedFile = function(fileId, path)
    3636  {
    37     selected[0] = {'id': fileId, 'path': path};
     37    selected[0] = {'id': fileId, 'name': path};
    3838    selectFile.updatePath();
    3939  }
     
    4646    if (selectFile.getSelectedFileIndex(fileId) == -1)
    4747    {
    48       selected[selected.length] = {'id': fileId, 'path': path};
     48      selected[selected.length] = {'id': fileId, 'name': path};
    4949    }
    5050    selectFile.updatePath();
     
    7373    {
    7474      if (path != '') path += ', ';
    75       path += selected[i].path;
     75      path += selected[i].name;
    7676    }
    7777    Doc.element('files').innerHTML = path;
     
    8484    var callbackMethod = window.opener[callback];
    8585   
     86    var remaining = selected.length-1;
    8687    for (var i = 0; i < selected.length; i++)
    8788    {
     89      var s = selected[i];
     90      s.remaining = remaining--;
    8891      if (notifyTarget)
    8992      {
    9093        // Send event to the target in the opener window
    91         Events.sendCustomEvent(notifyTarget, 'base-selected', {'id': selected[i].id, 'name': selected[i].path});
     94        Events.sendCustomEvent(notifyTarget, 'base-selected', s);
    9295      }
    9396      else if (callbackMethod)
    9497      {
    9598        // Call the callback method in the opener window
    96         callbackMethod.call(null, selected[i].id, selected[i].path);
     99        callbackMethod.call(null, s.id, s.path);
    97100      }
    98101    }
  • branches/3.3-stable/www/include/scripts/table.js

    r6556 r6564  
    736736    }
    737737   
    738     var numSelected = 0;
     738    var selected = [];
    739739    if (frm.item_id)
    740740    {
     
    744744      {
    745745        var id = element.value.match(/^\d+$/) ? parseInt(element.value) : element.value;
    746         if (notifyTarget)
    747         {
    748           // Send event to the target in the opener window
    749           Events.sendCustomEvent(notifyTarget, 'base-selected', {'id': id, 'name': element.title, 'itemType': itemType});
    750         }
    751         else if (callbackMethod)
    752         {
    753           // Call the callback method in the opener window
    754           callbackMethod.call(null, id, element.title);
    755         }
    756         numSelected = 1;
     746        selected[selected.length] = {'id': id, 'name': element.title, 'itemType': itemType};
    757747      }
    758748    }
     
    766756        {
    767757          var id = element.value.match(/^\d+$/) ? parseInt(element.value) : element.value;
    768           if (notifyTarget)
    769           {
    770             // Send event to the target in the opener window
    771             Events.sendCustomEvent(notifyTarget, 'base-selected', {'id': id, 'name': element.title, 'itemType': itemType});
    772           }
    773           else if (callbackMethod)
    774           {
    775             // Call the callback method in the opener window
    776             callbackMethod.call(null, id, element.title);
    777           }
    778           numSelected++;
     758          selected[selected.length] = {'id': id, 'name': element.title, 'itemType': itemType};
    779759        }
    780760      }
    781761    }
    782     return numSelected;
     762   
     763    var remaining = selected.length-1;
     764    for (var i = 0; i < selected.length; i++)
     765    {
     766      var s = selected[i];
     767      s.remaining = remaining--;
     768      if (notifyTarget)
     769      {
     770        // Send event to the target in the opener window
     771        Events.sendCustomEvent(notifyTarget, 'base-selected', s);
     772      }
     773      else if (callbackMethod)
     774      {
     775        // Call the callback method in the opener window
     776        callbackMethod.call(null, s.id, s.name);
     777      }
     778    }
     779
     780    return selected.length;
    783781  }
    784782
  • branches/3.3-stable/www/views/physicalbioassays/bioassays.js

    r6400 r6564  
    353353    event.detail.value = ':1';
    354354    Link.addItem('extracts', 'EXTRACT', event.detail);
    355     bioassays.extractsOnChange();
     355    if (event.detail.remaining == 0)
     356    {
     357      bioassays.extractsOnChange();
     358    }
    356359  }
    357360
Note: See TracChangeset for help on using the changeset viewer.