Compare commits

...

7 Commits

Author SHA1 Message Date
8c2ee441fc Merge pull request 'Added support for European numeric formats' (#16) from issue-1 into development
Reviewed-on: #16
Reviewed-by: allan <allan@4gl.io>
2023-08-23 14:46:37 +00:00
0a7d23c763 Merge branch 'development' into issue-1
All checks were successful
Build / Build-and-ng-test (pull_request) Successful in 25s
2023-08-23 14:45:59 +00:00
Mihajlo Medjedovic
52d4b3eefc chore(git): Merge branch 'issue-1' of ssh://git.datacontroller.io:29419/dc/dc into issue-1
All checks were successful
Build / Build-and-ng-test (pull_request) Successful in 7m52s
2023-07-31 10:12:40 +02:00
Mihajlo Medjedovic
908d2761f2 chore: addressing comments 2023-07-31 10:12:22 +02:00
7c98ad8c5b Merge branch 'development' into issue-1
All checks were successful
Build / Build-and-ng-test (pull_request) Successful in 7m40s
2023-07-28 18:10:25 +00:00
Mihajlo Medjedovic
5bb55e6484 style: lint
All checks were successful
Build / Build-and-ng-test (pull_request) Successful in 7m39s
2023-07-28 20:03:58 +02:00
Mihajlo Medjedovic
e48e47bc63 feat: support for European numeric formats 2023-07-28 20:03:41 +02:00
8 changed files with 411 additions and 349 deletions

719
client/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -69,7 +69,6 @@
"ngx-clipboard": "^16.0.0",
"ngx-json-viewer": "file:libraries/ngx-json-viewer-3.2.1.tgz",
"nodejs": "0.0.0",
"numbro": "^2.1.1",
"os-browserify": "0.3.0",
"rxjs": "^7.8.0",
"save-svg-as-png": "^1.4.17",

View File

@ -1,5 +1,5 @@
declare module 'save-svg-as-png'
declare module 'numbro/dist/languages.min'
declare interface Navigator {
msSaveBlob: (blob: any, defaultName?: string) => boolean
}

View File

@ -385,7 +385,6 @@
[class.hidden]="hotTable.hidden"
[licenseKey]="hotTable.licenseKey"
>
<!--[licenseKey]=""-->
</hot-table>
</div>

View File

@ -63,6 +63,8 @@ import {
} from './utils/renderers.utils'
import { isStringDecimal, isStringNumber } from './utils/types.utils'
import { LicenceService } from '../services/licence.service'
import * as numbro from 'numbro'
import * as languages from 'numbro/dist/languages.min'
@Component({
selector: 'app-editor',
@ -362,6 +364,10 @@ export class EditorComponent implements OnInit, AfterViewInit {
private cdf: ChangeDetectorRef,
private hotRegisterer: HotTableRegisterer
) {
const lang = languages[window.navigator.language]
if (lang)
numbro.default.registerLanguage(languages[window.navigator.language])
this.hotRegisterer = new HotTableRegisterer()
this.parseRestrictions()

View File

@ -19,6 +19,7 @@ import { mergeColsRules } from './utils/mergeColsRules'
import { parseColType } from './utils/parseColType'
import { dqValidate } from './validations/dq-validation'
import { specialMissingNumericValidator } from './validations/hot-custom-validators'
import { applyNumericFormats } from './utils/applyNumericFormats'
export class DcValidator {
private rules: DcValidation[] = []
@ -41,6 +42,7 @@ export class DcValidator {
this.hotInstance = hotInstance
this.rules = parseColType(sasparams.COLTYPE)
this.rules = mergeColsRules(cols, this.rules, $dataFormats)
this.rules = applyNumericFormats(this.rules)
this.dqrules = dqRules
this.dqdata = dqData
this.primaryKeys = sasparams.PK.split(' ')

View File

@ -0,0 +1,26 @@
import { DcValidation } from '../models/dc-validation.model'
import * as languages from 'numbro/dist/languages.min'
/**
* Applying the numeric formats based on the browser locale/language
* So that correct decimal separators are applied.
* For example european format (thousand dot, decimal comma): 1.000,00
*
* @param rules Cell Validation rules to be updated
* Those rules are passed in the `columns` property Of handsontable settings.
*/
export const applyNumericFormats = (rules: DcValidation[]): DcValidation[] => {
const lang = languages[window.navigator.language]
if (!lang) return rules
for (let rule of rules) {
if (rule.type === 'numeric')
rule.numericFormat = {
pattern: '0,0',
culture: window.navigator.language // use this for EUR (German),
// more cultures available on http://numbrojs.com/languages.html
}
}
return rules
}

View File

@ -6,7 +6,8 @@ import { DcValidation } from '../models/dc-validation.model'
* Merging old validation params from sasparams with cols params
* @param sasparams sasparams coming from SAS
* @param cols cols coming from SAS
* @param rules rules to be updated
* @param rules Cell Validation rules to be updated
* Those rules are passed in the `columns` property Of handsontable settings.
* @returns
*/
export const mergeColsRules = (