Skip to content

Commit

Permalink
Fixed issues with filters
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jun 23, 2021
1 parent 93f6527 commit edd222f
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backend/src/main/resources/nameid-filter.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"type": "object",
"properties": {
"nameIdFormatFilterTargetType": {
"title": "",
"title": "label.filter-target-type",
"type": "string",
"default": "ENTITY",
"enum": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export function PrimitiveProperty ({ property, columns }) {

const width = usePropertyWidth(columns);

const getValue = (v) => {
return property.enum && property.enumNames ? property.enumNames[property.enum.indexOf(v)] : v;
}

return (
<div tabIndex="0">
{property.differences && <span className="sr-only">Changed:</span> }
Expand All @@ -21,7 +25,7 @@ export function PrimitiveProperty ({ property, columns }) {
<Translate value={property.name}>{ property.name }</Translate>
</span>
{property.value.map((v, valIdx) =>
<PropertyValue key={`prop-${valIdx}`} value={v} name={property.name} columns={columns} index={valIdx} />
<PropertyValue key={`prop-${valIdx}`} value={getValue(v)} name={property.name} columns={columns} index={valIdx} />
) }
</div>

Expand Down
5 changes: 4 additions & 1 deletion ui/src/app/metadata/component/properties/PropertyValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Popover from 'react-bootstrap/Popover';
import OverlayTrigger from 'react-bootstrap/OverlayTrigger';

import { usePropertyWidth } from './hooks';
import Translate from '../../../i18n/components/translate';

export function PropertyValue ({ name, value, columns, className }) {

Expand All @@ -20,7 +21,9 @@ export function PropertyValue ({ name, value, columns, className }) {
className={`d-block text-truncate ${className}`}
role="definition"
style={columns ? { width } : {}}>
{value !== undefined ? value.toString() : (value === false) ? value.toString() : '-'}
<Translate value={value !== undefined ? value.toString() : (value === false) ? value.toString() : '-'}>
{value !== undefined ? value.toString() : (value === false) ? value.toString() : '-'}
</Translate>
</span>
</OverlayTrigger>
: <span className={`d-block text-truncate ${className}`} style={columns ? { width } : {}}>-</span>}
Expand Down
6 changes: 5 additions & 1 deletion ui/src/app/metadata/hooks/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ export function useMetadataUpdater (path, current) {
}));
});
}
return Promise.resolve(req);
if (response.ok) {
return Promise.resolve(req);
} else {
return Promise.reject(req);
}
}

return {
Expand Down
7 changes: 6 additions & 1 deletion ui/src/app/metadata/new/NewFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,27 @@ import { MetadataForm } from '../hoc/MetadataFormContext';
import { MetadataSchema } from '../hoc/MetadataSchema';
import { useMetadataFilters, useMetadataFilterTypes } from '../hooks/api';
import { MetadataFilterTypeSelector } from '../wizard/MetadataFilterTypeSelector';
import { createNotificationAction, NotificationTypes, useNotificationDispatcher } from '../../notifications/hoc/Notifications';

export function NewFilter() {

const { id, section } = useParams();
const history = useHistory();
const types = useMetadataFilterTypes();
const dispatch = useNotificationDispatcher();

const { post, response, loading } = useMetadataFilters(id, {});

const [blocking, setBlocking] = React.useState(false);


async function save(metadata) {
await post(``, metadata);
const resp = await post(``, metadata);
if (response.ok) {
dispatch(createNotificationAction('Filter saved'));
gotoDetail({ refresh: true });
} else {
dispatch(createNotificationAction(resp.cause, NotificationTypes.DANGER));
}
};

Expand Down
10 changes: 7 additions & 3 deletions ui/src/app/metadata/view/EditFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ import { MetadataSchema } from '../hoc/MetadataSchema';
import { getMetadataPath, useMetadataUpdater } from '../hooks/api';
import { useMetadataFilterObject } from '../hoc/MetadataFilterSelector';
import API_BASE_PATH from '../../App.constant';
import { createNotificationAction, NotificationTypes, useNotificationDispatcher } from '../../notifications/hoc/Notifications';

export function EditFilter() {

const dispatch = useNotificationDispatcher();

const { id, filterId } = useParams();
const filter = useMetadataFilterObject();
const history = useHistory();
Expand All @@ -33,10 +36,11 @@ export function EditFilter() {

function save(metadata) {
setBlocking(false);
update(``, metadata).then(() => {
update(``, metadata).then((resp) => {
dispatch(createNotificationAction('Filter saved'));
gotoDetail({ refresh: true });
}).catch(() => {
window.location.reload();
}).catch((error) => {
dispatch(createNotificationAction(error.cause, NotificationTypes.DANGER));
});
};

Expand Down
2 changes: 0 additions & 2 deletions ui/src/app/metadata/view/MetadataUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ export function MetadataUpload() {

async function save({serviceProviderName, file, url}) {

console.log(serviceProviderName, file);

setSaving(true);

const f = file?.length > 0 ? file[0] : null;
Expand Down

0 comments on commit edd222f

Please sign in to comment.