-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from open-formulieren/feature/op-24-product-pr…
…ice-component add productPrice component
- Loading branch information
Showing
4 changed files
with
107 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {InputComponentSchema} from '..'; | ||
|
||
type Validator = 'required'; | ||
type TranslatableKeys = 'label' | 'description' | 'tooltip'; | ||
|
||
export type ProductPriceInputSchema = InputComponentSchema<never, Validator, TranslatableKeys>; | ||
|
||
/** | ||
* Experimental feature that could change. | ||
* @experimental | ||
* @group Form.io components | ||
* @category Concrete types | ||
*/ | ||
export interface ProductPriceComponentSchema | ||
extends Omit<ProductPriceInputSchema, 'hideLabel' | 'disabled'> { | ||
type: 'productPrice'; | ||
product: string; | ||
} |
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,86 @@ | ||
import {expectAssignable, expectNotAssignable} from 'tsd'; | ||
|
||
import {ProductPriceComponentSchema} from '../../../lib/'; | ||
|
||
// minimal productPrice component schema | ||
expectAssignable<ProductPriceComponentSchema>({ | ||
id: '123', | ||
type: 'productPrice', | ||
key: 'aProductPrice', | ||
label: 'A Product Price', | ||
product: '123' | ||
} as const); | ||
|
||
// different component type | ||
expectNotAssignable<ProductPriceComponentSchema>({ | ||
type: 'textfield', | ||
} as const); | ||
|
||
// using unsupported properties | ||
expectNotAssignable<ProductPriceComponentSchema>({ | ||
id: '123', | ||
type: 'productPrice', | ||
key: 'aProductPrice', | ||
label: 'A Product Price', | ||
product: '123', | ||
hideLabel: true, | ||
} as const); | ||
|
||
// No defaultValue allowed | ||
expectNotAssignable<ProductPriceComponentSchema>({ | ||
id: '123', | ||
type: 'productPrice', | ||
key: 'aProductPrice', | ||
label: 'A Product Price', | ||
product: '123', | ||
defaultValue: 1, | ||
}); | ||
|
||
// full, correct schema | ||
expectAssignable<ProductPriceComponentSchema>({ | ||
id: '8aosjaw', | ||
type: 'productPrice', | ||
// basic tab in builder form | ||
key: 'aProductPrice', | ||
label: 'A Product Price', | ||
product: '123', | ||
description: 'Sample description', | ||
tooltip: 'A tooltip', | ||
showInSummary: true, | ||
showInEmail: false, | ||
showInPDF: true, | ||
// multiple: false, | ||
hidden: false, | ||
clearOnHide: true, | ||
isSensitiveData: false, | ||
// advanced tab in builder form | ||
conditional: { | ||
show: undefined, | ||
when: undefined, | ||
eq: undefined, | ||
}, | ||
// validation tab in builder form | ||
validate: { | ||
required: false, | ||
plugins: undefined, | ||
}, | ||
translatedErrors: { | ||
nl: { | ||
required: 'Je moet een waarde opgeven!!!', | ||
}, | ||
}, | ||
errors: { | ||
// translatedErrors is converted into errors by the backend | ||
required: 'Je moet een waarde opgeven!!!', | ||
}, | ||
// registration tab in builder form | ||
registration: { | ||
attribute: '', | ||
}, | ||
// translations tab in builder form | ||
openForms: { | ||
translations: { | ||
nl: {tooltip: 'bar'}, | ||
}, | ||
}, | ||
}); |