entities_attribute.js.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: entities/attribute.js</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Source: entities/attribute.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>import promotedAttributeDefinitionParser from '../services/promoted_attribute_definition_parser.js';
  20. /**
  21. * Attribute is an abstract concept which has two real uses - label (key - value pair)
  22. * and relation (representing named relationship between source and target note)
  23. */
  24. class Attribute {
  25. constructor(froca, row) {
  26. this.froca = froca;
  27. this.update(row);
  28. }
  29. update(row) {
  30. /** @type {string} */
  31. this.attributeId = row.attributeId;
  32. /** @type {string} */
  33. this.noteId = row.noteId;
  34. /** @type {string} */
  35. this.type = row.type;
  36. /** @type {string} */
  37. this.name = row.name;
  38. /** @type {string} */
  39. this.value = row.value;
  40. /** @type {int} */
  41. this.position = row.position;
  42. /** @type {boolean} */
  43. this.isInheritable = !!row.isInheritable;
  44. }
  45. /** @returns {NoteShort} */
  46. getNote() {
  47. return this.froca.notes[this.noteId];
  48. }
  49. get targetNoteId() { // alias
  50. return this.type === 'relation' ? this.value : undefined;
  51. }
  52. get isAutoLink() {
  53. return this.type === 'relation' &amp;&amp; ['internalLink', 'imageLink', 'relationMapLink', 'includeNoteLink'].includes(this.name);
  54. }
  55. get toString() {
  56. return `Attribute(attributeId=${this.attributeId}, type=${this.type}, name=${this.name}, value=${this.value})`;
  57. }
  58. isDefinition() {
  59. return this.type === 'label' &amp;&amp; (this.name.startsWith('label:') || this.name.startsWith('relation:'));
  60. }
  61. getDefinition() {
  62. return promotedAttributeDefinitionParser.parse(this.value);
  63. }
  64. isDefinitionFor(attr) {
  65. return this.type === 'label' &amp;&amp; this.name === `${attr.type}:${attr.name}`;
  66. }
  67. get dto() {
  68. const dto = Object.assign({}, this);
  69. delete dto.froca;
  70. return dto;
  71. }
  72. }
  73. export default Attribute;
  74. </code></pre>
  75. </article>
  76. </section>
  77. </div>
  78. <nav>
  79. <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Attribute.html">Attribute</a></li><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteComplement.html">NoteComplement</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3>Global</h3><ul><li><a href="global.html#doRenderBody">doRenderBody</a></li></ul>
  80. </nav>
  81. <br class="clear">
  82. <footer>
  83. Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a>
  84. </footer>
  85. <script> prettyPrint(); </script>
  86. <script src="scripts/linenumber.js"> </script>
  87. </body>
  88. </html>