src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue
changeset 418 a04c55054afe
parent 403 0ed5207089ee
child 427 2a9ce7ec3a29
equal deleted inserted replaced
417:3a2a2a798bf4 418:a04c55054afe
    74             'tag-list': TagList
    74             'tag-list': TagList
    75         },
    75         },
    76         data() {
    76         data() {
    77             return defaults;
    77             return defaults;
    78         },
    78         },
       
    79         mounted() {
       
    80             if (this.annotation) {
       
    81                 this.loadAnnotation(this.annotation);
       
    82             }
       
    83         },
    79         watch: {
    84         watch: {
    80             annotation: function(annotation) {
    85             annotation: function(annotation) {
    81                 if (annotation) {
    86                 if (annotation) {
    82                     // Make sure we have an actual copy
    87                     this.loadAnnotation(annotation);
    83                     Object.assign(this, {
       
    84                         title: annotation.title,
       
    85                         description: annotation.description,
       
    86                         fragment: annotation.fragment,
       
    87                         tags: annotation.tags.slice(),
       
    88                         readonly: true,
       
    89                     });
       
    90                 } else {
    88                 } else {
    91                     this.reset();
    89                     this.reset();
    92                 }
    90                 }
    93             }
    91             }
    94         },
    92         },
   126                 this.tags = tags;
   124                 this.tags = tags;
   127             },
   125             },
   128             reset: function() {
   126             reset: function() {
   129                 Object.assign(this, defaults);
   127                 Object.assign(this, defaults);
   130             },
   128             },
       
   129             loadAnnotation(annotation) {
       
   130                 // Make sure we have an actual copy
       
   131                 Object.assign(this, {
       
   132                     title: annotation.title,
       
   133                     description: annotation.description,
       
   134                     fragment: annotation.fragment,
       
   135                     tags: annotation.tags.slice(),
       
   136                     readonly: true,
       
   137                 });
       
   138             }
   131         }
   139         }
   132     }
   140     }
   133 
   141 
   134 </script>
   142 </script>
   135 
   143