Skip to content

Commit

Permalink
fix: 🐛 update dataset creator/contributor names (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
megasanjay authored Feb 21, 2024
1 parent 8a784b1 commit ff24a62
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 32 deletions.
6 changes: 4 additions & 2 deletions src/types/Dataset.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ export interface DatasetPersonAffiliation {

export interface DatasetCreator {
id: string;
name: string;
affiliations: DatasetPersonAffiliation[];
family_name: string;
given_name: string;
name_identifier: string;
name_identifier_scheme: string;
name_identifier_scheme_uri: string;
Expand All @@ -91,9 +92,10 @@ export interface DatasetCreators {

export interface DatasetContributor {
id: string;
name: string;
affiliations: DatasetPersonAffiliation[];
contributor_type: string | null;
family_name: string;
given_name: string;
name_identifier: string;
name_identifier_scheme: string;
name_identifier_scheme_uri: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ const removeContributor = async (id: string) => {
const addContributor = () => {
moduleData.contributors.push({
id: nanoid(),
name: "",
affiliations: [],
contributor_type: null,
family_name: "",
given_name: "",
name_identifier: "",
name_identifier_scheme: "",
name_identifier_scheme_uri: "",
Expand All @@ -107,7 +108,6 @@ const saveMetadata = (e: MouseEvent) => {
if (!errors) {
const data: any = moduleData.contributors.map((item) => {
const entry = {
name: item.name,
affiliations: item.affiliations.map((affiliation) => {
return {
name: affiliation.name || "",
Expand All @@ -117,6 +117,8 @@ const saveMetadata = (e: MouseEvent) => {
};
}),
contributor_type: item.contributor_type,
family_name: item.family_name || "",
given_name: item.given_name,
name_identifier: item.name_identifier,
name_identifier_scheme: item.name_identifier_scheme,
name_identifier_scheme_uri: item.name_identifier_scheme_uri || "",
Expand Down Expand Up @@ -196,7 +198,9 @@ const saveMetadata = (e: MouseEvent) => {
v-for="(item, index) in moduleData.contributors"
:key="item.id"
class="mb-5 shadow-md"
:title="item.name || `Contributor ${index + 1}`"
:title="
item.given_name ? `${item.given_name} ${item.family_name}` : `Contributor ${index + 1}`
"
bordered
>
<template #header-extra>
Expand Down Expand Up @@ -232,18 +236,6 @@ const saveMetadata = (e: MouseEvent) => {
/>
</n-form-item>

<n-form-item
label="Name"
:path="`contributors[${index}].name`"
:rule="{
message: 'Please enter a name',
required: true,
trigger: ['blur', 'input'],
}"
>
<n-input v-model:value="item.name" placeholder="Bertolt Hoover" clearable />
</n-form-item>

<n-form-item
label="Name Type"
:path="`contributors[${index}].name_type`"
Expand All @@ -261,6 +253,35 @@ const saveMetadata = (e: MouseEvent) => {
/>
</n-form-item>

<n-form-item
label="Given Name"
:path="`contributors[${index}].given_name`"
:rule="{
message: 'Please enter a name',
required: true,
trigger: ['blur', 'input'],
}"
>
<n-input v-model:value="item.given_name" placeholder="Bertolt" clearable />
</n-form-item>

<n-form-item
label="Family Name"
:path="`contributors[${index}].family_name`"
:rule="{
message: 'Please enter a value',
required: item.name_type === 'Personal',
trigger: ['blur', 'input'],
}"
>
<n-input
v-model:value="item.family_name"
:placeholder="item.name_type === 'Organizational' ? 'N/A' : 'Hoover'"
clearable
:disabled="item.name_type === 'Organizational'"
/>
</n-form-item>

<n-form-item
label="Name Identifier"
:path="`contributors[${index}].name_identifier`"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ const removeCreator = async (id: string) => {
const addCreator = () => {
moduleData.creators.push({
id: nanoid(),
name: "",
affiliations: [],
family_name: "",
given_name: "",
name_identifier: "",
name_identifier_scheme: "",
name_identifier_scheme_uri: "",
Expand All @@ -106,7 +107,6 @@ const saveMetadata = (e: MouseEvent) => {
if (!errors) {
const data: any = moduleData.creators.map((item) => {
const entry = {
name: item.name,
affiliations: item.affiliations.map((affiliation) => {
return {
name: affiliation.name || "",
Expand All @@ -115,6 +115,8 @@ const saveMetadata = (e: MouseEvent) => {
scheme_uri: affiliation.scheme_uri || "",
};
}),
family_name: item.family_name || "",
given_name: item.given_name,
name_identifier: item.name_identifier,
name_identifier_scheme: item.name_identifier_scheme,
name_identifier_scheme_uri: item.name_identifier_scheme_uri || "",
Expand Down Expand Up @@ -194,7 +196,9 @@ const saveMetadata = (e: MouseEvent) => {
v-for="(item, index) in moduleData.creators"
:key="item.id"
class="mb-5 shadow-md"
:title="item.name || `Creator ${index + 1}`"
:title="
item.given_name ? `${item.given_name} ${item.family_name}` : `Creator ${index + 1}`
"
bordered
>
<template #header-extra>
Expand All @@ -214,31 +218,48 @@ const saveMetadata = (e: MouseEvent) => {
</template>

<n-form-item
label="Name"
:path="`creators[${index}].name`"
label="Name Type"
:path="`creators[${index}].name_type`"
:rule="{
message: 'Please select a name type',
required: true,
trigger: ['blur', 'change'],
}"
>
<n-select
v-model:value="item.name_type"
placeholder="Personal"
clearable
:options="FORM_JSON.datasetNameTypeOptions"
/>
</n-form-item>

<n-form-item
label="Given Name"
:path="`creators[${index}].given_name`"
:rule="{
message: 'Please enter a name',
required: true,
trigger: ['blur', 'input'],
}"
>
<n-input v-model:value="item.name" placeholder="Bertolt Hoover" clearable />
<n-input v-model:value="item.given_name" placeholder="Bertolt" clearable />
</n-form-item>

<n-form-item
label="Name Type"
:path="`creators[${index}].name_type`"
label="Family Name"
:path="`creators[${index}].family_name`"
:rule="{
message: 'Please select an intervention type',
required: true,
trigger: ['blur', 'change'],
message: 'Please enter a value',
required: item.name_type === 'Personal',
trigger: ['blur', 'input'],
}"
>
<n-select
v-model:value="item.name_type"
placeholder="Personal"
<n-input
v-model:value="item.family_name"
:placeholder="item.name_type === 'Organizational' ? 'N/A' : 'Hoover'"
clearable
:options="FORM_JSON.datasetNameTypeOptions"
:disabled="item.name_type === 'Organizational'"
/>
</n-form-item>

Expand Down

0 comments on commit ff24a62

Please sign in to comment.