// SPDX-License-Identifier: AGPL-3.0
import { PropertyValue } from "~/models/search-bar";
+import { Vocabulary, getTagKeyLabel, getTagValueLabel } from "~/models/vocabulary";
export const formatDate = (isoDate?: string | null, utc: boolean = false) => {
if (isoDate) {
}
];
-export const formatPropertyValue = (pv: PropertyValue) => {
+export const formatPropertyValue = (pv: PropertyValue, vocabulary?: Vocabulary) => {
+ if (vocabulary && pv.keyID && pv.valueID) {
+ return `${getTagKeyLabel(pv.keyID, vocabulary)}: ${getTagValueLabel(pv.keyID, pv.valueID!, vocabulary)}`;
+ }
if (pv.key) {
return pv.value
? `${pv.key}: ${pv.value}`
// SPDX-License-Identifier: AGPL-3.0
import * as React from 'react';
-import { Dispatch } from 'redux';
+import { Dispatch, compose } from 'redux';
import { connect } from 'react-redux';
import { InjectedFormProps, formValueSelector } from 'redux-form';
import { Grid, withStyles, StyleRulesCallback, WithStyles, Button } from '@material-ui/core';
import { SearchBarKeyField, SearchBarValueField } from '~/views-components/form-fields/search-bar-form-fields';
import { Chips } from '~/components/chips/chips';
import { formatPropertyValue } from "~/common/formatters";
+import { Vocabulary } from '~/models/vocabulary';
+import { connectVocabulary } from '../resource-properties-form/property-field-common';
type CssRules = 'label' | 'button';
pristine: boolean;
propertyValues: PropertyValue;
fields: PropertyValue[];
+ vocabulary: Vocabulary;
}
interface SearchBarAdvancedPropertiesViewActionProps {
}
});
-export const SearchBarAdvancedPropertiesView = connect(mapStateToProps, mapDispatchToProps)(
+export const SearchBarAdvancedPropertiesView = compose(
+ connectVocabulary,
+ connect(mapStateToProps, mapDispatchToProps))(
withStyles(styles)(
- ({ classes, fields, propertyValues, setProps, addProp, getAllFields }: SearchBarAdvancedPropertiesViewProps) =>
+ ({ classes, fields, propertyValues, setProps, addProp, getAllFields, vocabulary }: SearchBarAdvancedPropertiesViewProps) =>
<Grid container item xs={12} spacing={16}>
<Grid item xs={2} className={classes.label}>Properties</Grid>
<Grid item xs={4}>
<Chips values={getAllFields(fields)}
deletable
onChange={setProps}
- getLabel={(field: PropertyValue) => formatPropertyValue(field)} />
+ getLabel={(field: PropertyValue) => formatPropertyValue(field, vocabulary)} />
</Grid>
</Grid>
)