// Generated by CoffeeScript 1.12.7
var CustomDataTypeDANTEFacet,
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  hasProp = {}.hasOwnProperty;

CustomDataTypeDANTEFacet = (function(superClass) {
  extend(CustomDataTypeDANTEFacet, superClass);

  function CustomDataTypeDANTEFacet() {
    return CustomDataTypeDANTEFacet.__super__.constructor.apply(this, arguments);
  }

  CustomDataTypeDANTEFacet.prototype.initOpts = function() {
    CustomDataTypeDANTEFacet.__super__.initOpts.call(this);
    return this.addOpts({
      field: {
        mandatory: true,
        check: Field
      }
    });
  };

  CustomDataTypeDANTEFacet.prototype.requestFacetWithLimit = function(obj) {
    return {
      limit: this.getLimit(),
      field: this._field.fullName() + ".facetTerm",
      sort: "count",
      type: "term"
    };
  };

  CustomDataTypeDANTEFacet.prototype.getObjects = function(key, data) {
    var ref;
    if (key == null) {
      key = this.name();
    }
    if (data == null) {
      data = this.data();
    }
    return ((ref = data[key]) != null ? ref.terms : void 0) || [];
  };

  CustomDataTypeDANTEFacet.prototype.renderObjectText = function(object) {
    var label, parts;
    parts = object.term.split('@$@');
    label = '---';
    if (parts.length === 2) {
      if (parts[0] !== '') {
        label = parts[0];
      }
    }
    return label;
  };

  CustomDataTypeDANTEFacet.prototype.getObjectPath = function(obj) {
    return [obj.term];
  };

  CustomDataTypeDANTEFacet.prototype.name = function() {
    return this._field.fullName() + ".facetTerm";
  };

  CustomDataTypeDANTEFacet.prototype.requestSearchFilter = function(obj) {
    return {
      bool: "must",
      fields: [this._field.fullName() + ".facetTerm"],
      type: "in",
      "in": [obj.term]
    };
  };

  return CustomDataTypeDANTEFacet;

})(FieldFacet);
