mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
fix: mobile saveas template not working correctly (#6420)
This commit is contained in:
parent
34de353e4a
commit
67fb0df0f8
@ -857,5 +857,6 @@
|
||||
"Notification": "Notifica",
|
||||
"Ellipsis overflow content": "Contenuto Ellipsis overflow",
|
||||
"Hide column": "Nascondi colonna",
|
||||
"In configuration mode, the entire column becomes transparent. In non-configuration mode, the entire column will be hidden. Even if the entire column is hidden, its configured default values and other settings will still take effect.": "In modalità di configurazione, l'intera colonna diventa trasparente. In modalità non di configurazione, l'intera colonna verrà nascosta. Anche se l'intera colonna è nascosta, i suoi valori predefiniti configurati e le altre impostazioni avranno comunque effetto."
|
||||
"In configuration mode, the entire column becomes transparent. In non-configuration mode, the entire column will be hidden. Even if the entire column is hidden, its configured default values and other settings will still take effect.": "In modalità di configurazione, l'intera colonna diventa trasparente. In modalità non di configurazione, l'intera colonna verrà nascosta. Anche se l'intera colonna è nascosta, i suoi valori predefiniti configurati e le altre impostazioni avranno comunque effetto.",
|
||||
"The following old template features have been deprecated and will be removed in next version.": "Le seguenti funzionalità dei modelli vecchi sono state deprecate e saranno rimosse nella prossima versione."
|
||||
}
|
||||
|
@ -1083,5 +1083,5 @@
|
||||
"Are you sure you want to hide this tab?": "你确定要隐藏该标签页吗?",
|
||||
"After hiding, this tab will no longer appear in the tab bar. To show it again, you need to go to the route management page to set it.": "隐藏后,该标签将不再显示在标签栏中。要想再次显示它,你需要到路由管理页面进行设置。",
|
||||
"Deprecated": "已弃用",
|
||||
"The following old templates have been deprecated and will be removed in next version.": "以下旧的模板功能已弃用,将在下个版本移除。"
|
||||
"The following old template features have been deprecated and will be removed in next version.": "以下旧的模板功能已弃用,将在下个版本移除。"
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ export const BlockTemplatePage = () => {
|
||||
<div
|
||||
style={{
|
||||
margin: -token.margin,
|
||||
marginTop: -token.marginXL,
|
||||
padding: token.paddingSM,
|
||||
background: token.colorBgContainer,
|
||||
display: 'flex',
|
||||
|
@ -7,7 +7,7 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { ISchema, SchemaSettingsModalItem, useResource } from '@nocobase/client';
|
||||
import { ISchema, SchemaSettingsModalItem, useResource, useSchemaSettings } from '@nocobase/client';
|
||||
import React from 'react';
|
||||
import { useT } from '../locale';
|
||||
import { useFieldSchema, useField, useForm } from '@formily/react';
|
||||
@ -19,6 +19,7 @@ import { blockKeepProps } from '../initializers/TemplateBlockInitializer';
|
||||
import _ from 'lodash';
|
||||
import { addToolbarClass, syncExtraTemplateInfo } from '../utils/template';
|
||||
import { useBlockTemplateMenus } from './BlockTemplateMenusProvider';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
const blockDecoratorMenuMaps = {
|
||||
TableBlockProvider: ['Table', 'table'],
|
||||
@ -45,6 +46,8 @@ export const SaveAsTemplateSetting = () => {
|
||||
const { message } = App.useApp();
|
||||
const plugin = usePlugin(PluginBlockTemplateClient);
|
||||
const { templates } = useBlockTemplateMenus();
|
||||
const location = useLocation();
|
||||
const { template: deprecatedTemplate } = useSchemaSettings();
|
||||
|
||||
return (
|
||||
<SchemaSettingsModalItem
|
||||
@ -83,11 +86,11 @@ export const SaveAsTemplateSetting = () => {
|
||||
}
|
||||
onSubmit={async ({ title, key, description }) => {
|
||||
// step 0: get type of the current block
|
||||
const type = window.location.pathname.startsWith('/m/') ? 'Mobile' : 'Desktop';
|
||||
const type = location.pathname.startsWith('/page/') ? 'Mobile' : 'Desktop';
|
||||
const schemaUid = uid();
|
||||
const isMobile = type === 'Mobile';
|
||||
const templateSchema = getTemplateSchemaFromPage(fieldSchema.toJSON());
|
||||
if (containsReferenceTemplate(templateSchema)) {
|
||||
if (deprecatedTemplate || containsReferenceTemplate(templateSchema)) {
|
||||
message.error(t('This block is using some reference templates, please convert to duplicate template first.'));
|
||||
return;
|
||||
}
|
||||
@ -137,6 +140,7 @@ export const SaveAsTemplateSetting = () => {
|
||||
const newTemplate = {
|
||||
title,
|
||||
key,
|
||||
type,
|
||||
description,
|
||||
uid: schemaUid,
|
||||
configured: true,
|
||||
@ -180,7 +184,7 @@ export const SaveAsTemplateSetting = () => {
|
||||
return;
|
||||
}
|
||||
s['x-block-template-key'] = key;
|
||||
s['x-template-uid'] = templateSchema['x-uid'];
|
||||
s['x-template-uid'] = t['x-uid'];
|
||||
if (t.properties) {
|
||||
for (const key in t.properties) {
|
||||
fillTemplateInfo(s.properties[key], t.properties[key]);
|
||||
@ -226,7 +230,7 @@ export const SaveAsTemplateSetting = () => {
|
||||
data: getAllSchemas(schema),
|
||||
});
|
||||
// step 4: create a link between template and block
|
||||
await blockTemplatesResource.create({
|
||||
await blockTemplatesResource.link({
|
||||
values: {
|
||||
templateKey: key,
|
||||
templateBlockUid: templateSchema['x-uid'],
|
||||
|
@ -19,10 +19,10 @@ export const useIsPageBlock = () => {
|
||||
if (!fieldSchema || fieldSchema['x-template-uid']) {
|
||||
return false;
|
||||
}
|
||||
const isPage = location.pathname.includes('/admin/') || location.pathname.includes('/m/');
|
||||
const isPage = location.pathname.startsWith('/admin/') || location.pathname.startsWith('/page/');
|
||||
const notInPopup = !location.pathname.includes('/popups/');
|
||||
const notInSetting = !location.pathname.includes('/admin/settings/');
|
||||
const notInBlockTemplate = !location.pathname.includes('/m/block-templates/');
|
||||
const notInSetting = !location.pathname.startsWith('/admin/settings/');
|
||||
const notInBlockTemplate = !location.pathname.startsWith('/block-templates/');
|
||||
return isPage && notInPopup && notInSetting && notInBlockTemplate;
|
||||
}, [location.pathname, fieldSchema]);
|
||||
|
||||
|
@ -16,6 +16,7 @@ import {
|
||||
SchemaSettingsTemplate,
|
||||
SchemaSettingsConnectDataBlocks,
|
||||
usePlugin,
|
||||
useSchemaSettings,
|
||||
} from '@nocobase/client';
|
||||
|
||||
export const hideConvertToBlockSettingItem = (
|
||||
@ -27,14 +28,15 @@ export const hideConvertToBlockSettingItem = (
|
||||
settingItem['Component'] === SchemaSettingsTemplate ||
|
||||
settingItem['Component'] === SchemaSettingsFormItemTemplate
|
||||
) {
|
||||
// const visible = schemaSetting.items[i]['useVisible'] || (() => true);
|
||||
// schemaSetting.items[i]['useVisible'] = () => {
|
||||
// const notInBlockTemplate = !window.location.pathname.includes('admin/settings/block-templates');
|
||||
// return notInBlockTemplate && visible();
|
||||
// };
|
||||
|
||||
// hide covert to block setting item
|
||||
settingItem['useVisible'] = () => false;
|
||||
settingItem['useVisible'] = function useVisible() {
|
||||
const { template: deprecatedTemplate } = useSchemaSettings();
|
||||
if (deprecatedTemplate && ['formItemTemplate', 'ConvertReferenceToDuplicate'].includes(settingItem['name'])) {
|
||||
// still allow user to convert reference to duplicate, this way user can migrate to new template easily
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
if (preSettingItem?.['type'] === 'divider') {
|
||||
preSettingItem['useVisible'] = () => false;
|
||||
}
|
||||
|
@ -34,5 +34,6 @@
|
||||
"Please select the records you want to delete": "Please select the records you want to delete",
|
||||
"Search and select template": "Search and select template",
|
||||
"This is part of a template, deletion is not allowed": "This is part of a template, deletion is not allowed",
|
||||
"This block is using some reference templates, please convert to duplicate template first.": "This block is using some reference templates, please convert to duplicate template first."
|
||||
"This block is using some reference templates, please convert to duplicate template first.": "This block is using some reference templates, please convert to duplicate template first.",
|
||||
"Save as template successfully": "Save as template successfully"
|
||||
}
|
@ -34,5 +34,6 @@
|
||||
"Please select the records you want to delete": "请选择要删除的记录",
|
||||
"Search and select template": "搜索并选择模板",
|
||||
"This is part of a template, deletion is not allowed": "这是模板的一部分,不允许删除",
|
||||
"This block is using some reference templates, please convert to duplicate template first.": "该区块使用了引用模板,请先将其转换为复制模板。"
|
||||
"This block is using some reference templates, please convert to duplicate template first.": "该区块使用了引用模板,请先将其转换为复制模板。",
|
||||
"Save as template successfully": "保存为模板成功"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user