
angular.module('os.biospecimen.participant.list', ['os.biospecimen.models'])
  .controller('ParticipantListCtrl', function(
    $scope, $state, cp, twoStepReg, mobileDataEntryEnabled, addParticipantWorkflow,
    ParticipantsHolder, PluginReg, DeleteUtil, CollectionProtocolRegistration) {

    var ctrl = this;

    function init() {
      $scope.cpId = cp.id;
      $scope.ctx = {
        params: {
          listName: 'participant-list-view',
          objectId: cp.id
        },
        emptyState: {
          loadingMessage: 'participant.loading_list',
          emptyMessage: 'participant.empty_list'
        }
      };

      angular.extend($scope.listViewCtx, {
        twoStepReg: twoStepReg,
        listName: 'participant.list',
        ctrl: ctrl,
        headerButtonsTmpl: 'modules/biospecimen/participant/register-button.html',
        headerActionsTmpl: 'modules/biospecimen/participant/list-pager.html',
        showPrimaryBtnDd: !!cp.bulkPartRegEnabled || (PluginReg.getTmpls('participant-list', 'primary-button').length > 0),
        showRapidRegistration: addParticipantWorkflow == 'rapid',
        mobileDataEntryEnabled: mobileDataEntryEnabled
      });
    }

    $scope.showParticipant = function(row) {
      $state.go('participant-detail.overview', {cprId: row.hidden.cprId});
    };

    $scope.setListCtrl = function(listCtrl) {
      ctrl.listCtrl = $scope.ctx.listCtrl = listCtrl;
      $scope.listViewCtx.showSearch = listCtrl.haveFilters;
      $scope.listViewCtx.pagerOpts  =  listCtrl.pagerOpts;
    }

    ctrl.bulkEdit = function() {
      var selectedRows = ctrl.listCtrl.getSelectedItems();
      var cprs = selectedRows.map(function(row) { return {id: +row.hidden.cprId}; });
      ParticipantsHolder.setParticipants(cprs);
      $state.go('participant-bulk-edit');
    }

    ctrl.deleteParticipants = function() {
      var selectedRows = ctrl.listCtrl.getSelectedItems();
      var cprIds = selectedRows.map(function(row) { return +row.hidden.cprId; });

      var opts = {
        confirmDelete:  'participant.delete_participants',
        successMessage: 'participant.participants_deleted',
        pendingMessage: 'participant.participants_delete_pending',
        onBulkDeletion: function() { ctrl.listCtrl.loadList(); },
        askReason:      true
      }

      DeleteUtil.bulkDelete({bulkDelete: CollectionProtocolRegistration.bulkDelete}, cprIds, opts);
    }

    init();
  })

  .directive('osShowIfMultipleOptionsPresent', function($timeout) {
    function isElementDisplayed(item) {
      return !(item.style.display == 'none' || item.style.visibility == 'hidden' || parseFloat(item.style.opacity) <= 0 || item.classList.contains('ng-hide'));
    }

    return {
      restrict: 'A',
      link: function(scope, element, attrs) {
        scope.$watch(
          function() {
            return element.find("ul.dropdown-menu > li:not(.divider)").
              filter(function() {
                return isElementDisplayed(this);
              }).length;
          }, function(val) {
            if (val <= 1) {
              element.find('.dropdown-toggle').hide();
              element.find('.single-option').show();
            } else {
              element.find('.dropdown-toggle').show();
              element.find('.single-option').hide();
            }
          }
        );
      }
    }
  });

@@ -2548,16 +2548,25 @@
 eturn !(
+%0A        
 item.sty
@@ -2588,16 +2588,24 @@
 none' %7C%7C
+%0A       
  item.st
@@ -2633,16 +2633,24 @@
 dden' %7C%7C
+%0A       
  parseFl
@@ -2680,16 +2680,91 @@
  %3C= 0 %7C%7C
+%0A        (item.classList && typeof item.classList.contains == 'function' &&
  item.cl
@@ -2791,16 +2791,24 @@
 -hide'))
+%0A      )
 ;%0A    %7D%0A

Fix browser warnings.