mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 09:17:23 +00:00
feat: add 'Clear default value' settings for Reset action (#4889)
* fix(client): sub application name (#4886)
* Revert "fix(client): sub application name (#4886)" (#4887)
This reverts commit ac2e2a2043
.
* feat: add 'Clear default value' settings for Reset action
* chore: add translation
* test: add e2e tests
---------
Co-authored-by: YANG QIA <2013xile@gmail.com>
This commit is contained in:
parent
9dc713637a
commit
49a55495ee
@ -520,7 +520,9 @@ const useDoReset = () => {
|
||||
|
||||
return {
|
||||
doReset: async () => {
|
||||
await form.reset();
|
||||
await form.reset(undefined, {
|
||||
forceClear: !!fieldSchema?.['x-component-props']?.clearDefaultValue,
|
||||
});
|
||||
if (_.isEmpty(getFilterFromCurrentForm())) {
|
||||
return doReset({ getDataBlocks, targets, uid });
|
||||
}
|
||||
|
@ -831,5 +831,6 @@
|
||||
"The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string.": "The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string.",
|
||||
"URL search params": "URL search params",
|
||||
"Expand All": "Expand All",
|
||||
"Search": "Search"
|
||||
"Search": "Search",
|
||||
"Clear default value": "Clear default value"
|
||||
}
|
||||
|
@ -762,5 +762,6 @@
|
||||
"This variable has been deprecated and can be replaced with \"Current form\"": "La variable ha sido obsoleta; \"Formulario actual\" puede ser utilizada como sustituto",
|
||||
"The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string.": "El valor de esta variable se deriva de la cadena de consulta de la URL de la página. Esta variable sólo puede utilizarse normalmente cuando la página tiene una cadena de consulta.",
|
||||
"URL search params": "Parámetros de búsqueda de URL",
|
||||
"Expand All": "Expandir todo"
|
||||
"Expand All": "Expandir todo",
|
||||
"Clear default value": "Borrar valor por defecto"
|
||||
}
|
||||
|
@ -782,5 +782,6 @@
|
||||
"This variable has been deprecated and can be replaced with \"Current form\"": "La variable a été obsolète ; \"Formulaire actuel\" peut être utilisé comme substitut",
|
||||
"The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string.": "La valeur de cette variable est dérivée de la chaîne de requête de l'URL de la page. Cette variable ne peut être utilisée normalement que lorsque la page a une chaîne de requête.",
|
||||
"URL search params": "Paramètres de recherche d'URL",
|
||||
"Expand All": "Tout déplier"
|
||||
"Expand All": "Tout déplier",
|
||||
"Clear default value": "Effacer la valeur par défaut"
|
||||
}
|
||||
|
@ -701,5 +701,6 @@
|
||||
"This variable has been deprecated and can be replaced with \"Current form\"": "この変数は非推奨です。代わりに「現在のフォーム」を使用してください",
|
||||
"The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string.": "この変数の値はページURLのクエリ文字列から取得されます。この変数は、ページにクエリ文字列がある場合にのみ正常に使用できます。",
|
||||
"URL search params": "URL検索パラメータ",
|
||||
"Expand All": "すべて展開"
|
||||
"Expand All": "すべて展開",
|
||||
"Clear default value": "デフォルト値をクリア"
|
||||
}
|
||||
|
@ -873,5 +873,6 @@
|
||||
"This variable has been deprecated and can be replaced with \"Current form\"": "변수가 폐기되었습니다. \"현재 폼\"을 대체로 사용할 수 있습니다",
|
||||
"The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string.": "이 변수의 값은 페이지 URL의 쿼리 문자열에서 파생됩니다. 이 변수는 페이지에 쿼리 문자열이 있는 경우에만 정상적으로 사용할 수 있습니다.",
|
||||
"URL search params": "URL 검색 매개변수",
|
||||
"Expand All": "모두 펼치기"
|
||||
"Expand All": "모두 펼치기",
|
||||
"Clear default value": "기본값 지우기"
|
||||
}
|
||||
|
@ -739,5 +739,6 @@
|
||||
"URL search params": "Parâmetros de pesquisa de URL",
|
||||
"Expand All": "Expandir tudo",
|
||||
"Parent popup record": "Registro pop-up pai",
|
||||
"Current popup record": "Registro pop-up atual"
|
||||
"Current popup record": "Registro pop-up atual",
|
||||
"Clear default value": "Limpar valor padrão"
|
||||
}
|
||||
|
@ -576,5 +576,6 @@
|
||||
"This variable has been deprecated and can be replaced with \"Current form\"": "Переменная устарела; \"Текущая форма\" может быть использована в качестве замены",
|
||||
"The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string.": "Значение этой переменной происходит из строки запроса URL страницы. Эта переменная может использоваться только в том случае, если у страницы есть строка запроса.",
|
||||
"URL search params": "Параметры поиска URL",
|
||||
"Expand All": "Развернуть все"
|
||||
"Expand All": "Развернуть все",
|
||||
"Clear default value": "Очистить значение по умолчанию"
|
||||
}
|
||||
|
@ -574,5 +574,6 @@
|
||||
"This variable has been deprecated and can be replaced with \"Current form\"": "Değişken kullanımdan kaldırıldı; \"Geçerli form\" yerine kullanılabilir",
|
||||
"The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string.": "Bu değişkenin değeri sayfa URL'sinin sorgu dizgisinden türetilir. Bu değişken, sayfanın bir sorgu dizgisi olduğunda yalnızca normal olarak kullanılabilir.",
|
||||
"URL search params": "URL arama parametreleri",
|
||||
"Expand All": "Tümünü genişlet"
|
||||
"Expand All": "Tümünü genişlet",
|
||||
"Clear default value": "Varsayılan değeri temizle"
|
||||
}
|
||||
|
@ -782,5 +782,6 @@
|
||||
"This variable has been deprecated and can be replaced with \"Current form\"": "Змінна була застарілою; \"Поточна форма\" може бути використана як заміна",
|
||||
"The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string.": "Значення цієї змінної походить з рядка запиту URL-адреси сторінки. Цю змінну можна використовувати нормально лише тоді, коли у сторінки є рядок запиту.",
|
||||
"URL search params": "Параметри пошуку URL",
|
||||
"Expand All": "Розгорнути все"
|
||||
"Expand All": "Розгорнути все",
|
||||
"Clear default value": "Очистити значення за замовчуванням"
|
||||
}
|
||||
|
@ -962,5 +962,6 @@
|
||||
"Add parameter": "添加参数",
|
||||
"URL search params": "URL 查询参数",
|
||||
"Expand All": "展开全部",
|
||||
"Search": "搜索"
|
||||
"Search": "搜索",
|
||||
"Clear default value": "清除默认值"
|
||||
}
|
||||
|
@ -871,5 +871,6 @@
|
||||
"This variable has been deprecated and can be replaced with \"Current form\"": "該變數已被棄用,可以使用“當前表單”作為替代",
|
||||
"The value of this variable is derived from the query string of the page URL. This variable can only be used normally when the page has a query string.": "該變數的值來自頁面 URL 的查詢字符串,只有當頁面有查詢字符串時,該變數才能正常使用。",
|
||||
"URL search params": "URL 查詢參數",
|
||||
"Expand All": "展開全部"
|
||||
"Expand All": "展開全部",
|
||||
"Clear default value": "清除預設值"
|
||||
}
|
||||
|
@ -71,6 +71,23 @@ test.describe('filter form', () => {
|
||||
await expect(
|
||||
page.getByLabel('block-item-CardItem-users-table').getByRole('button', { name: 'Super Admin' }),
|
||||
).not.toBeVisible();
|
||||
|
||||
// 5. 打开 “Clear default value” 开关,然后点击 Reset 按钮,应该显示所有数据
|
||||
await page.getByLabel('action-Action-Reset-users-').hover();
|
||||
await page.getByRole('button', { name: 'designer-schema-settings-Action-Action.Designer-users' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Clear default value' }).click();
|
||||
await page.getByLabel('action-Action-Reset-users-').click({
|
||||
position: {
|
||||
x: 10,
|
||||
y: 10,
|
||||
},
|
||||
});
|
||||
await expect(
|
||||
page.getByLabel('block-item-CardItem-users-table').getByRole('button', { name: 'test name' }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByLabel('block-item-CardItem-users-table').getByRole('button', { name: 'Super Admin' }),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('with dataLoadingMode is manual', async ({ page, mockPage, mockRecord }) => {
|
||||
@ -124,5 +141,17 @@ test.describe('filter form', () => {
|
||||
await expect(
|
||||
page.getByLabel('block-item-CardItem-users-table').getByRole('button', { name: 'test name' }),
|
||||
).not.toBeVisible();
|
||||
|
||||
// 5. 打开 “Clear default value” 开关,然后点击 Reset 按钮,应该显示空数据
|
||||
await page.getByLabel('action-Action-Reset-users-').hover();
|
||||
await page.getByRole('button', { name: 'designer-schema-settings-Action-Action.Designer-users' }).hover();
|
||||
await page.getByRole('menuitem', { name: 'Clear default value' }).click();
|
||||
await page.getByLabel('action-Action-Reset-users-').click({
|
||||
position: {
|
||||
x: 10,
|
||||
y: 10,
|
||||
},
|
||||
});
|
||||
await expect(page.getByLabel('block-item-CardItem-users-table').getByText('No data')).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
@ -768,6 +768,33 @@ export const actionSettingsItems: SchemaSettingOptions['items'] = [
|
||||
return isValid(fieldSchema?.['x-action-settings']?.triggerWorkflows);
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'switch',
|
||||
name: 'clearDefaultValue',
|
||||
useComponentProps() {
|
||||
const { t } = useTranslation();
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { dn } = useDesignable();
|
||||
|
||||
return {
|
||||
title: t('Clear default value'),
|
||||
checked: fieldSchema?.['x-component-props']?.clearDefaultValue,
|
||||
onChange: (value) => {
|
||||
dn.deepMerge({
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
'x-component-props': {
|
||||
clearDefaultValue: value,
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
useVisible() {
|
||||
const fieldSchema = useFieldSchema();
|
||||
const isResetButton = fieldSchema['x-use-component-props'] === 'useResetBlockActionProps';
|
||||
return isResetButton;
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'remove',
|
||||
sort: 100,
|
||||
|
Loading…
Reference in New Issue
Block a user