From 2a78930923a5fa65823fd3cdb8099a453c6256a3 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:31:02 +0530 Subject: [PATCH] Nc feat/form view builder field settings in right pannel and fixed column delete modal virtual cell icon issue (#7927) * feat(nc-gui): form field in right pannel setup * fix(nc-gui): inline form field reorder issue * fix(nc-gui): make edit form field right panel scrollable * fix(nc-gui): form field limit option hide btn focus box shadow style issue * fix(nc-gui): add support to edit form column in form view builder * feat(nc-gui): added form field header menu dropdown * fix(nc-gui): tab issue in form builder * feat(nc-gui): add support to edit column from form builder itself * fix(nc-gui): wrong virtual cell icon in column delete modal * feat(nc-gui): column edit, hide, delete option in form builder field settings * fix(nc-gui): move all form field settings radio btns to the right side * chore(nc-gui): lint * chore(nc-gui): lint errors * chore(nc-gui): lint * fix(nc-gui): update 'change icon color' text case * fix(nc-gui): small changes * fix(nc-gui): form builder side panel field div key issue * fix(nc-gui): form view outsideclick fild toggle issue * chore(nc-gui): lint * fix(nc-gui): hide select dropdown in value is selected and show if value is not selected * fix(nc-gui): suggested review changes * fix(nc-gui): make form field rich text options sticky at bottom * chore(nc-gui): lint * fix(nc-gui): small changes * fix(nc-gui): lazy import richtext component * fix(nc-gui): set the max height for form rich text fields * fix(nc-gui): move form settings switch inputs to the right side * fix(nc-gui): move form select type field layout option to appearance settings section * fix(nc-gui): select form active field text on focus * fix(nc-gui): form rich text element menu option tabindex issue * fix(nc-gui): form search field input autofill issue * fix(nc-gui): update position of rich text menu option of form description * feat(nc-gui): adjustable form view sidebar width * chore(nc-gui): lint * fix(nc-gui): typo mistake * fix(nc-gui): PR review changes --- .../nc-gui/components/cell/MultiSelect.vue | 5 + packages/nc-gui/components/cell/RichText.vue | 56 +- .../cell/RichText/SelectedBubbleMenu.vue | 311 +-- .../nc-gui/components/cell/SingleSelect.vue | 5 + .../dlg/share-and-collaborate/SharePage.vue | 8 +- .../components/general/ShareProject.vue | 2 +- .../nc-gui/components/smartsheet/Form.vue | 1861 +++++++++-------- .../components/smartsheet/form/FieldMenu.vue | 248 +++ .../components/smartsheet/form/Layout.vue | 94 + .../smartsheet/form/LimitOptions.vue | 6 +- .../smartsheet/header/DeleteColumnModal.vue | 8 +- packages/nc-gui/lang/en.json | 6 +- packages/nc-gui/lib/enums.ts | 17 + packages/nc-gui/store/sidebar.ts | 13 + .../playwright/pages/Dashboard/Form/index.ts | 2 +- 15 files changed, 1603 insertions(+), 1039 deletions(-) create mode 100644 packages/nc-gui/components/smartsheet/form/FieldMenu.vue create mode 100644 packages/nc-gui/components/smartsheet/form/Layout.vue diff --git a/packages/nc-gui/components/cell/MultiSelect.vue b/packages/nc-gui/components/cell/MultiSelect.vue index 5b91e4dadb..10913279e9 100644 --- a/packages/nc-gui/components/cell/MultiSelect.vue +++ b/packages/nc-gui/components/cell/MultiSelect.vue @@ -10,6 +10,7 @@ import { EditColumnInj, EditModeInj, IsKanbanInj, + IsSurveyFormInj, ReadonlyInj, RowHeightInj, computed, @@ -64,6 +65,8 @@ const isEditColumn = inject(EditColumnInj, ref(false)) const rowHeight = inject(RowHeightInj, ref(undefined)) +const isSurveyForm = inject(IsSurveyFormInj, ref(false)) + const selectedIds = ref([]) const aselect = ref() @@ -386,6 +389,8 @@ const onFocus = () => { isFocusing.value = false }, 250) + if (isSurveyForm.value && vModel.value?.length) return + isOpen.value = true } diff --git a/packages/nc-gui/components/cell/RichText.vue b/packages/nc-gui/components/cell/RichText.vue index 422bea455f..4bc2c87660 100644 --- a/packages/nc-gui/components/cell/RichText.vue +++ b/packages/nc-gui/components/cell/RichText.vue @@ -9,22 +9,31 @@ import Underline from '@tiptap/extension-underline' import Placeholder from '@tiptap/extension-placeholder' import { TaskItem } from '@/helpers/dbTiptapExtensions/task-item' import { Link } from '@/helpers/dbTiptapExtensions/links' +import type { RichTextBubbleMenuOptions } from '#imports' import { IsExpandedFormOpenInj, IsFormInj, IsGridInj, ReadonlyInj, RowHeightInj } from '#imports' -const props = defineProps<{ - value?: string | null - readOnly?: boolean - syncValueChange?: boolean - showMenu?: boolean - fullMode?: boolean - isFormField?: boolean - autofocus?: boolean - placeholder?: string - renderAsText?: boolean -}>() +const props = withDefaults( + defineProps<{ + value?: string | null + readOnly?: boolean + syncValueChange?: boolean + showMenu?: boolean + fullMode?: boolean + isFormField?: boolean + autofocus?: boolean + placeholder?: string + renderAsText?: boolean + hiddenBubbleMenuOptions?: RichTextBubbleMenuOptions[] + }>(), + { + hiddenBubbleMenuOptions: () => [], + }, +) const emits = defineEmits(['update:value']) +const { hiddenBubbleMenuOptions } = toRefs(props) + const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))! const rowHeight = inject(RowHeightInj, ref(1 as const)) @@ -208,7 +217,8 @@ useEventListener( editorDom, 'focusout', (e: FocusEvent) => { - if (!(e?.relatedTarget as HTMLElement)?.closest('.bubble-menu, .nc-textarea-rich-editor')) { + const targetEl = e?.relatedTarget as HTMLElement + if (targetEl?.classList?.contains('tiptap') || !targetEl?.closest('.bubble-menu, .nc-textarea-rich-editor')) { isFocused.value = false } }, @@ -223,7 +233,7 @@ useEventListener( 'flex flex-col flex-grow nc-rich-text-full': fullMode, 'nc-rich-text-embed flex flex-col pl-1 w-full': !fullMode, 'readonly': readOnly, - 'nc-form-rich-text-field !p-0': isFormField, + 'nc-form-rich-text-field !p-0 relative': isFormField, 'nc-rich-text-grid': isGrid, }" :tabindex="readOnlyCell || isFormField ? -1 : 0" @@ -251,21 +261,26 @@ useEventListener( class="flex flex-col nc-textarea-rich-editor w-full" :class="{ 'mt-2.5 flex-grow': fullMode, - 'nc-scrollbar-md': !fullMode || (!fullMode && isExpandedFormOpen), + 'scrollbar-thin scrollbar-thumb-gray-200 scrollbar-track-transparent': !fullMode || (!fullMode && isExpandedFormOpen), 'flex-grow': isExpandedFormOpen, [`!overflow-hidden children:line-clamp-${rowHeight}`]: !fullMode && readOnly && rowHeight && !isExpandedFormOpen && !isForm, }" /> -
+
- +
@@ -343,7 +358,7 @@ useEventListener( .nc-textarea-rich-editor { .tiptap p.is-editor-empty:first-child::before { - color: #6a7184; + color: #9aa2af; content: attr(data-placeholder); float: left; height: 0; @@ -462,4 +477,9 @@ useEventListener( height: fit-content; } } +.nc-form-field-bubble-menu-wrapper { + @apply absolute -bottom-9 left-1/2 z-50 rounded-lg; + transform: translateX(-50%); + box-shadow: 0px 8px 8px -4px rgba(0, 0, 0, 0.04), 0px 20px 24px -4px rgba(0, 0, 0, 0.1); +} diff --git a/packages/nc-gui/components/cell/RichText/SelectedBubbleMenu.vue b/packages/nc-gui/components/cell/RichText/SelectedBubbleMenu.vue index ed5048d9fd..7d48b3b472 100644 --- a/packages/nc-gui/components/cell/RichText/SelectedBubbleMenu.vue +++ b/packages/nc-gui/components/cell/RichText/SelectedBubbleMenu.vue @@ -10,16 +10,22 @@ import MsFormatH3 from '~icons/material-symbols/format-h3' import TablerBlockQuote from '~icons/tabler/blockquote' import MsCode from '~icons/material-symbols/code' import MsFormatQuote from '~icons/material-symbols/format-quote' +import { RichTextBubbleMenuOptions } from '#imports' interface Props { editor: Editor embedMode?: boolean isFormField?: boolean + hiddenOptions?: RichTextBubbleMenuOptions[] } -const props = defineProps() +const props = withDefaults(defineProps(), { + embedMode: false, + isFormField: false, + hiddenOptions: () => [], +}) -const { editor, embedMode } = toRefs(props) +const { editor, embedMode, isFormField, hiddenOptions } = toRefs(props) const cmdOrCtrlKey = computed(() => { return isMac() ? '⌘' : 'CTRL' @@ -33,6 +39,14 @@ const altKey = computed(() => { return isMac() ? '⌥' : 'Alt' }) +const tooltipPlacement = computed(() => { + if (isFormField.value) return 'bottom' +}) + +const tabIndex = computed(() => { + return isFormField.value ? -1 : 0 +}) + const onToggleLink = () => { const activeNode = editor.value?.state?.selection?.$from?.nodeBefore || editor.value?.state?.selection?.$from?.nodeAfter @@ -74,19 +88,29 @@ const onToggleLink = () => { }, 100) } } + +const isOptionVisible = (option: RichTextBubbleMenuOptions) => { + if (isFormField.value) return !hiddenOptions.value.includes(option) + + return true +} + +const showDivider = (options: RichTextBubbleMenuOptions[]) => { + return !isFormField.value || options.some((o) => !hiddenOptions.value.includes(o)) +}