mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 07:36:01 +00:00
#136 configurable thousands separator in grid
This commit is contained in:
@@ -66,8 +66,6 @@
|
||||
import _ from 'lodash';
|
||||
import registerCommand from '../commands/registerCommand';
|
||||
import { registerMenu } from '../utility/contextMenu';
|
||||
import { useSettings } from '../utility/metadataLoaders';
|
||||
import { getCurrentSettings } from '../stores';
|
||||
import { getBoolSettingsValue } from '../settings/settingsTools';
|
||||
|
||||
export let config;
|
||||
|
||||
@@ -13,6 +13,18 @@
|
||||
}
|
||||
|
||||
const dateTimeRegex = /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d\d\d)?Z?$/;
|
||||
|
||||
function formatNumber(value) {
|
||||
if (value >= 10000 || value <= -10000) {
|
||||
if (getBoolSettingsValue('dataGrid.thousandsSeparator', false)) {
|
||||
return value.toLocaleString();
|
||||
} else {
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return value.toString();
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -20,6 +32,7 @@
|
||||
import _ from 'lodash';
|
||||
import { isTypeLogical } from 'dbgate-tools';
|
||||
import ShowFormButton from '../formview/ShowFormButton.svelte';
|
||||
import { getBoolSettingsValue } from '../settings/settingsTools';
|
||||
|
||||
export let rowIndex;
|
||||
export let col;
|
||||
@@ -80,16 +93,10 @@
|
||||
0
|
||||
{/if}
|
||||
{:else if _.isNumber(value)}
|
||||
{#if value >= 10000 || value <= -10000}
|
||||
{#if isDynamicStructure}
|
||||
<span class="value">{value.toLocaleString()}</span>
|
||||
{:else}
|
||||
{value.toLocaleString()}
|
||||
{/if}
|
||||
{:else if isDynamicStructure}
|
||||
<span class="value">{value.toString()}</span>
|
||||
{#if isDynamicStructure}
|
||||
<span class="value">{formatNumber(value)}</span>
|
||||
{:else}
|
||||
{value.toString()}
|
||||
{formatNumber(value)}
|
||||
{/if}
|
||||
{:else if _.isString(value)}
|
||||
{#if dateTimeRegex.test(value)}
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
/>
|
||||
<FormCheckboxField name="dataGrid.showHintColumns" label="Show foreign key hints" defaultValue={true} />
|
||||
|
||||
<FormCheckboxField name="dataGrid.thousandsSeparator" label="Use thounds separator for numbers" />
|
||||
|
||||
<div class="heading">Connection</div>
|
||||
<FormCheckboxField
|
||||
name="connection.autoRefresh"
|
||||
|
||||
Reference in New Issue
Block a user