Code coverage report for api/datum/DatumFields.js

Statements: 53.13% (17 / 32)      Branches: 10% (2 / 20)      Functions: 42.86% (3 / 7)      Lines: 53.13% (17 / 32)      Ignored: none     

All files » api/datum/ » DatumFields.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 1041 1                     1 8992 8992   8992 8992     1                                                                                                                                     725     725 725 129 129 129 129   725         1  
var Collection = require("./../Collection").Collection;
var DatumField = require("./../datum/DatumField").DatumField;
 
/**
 * @class Collection of Datum Field
 * @name  DatumFields
 * @description The DatumFields is a minimal customization of the Collection
 * to add an internal model of DatumField.
 *
 * @extends Collection
 * @constructs
 */
var DatumFields = function DatumFields(options) {
  Eif (!this._fieldDBtype) {
    this._fieldDBtype = "DatumFields";
  }
  this.debug("Constructing DatumFields length: ", options);
  Collection.apply(this, arguments);
};
 
DatumFields.prototype = Object.create(Collection.prototype, /** @lends DatumFields.prototype */ {
  constructor: {
    value: DatumFields
  },
 
  /**
   *  The primary key < v2 was "label" but we changed to use "id" so that
   *  "label" could be used only for a human friendly (and customizable)
   *  label while the id must remain unchanged for glossing and other automation.
   * @type {Object}
   */
  primaryKey: {
    value: "id"
  },
 
  INTERNAL_MODELS: {
    value: {
      item: DatumField
    }
  },
 
  capitalizeFirstCharacterOfPrimaryKeys: {
    value: false
  },
 
  /**
   *  Docs/items in a DatumFields are reorderable by default
   * @type {Boolean}
   */
  docsAreReorderable: {
    get: function() {
      if (this._docsAreReorderable !== null && this._docsAreReorderable !== undefined) {
        return this._docsAreReorderable;
      }
      return true;
    },
    set: function(value) {
      if (value === null || value === undefined) {
        delete this._docsAreReorderable;
        return;
      }
      this._docsAreReorderable = value;
    }
  },
 
  /**
   *  Docs/items in a DatumFields are reorderable by default
   * @type {Boolean}
   */
  showDocPosition: {
    get: function() {
      if (this._showDocPosition !== null && this._showDocPosition !== undefined) {
        return this._showDocPosition;
      }
      return true;
    },
    set: function(value) {
      if (value === null || value === undefined) {
        delete this._showDocPosition;
        return;
      }
      this._showDocPosition = value;
    }
  },
 
  cloneStructure: {
    value: function(includeEvenEmptyAttributes) {
      Iif (includeEvenEmptyAttributes) {
        this.todo("includeEvenEmptyAttributes is not implemented: " + includeEvenEmptyAttributes);
      }
      var json = Collection.prototype.toJSON.apply(this, arguments);
      json.map = json.map(function(field) {
        field.value = "";
        field.mask = "";
        field.encryptedValue = "";
        return field;
      });
      return json;
    }
  }
 
});
exports.DatumFields = DatumFields;