Skip to content

Commit

Permalink
feat: refactor InputCurrency component to handle currency display option
Browse files Browse the repository at this point in the history
  • Loading branch information
maksimzinchuk committed Jun 5, 2024
1 parent b96e239 commit f11a193
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ export default {
setup(props: ExtractPropTypes<typeof componentProps> & { element: InputCurrencySchema }) {
return () => {
const options =
toValue(getModel(props.element.options, props.fieldContext ?? {})) ||
toValue(unref(props.bladeContext.scope)?.[props.element.options]);
(safeIn("options", props.element) &&
props.element.options &&
(toValue(getModel(props.element.options, props.fieldContext ?? {})) ||
toValue(unref(props.bladeContext.scope)?.[props.element.options]))) ??
undefined;

const contextProperty =
safeIn("optionProperty", props.element) &&
Expand All @@ -34,6 +37,7 @@ export default {
{},
{
option: toValue(scopedProperty ?? contextProperty),
currencyDisplay: props.element.currencyDisplay,
optionLabel: props.element.optionLabel,
optionValue: props.element.optionValue,
options,
Expand Down
7 changes: 6 additions & 1 deletion framework/shared/modules/dynamic/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from "./../../../../ui/components";
import { ITableColumns, IValidationRules, MenuItemConfig } from "../../../../core/types";
import type { ComponentProps } from "./../../../utilities/vueUtils";
import VcInputCurrency from "../../../../ui/components/molecules/vc-input-currency/vc-input-currency.vue";

export type KeysOfUnion<T> = T extends T ? keyof T : never;

Expand Down Expand Up @@ -644,7 +645,7 @@ export interface InputCurrencySchema extends Omit<SchemaBase, "multilanguage"> {
* List of currency options to be displayed in the dropdown.
* @description Array should be defined in the blade `scope`.
*/
options: string;
options?: string;
/**
* Name of property that holds currency value.
* @type {string}
Expand All @@ -671,6 +672,10 @@ export interface InputCurrencySchema extends Omit<SchemaBase, "multilanguage"> {
* Text below control.
*/
hint?: string;
/**
* How to show the currency.
*/
currencyDisplay?: ComponentProps<typeof VcInputCurrency>["currencyDisplay"];
}

/**
Expand Down

0 comments on commit f11a193

Please sign in to comment.