-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added filter version list comparison
- Loading branch information
Showing
12 changed files
with
145 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
ui/src/app/metadata/domain/filter/component/MetadataFilterVersionListItem.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import React from 'react'; | ||
| import { faCheckSquare, faSquare } from '@fortawesome/free-regular-svg-icons'; | ||
| import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
| import { MetadataConfiguration } from '../../../component/MetadataConfiguration'; | ||
| import { getDefinition } from '../../../domain/index'; | ||
| import { useMetadataSchema } from '../../../hooks/api'; | ||
| import { useMetadataConfiguration } from '../../../hooks/configuration'; | ||
|
|
||
| export function MetadataFilterVersionListItem ({ filters, width, selected, index, comparing, limited, onSelect }) { | ||
|
|
||
| const filter = filters.find(f => f.hasOwnProperty('@type')); | ||
| const type = filter['@type']; | ||
|
|
||
| React.useEffect(() => console.log(filters), [filters]); | ||
|
|
||
| const definition = React.useMemo(() => getDefinition(type), [type]); | ||
|
|
||
| const { get, response } = useMetadataSchema(); | ||
|
|
||
| const [schema, setSchema] = React.useState(); | ||
|
|
||
| async function loadSchema(d) { | ||
| const source = await get(`/${d.schema}`) | ||
| if (response.ok) { | ||
| setSchema(source); | ||
| } | ||
| } | ||
|
|
||
| /*eslint-disable react-hooks/exhaustive-deps*/ | ||
| React.useEffect(() => { loadSchema(definition) }, [definition]); | ||
|
|
||
| const config = useMetadataConfiguration([...filters.filter(f => !!f)], schema, definition, limited); | ||
|
|
||
| return ( | ||
| <React.Fragment> | ||
| {!comparing && | ||
| <div className="d-flex border-bottom border-light"> | ||
| <div style={{ width }} className="py-2"> | ||
| {index + 1} | ||
| </div> | ||
| {filters.map((filter, n) => | ||
| <React.Fragment key={n}> | ||
|
|
||
| <div style={{ width }} className="border-primary"> | ||
| {filter ? | ||
| <div className={`p-2 d-flex align-items-center ${((n % 2 === 0) && selected !== filter.resourceId) ? 'bg-lighter' : 'bg-primary-light'}`}> | ||
| <div className="w-50"> | ||
| <p className="mb-0">{filter.name}</p> | ||
| <p className="mb-0 text-muted">{filter['@type']}</p> | ||
| </div> | ||
| {filter.comparable && | ||
| <button className="btn btn-link mx-auto" onClick={() => onSelect(filter.resourceId)}> | ||
| <FontAwesomeIcon icon={selected === filter.resourceId ? faCheckSquare : faSquare} size="lg" /> | ||
| <span className="sr-only">Compare</span> | ||
| </button> | ||
| } | ||
| </div> | ||
| : | ||
| <div className="p-2 w-100">-</div> | ||
| } | ||
| </div> | ||
|
|
||
| </React.Fragment> | ||
| )} | ||
| </div> | ||
| } | ||
| {comparing === filter.resourceId && | ||
| <MetadataConfiguration configuration={config} /> | ||
| } | ||
| </React.Fragment> | ||
| ); | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters