Browse Source

fic(nc-gui): percent field letter spacing and display as percent if value is 0

nc-feat/percent-field-v2
Ramesh Mane 10 months ago
parent
commit
75a40ce0cf
  1. 5
      packages/nc-gui/components/cell/Percent.vue
  2. 2
      packages/nc-gui/utils/percentUtils.ts

5
packages/nc-gui/components/cell/Percent.vue

@ -160,7 +160,8 @@ function onKeyDown(evt: KeyboardEvent) {
v-if="!readOnly && editEnabled && (isExpandedFormOpen ? expandedEditEnabled : true)"
:ref="focus"
v-model="vModel"
class="nc-cell-field w-full !text-sm !border-none !outline-none focus:ring-0 text-base py-1"
class="nc-cell-field w-full !text-sm !border-none !outline-none focus:ring-0 py-1"
style="letter-spacing: 0.06rem"
type="number"
:placeholder="isEditColumn ? $t('labels.optional') : ''"
:step="percentStep"
@ -188,7 +189,7 @@ function onKeyDown(evt: KeyboardEvent) {
/>
</div>
<!-- nbsp to keep height even if vModel is zero length -->
<span v-else class="nc-cell-field">{{ displayValue }}&nbsp;</span>
<span v-else class="nc-cell-field text-sm">{{ displayValue }}&nbsp;</span>
</div>
</template>

2
packages/nc-gui/utils/percentUtils.ts

@ -11,7 +11,7 @@ export const precisions = [
]
export function renderPercent(value: any, precision?: number, withPercentSymbol: boolean = true) {
if (!value) return value
if (typeof value !== 'number' && !value) return value
if (isNaN(Number(value))) return null
value = Number(value) * 100

Loading…
Cancel
Save