forked from open-formulieren/open-forms
-
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.
[maykinmedia/open-producten#24] Bump formio-builder & add product pri…
…ce component
- Loading branch information
Showing
9 changed files
with
59 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -10,4 +10,5 @@ | |
"map": "array", | ||
"editgrid": "array", | ||
"datetime": "datetime", | ||
# TODO: product price? | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* A form widget to select product prices. | ||
*/ | ||
import {Formio} from 'formiojs'; | ||
|
||
import {localiseSchema} from './i18n'; | ||
import {get} from '../../utils/fetch'; | ||
import {PRODUCT_PRICES_ENDPOINT} from '../admin/form_design/constants'; // TODO add new endpoint or add price options to existing one. | ||
|
||
export const getProducts = async () => { | ||
const response = await get(PRODUCT_PRICES_ENDPOINT); | ||
return response.data.map(item => ({ | ||
label: item.name, | ||
value: item.uuid, | ||
})); | ||
}; | ||
|
||
const Select = Formio.Components.components.select; | ||
|
||
class ProductPrice extends Select { | ||
static schema(...extend) { | ||
const schema = Select.schema( | ||
{ | ||
label: 'Select a product', | ||
key: 'productPrice', | ||
type: 'productPrice', | ||
product: '' | ||
}, | ||
...extend | ||
); | ||
return localiseSchema(schema); | ||
} | ||
|
||
static get builderInfo() { | ||
return { | ||
title: 'Product Price', | ||
icon: 'file', | ||
group: 'basic', | ||
weight: 10, | ||
schema: ProductPrice.schema(), | ||
}; | ||
} | ||
|
||
get defaultSchema() { | ||
return ProductPrice.schema(); | ||
} | ||
} | ||
|
||
export default ProductPrice; |
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