Skip to content

Commit d70c08a

Browse files
committed
meeting: replace URL with identifiers (breaking change)
* closes #1972
1 parent 525f684 commit d70c08a

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

invenio_rdm_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/customFields/Meeting.js

+18-11
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,30 @@
55
// Invenio-RDM-Records is free software; you can redistribute it and/or modify it
66
// under the terms of the MIT License; see LICENSE file for more details.
77

8+
import { IdentifiersField } from "@js/invenio_rdm_records/src/deposit/fields";
9+
import { i18next } from "@translations/invenio_rdm_records/i18next";
810
import React, { Component } from "react";
9-
11+
import { getInputFromDOM } from "@js/invenio_rdm_records";
1012
import { FieldLabel, Input } from "react-invenio-forms";
1113
import { Divider, Grid } from "semantic-ui-react";
1214

1315
import PropTypes from "prop-types";
1416

1517
export class Meeting extends Component {
18+
constructor(props) {
19+
super(props);
20+
this.config = getInputFromDOM("deposits-config");
21+
this.vocabularies = this.config.vocabularies;
22+
}
23+
1624
render() {
1725
const {
1826
fieldPath, // injected by the custom field loader via the `field` config property
1927
title,
2028
acronym,
2129
dates,
2230
place,
23-
url,
31+
// identifiers,
2432
session,
2533
session_part: sessionPart,
2634
icon,
@@ -75,15 +83,14 @@ export class Meeting extends Component {
7583
<label className="helptext mb-0">{dates.description}</label>
7684
)}
7785
</Grid.Column>
78-
<Grid.Column width="12">
79-
<Input
80-
fieldPath={`${fieldPath}.url`}
81-
label={url.label}
82-
placeholder={url.placeholder}
86+
<Grid.Column width="16">
87+
<IdentifiersField
88+
fieldPath={`${fieldPath}.identifiers`}
89+
label={i18next.t("Meeting identifiers")}
90+
labelIcon="barcode"
91+
schemeOptions={this.vocabularies.identifiers.scheme}
92+
showEmptyValue
8393
/>
84-
{url.description && (
85-
<label className="helptext mb-0">{url.description}</label>
86-
)}
8794
</Grid.Column>
8895
<Grid.Column width="6">
8996
<Input
@@ -117,7 +124,7 @@ Meeting.propTypes = {
117124
acronym: PropTypes.object.isRequired,
118125
session_part: PropTypes.object.isRequired,
119126
session: PropTypes.object.isRequired,
120-
url: PropTypes.object.isRequired,
127+
// identifiers: PropTypes.object.isRequired,
121128
dates: PropTypes.object.isRequired,
122129
place: PropTypes.object.isRequired,
123130
icon: PropTypes.string,

invenio_rdm_records/contrib/meeting/custom_fields.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
- meeting.title
1818
- meeting.url
1919
"""
20+
from functools import partial
2021

2122
from invenio_i18n import lazy_gettext as _
2223
from invenio_records_resources.services.custom_fields import BaseCF
2324
from marshmallow import fields
24-
from marshmallow_utils.fields import SanitizedUnicode
25+
from marshmallow_utils.fields import SanitizedUnicode, IdentifierValueSet
26+
from marshmallow_utils.schemas import IdentifierSchema
2527

26-
from ...services.schemas.metadata import _valid_url
28+
from ...services.schemas.metadata import record_identifiers_schemes
2729

2830

2931
class MeetingCF(BaseCF):
@@ -40,9 +42,12 @@ def field(self):
4042
"session_part": SanitizedUnicode(),
4143
"session": SanitizedUnicode(),
4244
"title": SanitizedUnicode(),
43-
"url": SanitizedUnicode(
44-
validate=_valid_url(error_msg=_("You must provide a valid URL.")),
45-
),
45+
"identifiers": IdentifierValueSet(
46+
fields.Nested(
47+
partial(IdentifierSchema,
48+
allowed_schemes=record_identifiers_schemes)
49+
)
50+
)
4651
}
4752
)
4853

@@ -61,7 +66,11 @@ def mapping(self):
6166
"type": "text",
6267
"fields": {"keyword": {"type": "keyword"}},
6368
},
64-
"url": {"type": "keyword"},
69+
"identifiers": {"type": "object",
70+
"properties": {
71+
"identifier": {"type": "keyword"},
72+
"schema": {"type": "keyword"}
73+
}},
6574
},
6675
}
6776

@@ -71,7 +80,6 @@ def mapping(self):
7180
"meeting": "",
7281
}
7382

74-
7583
MEETING_CUSTOM_FIELDS = [
7684
MeetingCF(name="meeting:meeting"),
7785
]
@@ -104,10 +112,8 @@ def mapping(self):
104112
"placeholder": "",
105113
"description": _("Location where the conference took place."),
106114
},
107-
"url": {
108-
"label": _("Website"),
109-
"placeholder": "",
110-
"description": "",
115+
"identifiers": {
116+
"label": _("Identifiers"),
111117
},
112118
"session": {
113119
"label": _("Session"),

0 commit comments

Comments
 (0)