Skip to content

Commit

Permalink
Switch subclassing method for metadata details
Browse files Browse the repository at this point in the history
This follows the approach suggested: redom/redom#140 (comment)
  • Loading branch information
acdha committed Mar 19, 2019
1 parent fdceec0 commit 7fb79d0
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions concordia/static/js/action-app/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ export class MetadataPanel {

class MetadataDetails {
constructor(sectionName, initialData) {
this.el = html('details', {open: true}, [
this.children = [
html('summary.h3', [
text(`${sectionName}: `),
html('span.title', text(initialData.title))
]),
html('div.details-body')
]);
];
this.el = html('details', {open: true}, this.children);
}
update(data) {
$('.details-body', this.el).innerText = data.description || '';
Expand Down Expand Up @@ -121,16 +122,9 @@ class ItemMetadataDetails extends MetadataDetails {

this.featuredMetadata = new FeaturedMetadata();
this.rawMetadataDisplay = new RawMetadataDisplay();
}

onmount() {
mount(this.el, this.featuredMetadata);
mount(this.el, this.rawMetadataDisplay);
}

onunmount() {
unmount(this.el, this.featuredMetadata);
unmount(this.el, this.rawMetadataDisplay);
this.children.push([this.featuredMetadata, this.rawMetadataDisplay]);
setChildren(this.el, this.children);
}

update(data) {
Expand Down

0 comments on commit 7fb79d0

Please sign in to comment.