Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Currency Mask Overwritting Decimal #341

Open
lhalver1 opened this issue Apr 2, 2020 · 6 comments
Open

Currency Mask Overwritting Decimal #341

lhalver1 opened this issue Apr 2, 2020 · 6 comments

Comments

@lhalver1
Copy link

lhalver1 commented Apr 2, 2020

I want to use this currency mask with overwrite set to true, but then it overwrites the decimal, which I cannot have. I would like to enter the dollar amount, then enter a decimal, the cursor shifts over to the cents and I can then enter the cents. Is there a way to do this?

moneyMask: any = {
    mask: '$num',
    blocks: {
      num: {
        mask: Number,
        signed: true,
        scale: 2,
        thousandsSeparator: ',',
        padFractionalZeros: true,
        radix: '.'
      }
    },
    overwrite: true
  };
@uNmAnNeR
Copy link
Owner

hi! currently no, overwrite is a base mask option which works for any character.
So as i understand you need something like
<int part with overwrite><radix><fraction part with overwrite>
I think this can be done this with pattern mask blocks, but whole Number mask validators/format will be lost in that case.

{
    mask: '$int,frac',
    blocks: {
      int: {
        mask: Number,
        signed: true,
        scale: 0,
        overwrite: true,
      },
      frac: {
        mask: MaskedRange,
        min: 0,
        max: 99,
        overwrite: true,
      }
    },
  };

But this is just an idea, i did not check it.

@uNmAnNeR
Copy link
Owner

@lhalver1 hm.. probably this is just like what you described in #340
So i think the solution is to use overwrite option per block. Does this work for you? In theory... because currently it does not work and should be fixed :)

@lhalver1
Copy link
Author

Hi @uNmAnNeR
Yeah, this would work for me but the issue mentioned in #340 I then get the weird bug when it places the thousandSeparator it deletes/eats/overwrites my first decimal place. If that bug was worked out, then this would definitely work for me.

@lhalver1
Copy link
Author

lhalver1 commented Jun 2, 2020

@uNmAnNeR I cannot get the overwrite option to work per block.

moneyMask: any = {
    mask: '$num{.}`cents',
    blocks: {
      num: {
        mask: Number,
        signed: true,
        scale: 0,
        overwrite: true
      },
      cents: {
        mask: '`0`0',
        normalizeZeros: true,
        padFractionalZeros: true,
        overwrite: true
      }
    }
  };

The overwrite option only works when it is set "globally" like this

moneyMask: any = {
    mask: '$num{.}`cents',
    blocks: {
      num: {
        mask: Number,
        signed: true,
        scale: 0
      },
      cents: {
        mask: '`0`0',
        normalizeZeros: true,
        padFractionalZeros: true,
      }
    },
    overwrite: true
  };

Is there are something I am doing wrong or is this an active issue?

@trazek
Copy link

trazek commented Jan 7, 2021

This is something I desire as well. I think I can get away with having .00 appended on blur if nothing is enter though

@uNmAnNeR
Copy link
Owner

possible solution: add flag overwrite to CharChangeDetails in v8.0 (#885)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants