diff --git a/packages/builder/cypress/integration/addMultiOptionDatatype.spec.js b/packages/builder/cypress/integration/addMultiOptionDatatype.spec.js index bc2619c53d..b3e0f413f8 100644 --- a/packages/builder/cypress/integration/addMultiOptionDatatype.spec.js +++ b/packages/builder/cypress/integration/addMultiOptionDatatype.spec.js @@ -1,41 +1,44 @@ context("Add Multi-Option Datatype", () => { - before(() => { - cy.login() - cy.createTestApp() - }) + before(() => { + cy.login() + cy.createTestApp() + }) - it("should create a new table, with data", () => { - cy.createTable("Multi Data") - cy.addColumn("Multi Data", "Test Data", "Multi-select", "1\n2\n3\n4\n5") - cy.addRowMultiValue(["1", "2", "3", "4", "5"]) - }) + it("should create a new table, with data", () => { + cy.createTable("Multi Data") + cy.addColumn("Multi Data", "Test Data", "Multi-select", "1\n2\n3\n4\n5") + cy.addRowMultiValue(["1", "2", "3", "4", "5"]) + }) - it ("should add form with multi select picker, containing 5 options", () => { - cy.navigateToFrontend() - cy.wait(500) - // Add data provider - cy.get(`[data-cy="category-Data Provider"]`).click() - cy.get('[data-cy="dataSource-prop-control"]').click() - cy.get(".dropdown").contains("Multi Data").click() - cy.wait(500) - // Add Form with schema to match table - cy.addComponent("Form", "Form") - cy.get('[data-cy="dataSource-prop-control"').click() - cy.get(".dropdown").contains("Multi Data").click() - cy.wait(500) - // Add multi-select picker to form - cy.addComponent("Form", "Multi-select Picker").then((componentId) => { - cy.get('[data-cy="field-prop-control"]').type("Test Data").type('{enter}') - cy.wait(1000) - cy.getComponent(componentId).contains("Choose some options").click() - // Check picker has 5 items - cy.getComponent(componentId).find('li').should('have.length', 5) - // Select all items - for (let i = 1; i < 6; i++) { - cy.getComponent(componentId).find('li').contains(i).click() - } - // Check items have been selected - cy.getComponent(componentId).find('.spectrum-Picker-label').contains("(5)") - }) + it("should add form with multi select picker, containing 5 options", () => { + cy.navigateToFrontend() + cy.wait(500) + // Add data provider + cy.get(`[data-cy="category-Data"]`).click() + cy.get(`[data-cy="component-Data Provider"]`).click() + cy.get('[data-cy="dataSource-prop-control"]').click() + cy.get(".dropdown").contains("Multi Data").click() + cy.wait(500) + // Add Form with schema to match table + cy.addComponent("Form", "Form") + cy.get('[data-cy="dataSource-prop-control"').click() + cy.get(".dropdown").contains("Multi Data").click() + cy.wait(500) + // Add multi-select picker to form + cy.addComponent("Form", "Multi-select Picker").then(componentId => { + cy.get('[data-cy="field-prop-control"]').type("Test Data").type("{enter}") + cy.wait(1000) + cy.getComponent(componentId).contains("Choose some options").click() + // Check picker has 5 items + cy.getComponent(componentId).find("li").should("have.length", 5) + // Select all items + for (let i = 1; i < 6; i++) { + cy.getComponent(componentId).find("li").contains(i).click() + } + // Check items have been selected + cy.getComponent(componentId) + .find(".spectrum-Picker-label") + .contains("(5)") }) + }) }) diff --git a/packages/builder/src/components/design/AppPreview/componentStructure.json b/packages/builder/src/components/design/AppPreview/componentStructure.json index 357ea5a7be..240de3ea6c 100644 --- a/packages/builder/src/components/design/AppPreview/componentStructure.json +++ b/packages/builder/src/components/design/AppPreview/componentStructure.json @@ -8,12 +8,24 @@ "repeaterblock" ] }, - "section", - "container", - "dataprovider", - "table", - "repeater", - "button", + { + "name": "Layout", + "icon": "ClassicGridView", + "children": [ + "container", + "section" + ] + }, + { + "name": "Data", + "icon": "Data", + "children": [ + "dataprovider", + "repeater", + "table", + "dynamicfilter" + ] + }, { "name": "Form", "icon": "Form", @@ -60,6 +72,7 @@ "children": [ "heading", "text", + "button", "divider", "image", "backgroundimage", diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 375aea3a02..d16b117215 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -247,7 +247,6 @@ "description": "A basic html button that is ready for styling", "icon": "Button", "editable": true, - "illegalChildren": ["section"], "showSettingsBar": true, "settings": [ { @@ -2647,6 +2646,49 @@ } ] }, + "dynamicfilter": { + "name": "Dynamic Filter", + "icon": "FilterEdit", + "showSettingsBar": true, + "settings": [ + { + "type": "dataProvider", + "label": "Provider", + "key": "dataProvider" + }, + { + "type": "multifield", + "label": "Allowed filter fields", + "key": "allowedFields", + "placeholder": "All fields" + }, + { + "type": "select", + "label": "Button size", + "showInBar": true, + "key": "size", + "options": [ + { + "label": "Small", + "value": "S" + }, + { + "label": "Medium", + "value": "M" + }, + { + "label": "Large", + "value": "L" + }, + { + "label": "Extra large", + "value": "XL" + } + ], + "defaultValue": "M" + } + ] + }, "tableblock": { "block": true, "name": "Table block", diff --git a/packages/client/src/components/ClientApp.svelte b/packages/client/src/components/ClientApp.svelte index 119a26800f..98dec9667b 100644 --- a/packages/client/src/components/ClientApp.svelte +++ b/packages/client/src/components/ClientApp.svelte @@ -121,6 +121,9 @@ -->
+ + + +
+ + + diff --git a/packages/client/src/components/app/dynamic-filter/index.js b/packages/client/src/components/app/dynamic-filter/index.js new file mode 100644 index 0000000000..5ac7d31730 --- /dev/null +++ b/packages/client/src/components/app/dynamic-filter/index.js @@ -0,0 +1 @@ +export { default as dynamicfilter } from "./DynamicFilter.svelte" diff --git a/packages/client/src/components/app/forms/Field.svelte b/packages/client/src/components/app/forms/Field.svelte index 3ef184c4a9..79de01351a 100644 --- a/packages/client/src/components/app/forms/Field.svelte +++ b/packages/client/src/components/app/forms/Field.svelte @@ -49,7 +49,7 @@ $: labelClass = labelPos === "above" ? "" : `spectrum-FieldLabel--${labelPos}` const updateLabel = e => { - builderStore.actions.updateProp("label", e.target.textContent) + builderStore.actions.updateProp("label", e.target.textContent.trim()) } diff --git a/packages/client/src/components/app/index.js b/packages/client/src/components/app/index.js index 92725f0738..f5d085e97b 100644 --- a/packages/client/src/components/app/index.js +++ b/packages/client/src/components/app/index.js @@ -33,6 +33,7 @@ export * from "./charts" export * from "./forms" export * from "./table" export * from "./blocks" +export * from "./dynamic-filter" // Deprecated component left for compatibility in old apps export { default as navigation } from "./deprecated/Navigation.svelte" diff --git a/packages/client/src/stores/builder.js b/packages/client/src/stores/builder.js index 08ac6ba906..35fb3edae2 100644 --- a/packages/client/src/stores/builder.js +++ b/packages/client/src/stores/builder.js @@ -10,7 +10,6 @@ const dispatchEvent = (type, data = {}) => { const createBuilderStore = () => { const initialState = { inBuilder: false, - appId: null, layout: null, screen: null, selectedComponentId: null, @@ -94,6 +93,7 @@ const createBuilderStore = () => { } return { ...writableStore, + set: state => writableStore.set({ ...initialState, ...state }), subscribe: derivedStore.subscribe, actions, }