Skip to content

Commit

Permalink
Merge pull request #277 from performant-software/feature/cdc204_relat…
Browse files Browse the repository at this point in the history
…ed_records

CDC #204 - Related Records
  • Loading branch information
dleadbetter authored May 9, 2024
2 parents 92e7675 + 74bd6bc commit f5943bf
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 27 deletions.
6 changes: 3 additions & 3 deletions packages/controlled-vocabulary/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/controlled-vocabulary",
"version": "2.2.0",
"version": "2.2.1",
"description": "A package of components to allow user to configure dropdown elements. Use with the \"controlled_vocabulary\" gem.",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand All @@ -23,8 +23,8 @@
"underscore": "^1.13.2"
},
"peerDependencies": {
"@performant-software/semantic-components": "^2.2.0",
"@performant-software/shared-components": "^2.2.0",
"@performant-software/semantic-components": "^2.2.1",
"@performant-software/shared-components": "^2.2.1",
"react": ">= 16.13.1 < 19.0.0",
"react-dom": ">= 16.13.1 < 19.0.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/core-data/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/core-data",
"version": "2.2.0",
"version": "2.2.1",
"description": "A package of components used with the Core Data platform.",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand Down Expand Up @@ -37,8 +37,8 @@
"underscore": "^1.13.2"
},
"peerDependencies": {
"@performant-software/shared-components": "^2.2.0",
"@performant-software/geospatial": "^2.2.0",
"@performant-software/shared-components": "^2.2.1",
"@performant-software/geospatial": "^2.2.1",
"@peripleo/maplibre": "^0.5.2",
"@peripleo/peripleo": "^0.5.2",
"react": ">= 16.13.1 < 19.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/geospatial/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/geospatial",
"version": "2.2.0",
"version": "2.2.1",
"description": "A package of components for all things map-related.",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/semantic-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/semantic-components",
"version": "2.2.0",
"version": "2.2.1",
"description": "A package of shared components based on the Semantic UI Framework.",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand Down Expand Up @@ -35,7 +35,7 @@
"zotero-translation-client": "^5.0.1"
},
"peerDependencies": {
"@performant-software/shared-components": "^2.2.0",
"@performant-software/shared-components": "^2.2.1",
"@samvera/clover-iiif": "^2.3.2",
"react": ">= 16.13.1 < 19.0.0",
"react-dnd": "^11.1.3",
Expand Down
13 changes: 13 additions & 0 deletions packages/semantic-ui/src/components/AssociatedDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class AssociatedDropdown extends Component<Props, State> {
{ this.renderEditButton() }
{ this.renderAddButton() }
{ this.renderClearButton() }
{ this.renderButtons() }
</Button.Group>
{ this.renderModal() }
{ this.state.saved && (
Expand Down Expand Up @@ -284,6 +285,18 @@ class AssociatedDropdown extends Component<Props, State> {
);
}

/**
* Renders the extra buttons.
*
* @returns {*}
*/
renderButtons() {
const excludeButtons = [BUTTON_ADD, BUTTON_CLEAR, BUTTON_EDIT];
const buttons = _.filter(this.props.buttons, (button) => !excludeButtons.includes(button.name));

return _.map(buttons, (button) => this.renderButton(button.name, _.omit(button, 'name')));
}

/**
* Renders the clear button.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/shared-components",
"version": "2.2.0",
"version": "2.2.1",
"description": "A package of shared, framework agnostic, components.",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand Down
38 changes: 38 additions & 0 deletions packages/storybook/src/semantic-ui/AssociatedDropdown.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,3 +465,41 @@ export const CustomButtons = () => (
upward={boolean('Open upward', false)}
/>
);

export const AdditionalButtons = () => (
<AssociatedDropdown
buttons={[{
name: 'add',
}, {
name: 'clear',
}, {
basic: true,
name: 'navigate',
content: 'Navigate',
icon: 'world',
onClick: action('navigate'),
type: 'button'
}]}
collectionName='items'
modal={{
component: AddModal,
props: {
onInitialize: () => Promise.resolve({ })
},
onSave: () => {
action('save')();
return Promise.resolve({});
}
}}
onSearch={(search) => Api.onLoad({ items, search, sort_by: 'text' })}
onSelection={action('selection')}
placeholder={text('Placeholder', 'Search')}
renderOption={(item) => ({
key: item.id,
value: item.id,
text: item.company,
description: item.country
})}
upward={boolean('Open upward', false)}
/>
);
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,36 @@ export const CustomAddButton = useDragDrop(() => {
/>
);
});

export const CustomActions = useDragDrop(() => {
const [items, setItems] = useState([]);

/**
* Removes the passed item from the list.
*
* @type {function(*): void}
*/
const onDelete = useCallback((item) => setItems((prevItems) => _.filter(prevItems, (i) => i !== item)), []);

/**
* Adds the passed item to the list.
*
* @type {function(*): void}
*/
const onSave = useCallback((item) => setItems((prevItems) => [...prevItems, item]), []);

return (
<UserDefinedFieldsEmbeddedList
actions={[{
name: 'edit',
icon: 'pencil'
}, {
name: 'delete',
icon: 'times'
}]}
items={items}
onDelete={onDelete}
onSave={onSave}
/>
);
});
6 changes: 3 additions & 3 deletions packages/user-defined-fields/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/user-defined-fields",
"version": "2.2.0",
"version": "2.2.1",
"description": "A package of components used for allowing end users to define fields on models. Use with the \"user_defined_fields\" gem.",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand All @@ -23,8 +23,8 @@
"underscore": "^1.13.2"
},
"peerDependencies": {
"@performant-software/semantic-components": "^2.2.0",
"@performant-software/shared-components": "^2.2.0",
"@performant-software/semantic-components": "^2.2.1",
"@performant-software/shared-components": "^2.2.1",
"react": ">= 16.13.1 < 19.0.0",
"react-dom": ">= 16.13.1 < 19.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import UserDefinedFieldModal from './UserDefinedFieldModal';
import UserDefinedFields from '../utils/UserDefinedFields';

type Props = EmbeddedListProps & {
actions?: Array<any>,
defaults: any,
excludeColumns?: Array<string>
};

const OMIT_PROPS = [
'actions',
'columns',
'defaults',
'excludeColumns',
Expand All @@ -34,11 +34,6 @@ const UserDefinedFieldsEmbeddedList = (props: Props) => {
return (
<EmbeddedList
{..._.omit(props, OMIT_PROPS)}
actions={[{
name: 'edit'
}, {
name: 'delete'
}]}
columns={[{
name: 'table_name',
label: i18n.t('UserDefinedFieldsEmbeddedList.columns.table'),
Expand Down Expand Up @@ -80,4 +75,12 @@ const UserDefinedFieldsEmbeddedList = (props: Props) => {
);
};

UserDefinedFieldsEmbeddedList.defaultProps = {
actions: [{
name: 'edit'
}, {
name: 'delete'
}]
};

export default UserDefinedFieldsEmbeddedList;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type Props = ListTableProps & {
};

const OMIT_PROPS = [
'actions',
'collectionName',
'columns',
'defaults',
Expand All @@ -39,11 +38,6 @@ const UserDefinedFieldsList: ComponentType<any> = (props: Props) => {
return (
<ListTable
{..._.omit(props, OMIT_PROPS)}
actions={[{
name: 'edit'
}, {
name: 'delete'
}]}
columns={[{
name: 'table_name',
label: i18n.t('UserDefinedFieldsList.columns.table'),
Expand Down Expand Up @@ -89,4 +83,12 @@ const UserDefinedFieldsList: ComponentType<any> = (props: Props) => {
);
};

UserDefinedFieldsList.defaultProps = {
actions: [{
name: 'edit'
}, {
name: 'delete'
}]
};

export default UserDefinedFieldsList;
2 changes: 1 addition & 1 deletion packages/visualize/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@performant-software/visualize",
"version": "2.2.0",
"version": "2.2.1",
"description": "A package of components used for data visualization",
"license": "MIT",
"main": "./dist/index.cjs.js",
Expand Down
2 changes: 1 addition & 1 deletion react-components.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"packages/user-defined-fields",
"packages/visualize"
],
"version": "2.2.0"
"version": "2.2.1"
}

0 comments on commit f5943bf

Please sign in to comment.