Skip to content

Commit

Permalink
Rename Hierarchical to Tree
Browse files Browse the repository at this point in the history
  • Loading branch information
claravox committed Dec 16, 2024
1 parent 809d226 commit e54ac97
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 38 deletions.
22 changes: 11 additions & 11 deletions deposit/metadata-form/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getTemplate } from '@rjsf/utils';
import Select from 'react-select';
import AffiliationIdentifier from 'YodaFields/AffiliationIdentifier'
import Geolocation from 'YodaFields/Geolocation'
import HierarchicalKeywordSelector from 'YodaFields/HierarchicalKeywordSelector'
import TreeKeywordSelector from 'YodaFields/TreeKeywordSelector'
import PersonIdentifier from 'YodaFields/PersonIdentifier'
import Vocabulary from 'YodaFields/Vocabulary'
import { withTheme } from "@rjsf/core";
Expand Down Expand Up @@ -206,7 +206,7 @@ const fields = {
vocabulary: Vocabulary,
affiliation_identifier: AffiliationIdentifier,
person_identifier: PersonIdentifier,
hierarchical_keyword_selector: HierarchicalKeywordSelector
tree_keyword_selector: TreeKeywordSelector
};

const CustomArrayFieldTemplate = (props) => {
Expand Down Expand Up @@ -470,13 +470,13 @@ class YodaForm extends React.Component {
// Turn save mode off.
formContext.saving = false;

if (id === "yoda_HierarchicalKeyword" &&
form.formData.HierarchicalKeyword &&
form.formData.HierarchicalKeyword.value &&
form.formData.HierarchicalKeyword.value.length &&
Object.keys(form.schema.properties.HierarchicalKeyword.items.properties).includes("subject")) {
if (id === "yoda_TreeKeyword" &&
form.formData.TreeKeyword &&
form.formData.TreeKeyword.value &&
form.formData.TreeKeyword.value.length &&
Object.keys(form.schema.properties.TreeKeyword.items.properties).includes("subject")) {

form.formData.HierarchicalKeyword = this.updateHierarchicalKeywords(form, form.formData.HierarchicalKeyword.value)
form.formData.TreeKeyword = this.updateTreeKeywords(form, form.formData.TreeKeyword.value)
}

this.setState({
Expand All @@ -485,7 +485,7 @@ class YodaForm extends React.Component {
});
}

updateHierarchicalKeywords = (form, value) => {
updateTreeKeywords = (form, value) => {
const newVal = value.map(val => {
if (val.value.endsWith(":")) {
// User created keyword
Expand All @@ -495,8 +495,8 @@ class YodaForm extends React.Component {
} else {
return {
"subject": val.label,
"subjectScheme": form.uiSchema.HierarchicalKeyword["ui:subjectScheme"],
"schemeUri": form.uiSchema.HierarchicalKeyword["ui:schemeUri"],
"subjectScheme": form.uiSchema.TreeKeyword["ui:subjectScheme"],
"schemeUri": form.uiSchema.TreeKeyword["ui:schemeUri"],
"valueUri": val.value.split(":").slice(1).join(":")
}
}
Expand Down
2 changes: 1 addition & 1 deletion deposit/static/deposit/js/metadata-form.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import axios from 'axios'
import { TreeSelect, ConfigProvider, theme } from 'antd'

class HierarchicalKeywordSelector extends React.Component {
class TreeKeywordSelector extends React.Component {
constructor (props) {
super(props)
this.state = {
Expand Down Expand Up @@ -234,4 +234,4 @@ class HierarchicalKeywordSelector extends React.Component {
}
}

export default HierarchicalKeywordSelector
export default TreeKeywordSelector
22 changes: 11 additions & 11 deletions research/metadata-form/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getTemplate } from '@rjsf/utils';
import Select from 'react-select';
import AffiliationIdentifier from 'YodaFields/AffiliationIdentifier'
import Geolocation from 'YodaFields/Geolocation'
import HierarchicalKeywordSelector from 'YodaFields/HierarchicalKeywordSelector'
import TreeKeywordSelector from 'YodaFields/TreeKeywordSelector'
import PersonIdentifier from 'YodaFields/PersonIdentifier'
import Vocabulary from 'YodaFields/Vocabulary'
import { withTheme } from "@rjsf/core";
Expand Down Expand Up @@ -205,7 +205,7 @@ const fields = {
vocabulary: Vocabulary,
affiliation_identifier: AffiliationIdentifier,
person_identifier: PersonIdentifier,
hierarchical_keyword_selector: HierarchicalKeywordSelector
tree_keyword_selector: TreeKeywordSelector
};

const CustomArrayFieldTemplate = (props) => {
Expand Down Expand Up @@ -469,13 +469,13 @@ class YodaForm extends React.Component {
// Turn save mode off.
formContext.saving = false;

if (id === "yoda_HierarchicalKeyword" &&
form.formData.HierarchicalKeyword &&
form.formData.HierarchicalKeyword.value &&
form.formData.HierarchicalKeyword.value.length &&
Object.keys(form.schema.properties.HierarchicalKeyword.items.properties).includes("subject")) {
if (id === "yoda_TreeKeyword" &&
form.formData.TreeKeyword &&
form.formData.TreeKeyword.value &&
form.formData.TreeKeyword.value.length &&
Object.keys(form.schema.properties.TreeKeyword.items.properties).includes("subject")) {

form.formData.HierarchicalKeyword = this.updateHierarchicalKeywords(form, form.formData.HierarchicalKeyword.value)
form.formData.TreeKeyword = this.updateTreeKeywords(form, form.formData.TreeKeyword.value)
}

this.setState({
Expand All @@ -487,7 +487,7 @@ class YodaForm extends React.Component {
updateCompleteness();
}

updateHierarchicalKeywords = (form, value) => {
updateTreeKeywords = (form, value) => {
const newVal = value.map(val => {
if (val.value.endsWith(":")) {
// User created keyword
Expand All @@ -497,8 +497,8 @@ class YodaForm extends React.Component {
} else {
return {
"subject": val.label,
"subjectScheme": form.uiSchema.HierarchicalKeyword["ui:subjectScheme"],
"schemeUri": form.uiSchema.HierarchicalKeyword["ui:schemeUri"],
"subjectScheme": form.uiSchema.TreeKeyword["ui:subjectScheme"],
"schemeUri": form.uiSchema.TreeKeyword["ui:schemeUri"],
"valueUri": val.value.split(":").slice(1).join(":")
}
}
Expand Down
2 changes: 1 addition & 1 deletion research/static/research/js/metadata-form.js

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions vault/metadata-form/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getTemplate } from '@rjsf/utils';
import Select from 'react-select';
import AffiliationIdentifier from 'YodaFields/AffiliationIdentifier'
import Geolocation from 'YodaFields/Geolocation'
import HierarchicalKeywordSelector from 'YodaFields/HierarchicalKeywordSelector'
import TreeKeywordSelector from 'YodaFields/TreeKeywordSelector'
import PersonIdentifier from 'YodaFields/PersonIdentifier'
import Vocabulary from 'YodaFields/Vocabulary'
import { withTheme } from "@rjsf/core";
Expand Down Expand Up @@ -207,7 +207,7 @@ const fields = {
vocabulary: Vocabulary,
affiliation_identifier: AffiliationIdentifier,
person_identifier: PersonIdentifier,
hierarchical_keyword_selector: HierarchicalKeywordSelector
tree_keyword_selector: TreeKeywordSelector
};

const CustomArrayFieldTemplate = (props) => {
Expand Down Expand Up @@ -471,13 +471,13 @@ class YodaForm extends React.Component {
// Turn save mode off.
formContext.saving = false;

if (id === "yoda_HierarchicalKeyword" &&
form.formData.HierarchicalKeyword &&
form.formData.HierarchicalKeyword.value &&
form.formData.HierarchicalKeyword.value.length &&
Object.keys(form.schema.properties.HierarchicalKeyword.items.properties).includes("subject")) {
if (id === "yoda_TreeKeyword" &&
form.formData.TreeKeyword &&
form.formData.TreeKeyword.value &&
form.formData.TreeKeyword.value.length &&
Object.keys(form.schema.properties.TreeKeyword.items.properties).includes("subject")) {

form.formData.HierarchicalKeyword = this.updateHierarchicalKeywords(form, form.formData.HierarchicalKeyword.value)
form.formData.TreeKeyword = this.updateTreeKeywords(form, form.formData.TreeKeyword.value)
}

this.setState({
Expand All @@ -489,7 +489,7 @@ class YodaForm extends React.Component {
updateCompleteness();
}

updateHierarchicalKeywords = (form, value) => {
updateTreeKeywords = (form, value) => {
const newVal = value.map(val => {
if (val.value.endsWith(":")) {
// User created keyword
Expand All @@ -499,8 +499,8 @@ class YodaForm extends React.Component {
} else {
return {
"subject": val.label,
"subjectScheme": form.uiSchema.HierarchicalKeyword["ui:subjectScheme"],
"schemeUri": form.uiSchema.HierarchicalKeyword["ui:schemeUri"],
"subjectScheme": form.uiSchema.TreeKeyword["ui:subjectScheme"],
"schemeUri": form.uiSchema.TreeKeyword["ui:schemeUri"],
"valueUri": val.value.split(":").slice(1).join(":")
}
}
Expand Down
2 changes: 1 addition & 1 deletion vault/static/vault/js/metadata-form.js

Large diffs are not rendered by default.

0 comments on commit e54ac97

Please sign in to comment.