多维表格
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
3.6 KiB

<script setup lang="ts">
import type { VNodeRef } from '@vue/runtime-core'
interface Props {
modelValue: number | null | undefined
Nc feat/form validation (#8409) * feat(nc-gui): custom validation setup * fix(nc-gui): custom validation table rounded issue * fix: add custom field validation type * fix(nc-gui): updated custom validator * feat(nc-gui): custom validation working state * fix(nc-gui): udpate default warning msg * chore(nc-gui): lint * fix(nc-gui): grayed out errors if input is focused * fix(nc-gui): input ring issue * fix(nc-gui): increase max height of validator select dropdown * fix(nc-gui): validator select dropdown item text color * fix(nc-gui): regex validation condition update * fix(nc-gui): add missing string validation types * fix(nc-gui): remove unwanted code * fix(nc-gui): move custom validation to ee * refacor(nc-gui): form view code * refactor(nc-gui): separate out formviewstore for ce & ee * fix(nc-gui): move all validations to another file * feat(nc-gui): add validation input component * feat(nc-gui): add time, month types * fix(nc-gui): add form field limit validations * fix(nc-gui): add limit link record validation * fix(nc-gui): add phonenumber & url validation type * feat(nc-gui): add email, url & phone number validators * fix(nc-gui): non working phone, email, url validation * chore(nc-giu): lint * feat(nc-gui): add attchment type validation * chore(nc-gui): lint * fix(nc-gui): add form field validation in shared form * fix(nc-gui): add form field validation in shared form oss * fix(nc-gui): oss validation conflict * fix(nc-gui): enter number validation function * fix(nc-gui): add config validators * fix(nc-gui): validation config error handling * fix(nc-gui): placeholder issue * fix(nc-gui): custom validation config error handling * fix(nc-gui): allow negative value validation * fix(nc-gui): add tooltip for required field switch * fix(nc-gui): refactor field validation from builder side * chore(nc-gui): lint * fix(nc-gui): update number validation logic * fix(nc-gui): rating field alignment issue * fix(nc-gui): small changes * fix(nc-gui): required field validation issue * fix(nc-gui): allow click on title to enable field config * feat(nc-gui): business email validation support * fix(nc-gui): add remove image btn in cell itself * fix(nc-gui): small changes * fix(nc-gui): survey form required field validation issue * fix(nc-gui): error field border issue * fix(nc-gui): currency validation input cell prefix issue * fix(nc-gui): remove console * chore(nc-gui): lint * fix: information text * fix(nc-gui): remove contains & doesn't contain option from phone number custom validation * fix(nc-gui): attachment merge conflict * fix(nc-gui): attachment cell expand btn size * fix(nc-gui): PR review changes * fix(nc-gui): lint * fix(nc-gui): updated form config heading text color * fix(nc-gui): small changes --------- Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com>
5 months ago
placeholder?: string
hidePrefix?: boolean
}
const props = defineProps<Props>()
const emit = defineEmits(['update:modelValue', 'save'])
const { showNull } = useGlobal()
const column = inject(ColumnInj)!
const editEnabled = inject(EditModeInj)!
const isEditColumn = inject(EditColumnInj, ref(false))
const readOnly = inject(ReadonlyInj, ref(false))
const _vModel = useVModel(props, 'modelValue', emit)
const vModel = computed({
get: () => _vModel.value,
set: (value: unknown) => {
if (value === '') {
_vModel.value = null
} else {
_vModel.value = value as number
}
},
})
const lastSaved = ref()
const currencyMeta = computed(() => {
return {
currency_locale: 'en-US',
currency_code: 'USD',
...parseProp(column?.value?.meta),
}
})
const currency = computed(() => {
try {
if (vModel.value === null || vModel.value === undefined || isNaN(vModel.value)) {
return vModel.value
}
return new Intl.NumberFormat(currencyMeta.value.currency_locale || 'en-US', {
style: 'currency',
currency: currencyMeta.value.currency_code || 'USD',
}).format(vModel.value)
} catch (e) {
return vModel.value
}
})
const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!
const isForm = inject(IsFormInj)!
const focus: VNodeRef = (el) =>
!isExpandedFormOpen.value && !isEditColumn.value && !isForm.value && (el as HTMLInputElement)?.focus()
const submitCurrency = () => {
if (lastSaved.value !== vModel.value) {
feat: Improved UI (#6222) * feat: Improved ui (#6156) * refactor: revert Signed-off-by: Pranav C <pranavxc@gmail.com> feat: shared base Signed-off-by: Pranav C <pranavxc@gmail.com> fix: remove duplicate import statement Signed-off-by: Pranav C <pranavxc@gmail.com> fix: disable starred & license menu Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: fix airtable wait issue Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: enable mysql in ci Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: fix checkbox order for sqlite Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: disable quick tests Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: fix dbType env variable for CI Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: workspace API access error fix Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: enable SQLite CI CD Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: use DB_TYPE env variable Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: enable SQLite UT Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: isHub cleanup Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: add check for EE Timezone spec Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> chore: cleanup Signed-off-by: Pranav C <pranavxc@gmail.com> chore: cleanup Signed-off-by: Pranav C <pranavxc@gmail.com> test: EE check fix Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> chore: test correction Signed-off-by: Pranav C <pranavxc@gmail.com> chore: sync latest changes Signed-off-by: Pranav C <pranavxc@gmail.com> test: set EE=false Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: set NC Edition to community in workflow file Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> chore: update sdk build command Signed-off-by: Pranav C <pranavxc@gmail.com> refactor: i18n and other changes Signed-off-by: Pranav C <pranavxc@gmail.com> feat: new ui Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: sync tests Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: lint Signed-off-by: Pranav C <pranavxc@gmail.com> * fix: shared view/base related bugs Signed-off-by: Pranav C <pranavxc@gmail.com> * test: checkbox verification sort order fix Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: fix sqlite reset Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: enable selfhosted runners Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * docs: table ops (draft) Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * Docs: screenshots for table-operations.md * refactor: introduce missing buttons Signed-off-by: Pranav C <pranavxc@gmail.com> * fix: get all fields Signed-off-by: Pranav C <pranavxc@gmail.com> * test: UT fix- new data API response Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: EE is false Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: webhook lookup as string in CE Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * fix: include created_at and updated_at Signed-off-by: Pranav C <pranavxc@gmail.com> * test: fix UT newDataAPI response for PG Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * fix: separate api for webhook related plugins Signed-off-by: Pranav C <pranavxc@gmail.com> * test: msyql filter corrections Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: mysql group by test corrections Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: fix datatype for rating field in groupby spec for pg Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: kanban datatype correction Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: column edit for mysql- rating field Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: misc fixes Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: enable 4 workers Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: enable 2 workers per shard only Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * docs: table CRUD * Rename table-operations.md to table-crud.md * Create column-crud.md * docs: row CRUD * Rename row.md to row-crud.md * docs: project crud * docs: toolbar (skeleton) * refactor: single page UI and bug fixes Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: sync tests playwright Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: add missing dependency Signed-off-by: Pranav C <pranavxc@gmail.com> * feat: single page ui, test corrections Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: tests Signed-off-by: Pranav C <pranavxc@gmail.com> * test: project rename test correction Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: remove only Signed-off-by: Pranav C <pranavxc@gmail.com> * test: remove wrong import statement Signed-off-by: Pranav C <pranavxc@gmail.com> * fix: delete option not visible in project context menu Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: move ws access within isEE() Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: fix groupby * test: groupby fix Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * docs: signup & landing page * docs: project crud * docs: project-crud misc * docs: toolbar fields * docs: toolbar / filters * docs: toolbar / group by * docs: toolbar / sort * docs: toolbar / row height * docs: filters additional options * docs: file re-order Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * docs: add links to column types * docs: code snippets * docs: links * docs: lookup * docs: rollup * docs: formula * docs: primary key * docs: display value * docs: development setup * docs: swagger * fix(nc-gui): encodeURIComponent for row id - closes: #6202 * docs: language * docs: expanded record * docs: import airtable * docs: airtable * docs: webhook * docs: revert file rename Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * docs: account settings * docs: audit * docs: meta management * docs: project settings * docs: shared base * docs: shared view * docs: meta sync * docs: team-auth * docs: views * docs: fix URL * docs: URL corrections * fix: shared base, view related bugs Signed-off-by: Pranav C <pranavxc@gmail.com> * test: EE check for WSaccess Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: exclude EE tests Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * fix: missing project delete closes #6215 Signed-off-by: Pranav C <pranavxc@gmail.com> * fix: merge existing project meta if found closes #6216 Signed-off-by: Pranav C <pranavxc@gmail.com> * fix: merge existing project meta if found closes #6216 Signed-off-by: Pranav C <pranavxc@gmail.com> --------- Signed-off-by: Pranav C <pranavxc@gmail.com> Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com> Co-authored-by: DarkPhoenix2704 <anbarasun123@gmail.com> Co-authored-by: Wing-Kam Wong <wingkwong.code@gmail.com> * refactor: docs and other bug fixes Signed-off-by: Pranav C <pranavxc@gmail.com> * feat: populate default project on super admin signup Signed-off-by: Pranav C <pranavxc@gmail.com> * fix: include created project details in signup response if avail, missing Dockerfile Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: use custom function for resolving ts path aliases Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: add missing generate script Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: webpack build correction - ts path resolve Signed-off-by: Pranav C <pranavxc@gmail.com> --------- Signed-off-by: Pranav C <pranavxc@gmail.com> Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> Co-authored-by: mertmit <mertmit99@gmail.com> Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com> Co-authored-by: DarkPhoenix2704 <anbarasun123@gmail.com> Co-authored-by: Wing-Kam Wong <wingkwong.code@gmail.com>
1 year ago
vModel.value = lastSaved.value = vModel.value ?? null
emit('save')
}
editEnabled.value = false
}
const onBlur = () => {
// triggered by events like focus-out / pressing enter
// for non-firefox browsers only
submitCurrency()
}
const onKeydownEnter = () => {
// onBlur is never executed for firefox & safari
// we use keydown.enter to trigger submitCurrency
if (/(Firefox|Safari)/.test(navigator.userAgent)) {
submitCurrency()
}
}
onMounted(() => {
lastSaved.value = vModel.value
})
</script>
<template>
<div
Nc feat/form validation (#8409) * feat(nc-gui): custom validation setup * fix(nc-gui): custom validation table rounded issue * fix: add custom field validation type * fix(nc-gui): updated custom validator * feat(nc-gui): custom validation working state * fix(nc-gui): udpate default warning msg * chore(nc-gui): lint * fix(nc-gui): grayed out errors if input is focused * fix(nc-gui): input ring issue * fix(nc-gui): increase max height of validator select dropdown * fix(nc-gui): validator select dropdown item text color * fix(nc-gui): regex validation condition update * fix(nc-gui): add missing string validation types * fix(nc-gui): remove unwanted code * fix(nc-gui): move custom validation to ee * refacor(nc-gui): form view code * refactor(nc-gui): separate out formviewstore for ce & ee * fix(nc-gui): move all validations to another file * feat(nc-gui): add validation input component * feat(nc-gui): add time, month types * fix(nc-gui): add form field limit validations * fix(nc-gui): add limit link record validation * fix(nc-gui): add phonenumber & url validation type * feat(nc-gui): add email, url & phone number validators * fix(nc-gui): non working phone, email, url validation * chore(nc-giu): lint * feat(nc-gui): add attchment type validation * chore(nc-gui): lint * fix(nc-gui): add form field validation in shared form * fix(nc-gui): add form field validation in shared form oss * fix(nc-gui): oss validation conflict * fix(nc-gui): enter number validation function * fix(nc-gui): add config validators * fix(nc-gui): validation config error handling * fix(nc-gui): placeholder issue * fix(nc-gui): custom validation config error handling * fix(nc-gui): allow negative value validation * fix(nc-gui): add tooltip for required field switch * fix(nc-gui): refactor field validation from builder side * chore(nc-gui): lint * fix(nc-gui): update number validation logic * fix(nc-gui): rating field alignment issue * fix(nc-gui): small changes * fix(nc-gui): required field validation issue * fix(nc-gui): allow click on title to enable field config * feat(nc-gui): business email validation support * fix(nc-gui): add remove image btn in cell itself * fix(nc-gui): small changes * fix(nc-gui): survey form required field validation issue * fix(nc-gui): error field border issue * fix(nc-gui): currency validation input cell prefix issue * fix(nc-gui): remove console * chore(nc-gui): lint * fix: information text * fix(nc-gui): remove contains & doesn't contain option from phone number custom validation * fix(nc-gui): attachment merge conflict * fix(nc-gui): attachment cell expand btn size * fix(nc-gui): PR review changes * fix(nc-gui): lint * fix(nc-gui): updated form config heading text color * fix(nc-gui): small changes --------- Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com>
5 months ago
v-if="isForm && !isEditColumn && !hidePrefix"
class="nc-currency-code h-full !bg-gray-100 border-r border-gray-200 px-3 mr-1 flex items-center"
>
<span>
{{ currencyMeta.currency_code }}
</span>
</div>
<input
v-if="(!readOnly && editEnabled) || (isForm && !isEditColumn)"
:ref="focus"
v-model="vModel"
type="number"
Nc fix: UI improvements (#8223) * fix(nc-gui): add background color for row on hover in grid view * fix(nc-gui): reduce width of index column * fix(nc-gui): on hover grid row bg opacity issue * fix(nc-gui): reduce font size and grid cell height * fix(nc-gui): reduce font size * fix(nc-gui): set column default width to 180px * fix(nc-gui): revert sidebar changes * fix(nc-gui): disable grid row hover effect if fillMode is true * fix(nc-gui): display checkbox & row expand icon if it is active row * fix(nc-gui): increase the weight of display value cell * fix(nc-gui): grid cell should have constant padding * fix(nc-gui): att cell row height auto increase issue * fix(nc-gui): att cell center align issue * fix(nc-gui): percent cell spacing issue * fix(nc-gui): text overflow ellipsis * fix(nc-gui): single select auto increase height issue if rowHeight is short * fix(nc-gui): grayed out header text color * fix(nc-gui): reduce header icon size * fix(nc-gui): set 12px grid header horizontal padding * fix(nc-gui): center align expand icon for short row height * fix(nc-gui): rich text and select type field auto row height increase issue * fix(nc-gui): lookup cell auto increase height issue * fix(nc-gui): small changes * fix(nc-gui): truncate text after no. of lines base on rowHeight * fix(nc-gui): barcode & qrcode cell row height issue * chore(nc-gui): lint * fix(test): update row height pw test * fix(test): grid toolbar rowHeight test update * fix(nc-gui): ai review changes * fix(test): multiselect pw test update * fix(test): verify multiselct options test update * fix(nc-gui): merge conflicts * fix(nc-gui): small changes * fix(nc-gui): small changes * fix(nc-gui): display value should be in blue color
6 months ago
class="nc-cell-field h-full border-none rounded-md py-1 outline-none focus:outline-none focus:ring-0"
:class="isForm && !isEditColumn ? 'flex flex-1' : 'w-full'"
Nc feat/new field modal (#8578) * fix(nc-gui): remove field modal title & type selector label * fix(nc-gui): hide default value input initially * fix(nc-gui): remove clear icon from default value input * fix(nc-gui): update email, phone, url column validation settings ui * fix(nc-gui): add missing validate field condition * fix(nc-gui): update long text field modal ui * fix(nc-gui): update default field modal width & enable rich text option * fix(nc-gui): small changes * fix(nc-gui): hide default value input only if user clicks on delete icon * fix(nc-gui): decimal field option ui * fix(nc-gui): update percent option ui * fix(nc-gui): small changes * fix(nc-gui): update field modal switch option alignment * fix(nc-gui): update date & dateTime field modal options * feat(nc-gui): add 12, 24 hrs time format option in field modal * feat(nc-gui): add 12hr time cell format support * fix(nc-gui): update time cell placeholder according to time format * fix(nc-gui): field modal default value option visibility issue * fix(nc-gui): update barcode, qr code field modal option * fix(nc-gui): field modal expanded json input modal overlay click issue * fix(nc-gui): currency code option from field modal * fix(nc-gui): udpate duration option * fix(nc-gui): date time cell clear icon visibility issue in link record dropdown * fix(nc-gui): update field modal lookup options * fix(nc-gui): update user option from field modal * fix(nc-gui): update rollup option from field modal * fix(nc-gui): update select field type ui for create column * fix(nc-gui): update field modal cancel & save btn alignment * fix(nc-gui): update formula option margin * fic(nc-gui): update select type option * fix(nc-gui): small changes * fix(nc-gui): update links field options * fix(nc-gui): small changes * fix(nc-gui): select option border issue * fix(nc-gui): add new color picker * fix(nc-gui): update rating field options * fix(nc-gui): update geodata field options * fix(nc-gui): geodata option small changes * fix(nc-gui): add new color picker for select type options * fix(nc-gui): show only title & field type list if uidt is null * feat(nc-gui): add 12hrs time support in dateTime cell * fix(nc-gui): formula suggestion list visibility issue * fix(nc-gui): reduce formaula suggestion fields icon size * fix(nc-gui): rich text default value visibility issue in field modal * fix(nc-gui): update rich text default value bubble menu option * fix(nc-gui): some pr review changes * fix(nc-gui): remove example from duration format * feat(nc-gui): add keyboard navigation support for field list * fix(nc-gui): update email, url, phone validate text * fix(nc-gui): update qr & barcode value select input * fix(nc-gui): pr review changes * test: update create column test cases * fix(nc-gui): remove required symbol from field modal inputs * fix(nc-gui): remove delete default value icon and add cross icon in default input itself * test: update duration field type test * fix(nc-gui): update column name & type input shadow * fix(nc-gui): add hover effect on selected type * fix(nc-gui): enabel rich text case update * fix(nc-gui): update select options * fix(nc-gui): show full time format in edit modal default value * fix(nc-gui): remove optional placeholder of default value * fix(nc-gui): instead of removing field type option disable it if it is onlyNameUpdateOnEditColumns * fix(nc-gui): update links field icons from field modal * fix(nc-gui): add links options in edit modal * fix(nc-gui): show links config and disable if it is not editable in edit column mode * fix(nc-gui): add support to configure date time format for create & last modified type field * fix(nc-gui): virtual field icon visibility issue if it is edit mode * fix(nc-gui): disabled edit option from field context menu if column is pk or system column * fix(nc-gui): update field modal submit btn text * fix(nc-gui): add shdow on input field in field modal * fix(nc-gui): disable submit btn if field modal has some warnings * test: update field add/edit save test case * test: update links column add/edit test cases * test: uncomment code * test: update user field default value update test cases * test: update select type option default value * test: update multi field editor test cases * test: update kanban view add option test cases * test: update multifield editor test cases * test: update create column keyboard shortcut test case * chore(nc-gui): lint * fix(nc-gui): field modal redio option shadow issue * fix(nc-gui): update field modal select option color picker btn border radius * fix(nc-gui): checkbox & rating icon alignment issue * fix(nc-gui): update field modal formula field * fix(nc-gui): field modal padding and gap issue * fix(nc-gui): update set default value font case & font color * fix(nc-gui): update field modal formula suggestion list ui * fix(nc-gui): removecolumn create field search list from multifield editor * fix(nc-gui): add placeholder for lookup & rollup options * fix: label * fix(nc-gui): remove placeholder from select type * fix(nc-gui): remove link type from link field select option * fix(nc-gui): qr, barcode value field icon issue * fix(nc-gui): set color picker tab according to active color * fix(nc-gui): json editor save btn ui changes in edit modal * fix(nc-gui): disable editing primary key col * chore(nc-gui): lint --------- Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com>
4 months ago
:placeholder="placeholder"
:disabled="readOnly"
@blur="onBlur"
@keydown.enter="onKeydownEnter"
@keydown.down.stop
@keydown.left.stop
@keydown.right.stop
@keydown.up.stop
@keydown.delete.stop
@selectstart.capture.stop
@mousedown.stop
@contextmenu.stop
/>
<span v-else-if="vModel === null && showNull" class="nc-cell-field nc-null uppercase">{{ $t('general.null') }}</span>
<!-- only show the numeric value as previously string value was accepted -->
<span v-else-if="!isNaN(vModel)" class="nc-cell-field">{{ currency }}</span>
<!-- possibly unexpected string / null with showNull == false -->
<span v-else />
</template>
<style lang="scss" scoped>
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type='number'] {
-moz-appearance: textfield;
}
</style>