-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds FileTypesWithFunctionalEquivalents component; updates form table…
… component to accept needed style changes; adds Google Font icons and license.
- Loading branch information
1 parent
6311d8c
commit 78cc9ce
Showing
11 changed files
with
155 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -410,17 +410,14 @@ describe('FormField - Tests', () => { | |
}); | ||
|
||
it('should remove single on click', () => { | ||
cy.spy(props, 'onChange'); | ||
cy.spy(props, 'onChange').as('onChange'); | ||
mount(<FormField {...props}/>); | ||
cy.get('#dataCustodianEmail').type('[email protected]'); | ||
cy.get('#dataCustodianEmail').type('{enter}'); | ||
const firstPill = cy.get('.formField-dataCustodianEmail .pill').first(); | ||
firstPill.should('exist'); | ||
firstPill.click(); | ||
firstPill.then(() => { | ||
expect(props.onChange).to.be.calledWith({key: 'dataCustodianEmail', value: [], isValid: true}); // code value | ||
cy.get('.formField-dataCustodianEmail .pill').should('not.exist'); | ||
}); | ||
cy.get('.formField-dataCustodianEmail .pill').first().should('exist'); | ||
cy.get('.formField-dataCustodianEmail .pill').first().click(); | ||
cy.get('.formField-dataCustodianEmail .pill').should('not.exist'); | ||
cy.get('@onChange').should('have.been.called.with', {key: 'dataCustodianEmail', value: [], isValid: true}); | ||
}); | ||
|
||
it('should remove [x, 1, 2] from array on click', () => { | ||
|
@@ -577,7 +574,7 @@ describe('FormField - Tests', () => { | |
mount(<FormField {...props}/>); | ||
cy.get('#studyType').type('asdf{enter}'); | ||
cy.get('#studyType').then(() => { | ||
expect(props.onChange).to.not.be.called; | ||
expect(props.onChange).to.have.callCount(0); | ||
}); | ||
}); | ||
|
||
|
@@ -816,6 +813,28 @@ describe('FormField - Tests', () => { | |
cy.get('#delete-table-row-fileTypes-0').should('be.disabled'); | ||
}); | ||
}); | ||
|
||
it('should be able to override some style elements', ()=>{ | ||
const customProps = { | ||
...props, | ||
styleProps: { | ||
enableAddingRowStyle: { | ||
display: 'flex', | ||
width: '100%', | ||
justifyContent: 'flex-start', | ||
marginTop: 10 | ||
}, | ||
addingRowButtonClassName: 'button-complex-submission', | ||
addRowButtonIconClassName: 'button-icon button-icon-circle-plus-outline', | ||
removeRowButtonIconClassName: 'button-icon button-icon-close' | ||
} | ||
}; | ||
mount(<FormTable {...customProps} />); | ||
cy.get('#fileTypes-0-functionalEquivalence').type('hello'); | ||
cy.get('#add-new-table-row-fileTypes').should('have.class','button-complex-submission'); | ||
cy.get('#add-new-table-row-fileTypes').find('span').should('have.class','button-icon-circle-plus-outline'); | ||
cy.get('#delete-table-row-fileTypes-0').find('span').should('have.class', 'button-icon-close'); | ||
}); | ||
}); | ||
describe('Prop validation', () => { | ||
it('should not allow mounting if unknown prop', (done) => { | ||
|
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
44 changes: 44 additions & 0 deletions
44
src/components/forms/FileTypesWithFunctionalEquivalents.tsx
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,44 @@ | ||
import React from 'react'; | ||
import {FormFieldTypes, FormTable} from './forms'; | ||
|
||
export type FileTypeAndFunctionalEquivalence = { | ||
type: string, | ||
value: string | ||
} | ||
export type FileTypesWithFunctionalEquivalentsProps = { | ||
id: string, | ||
onChange: ({key, value} :{key: string, value: never}) => void, | ||
defaultValue: Array<FileTypeAndFunctionalEquivalence> | ||
} | ||
|
||
export const FileTypesWithFunctionalEquivalents = (props: FileTypesWithFunctionalEquivalentsProps) => { | ||
const {id, onChange, defaultValue} = props; | ||
return (<FormTable | ||
id={id} | ||
formFields={[ | ||
{ | ||
id: id + '_fileType', | ||
name: 'fileType', | ||
title: 'File Type', | ||
type: FormFieldTypes.SELECT, | ||
selectOptions: ['Arrays', 'Genome', 'Exome', 'Survey', 'Phenotype'], | ||
}, | ||
{ | ||
id: id + '_functionalEquivalence', | ||
name: 'functionalEquivalence', | ||
title: 'Functional Equivalence', | ||
placeholder: 'Type', | ||
} | ||
]} | ||
defaultValue={defaultValue} | ||
enableAddingRow={true} | ||
addRowLabel='Add File' | ||
minLength={1} | ||
onChange={onChange} | ||
styleProps={{enableAddingRowStyle:{ display: 'flex', width: '100%', justifyContent: 'flex-start', marginTop: 10 }, | ||
addingRowButtonClassName:'button-complex-submission', | ||
addRowButtonIconClassName:'button-icon button-icon-circle-plus-outline', | ||
removeRowButtonIconClassName:'button-icon button-icon-close' | ||
}} | ||
/>); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
The files in this directory were generated on 2/25/2025 using Google's Icon generator. | ||
|
||
At the time the icons were generated, they were subject to the APACHE LICENSE, VERSION 2.0: | ||
https://www.apache.org/licenses/LICENSE-2.0.html | ||
|
||
URLs to regenerate the icons: | ||
|
||
[Upload](https://fonts.google.com/icons?selected=Material+Symbols+Outlined:upload:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=upload&icon.size=24&icon.color=%234D72AA) | ||
|
||
[Add](https://fonts.google.com/icons?selected=Material+Symbols+Outlined:add_circle:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=circle&icon.size=24&icon.color=%234D72AA) | ||
|
||
[Delete](https://fonts.google.com/icons?selected=Material+Symbols+Outlined:add_circle:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=circle&icon.size=24&icon.color=%234D72AA) | ||
|
||
[X](https://fonts.google.com/icons?selected=Material+Symbols+Outlined:close_small:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=remove&icon.size=24&icon.color=%234D72AA) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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