Source: volume/accessSearch.js

// Generated by CoffeeScript 1.12.7

/**
 * Search invidiauls to grant access to.
 * @module
 */
'use strict';
app.directive('accessSearchForm', [
  'constantService', 'modelService', function(constants, models) {
    return {
      restrict: 'E',
      templateUrl: 'volume/accessSearch.html',
      link: function($scope, $element, $attrs) {
        var form, select, volume;
        volume = $scope.volume;
        form = $scope.accessSearchForm;
        select = function(found) {
          return function() {
            $scope.selectFn(found);
            form.$setPristine();
            return '';
          };
        };

        /**
         * Search invidiauls to grant access to.
         * @interface form/search
         */
        form.search = function(val) {
          return models.Party.search({
            query: val
          }).then(function(data) {
            var found, i, len, results;
            form.validator.server({});
            results = [];
            for (i = 0, len = data.length; i < len; i++) {
              found = data[i];
              results.push({
                text: found.name,
                email: found.email !== void 0 ? ' (' + found.email + ')' : void 0,
                select: select(found)
              });
            }
            return results;
          }, function(res) {
            form.validator.server(res);
          });
        };
        form.validator.client({
          name: {
            tips: constants.message('access.search.name.help')
          }
        }, true);
      }
    };
  }
]);

//# sourceMappingURL=accessSearch.js.map