Skip to content

Locale support for sa-currency-input and date-picker#44

Open
Dastaan2k wants to merge 17 commits intosimplifiedautomation:masterfrom
Dastaan2k:locale-support-new
Open

Locale support for sa-currency-input and date-picker#44
Dastaan2k wants to merge 17 commits intosimplifiedautomation:masterfrom
Dastaan2k:locale-support-new

Conversation

@Dastaan2k
Copy link
Copy Markdown

Added locale support for currency input and date time picker

@Jeet-s
Copy link
Copy Markdown
Contributor

Jeet-s commented Aug 17, 2021

remove package.json

stateChanges = new Subject<void>();
private _value: any;
private viewValue: string;
//private viewValue: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment


constructor(private _focusMonitor: FocusMonitor, private _elementRef: ElementRef<HTMLElement>, @Optional() @Self() public ngControl: NgControl, @Inject(LOCALE_ID) private locale: string,private currencyPipe: CurrencyPipe) {

this.decimalSeparator = '.';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get decimal separator based on locale

@@ -1,7 +1,33 @@
import { NgModule } from '@angular/core';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a different PR for examples

Comment thread projects/simplified-ui/src/lib/simplified-ui.module.ts Outdated
- Both decimal and group selector values are now set based on the app's locale instead of hardcoded values.
- Registered spanish locale data.
- Removed the hardcoded locale from module.ts
- Removed commented code.
- Fixed shouldLabelFloat based on current focused state and FormControl's value
static nextId = 0;
private decimalSeparator: string;

private decimalSeparator;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add type

private decimalSeparator: string;

private decimalSeparator;
private groupSeparator;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


import localeEs from '@angular/common/locales/es';

registerLocaleData(localeEs);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can register locale in the app only

this.viewValue = num;
this.value = this.parse(num);
});
this.currencyValue.valueChanges.pipe(debounceTime(200)).subscribe((num) => {});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove this subscription

set value(val: string | null) {
this._value = val;
if (this._value != null && this._value !== '') {
if (this._value != null && this._value !== '' && this._value >= 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove greater than check

get shouldLabelFloat() {
return this.focused || !this.empty;
if (!this.focused) {
return this.currencyValue.value !== null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use this.empty instead of checking null?

@ViewChild('input') inputRef: ElementRef;
@Input() allowNegative: boolean = true;

@Input()allowNegative: boolean = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add space


if(this.currencyValue.value != null) {
if (origin) {
this.currencyValue.setValue(this.parse(this.currencyValue.value.replace(getLocaleCurrencySymbol(this.locale), '')));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add logic to replace currency symbol in parse method

Comment thread angular.json Outdated
}
"defaultProject": "simplified-ui-library",
"cli": {
"analytics": "cb8df5c8-539c-4c04-bbee-3864e14c6b3a"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we using this analytics property?

@Dastaan2k Dastaan2k changed the title Locale support new Locale support for sa-currency-input and date-picker Aug 20, 2021
@Dastaan2k Dastaan2k mentioned this pull request Aug 20, 2021
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

Successfully merging this pull request may close these issues.

2 participants