-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add form display configuration * Remove code * Add currency feedback * wip * wip * final fixes * Remove unnecessary code --------- Co-authored-by: Maxim Buur <[email protected]>
- Loading branch information
1 parent
473af32
commit 7412b30
Showing
9 changed files
with
216 additions
and
93 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
103 changes: 103 additions & 0 deletions
103
...ects/valtimo/components/src/lib/components/form-io/form-io-currency/currency-edit-form.ts
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,103 @@ | ||
/* | ||
* Copyright 2015-2024 Ritense BV, the Netherlands. | ||
* | ||
* Licensed under EUPL, Version 1.2 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" basis, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import {Components} from 'formiojs'; | ||
|
||
const TextFieldEditForm = Components.components.textfield.editForm; | ||
|
||
export const currencyEditForm = () => { | ||
const editForm = TextFieldEditForm(); | ||
|
||
const localeSelection = { | ||
type: 'select', | ||
input: true, | ||
key: 'customOptions.currencyLocale', | ||
label: 'Currency locale', | ||
tooltip: 'The locale used for the currency input', | ||
weight: 20, | ||
defaultValue: 'nl-NL', | ||
dataSrc: 'values', | ||
data: { | ||
values: [ | ||
{ | ||
label: 'Dutch (Netherlands)', | ||
value: 'nl-NL', | ||
}, | ||
{ | ||
label: 'English (US)', | ||
value: 'en-US', | ||
}, | ||
{ | ||
label: 'English (UK)', | ||
value: 'en-GB', | ||
}, | ||
{ | ||
label: 'German', | ||
value: 'de-DE', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const currencySelection = { | ||
type: 'select', | ||
input: true, | ||
key: 'customOptions.currencyCurrency', | ||
label: 'Currency', | ||
tooltip: 'The currency used for the currency input', | ||
weight: 20, | ||
defaultValue: 'EUR', | ||
dataSrc: 'values', | ||
data: { | ||
values: [ | ||
{ | ||
label: 'Euro', | ||
value: 'EUR', | ||
}, | ||
{ | ||
label: 'British pound', | ||
value: 'GBP', | ||
}, | ||
{ | ||
label: 'United States Dollar', | ||
value: 'USD', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const allowEmptyValueCheckbox = { | ||
type: 'checkbox', | ||
input: true, | ||
key: 'customOptions.allowEmptyValue', | ||
label: 'Allow Empty Value', | ||
tooltip: 'Check to allow empty values for this field', | ||
weight: 10, | ||
defaultValue: false, // Default to false | ||
}; | ||
|
||
const tabsComponent = editForm.components.find(component => component.key === 'tabs'); | ||
if (tabsComponent) { | ||
const displayTab = tabsComponent.components.find(tab => tab.key === 'display'); | ||
if (displayTab) { | ||
displayTab.components.unshift(localeSelection); | ||
displayTab.components.unshift(currencySelection); | ||
displayTab.components.unshift(allowEmptyValueCheckbox); | ||
} | ||
} | ||
|
||
return editForm; | ||
}; |
14 changes: 1 addition & 13 deletions
14
...ts/valtimo/components/src/lib/components/form-io/form-io-currency/currency.component.html
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 |
---|---|---|
@@ -1,17 +1,5 @@ | ||
<div class="currencyForm-container" [formGroup]="currencyForm"> | ||
<div class="input-group"> | ||
<input id="currency" formControlName="currency" class="form-control" placeholder="0.00" /> | ||
<div | ||
class="formio-errors invalid-feedback" | ||
*ngIf=" | ||
currencyForm.controls.currency.invalid && | ||
(currencyForm.controls.currency.touched || !currencyForm.controls.currency.pristine) && | ||
currencyForm.controls?.currency?.errors | ||
" | ||
> | ||
<div class="form-text error"> | ||
{{ 'formioTranslations.formioCurrencyComponent.errorMessage' | translate }} | ||
</div> | ||
</div> | ||
<input #currencyElement id="currency" formControlName="currencyValue" class="form-control" /> | ||
</div> | ||
</div> |
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
Oops, something went wrong.