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

ez5.PdfCreator.Template = (function(superClass) {
  extend(Template, superClass);

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

  Template.prototype.initOpts = function() {
    Template.__super__.initOpts.call(this);
    this.addOpts({
      data: {
        check: "PlainObject"
      }
    });
    return this;
  };

  Template.prototype.getDisplayName = function() {
    return ez5.loca.getBestFrontendValue(this._data.name) || $$("pdf-creator.list.template-name.default-value");
  };

  Template.prototype.getData = function() {
    return this._data;
  };

  Template.prototype.print = function(objects, idMask) {
    var data, documentData, pdfDocumentNode, printPromise;
    data = CUI.util.copyObject(this._data.documentData, true);
    documentData = ez5.PdfCreatorUtils.initDocumentData(data);
    documentData.idMask = idMask;
    pdfDocumentNode = new ez5.PdfCreator.Node.Document(documentData);
    printPromise = ez5.PdfCreatorUtils.print(objects, pdfDocumentNode).fail(function(errorMessage) {
      if (CUI.util.isString(errorMessage)) {
        return CUI.problem({
          text: errorMessage
        });
      }
    });
    return printPromise;
  };

  return Template;

})(CUI.Element);
