Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: explicit EDM init #2469

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/portal/src/composables/itemMediaPresentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ const fetchPresentation = async(uri) => {

const setPresentationFromWebResources = (webResources) => {
presentation.value = new EuropeanaMediaPresentation({
canvases: webResources.map((resource) => ({
resource: EuropeanaMediaResource.fromEDM(resource)
canvases: webResources.map((wr) => ({
resource: EuropeanaMediaResource.fromEDM(wr)
}))
});
};
Expand Down
15 changes: 8 additions & 7 deletions packages/portal/src/utils/europeana/media/Resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Service from './Service.js';
import EDMWebResource from '@/plugins/europeana/edm/WebResource.js';

export default class EuropeanaMediaResource extends Base {
$edm;
#edm;

static fromEDM(edm) {
if (!edm) {
Expand All @@ -15,7 +15,6 @@ export default class EuropeanaMediaResource extends Base {
data.id = edm;
} else {
data = this.omitIsUndefined({
edm,
id: edm.about,
format: edm.ebucoreHasMimeType,
height: edm.ebucoreHeight,
Expand All @@ -24,7 +23,9 @@ export default class EuropeanaMediaResource extends Base {
});
}

return new this(data);
const resource = new this(data);
resource.edm = edm;
return resource;
}

parseData(data) {
Expand All @@ -42,7 +43,7 @@ export default class EuropeanaMediaResource extends Base {
}

get edm() {
if (!this.$edm) {
if (!this.#edm) {
const data = this.constructor.omitIsUndefined({
about: this.id,
ebucoreHasMimeType: this.format,
Expand All @@ -51,12 +52,12 @@ export default class EuropeanaMediaResource extends Base {
svcsHasService: [].concat(this.service || [])[0]?.edm
});

this.$edm = new EDMWebResource(data);
this.#edm = new EDMWebResource(data);
}
return this.$edm;
return this.#edm;
}

set edm(value) {
this.$edm = value;
this.#edm = value;
}
}
15 changes: 8 additions & 7 deletions packages/portal/src/utils/europeana/media/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Base from './Base.js';
import EDMService from '@/plugins/europeana/edm/Service.js';

export default class EuropeanaMediaService extends Base {
$edm;
#edm;

static fromEDM(edm) {
if (!edm) {
Expand All @@ -14,14 +14,15 @@ export default class EuropeanaMediaService extends Base {
data.id = edm;
} else {
data = this.omitIsUndefined({
edm,
context: 'http://iiif.io/api/image/2/context.json',
id: edm.about,
profile: edm.doapImplements
});
}

return new this(data);
const service = new this(data);
service.edm = edm;
return service;
}

get infoUrl() {
Expand All @@ -35,19 +36,19 @@ export default class EuropeanaMediaService extends Base {
}

get edm() {
if (!this.$edm) {
if (!this.#edm) {
const data = this.constructor.omitIsUndefined({
about: this.id,
doapImplements: this.profile,
dctermsConformsTo: ['http://iiif.io/api/image']
});

this.$edm = new EDMService(data);
this.#edm = new EDMService(data);
}
return this.$edm;
return this.#edm;
}

set edm(value) {
this.$edm = value;
this.#edm = value;
}
}
Loading