uhlryk / angular-dynamic-number

Highly customizable angular directive for numbers
64 stars 32 forks source link

New Property 'Blank' #51

Open gjeanmart opened 7 years ago

gjeanmart commented 7 years ago

Added a new property blank that allows to set a default value if the value in the ng-model is null, undefined or empty string. Meaningful to display 'N/A' or '-' instead of 0. Default value is '0'

uhlryk commented 7 years ago

Thank you very much for you work. It is great. It works. But Im not convinced that this is good way to solve problem. Because your solution display as a value which means that for user it can display 'N/A' and then he need to push backspace 3 times to clear it.

Please look on this pull request https://github.com/uhlryk/angular-dynamic-number/pull/52 (it is available on branch return-null). For wrong values it will return null in model and empty string for input field. When input field get empty string it will show value from placeholder. And I think that this solves the problem. Because it will show placeholder more often. You can change message in placeholder. For example you can set 'N/A' but if user click on it it will disappear which is in my opinion better user experience.

gjeanmart commented 7 years ago

Hi, thanks for the review.

My though was to especially use this property as a filter, for example in a table to display a null value as '-' or 'N/A'.

In the example below: image

However, I agree the behavior can be a little bit weird for an input if numBlank is different than a number or an empty string. But I guess, it's parameterization. Would be the same if the developer puts '@' as a decimal separator.

Regards,

uhlryk commented 7 years ago

Hey I saw your github profile and it looks like you are very active and have some fresh ideas for this module. If you like I can give you permission for write to this repo if you want.

gjeanmart commented 7 years ago

Thanks for the proposition. I can indeed spare some time to help you maintaining this module. Regards,

uhlryk commented 7 years ago

Thanks, I don't have any active angular project (all my current projects are based on react.js). I know that many other still may need it therefore I would like still support it, I will not abandon but Im not interested in improving it. I hope that you or someone else who still use it will make it better. I send you invitation.

The main problem with this module is that it at the beginning was designed for smaller number of features. And it started scaling up, but code quality is now terrible. It is great candidate for rewriting. But Im sure that it is not worth this.