LCOV - code coverage report
Current view: top level - src/components/SSVGPropList - RelationList.vue.js (source / functions) Hit Total Coverage
Test: lcov.info Lines: 12 16 75.0 %
Date: 2025-06-29 02:18:36 Functions: 5 5 100.0 %

          Line data    Source code
       1             : // @ts-check
       2             : 
       3             : import Vue from "vue";
       4             : import Relation from "./Relation.vue";
       5             : import Transform from "./Transform.vue";
       6             : import Direct from "./Direct.vue";
       7             : import CreateRelationButton from "./CreateRelationButton.vue";
       8             : import { forEach, get, isEmpty } from "lodash";
       9             : 
      10             : export default /** @type {V.Constructor<any, any>} */ (Vue).extend({
      11             :   name: "RelationList",
      12             :   components: { Relation, Transform, Direct, CreateRelationButton },
      13             :   props: {
      14             :     /* eslint-disable-next-line vue/require-prop-types */
      15             :     state: { /* type: SVGElement, VueX typecheck issues */ default: null },
      16             :     /* eslint-disable-next-line vue/require-prop-types */
      17             :     property: { /* type: SVGElement, VueX typecheck issues */ default: null }
      18             :   },
      19             :   /**
      20             :    * @return {{
      21             :    *  relations: { [index: string]: Element }|null,
      22             :    *  transforms: { [index: string]: Element }|null
      23             :    *  directs: { [index: string]: Element }|null
      24             :    * }}
      25             :    */
      26             :   data() {
      27          12 :     return { relations: null, transforms: null, directs: null };
      28             :   },
      29             :   watch: {
      30           5 :     property() { this.load(); }
      31             :   },
      32             :   mounted() {
      33          12 :     this.load();
      34             :   },
      35             :   methods: {
      36             :     load() {
      37             :       /** @type {{ [index: string]: Element }} */
      38          17 :       const relations = {};
      39             :       /** @type {{ [index: string]: Element }} */
      40          17 :       const transforms = {};
      41             :       /** @type {{ [index: string]: Element }} */
      42          17 :       const directs = {};
      43             : 
      44          17 :       forEach(get(this, [ "property", "children" ]), (elt, idx) => {
      45          17 :         if (elt.tagName === "relation") {
      46          17 :           relations[idx] = elt;
      47             :         }
      48           0 :         else if (elt.tagName === "transform") {
      49           0 :           transforms[idx] = elt;
      50             :         }
      51           0 :         else if (elt.tagName === "direct") {
      52           0 :           directs[idx] = elt;
      53             :         }
      54             :       });
      55          17 :       this.relations = isEmpty(relations) ? null : relations;
      56          17 :       this.transforms = isEmpty(transforms) ? null : transforms;
      57          17 :       this.directs = isEmpty(directs) ? null : directs;
      58             :     }
      59             :   }
      60             : });

Generated by: LCOV version 1.16