@griddo/ax 11.0.26 → 11.0.27-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/griddo-config/cx-polyfills/componentsBundle.js +1 -1
- package/package.json +2 -2
- package/scripts/griddo-sync-schemas.js +53 -37
- package/src/GlobalStore.tsx +3 -0
- package/src/__tests__/components/TableFilters/LiveFilter/LiveFilter.test.tsx +6 -0
- package/src/api/forms.tsx +191 -0
- package/src/api/index.tsx +2 -0
- package/src/components/Browser/index.tsx +42 -37
- package/src/components/Browser/style.tsx +3 -3
- package/src/components/BrowserContent/index.tsx +1 -1
- package/src/components/ConfigPanel/Form/index.tsx +6 -5
- package/src/components/ConfigPanel/GlobalPageForm/index.tsx +3 -1
- package/src/components/ConfigPanel/Header/index.tsx +1 -0
- package/src/components/Fields/ComponentArray/MixableComponentArray/AddItemButton/index.tsx +4 -5
- package/src/components/Fields/ComponentArray/MixableComponentArray/index.tsx +4 -4
- package/src/components/Fields/ComponentArray/helpers.tsx +1 -1
- package/src/components/Fields/FormFieldArray/index.tsx +13 -0
- package/src/components/Fields/ReferenceField/AutoPanel/index.tsx +1 -2
- package/src/components/Fields/ReferenceField/Context/index.tsx +0 -2
- package/src/components/Fields/ReferenceField/ItemList/index.tsx +1 -2
- package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +2 -2
- package/src/components/Fields/ReferenceField/index.tsx +1 -5
- package/src/components/Fields/TextField/index.tsx +3 -3
- package/src/components/Fields/TranslateButton/index.tsx +48 -10
- package/src/components/Fields/Wysiwyg/helpers.tsx +2 -2
- package/src/components/Fields/Wysiwyg/index.tsx +4 -11
- package/src/components/Fields/index.tsx +2 -0
- package/src/components/FieldsBehavior/index.tsx +8 -2
- package/src/components/Icon/components/Form.js +12 -0
- package/src/components/Icon/svgs/Form.svg +3 -0
- package/src/components/LanguageMenu/index.tsx +30 -27
- package/src/components/MainWrapper/AppBar/index.tsx +23 -68
- package/src/components/MainWrapper/index.tsx +4 -9
- package/src/components/MenuItem/index.tsx +2 -2
- package/src/components/ResizePanel/index.tsx +3 -2
- package/src/components/ResizePanel/style.tsx +11 -9
- package/src/components/SearchField/style.tsx +2 -2
- package/src/components/SideModal/SideModalOption/index.tsx +3 -2
- package/src/components/SideModal/SideModalOption/style.tsx +2 -2
- package/src/components/SideModal/index.tsx +11 -4
- package/src/components/SideModal/style.tsx +9 -7
- package/src/components/TableFilters/LiveFilter/index.tsx +4 -3
- package/src/components/index.tsx +4 -0
- package/src/containers/App/reducer.tsx +4 -1
- package/src/containers/Forms/actions.tsx +853 -0
- package/src/containers/Forms/constants.tsx +46 -0
- package/src/containers/Forms/index.tsx +4 -0
- package/src/containers/Forms/interfaces.tsx +95 -0
- package/src/containers/Forms/reducer.tsx +81 -0
- package/src/containers/Forms/utils.tsx +42 -0
- package/src/containers/Navigation/Menu/actions.tsx +6 -13
- package/src/containers/Navigation/Menu/reducer.tsx +0 -4
- package/src/containers/PageEditor/actions.tsx +3 -2
- package/src/containers/PageEditor/reducer.tsx +2 -2
- package/src/forms/editor.tsx +3 -1
- package/src/helpers/index.tsx +12 -1
- package/src/helpers/schemas.tsx +33 -8
- package/src/helpers/structuredData.tsx +3 -1
- package/src/helpers/themes.tsx +3 -1
- package/src/helpers/thumbnails.tsx +20 -2
- package/src/modules/Analytics/GroupPanel/utils.tsx +3 -1
- package/src/modules/App/Routing/NavMenu/index.tsx +16 -6
- package/src/modules/App/Routing/index.tsx +26 -9
- package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +4 -4
- package/src/modules/Categories/CategoriesList/index.tsx +16 -16
- package/src/modules/Content/BulkHeader/TableHeader/index.tsx +1 -5
- package/src/modules/Content/PageItem/index.tsx +34 -33
- package/src/modules/Content/index.tsx +23 -36
- package/src/modules/Content/utils.tsx +3 -1
- package/src/modules/Forms/FormCategoriesList/BulkHeader/TableHeader/index.tsx +42 -0
- package/src/modules/Forms/FormCategoriesList/BulkHeader/TableHeader/style.tsx +36 -0
- package/src/modules/Forms/FormCategoriesList/BulkHeader/index.tsx +37 -0
- package/src/modules/Forms/FormCategoriesList/BulkHeader/style.tsx +9 -0
- package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +125 -0
- package/src/modules/Forms/FormCategoriesList/CategoryItem/style.tsx +91 -0
- package/src/modules/Forms/FormCategoriesList/CategoryPanel/Form/index.tsx +50 -0
- package/src/modules/Forms/FormCategoriesList/CategoryPanel/index.tsx +112 -0
- package/src/modules/Forms/FormCategoriesList/CategoryPanel/style.tsx +31 -0
- package/src/modules/Forms/FormCategoriesList/atoms.tsx +33 -0
- package/src/modules/Forms/FormCategoriesList/hooks.tsx +61 -0
- package/src/modules/Forms/FormCategoriesList/index.tsx +245 -0
- package/src/modules/Forms/FormCategoriesList/style.tsx +82 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/Field/index.tsx +95 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/TemplateManager/index.tsx +102 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/TemplateManager/style.tsx +9 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/index.tsx +109 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/index.tsx +76 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/style.tsx +28 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Header/index.tsx +132 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Header/style.tsx +30 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/index.tsx +86 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/style.tsx +7 -0
- package/src/modules/Forms/FormEditor/Editor/index.tsx +106 -0
- package/src/modules/Forms/FormEditor/PageBrowser/index.tsx +96 -0
- package/src/modules/Forms/FormEditor/index.tsx +295 -0
- package/src/modules/Forms/FormEditor/style.tsx +32 -0
- package/src/modules/Forms/FormList/BulkHeader/TableHeader/index.tsx +61 -0
- package/src/modules/Forms/FormList/BulkHeader/TableHeader/style.tsx +47 -0
- package/src/modules/Forms/FormList/BulkHeader/index.tsx +60 -0
- package/src/modules/Forms/FormList/FormItem/index.tsx +218 -0
- package/src/modules/Forms/FormList/FormItem/style.tsx +87 -0
- package/src/modules/Forms/FormList/Summary/index.tsx +51 -0
- package/src/modules/Forms/FormList/Summary/style.tsx +46 -0
- package/src/modules/Forms/FormList/TemplateModal/index.tsx +67 -0
- package/src/modules/Forms/FormList/TemplateModal/style.tsx +54 -0
- package/src/modules/Forms/FormList/index.tsx +266 -0
- package/src/modules/Forms/FormList/style.tsx +31 -0
- package/src/modules/Forms/FormsMenu/MenuGroup/index.tsx +57 -0
- package/src/modules/Forms/FormsMenu/MenuGroup/style.tsx +55 -0
- package/src/modules/Forms/FormsMenu/index.tsx +78 -0
- package/src/modules/Forms/FormsMenu/style.tsx +9 -0
- package/src/modules/Forms/atoms.tsx +111 -0
- package/src/modules/Forms/style.tsx +11 -0
- package/src/modules/FramePreview/index.tsx +26 -12
- package/src/modules/GlobalEditor/index.tsx +52 -21
- package/src/modules/Navigation/Defaults/DefaultsEditor/index.tsx +32 -15
- package/src/modules/Navigation/Defaults/Item/atoms.tsx +6 -5
- package/src/modules/Navigation/Defaults/Item/index.tsx +10 -10
- package/src/modules/Navigation/Defaults/index.tsx +7 -6
- package/src/modules/Navigation/Menus/List/Nav/index.tsx +2 -10
- package/src/modules/Navigation/Menus/List/Table/SidePanel/Form/index.tsx +14 -11
- package/src/modules/Navigation/Menus/List/index.tsx +15 -16
- package/src/modules/Navigation/Menus/index.tsx +9 -17
- package/src/modules/PageEditor/index.tsx +54 -31
- package/src/modules/Settings/Globals/index.tsx +3 -1
- package/src/modules/Settings/Languages/Table/Item/index.tsx +11 -9
- package/src/modules/Sites/SitesList/ListView/BulkHeader/TableHeader/index.tsx +1 -1
- package/src/modules/StructuredData/Form/index.tsx +41 -28
- package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +1 -5
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +6 -8
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +5 -7
- package/src/modules/StructuredData/StructuredDataList/index.tsx +13 -10
- package/src/modules/StructuredData/StructuredDataList/utils.tsx +2 -1
- package/src/routes/multisite.tsx +53 -16
- package/src/routes/site.tsx +1 -0
- package/src/schemas/pages/FormPage.tsx +49 -0
- package/src/schemas/pages/GlobalPage.tsx +1 -0
- package/src/schemas/pages/Page.tsx +4 -1
- package/src/schemas/pages/index.tsx +2 -1
- package/src/types/forms.tsx +87 -0
- package/src/types/index.tsx +43 -7
- /package/src/modules/Navigation/Menus/{helpers.tsx → List/helpers.tsx} +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "11.0.
|
|
4
|
+
"version": "11.0.27-rc.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -225,5 +225,5 @@
|
|
|
225
225
|
"publishConfig": {
|
|
226
226
|
"access": "public"
|
|
227
227
|
},
|
|
228
|
-
"gitHead": "
|
|
228
|
+
"gitHead": "15beb457f7fddc15b542afc42274a740b267da67"
|
|
229
229
|
}
|
|
@@ -7,36 +7,32 @@ const dotenv = require("dotenv");
|
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const fs = require("fs");
|
|
9
9
|
const compiler = require("../config/webpackSchemas.config");
|
|
10
|
-
|
|
11
10
|
const { resolveComponentsPath, resolveComponentsGriddoConfig } = require("../config/griddo-config");
|
|
12
11
|
|
|
13
12
|
dotenv.config({ path: findUp.sync(".env") });
|
|
14
13
|
|
|
15
|
-
const API_URL
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const API_METHOD = "PUT";
|
|
19
|
-
const API_DEV_KEY = process.env.developerKey;
|
|
14
|
+
const { API_URL, REACT_APP_API_ENDPOINT, GRIDDO_API_URL, developerKey } = process.env;
|
|
15
|
+
const apiURL = API_URL || REACT_APP_API_ENDPOINT || GRIDDO_API_URL;
|
|
16
|
+
const tempFile = "__griddo_config_parsed__.js";
|
|
20
17
|
|
|
21
|
-
async
|
|
18
|
+
(async () => {
|
|
22
19
|
console.clear();
|
|
23
|
-
const tempFile = "__griddo_config_parsed__.js";
|
|
24
|
-
const componentsGriddoConfig = resolveComponentsGriddoConfig();
|
|
25
20
|
|
|
26
|
-
const
|
|
21
|
+
const instanceGriddoConfigFile = resolveComponentsGriddoConfig();
|
|
22
|
+
const inputFile = instanceGriddoConfigFile;
|
|
27
23
|
const outputFile = `${__dirname}/${tempFile}`;
|
|
28
24
|
|
|
29
|
-
if (fs.existsSync(outputFile)) {
|
|
30
|
-
fs.unlinkSync(outputFile);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
25
|
try {
|
|
26
|
+
if (fs.existsSync(outputFile)) {
|
|
27
|
+
fs.unlinkSync(outputFile);
|
|
28
|
+
}
|
|
29
|
+
|
|
34
30
|
if (!fs.existsSync(inputFile)) {
|
|
35
|
-
throw new Error(`
|
|
31
|
+
throw new Error(`Griddo config file not found: ${inputFile}`);
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
await compiler({
|
|
39
|
-
input:
|
|
35
|
+
input: instanceGriddoConfigFile,
|
|
40
36
|
output: { filename: tempFile, path: __dirname },
|
|
41
37
|
});
|
|
42
38
|
|
|
@@ -49,10 +45,30 @@ async function main() {
|
|
|
49
45
|
}
|
|
50
46
|
|
|
51
47
|
const _griddoConfig = require(path.resolve(__dirname, `./${tempFile}`));
|
|
52
|
-
const griddoConfig = _griddoConfig.default
|
|
48
|
+
const griddoConfig = _griddoConfig.default;
|
|
49
|
+
|
|
50
|
+
const gcs = griddoConfig.schemas;
|
|
51
|
+
|
|
52
|
+
const _schemas = {
|
|
53
|
+
all: {
|
|
54
|
+
...gcs.ui.modules,
|
|
55
|
+
...gcs.ui.components,
|
|
56
|
+
},
|
|
57
|
+
modules: gcs.ui.modules,
|
|
58
|
+
templates: gcs.ui.templates,
|
|
59
|
+
structuredData: gcs.contentTypes.structuredData,
|
|
60
|
+
dataPacks: gcs.contentTypes.dataPacks,
|
|
61
|
+
dataPacksCategories: gcs.contentTypes.dataPacksCategories,
|
|
62
|
+
languages: gcs.config.languages,
|
|
63
|
+
menus: gcs.config.menus,
|
|
64
|
+
menuItems: gcs.config.menuItems,
|
|
65
|
+
richTextConfig: gcs.config.richTextConfig,
|
|
66
|
+
forms: gcs.forms,
|
|
67
|
+
};
|
|
53
68
|
|
|
54
|
-
// La propiedad computed en los schemas de datos estructurados se perderá si
|
|
55
|
-
|
|
69
|
+
// La propiedad computed en los schemas de datos estructurados se perderá si
|
|
70
|
+
// no la stringificamos primero.
|
|
71
|
+
parseComputedPropInStructuredDataSchemas(_schemas.structuredData);
|
|
56
72
|
|
|
57
73
|
const { version } = require(resolveComponentsPath("package.json"));
|
|
58
74
|
|
|
@@ -64,29 +80,31 @@ async function main() {
|
|
|
64
80
|
dataPacksCategories: {},
|
|
65
81
|
languages: [],
|
|
66
82
|
};
|
|
67
|
-
|
|
83
|
+
const data = { version, ...emptySchemas, ..._schemas };
|
|
84
|
+
console.log("En sync schemas mandamos este data: \n");
|
|
85
|
+
console.log(data);
|
|
86
|
+
console.log("----------");
|
|
68
87
|
try {
|
|
69
88
|
await axios({
|
|
70
|
-
url:
|
|
71
|
-
headers: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
method: API_METHOD,
|
|
75
|
-
data: { version, ...emptySchemas, ...griddoConfig.schemas },
|
|
89
|
+
url: `${apiURL}/schemas`,
|
|
90
|
+
headers: { authorization: developerKey },
|
|
91
|
+
method: "PUT",
|
|
92
|
+
data,
|
|
76
93
|
});
|
|
77
|
-
console.log("
|
|
94
|
+
console.log(`${chalk.green(" ✔")} Schemas`);
|
|
78
95
|
} catch (e) {
|
|
79
96
|
console.log(chalk.red("ERROR:"), e.response?.data?.message || e.response || e.message);
|
|
80
97
|
process.exit(1);
|
|
81
98
|
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const checkComputedSchemas = (schemas) => {
|
|
85
|
-
const structuredDataSchemas = schemas.structuredData;
|
|
99
|
+
})();
|
|
86
100
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
/**
|
|
102
|
+
* Parse the computed property of structured data schemas to string.
|
|
103
|
+
* @mutates
|
|
104
|
+
*/
|
|
105
|
+
function parseComputedPropInStructuredDataSchemas(schemas) {
|
|
106
|
+
for (const schema in schemas) {
|
|
107
|
+
const fields = schemas[schema].schema?.fields;
|
|
90
108
|
|
|
91
109
|
if (!fields) continue;
|
|
92
110
|
|
|
@@ -96,6 +114,4 @@ const checkComputedSchemas = (schemas) => {
|
|
|
96
114
|
if (computed) field.computed = computed.toString();
|
|
97
115
|
}
|
|
98
116
|
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
main();
|
|
117
|
+
}
|
package/src/GlobalStore.tsx
CHANGED
|
@@ -21,6 +21,7 @@ import { redirectsReducer, redirectsInitialState } from "./containers/Redirects/
|
|
|
21
21
|
import { analyticsReducer, analyticsInitialState } from "./containers/Analytics/reducer";
|
|
22
22
|
import { integrationsReducer, integrationsInitialState } from "./containers/Integrations/reducer";
|
|
23
23
|
import { fileDriveReducer, fileDriveInitialState } from "./containers/FileDrive/reducer";
|
|
24
|
+
import { formsReducer, formsInitialState } from "./containers/Forms/reducer";
|
|
24
25
|
import { LOGOUT } from "./containers/App/constants";
|
|
25
26
|
|
|
26
27
|
import { IRootState } from "@ax/types";
|
|
@@ -56,6 +57,7 @@ export class GlobalStore {
|
|
|
56
57
|
analytics: analyticsReducer as Reducer<any, Action<any>>,
|
|
57
58
|
integrations: integrationsReducer as Reducer<any, Action<any>>,
|
|
58
59
|
fileDrive: fileDriveReducer as Reducer<any, Action<any>>,
|
|
60
|
+
forms: formsReducer as Reducer<any, Action<any>>,
|
|
59
61
|
});
|
|
60
62
|
|
|
61
63
|
const rootReducer = (state: IRootState | undefined, action: any) => {
|
|
@@ -78,6 +80,7 @@ export class GlobalStore {
|
|
|
78
80
|
analytics: analyticsInitialState,
|
|
79
81
|
integrations: integrationsInitialState,
|
|
80
82
|
fileDrive: fileDriveInitialState,
|
|
83
|
+
forms: formsInitialState,
|
|
81
84
|
};
|
|
82
85
|
}
|
|
83
86
|
|
|
@@ -17,6 +17,7 @@ const defaultProps = mock<ILiveFilterProps>();
|
|
|
17
17
|
|
|
18
18
|
describe("LiveFilter component rendering", () => {
|
|
19
19
|
it("should render live filter", async () => {
|
|
20
|
+
defaultProps.hasBasicStatus = false;
|
|
20
21
|
defaultProps.value = [{ value: "all", label: "All" }];
|
|
21
22
|
const filterItems = jest.fn() as CalledWithMock<void, [pointer: string, filter: IQueryValue[]]>;
|
|
22
23
|
|
|
@@ -52,6 +53,7 @@ describe("LiveFilter component rendering", () => {
|
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
it("should render the component with no options", async () => {
|
|
56
|
+
defaultProps.hasBasicStatus = false;
|
|
55
57
|
defaultProps.value = [{ value: "all", label: "All" }];
|
|
56
58
|
const filterItems = jest.fn() as CalledWithMock<void, [pointer: string, filter: IQueryValue[]]>;
|
|
57
59
|
|
|
@@ -89,6 +91,7 @@ describe("LiveFilter component rendering", () => {
|
|
|
89
91
|
|
|
90
92
|
describe("LiveFilter events", () => {
|
|
91
93
|
it("should render check group on click", async () => {
|
|
94
|
+
defaultProps.hasBasicStatus = false;
|
|
92
95
|
defaultProps.value = [{ value: "all", label: "All" }];
|
|
93
96
|
const filterItemsMock = jest.fn() as CalledWithMock<void, [pointer: string, filter: IQueryValue[]]>;
|
|
94
97
|
|
|
@@ -129,6 +132,7 @@ describe("LiveFilter events", () => {
|
|
|
129
132
|
});
|
|
130
133
|
|
|
131
134
|
it("should check option on click", async () => {
|
|
135
|
+
defaultProps.hasBasicStatus = false;
|
|
132
136
|
defaultProps.value = [{ value: "all", label: "All" }];
|
|
133
137
|
const filterItemsMock = jest.fn() as CalledWithMock<void, [pointer: string, filter: IQueryValue[]]>;
|
|
134
138
|
|
|
@@ -172,6 +176,7 @@ describe("LiveFilter events", () => {
|
|
|
172
176
|
});
|
|
173
177
|
|
|
174
178
|
it("should uncheck selected option on click and select 'All' option", async () => {
|
|
179
|
+
defaultProps.hasBasicStatus = false;
|
|
175
180
|
defaultProps.value = [{ value: "all", label: "All" }];
|
|
176
181
|
const filterItemsMock = jest.fn() as CalledWithMock<void, [pointer: string, filter: IQueryValue[]]>;
|
|
177
182
|
|
|
@@ -220,6 +225,7 @@ describe("LiveFilter events", () => {
|
|
|
220
225
|
});
|
|
221
226
|
|
|
222
227
|
it("should call filterItems action on change", async () => {
|
|
228
|
+
defaultProps.hasBasicStatus = false;
|
|
223
229
|
defaultProps.value = [{ value: "all", label: "All" }];
|
|
224
230
|
const filterItemsMock = jest.fn() as CalledWithMock<void, [pointer: string, filter: IQueryValue[]]>;
|
|
225
231
|
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FormCategoriesOrderParams,
|
|
3
|
+
FormContent,
|
|
4
|
+
FormState,
|
|
5
|
+
GetFormsParams,
|
|
6
|
+
PostFormCategoryParams,
|
|
7
|
+
PutFormCategoryParams,
|
|
8
|
+
} from "@ax/types";
|
|
9
|
+
import { template } from "./config";
|
|
10
|
+
import { IServiceConfig, sendRequest } from "./utils";
|
|
11
|
+
|
|
12
|
+
const SERVICES: { [key: string]: IServiceConfig } = {
|
|
13
|
+
GET_FORMS: {
|
|
14
|
+
...template,
|
|
15
|
+
endpoint: ["/site/", "/forms"],
|
|
16
|
+
method: "GET",
|
|
17
|
+
},
|
|
18
|
+
GET_FORM: {
|
|
19
|
+
...template,
|
|
20
|
+
endpoint: "/form/",
|
|
21
|
+
method: "GET",
|
|
22
|
+
},
|
|
23
|
+
CREATE_FORM: {
|
|
24
|
+
...template,
|
|
25
|
+
endpoint: "/form",
|
|
26
|
+
method: "POST",
|
|
27
|
+
},
|
|
28
|
+
UPDATE_FORM: {
|
|
29
|
+
...template,
|
|
30
|
+
endpoint: "/form/",
|
|
31
|
+
method: "PUT",
|
|
32
|
+
},
|
|
33
|
+
DELETE_FORM: {
|
|
34
|
+
...template,
|
|
35
|
+
endpoint: "/form/",
|
|
36
|
+
method: "DELETE",
|
|
37
|
+
},
|
|
38
|
+
DELETE_FORM_BULK: {
|
|
39
|
+
...template,
|
|
40
|
+
endpoint: "/form/bulk",
|
|
41
|
+
method: "DELETE",
|
|
42
|
+
},
|
|
43
|
+
UPDATE_FORM_STATE: {
|
|
44
|
+
...template,
|
|
45
|
+
endpoint: ["/form/", "/state/"],
|
|
46
|
+
method: "PUT",
|
|
47
|
+
},
|
|
48
|
+
GET_FORM_CATEGORIES: {
|
|
49
|
+
...template,
|
|
50
|
+
endpoint: ["/site/", "/form/categories/"],
|
|
51
|
+
method: "GET",
|
|
52
|
+
},
|
|
53
|
+
CREATE_FORM_CATEGORY: {
|
|
54
|
+
...template,
|
|
55
|
+
endpoint: "/form/category",
|
|
56
|
+
method: "POST",
|
|
57
|
+
},
|
|
58
|
+
UPDATE_FORM_CATEGORY: {
|
|
59
|
+
...template,
|
|
60
|
+
endpoint: "/form/category/",
|
|
61
|
+
method: "PUT",
|
|
62
|
+
},
|
|
63
|
+
DELETE_FORM_CATEGORY: {
|
|
64
|
+
...template,
|
|
65
|
+
endpoint: "/form/category/",
|
|
66
|
+
method: "DELETE",
|
|
67
|
+
},
|
|
68
|
+
DELETE_FORM_CATEGORY_BULK: {
|
|
69
|
+
...template,
|
|
70
|
+
endpoint: "/form/category/bulk",
|
|
71
|
+
method: "DELETE",
|
|
72
|
+
},
|
|
73
|
+
ORDER_FORM_CATEGORY: {
|
|
74
|
+
...template,
|
|
75
|
+
endpoint: "/form/category/order",
|
|
76
|
+
method: "PUT",
|
|
77
|
+
},
|
|
78
|
+
FORM_AI_TRANSLATION: {
|
|
79
|
+
...template,
|
|
80
|
+
endpoint: "/translations/form/",
|
|
81
|
+
method: "POST",
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const getForms = async (siteID: number | "global", params: GetFormsParams) => {
|
|
86
|
+
const {
|
|
87
|
+
host,
|
|
88
|
+
endpoint: [prefix, suffix],
|
|
89
|
+
} = SERVICES.GET_FORMS;
|
|
90
|
+
|
|
91
|
+
const { page, itemsPerPage, pagination } = params;
|
|
92
|
+
|
|
93
|
+
SERVICES.GET_FORMS.dynamicUrl = `${host}${prefix}${siteID}${suffix}?page=${page}&itemsPerPage=${itemsPerPage}&pagination=${pagination}`;
|
|
94
|
+
return sendRequest(SERVICES.GET_FORMS);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const getForm = async (formID: number) => {
|
|
98
|
+
const { host, endpoint } = SERVICES.GET_FORM;
|
|
99
|
+
SERVICES.GET_FORM.dynamicUrl = `${host}${endpoint}${formID}`;
|
|
100
|
+
|
|
101
|
+
return sendRequest(SERVICES.GET_FORM);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const createForm = async (data: any) => sendRequest(SERVICES.CREATE_FORM, { ...data });
|
|
105
|
+
|
|
106
|
+
const updateForm = async (formID: number, data: any) => {
|
|
107
|
+
const { host, endpoint } = SERVICES.UPDATE_FORM;
|
|
108
|
+
SERVICES.UPDATE_FORM.dynamicUrl = `${host}${endpoint}${formID}`;
|
|
109
|
+
|
|
110
|
+
return sendRequest(SERVICES.UPDATE_FORM, { ...data });
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const deleteForm = async (formID: number) => {
|
|
114
|
+
const { host, endpoint } = SERVICES.DELETE_FORM;
|
|
115
|
+
|
|
116
|
+
SERVICES.DELETE_FORM.dynamicUrl = `${host}${endpoint}${formID}`;
|
|
117
|
+
|
|
118
|
+
return sendRequest(SERVICES.DELETE_FORM);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const updateFormState = async (formID: number, state: FormState) => {
|
|
122
|
+
const {
|
|
123
|
+
host,
|
|
124
|
+
endpoint: [prefix, suffix],
|
|
125
|
+
} = SERVICES.UPDATE_FORM_STATE;
|
|
126
|
+
|
|
127
|
+
SERVICES.UPDATE_FORM_STATE.dynamicUrl = `${host}${prefix}${formID}${suffix}${state}`;
|
|
128
|
+
return sendRequest(SERVICES.UPDATE_FORM_STATE);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const deleteFormBulk = async (formIds: number[]) => {
|
|
132
|
+
return sendRequest(SERVICES.DELETE_FORM_BULK, { formIds });
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const getFormTranslation = async (data: FormContent, langID: number) => {
|
|
136
|
+
const { host, endpoint } = SERVICES.FORM_AI_TRANSLATION;
|
|
137
|
+
SERVICES.FORM_AI_TRANSLATION.dynamicUrl = `${host}${endpoint}${langID}`;
|
|
138
|
+
|
|
139
|
+
return sendRequest(SERVICES.FORM_AI_TRANSLATION, { ...data });
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const getFormCategories = async (siteID: number | "global", type: string) => {
|
|
143
|
+
const {
|
|
144
|
+
host,
|
|
145
|
+
endpoint: [prefix, suffix],
|
|
146
|
+
} = SERVICES.GET_FORM_CATEGORIES;
|
|
147
|
+
|
|
148
|
+
SERVICES.GET_FORM_CATEGORIES.dynamicUrl = `${host}${prefix}${siteID}${suffix}${type}`;
|
|
149
|
+
return sendRequest(SERVICES.GET_FORM_CATEGORIES);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const createFormCategory = async (data: PostFormCategoryParams) =>
|
|
153
|
+
sendRequest(SERVICES.CREATE_FORM_CATEGORY, { ...data });
|
|
154
|
+
|
|
155
|
+
const updateFormCategory = async (categoryID: number, data: PutFormCategoryParams) => {
|
|
156
|
+
const { host, endpoint } = SERVICES.UPDATE_FORM_CATEGORY;
|
|
157
|
+
SERVICES.UPDATE_FORM_CATEGORY.dynamicUrl = `${host}${endpoint}${categoryID}`;
|
|
158
|
+
|
|
159
|
+
return sendRequest(SERVICES.UPDATE_FORM_CATEGORY, { ...data });
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const deleteFormCategory = async (categoryID: number) => {
|
|
163
|
+
const { host, endpoint } = SERVICES.DELETE_FORM_CATEGORY;
|
|
164
|
+
|
|
165
|
+
SERVICES.DELETE_FORM_CATEGORY.dynamicUrl = `${host}${endpoint}${categoryID}`;
|
|
166
|
+
|
|
167
|
+
return sendRequest(SERVICES.DELETE_FORM_CATEGORY);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const deleteFormCategoryBulk = async (categoryIds: number[]) => {
|
|
171
|
+
return sendRequest(SERVICES.DELETE_FORM_CATEGORY_BULK, { categoryIds });
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const orderFormCategory = (data: FormCategoriesOrderParams) => sendRequest(SERVICES.ORDER_FORM_CATEGORY, { ...data });
|
|
175
|
+
|
|
176
|
+
export default {
|
|
177
|
+
getForms,
|
|
178
|
+
getForm,
|
|
179
|
+
createForm,
|
|
180
|
+
updateForm,
|
|
181
|
+
deleteForm,
|
|
182
|
+
deleteFormBulk,
|
|
183
|
+
getFormCategories,
|
|
184
|
+
createFormCategory,
|
|
185
|
+
updateFormCategory,
|
|
186
|
+
deleteFormCategory,
|
|
187
|
+
deleteFormCategoryBulk,
|
|
188
|
+
orderFormCategory,
|
|
189
|
+
updateFormState,
|
|
190
|
+
getFormTranslation,
|
|
191
|
+
};
|
package/src/api/index.tsx
CHANGED
|
@@ -18,6 +18,7 @@ import redirects from "./redirects";
|
|
|
18
18
|
import analytics from "./analytics";
|
|
19
19
|
import roles from "./roles";
|
|
20
20
|
import integrations from "./integrations";
|
|
21
|
+
import forms from "./forms";
|
|
21
22
|
|
|
22
23
|
export {
|
|
23
24
|
sites,
|
|
@@ -40,4 +41,5 @@ export {
|
|
|
40
41
|
analytics,
|
|
41
42
|
roles,
|
|
42
43
|
integrations,
|
|
44
|
+
forms,
|
|
43
45
|
};
|
|
@@ -28,11 +28,13 @@ const Browser = (props: IBrowserProps): JSX.Element => {
|
|
|
28
28
|
showIframe,
|
|
29
29
|
browserRef,
|
|
30
30
|
actions,
|
|
31
|
+
editorType = "page",
|
|
31
32
|
} = props;
|
|
32
33
|
|
|
33
34
|
const { id, entity } = content;
|
|
34
35
|
const domain = window.location.origin;
|
|
35
|
-
const urlPreview = `${domain}/editor/page-preview?preview=${!!isPreview}&disabled=${!!disabled}`;
|
|
36
|
+
const urlPreview = `${domain}/editor/page-preview?preview=${!!isPreview}&disabled=${!!disabled}&type=${editorType}`;
|
|
37
|
+
const isPageEditor = editorType === "page";
|
|
36
38
|
|
|
37
39
|
const [resolution, setResolution] = useState("desktop");
|
|
38
40
|
const { isVisible, toggleToast, setIsVisible } = useToast();
|
|
@@ -106,43 +108,45 @@ const Browser = (props: IBrowserProps): JSX.Element => {
|
|
|
106
108
|
|
|
107
109
|
return (
|
|
108
110
|
<S.BrowserWrapper data-testid="browser-wrapper" ref={browserRef}>
|
|
109
|
-
|
|
110
|
-
<S.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<S.
|
|
114
|
-
<
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
<
|
|
120
|
-
<
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
111
|
+
{isPageEditor && (
|
|
112
|
+
<S.NavBar>
|
|
113
|
+
<S.NavUrl>{url}</S.NavUrl>
|
|
114
|
+
{isPreview && (
|
|
115
|
+
<S.NavActions data-testid="nav-actions-wrapper">
|
|
116
|
+
<S.IconWrapper data-testid="icon-wrapper-browser" onClick={copyUrl}>
|
|
117
|
+
<Tooltip content="Copy url to share draft" bottom>
|
|
118
|
+
<Icon name="share" size="24" />
|
|
119
|
+
</Tooltip>
|
|
120
|
+
</S.IconWrapper>
|
|
121
|
+
<S.IconWrapper active={resolution === "desktop"} onClick={() => setResolution("desktop")}>
|
|
122
|
+
<Tooltip content="Desktop" bottom>
|
|
123
|
+
<Icon name="desktop" size="24" />
|
|
124
|
+
</Tooltip>
|
|
125
|
+
</S.IconWrapper>
|
|
126
|
+
<S.IconWrapper
|
|
127
|
+
data-testid="icon-res-tablet"
|
|
128
|
+
active={resolution === "tablet"}
|
|
129
|
+
onClick={() => setResolution("tablet")}
|
|
130
|
+
>
|
|
131
|
+
<Tooltip content="Tablet" bottom>
|
|
132
|
+
<Icon name="tablet" size="24" />
|
|
133
|
+
</Tooltip>
|
|
134
|
+
</S.IconWrapper>
|
|
135
|
+
<S.IconWrapper
|
|
136
|
+
data-testid="icon-res-phone"
|
|
137
|
+
active={resolution === "phone"}
|
|
138
|
+
onClick={() => setResolution("phone")}
|
|
139
|
+
>
|
|
140
|
+
<Tooltip content="Mobile" bottom>
|
|
141
|
+
<Icon name="phone" size="24" />
|
|
142
|
+
</Tooltip>
|
|
143
|
+
</S.IconWrapper>
|
|
144
|
+
</S.NavActions>
|
|
145
|
+
)}
|
|
146
|
+
</S.NavBar>
|
|
147
|
+
)}
|
|
144
148
|
{showIframe ? (
|
|
145
|
-
<S.FrameWrapper data-testid="navbar-iframe-wrapper">
|
|
149
|
+
<S.FrameWrapper hasBorder={isPageEditor} data-testid="navbar-iframe-wrapper">
|
|
146
150
|
<iframe title="Preview" width={getWidth(resolution)} height="100%" src={urlPreview} loading="lazy" />
|
|
147
151
|
</S.FrameWrapper>
|
|
148
152
|
) : (
|
|
@@ -189,6 +193,7 @@ export interface IBrowserProps {
|
|
|
189
193
|
isPreview?: boolean;
|
|
190
194
|
showIframe?: boolean;
|
|
191
195
|
browserRef?: React.RefObject<HTMLDivElement>;
|
|
196
|
+
editorType?: "form" | "page";
|
|
192
197
|
actions?: {
|
|
193
198
|
setSelectedContentAction: any;
|
|
194
199
|
deleteModuleAction(editorID: number[]): void;
|
|
@@ -46,10 +46,10 @@ const IconWrapper = styled.div<{ active?: boolean }>`
|
|
|
46
46
|
}
|
|
47
47
|
`;
|
|
48
48
|
|
|
49
|
-
const FrameWrapper = styled.div
|
|
50
|
-
border-left:
|
|
49
|
+
const FrameWrapper = styled.div<{ hasBorder: boolean }>`
|
|
50
|
+
border-left: ${(p) => (p.hasBorder ? `1px solid ${p.theme.color.uiLine}` : "none")};
|
|
51
51
|
border-right: 1px solid ${(p) => p.theme.color.uiLine};
|
|
52
|
-
border-bottom:
|
|
52
|
+
border-bottom: ${(p) => (p.hasBorder ? `1px solid ${p.theme.color.uiLine}` : "none")};
|
|
53
53
|
display: flex;
|
|
54
54
|
justify-content: center;
|
|
55
55
|
height: 100%;
|
|
@@ -76,7 +76,7 @@ interface IProps {
|
|
|
76
76
|
footer?: any;
|
|
77
77
|
languageID: number;
|
|
78
78
|
pageLanguages: Core.Page["pageLanguages"];
|
|
79
|
-
renderer: "editor" | "preview";
|
|
79
|
+
renderer: "editor" | "preview" | "forms";
|
|
80
80
|
selectEditorID?(
|
|
81
81
|
selectedComponent: { editorID: number; component: any; type: string; parentEditorID: number },
|
|
82
82
|
parentComponent: string | undefined | null,
|
|
@@ -35,7 +35,7 @@ export const Form = (props: IFormProps): JSX.Element => {
|
|
|
35
35
|
(!isGlobal && isAllowedToEditConfigPages) || (isGlobal && isAllowedToEditGlobalData);
|
|
36
36
|
const isAllowedToEditPageSEO = (!isGlobal && isAllowedToEditSiteSeo) || (isGlobal && isAllowedToEditGlobalSeo);
|
|
37
37
|
|
|
38
|
-
const tabContent = schema.configTabs.find((tab: ISchemaTab) => tab.title === selectedTab);
|
|
38
|
+
const tabContent = schema.configTabs.find((tab: ISchemaTab) => tab.title.toLowerCase() === selectedTab);
|
|
39
39
|
const setTab = (tab: string) => setSelectedTab(tab);
|
|
40
40
|
|
|
41
41
|
const generateFields = (field: ISchemaField) => {
|
|
@@ -76,14 +76,15 @@ export const Form = (props: IFormProps): JSX.Element => {
|
|
|
76
76
|
.filter((value: string | boolean) => !!value);
|
|
77
77
|
} else {
|
|
78
78
|
mappedTabs = schema.configTabs.reduce((acc: string[], curr: ISchemaTab) => {
|
|
79
|
+
const currTitle = curr.title.toLowerCase();
|
|
79
80
|
if (
|
|
80
81
|
!isPageSchema ||
|
|
81
82
|
(isPageSchema &&
|
|
82
|
-
((
|
|
83
|
-
(
|
|
84
|
-
(
|
|
83
|
+
((currTitle === "content" && isAllowedToEditPageContent) ||
|
|
84
|
+
(currTitle === "config" && isAllowedToEditPageConfig) ||
|
|
85
|
+
(currTitle === "seo & analytics" && isAllowedToEditPageSEO)))
|
|
85
86
|
) {
|
|
86
|
-
return [...acc,
|
|
87
|
+
return [...acc, currTitle];
|
|
87
88
|
}
|
|
88
89
|
return acc;
|
|
89
90
|
}, []);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { config } from "components";
|
|
3
3
|
|
|
4
4
|
import { Icon, NoteField, Tabs } from "@ax/components";
|
|
5
5
|
import { INotification, ISchema } from "@ax/types";
|
|
@@ -9,6 +9,8 @@ import ConnectedField from "../Form/ConnectedField";
|
|
|
9
9
|
|
|
10
10
|
import * as S from "./style";
|
|
11
11
|
|
|
12
|
+
const themes = config.schemas.config.themes;
|
|
13
|
+
|
|
12
14
|
const noteText = "This is Global content and you cannot edit it here. To do so, you must go to the Global page";
|
|
13
15
|
const noteTitle = "Global content";
|
|
14
16
|
const errorText = "You don't have the permissions to edit the original content.";
|
|
@@ -2,11 +2,10 @@ import React, { memo } from "react";
|
|
|
2
2
|
import { IconAction, SideModal, Tooltip } from "@ax/components";
|
|
3
3
|
|
|
4
4
|
const AddItemButton = (props: IProps) => {
|
|
5
|
-
const { handleClick, whiteList,
|
|
6
|
-
const optionsType = isModuleArr ? "modules" : "components";
|
|
5
|
+
const { handleClick, whiteList, categories, theme, isOpen, contentType, toggleModal } = props;
|
|
7
6
|
const addAction = whiteList.length <= 1 ? () => handleClick(whiteList[0]) : toggleModal;
|
|
8
7
|
|
|
9
|
-
const tooltip =
|
|
8
|
+
const tooltip = contentType === "fields" ? "Add field" : contentType === "module" ? "Add module" : "Add component";
|
|
10
9
|
|
|
11
10
|
return (
|
|
12
11
|
<>
|
|
@@ -14,7 +13,7 @@ const AddItemButton = (props: IProps) => {
|
|
|
14
13
|
<IconAction icon="add" onClick={addAction} />
|
|
15
14
|
</Tooltip>
|
|
16
15
|
<SideModal
|
|
17
|
-
optionsType={
|
|
16
|
+
optionsType={contentType}
|
|
18
17
|
whiteList={whiteList}
|
|
19
18
|
categories={categories}
|
|
20
19
|
toggleModal={toggleModal}
|
|
@@ -30,11 +29,11 @@ const AddItemButton = (props: IProps) => {
|
|
|
30
29
|
interface IProps {
|
|
31
30
|
handleClick: any;
|
|
32
31
|
whiteList: any[];
|
|
33
|
-
isModuleArr: boolean;
|
|
34
32
|
categories?: any;
|
|
35
33
|
theme: string;
|
|
36
34
|
toggleModal: () => void;
|
|
37
35
|
isOpen: boolean;
|
|
36
|
+
contentType: string;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
export default memo(AddItemButton);
|