// Generated by CoffeeScript 1.12.7
var CustomDataTypeLinkFacet,
  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;

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

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

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

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

  CustomDataTypeLinkFacet.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) || [];
  };

  CustomDataTypeLinkFacet.prototype.renderObjectText = function(object) {
    return object.term;
  };

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

  CustomDataTypeLinkFacet.prototype.name = function() {
    return "cdt_link";
  };

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

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

  return CustomDataTypeLinkFacet;

})(FieldFacet);
