
org.grails.scaffolding.registry.input.CurrencyInputRenderer.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fields Show documentation
Show all versions of fields Show documentation
Fields integration for Grails
The newest version!
package org.grails.scaffolding.registry.input
import org.grails.scaffolding.model.property.DomainProperty
import org.grails.scaffolding.registry.DomainInputRenderer
import groovy.transform.CompileStatic
/**
* The default renderer for rendering {@link Currency} properties
*
* @author James Kleeh
*/
@CompileStatic
class CurrencyInputRenderer implements MapToSelectInputRenderer {
String getOptionValue(Currency currency) {
currency.currencyCode
}
String getOptionKey(Currency currency) {
currency.currencyCode
}
protected List getDefaultCurrencyCodes() {
['EUR', 'XCD', 'USD', 'XOF', 'NOK', 'AUD',
'XAF', 'NZD', 'MAD', 'DKK', 'GBP', 'CHF',
'XPF', 'ILS', 'ROL', 'TRL']
}
Map getOptions() {
defaultCurrencyCodes.collectEntries {
Currency currency = Currency.getInstance(it)
[(getOptionKey(currency)): getOptionValue(currency)]
}
}
Currency getDefaultOption() {
Currency.getInstance(Locale.default)
}
@Override
boolean supports(DomainProperty property) {
property.type in Currency
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy