From 7c615768b6ea233a4cd08ee9459794b5cd60db94 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 19 Nov 2022 19:10:44 +0800 Subject: [PATCH 01/16] feat(nc-gui): add save & exit and save & stay --- packages/nc-gui/lang/en.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json index 08db4c8610..bd19e8ad4a 100644 --- a/packages/nc-gui/lang/en.json +++ b/packages/nc-gui/lang/en.json @@ -368,6 +368,8 @@ "setPrimary": "Set as Primary value", "addRow": "Add new row", "saveRow": "Save row", + "saveAndExit": "Save & Exit", + "saveAndStay": "Save & Stay", "insertRow": "Insert New Row", "deleteRow": "Delete Row", "deleteSelectedRow": "Delete Selected Rows", From 633fec95f92ea19ac7564ff8069d507b876dd0ae Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 19 Nov 2022 19:11:20 +0800 Subject: [PATCH 02/16] feat(nc-gui): remove important on py-0 --- packages/nc-gui/assets/style.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nc-gui/assets/style.scss b/packages/nc-gui/assets/style.scss index 7e3d0f5cd5..76489a82dd 100644 --- a/packages/nc-gui/assets/style.scss +++ b/packages/nc-gui/assets/style.scss @@ -261,7 +261,7 @@ a { } .ant-dropdown-menu-item, .ant-menu-item { - @apply !py-0 active:(ring ring-accent ring-opacity-100); + @apply py-0 active:(ring ring-accent ring-opacity-100); } .ant-dropdown-menu-title-content, From d57d722566d619bfc52663532870149ff0fde467 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 19 Nov 2022 19:13:06 +0800 Subject: [PATCH 03/16] feat(nc-gui): add MdiCancel, MdiContentSaveEdit & ADropdownButton --- packages/nc-gui/components.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/nc-gui/components.d.ts b/packages/nc-gui/components.d.ts index 1be206af09..681ddee0f7 100644 --- a/packages/nc-gui/components.d.ts +++ b/packages/nc-gui/components.d.ts @@ -24,6 +24,7 @@ declare module '@vue/runtime-core' { ADivider: typeof import('ant-design-vue/es')['Divider'] ADrawer: typeof import('ant-design-vue/es')['Drawer'] ADropdown: typeof import('ant-design-vue/es')['Dropdown'] + ADropdownButton: typeof import('ant-design-vue/es')['DropdownButton'] AEmpty: typeof import('ant-design-vue/es')['Empty'] AForm: typeof import('ant-design-vue/es')['Form'] AFormItem: typeof import('ant-design-vue/es')['FormItem'] @@ -126,6 +127,7 @@ declare module '@vue/runtime-core' { MdiBugOutline: typeof import('~icons/mdi/bug-outline')['default'] MdiCalculator: typeof import('~icons/mdi/calculator')['default'] MdiCalendarMonth: typeof import('~icons/mdi/calendar-month')['default'] + MdiCancel: typeof import('~icons/mdi/cancel')['default'] MdiCardsHeart: typeof import('~icons/mdi/cards-heart')['default'] MdiCellphoneMessage: typeof import('~icons/mdi/cellphone-message')['default'] MdiChat: typeof import('~icons/mdi/chat')['default'] @@ -143,6 +145,7 @@ declare module '@vue/runtime-core' { MdiCommentTextOutline: typeof import('~icons/mdi/comment-text-outline')['default'] MdiContentCopy: typeof import('~icons/mdi/content-copy')['default'] MdiContentSave: typeof import('~icons/mdi/content-save')['default'] + MdiContentSaveEdit: typeof import('~icons/mdi/content-save-edit')['default'] MdiCurrencyUsd: typeof import('~icons/mdi/currency-usd')['default'] MdiDatabaseOutline: typeof import('~icons/mdi/database-outline')['default'] MdiDatabaseSync: typeof import('~icons/mdi/database-sync')['default'] From f9250b7c95c1125585d9b6c89db25ffae1bf6080 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 19 Nov 2022 19:13:28 +0800 Subject: [PATCH 04/16] feat(nc-gui): add save and exit / stay logic --- .../smartsheet/expanded-form/Header.vue | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/expanded-form/Header.vue b/packages/nc-gui/components/smartsheet/expanded-form/Header.vue index 8519599e32..9e67e7fb98 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/Header.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/Header.vue @@ -25,6 +25,8 @@ const { isUIAllowed } = useUIPermission() const reloadTrigger = inject(ReloadRowDataHookInj, createEventHook()) +const saveRowAndStay = ref(0) + const save = async () => { if (isNew.value) { const data = await _save(state.value) @@ -34,6 +36,9 @@ const save = async () => { await _save() reloadTrigger?.trigger() } + if (!saveRowAndStay.value) { + emit('cancel') + } } // todo: accept as a prop / inject @@ -101,14 +106,39 @@ const copyRecordUrl = () => { - - {{ $t('general.cancel') }} +
+ + + {{ $t('general.cancel') }} +
- - - {{ $t('activity.saveRow') }} - + + +
+ + {{ $t('activity.saveAndExit') }} +
+
+ + {{ $t('activity.saveAndStay') }} +
+
From 6e153b7bfcf9ece5a1702016f19563d7411de9a3 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 19 Nov 2022 23:18:01 +0800 Subject: [PATCH 05/16] test(playwright): update Save Row button text --- tests/playwright/pages/Dashboard/ExpandedForm/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/playwright/pages/Dashboard/ExpandedForm/index.ts b/tests/playwright/pages/Dashboard/ExpandedForm/index.ts index 22dc0bfe03..df73b29a4a 100644 --- a/tests/playwright/pages/Dashboard/ExpandedForm/index.ts +++ b/tests/playwright/pages/Dashboard/ExpandedForm/index.ts @@ -57,7 +57,7 @@ export class ExpandedFormPage extends BasePage { }: { waitForRowsData?: boolean; } = {}) { - const saveRowAction = this.get().locator('button:has-text("Save Row")').click(); + const saveRowAction = this.get().locator('button:has-text("Save & Exit")').click(); if (waitForRowsData) { await this.waitForResponse({ uiAction: saveRowAction, @@ -104,9 +104,9 @@ export class ExpandedFormPage extends BasePage { async validateRoleAccess(param: { role: string }) { if (param.role === 'commenter' || param.role === 'viewer') { - await expect(await this.get().locator('button:has-text("Save Row")')).toBeDisabled(); + await expect(await this.get().locator('button:has-text("Save & Exit")')).toBeDisabled(); } else { - await expect(await this.get().locator('button:has-text("Save Row")')).toBeEnabled(); + await expect(await this.get().locator('button:has-text("Save & Exit")')).toBeEnabled(); } if (param.role === 'viewer') { await expect(await this.toggleCommentsButton).toHaveCount(0); From 874a3f122ba5206973f1ad6b20bcfad88a12c534 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sun, 20 Nov 2022 09:57:35 +0800 Subject: [PATCH 06/16] feat(nc-gui): rename cancel button to close --- .../nc-gui/components/smartsheet/expanded-form/Header.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/expanded-form/Header.vue b/packages/nc-gui/components/smartsheet/expanded-form/Header.vue index 9e67e7fb98..0517ee6c54 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/Header.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/Header.vue @@ -107,9 +107,9 @@ const copyRecordUrl = () => {
- - - {{ $t('general.cancel') }} + + + {{ $t('general.close') }}
From d1aaef0a6aaceeec621b410af6fefca72a6ceebd Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 21 Nov 2022 11:42:15 +0800 Subject: [PATCH 07/16] feat(nc-gui): add classes for playwright --- .../nc-gui/components/smartsheet/expanded-form/Header.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/expanded-form/Header.vue b/packages/nc-gui/components/smartsheet/expanded-form/Header.vue index 0517ee6c54..5141bc8313 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/Header.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/Header.vue @@ -113,9 +113,9 @@ const copyRecordUrl = () => { - +