@griddo/ax 11.7.1 → 11.7.2-rc.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "11.7.1",
4
+ "version": "11.7.2-rc.1",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -223,5 +223,5 @@
223
223
  "publishConfig": {
224
224
  "access": "public"
225
225
  },
226
- "gitHead": "38d318f83977dd42f6ad1f304d22601b0ecc2ea1"
226
+ "gitHead": "b2689ccb9a6cf4ea02888fd0d5467343cc526d02"
227
227
  }
@@ -55,6 +55,7 @@ const Button = styled.button<{ iconFill: boolean }>`
55
55
  }
56
56
  svg {
57
57
  position: absolute;
58
+ left: 0;
58
59
  top: 50%;
59
60
  transform: translateY(-50%);
60
61
  width: ${(p) => p.theme.spacing.s};
@@ -4,6 +4,7 @@ import { connect } from "react-redux";
4
4
  import { FormContent, GetFormsParams, IModal, IQueryValue, IRootState } from "@ax/types";
5
5
  import {
6
6
  Button,
7
+ CategoryFilter,
7
8
  EmptyState,
8
9
  ErrorToast,
9
10
  FilterTagsBar,
@@ -19,21 +20,7 @@ import { formsActions } from "@ax/containers/Forms";
19
20
  import * as S from "./style";
20
21
 
21
22
  const FormModal = (props: IFormModal): JSX.Element => {
22
- const {
23
- isOpen,
24
- toggleModal,
25
- site,
26
- forms,
27
- categories,
28
- getForms,
29
- selectedForm,
30
- setSelectedForm,
31
- selectForm,
32
- filters,
33
- filterValues,
34
- resetFilterQuery,
35
- filterItems,
36
- } = props;
23
+ const { isOpen, toggleModal, site, forms, categories, getForms, selectedForm, setSelectedForm, selectForm } = props;
37
24
 
38
25
  const tabs: string[] = [];
39
26
  if (site) {
@@ -49,6 +36,9 @@ const FormModal = (props: IFormModal): JSX.Element => {
49
36
  const [searchQuery, setSearchQuery] = useState<string>("");
50
37
  const [isLoading, setIsLoading] = useState<boolean>(false);
51
38
 
39
+ const initialState = formCategories.reduce((a, v) => ({ ...a, [v.value]: [{ value: "all", label: "All" }] }), {});
40
+ const [filterValues, setFilterValues] = useState<Record<string, IQueryValue[]>>(initialState);
41
+
52
42
  const siteID = site && selectedTab !== "Global" ? site : null;
53
43
  const isFiltering = searchQuery.length > 0 || Object.values(filterValues).length;
54
44
 
@@ -98,6 +88,33 @@ const FormModal = (props: IFormModal): JSX.Element => {
98
88
  }
99
89
  };
100
90
 
91
+ const filterItems = (filterPointer: string, filtersSelected: IQueryValue[]) =>
92
+ setFilterValues((state) => ({ ...state, [filterPointer]: filtersSelected }));
93
+
94
+ const resetFilterQuery = () => setFilterValues(initialState);
95
+
96
+ const filters = formCategories ? (
97
+ <S.Filters>
98
+ {formCategories.map((formCategory, i: number) => (
99
+ <S.FilterWrapper key={formCategory.value}>
100
+ <CategoryFilter
101
+ filterItems={filterItems}
102
+ value={filterValues[formCategory.value]}
103
+ formCategory={formCategory}
104
+ siteID={siteID}
105
+ pointer={formCategory.value}
106
+ autoWidth={true}
107
+ menuPosition={i === formCategories.length - 1 && !isGlobal ? "right" : "left"}
108
+ hideValues={categories}
109
+ hideOnLoading={true}
110
+ />
111
+ </S.FilterWrapper>
112
+ ))}
113
+ </S.Filters>
114
+ ) : (
115
+ <></>
116
+ );
117
+
101
118
  const emptySearchStateProps = {
102
119
  icon: "search",
103
120
  title: "Oh! No Results Found",
@@ -184,10 +201,6 @@ interface IFormModal extends IModal {
184
201
  setSelectedForm: Dispatch<SetStateAction<FormContent | null>>;
185
202
  selectForm(): void;
186
203
  categories?: string[];
187
- filters: JSX.Element;
188
- filterValues: Record<string, IQueryValue[]>;
189
- resetFilterQuery(): void;
190
- filterItems(filterPointer: string, filtersSelected: IQueryValue[]): void;
191
204
  }
192
205
 
193
206
  const mapStateToProps = (state: IRootState) => ({
@@ -1,8 +1,8 @@
1
1
  import React, { useState } from "react";
2
2
  import { useModal, usePermission } from "@ax/hooks";
3
- import { getSchemaFormCategories, trimText } from "@ax/helpers";
4
- import { ActionMenu, CategoryFilter, HiddenField, Icon } from "@ax/components";
5
- import { FormContent, IQueryValue, ISite } from "@ax/types";
3
+ import { trimText } from "@ax/helpers";
4
+ import { ActionMenu, HiddenField, Icon } from "@ax/components";
5
+ import { FormContent, ISite } from "@ax/types";
6
6
 
7
7
  import FormModal from "./FormModal";
8
8
 
@@ -14,16 +14,9 @@ const FormContainer = (props: IFormContainerProps): JSX.Element => {
14
14
  const { title: formTitle } = value || { title: "" };
15
15
 
16
16
  const isEmpty = !value;
17
- const isGlobal = !site;
18
- const schemaFormCategories = getSchemaFormCategories();
19
17
 
20
18
  const { isOpen, toggleModal } = useModal();
21
19
  const [selectedForm, setSelectedForm] = useState<FormContent | null>(value || null);
22
- const initialState = schemaFormCategories.reduce(
23
- (a, v) => ({ ...a, [v.value]: [{ value: "all", label: "All" }] }),
24
- {}
25
- );
26
- const [filterValues, setFilterValues] = useState<Record<string, IQueryValue[]>>(initialState);
27
20
 
28
21
  const addFormPermission = site ? "forms.addFormsToPage" : "global.forms.addFormsToPage";
29
22
  const overwriteFormPermission = site ? "forms.overwriteDataForms" : "global.forms.overwriteDataForms";
@@ -53,31 +46,6 @@ const FormContainer = (props: IFormContainerProps): JSX.Element => {
53
46
  ]
54
47
  : [];
55
48
 
56
- const filterItems = (filterPointer: string, filtersSelected: IQueryValue[]) =>
57
- setFilterValues((state) => ({ ...state, [filterPointer]: filtersSelected }));
58
-
59
- const resetFilterQuery = () => setFilterValues(initialState);
60
-
61
- const filters = (
62
- <S.Filters>
63
- {schemaFormCategories.map((formCategory, i: number) => (
64
- <S.FilterWrapper key={formCategory.value}>
65
- <CategoryFilter
66
- filterItems={filterItems}
67
- value={filterValues[formCategory.value]}
68
- formCategory={formCategory}
69
- siteID={site?.id || null}
70
- pointer={formCategory.value}
71
- autoWidth={true}
72
- menuPosition={i === schemaFormCategories.length - 1 && !isGlobal ? "right" : "left"}
73
- hideValues={formCategories}
74
- hideOnLoading={true}
75
- />
76
- </S.FilterWrapper>
77
- ))}
78
- </S.Filters>
79
- );
80
-
81
49
  return (
82
50
  <>
83
51
  {isEmpty ? (
@@ -109,10 +77,6 @@ const FormContainer = (props: IFormContainerProps): JSX.Element => {
109
77
  setSelectedForm={setSelectedForm}
110
78
  selectForm={handleSelectForm}
111
79
  categories={formCategories}
112
- filters={filters}
113
- filterValues={filterValues}
114
- resetFilterQuery={resetFilterQuery}
115
- filterItems={filterItems}
116
80
  />
117
81
  )}
118
82
  </>
@@ -72,7 +72,7 @@ const CategoryFilter = (props: ICategoryFilterProps): JSX.Element => {
72
72
  setOptions(filters);
73
73
  });
74
74
  // eslint-disable-next-line react-hooks/exhaustive-deps
75
- }, []);
75
+ }, [siteID]);
76
76
 
77
77
  useEffect(() => {
78
78
  const parsedValue = Array.isArray(value) ? value.map((val) => val.value) : [];
@@ -3,7 +3,6 @@ import { FieldsBehavior } from "@ax/components";
3
3
 
4
4
  const Wrapper = styled.div`
5
5
  display: flex;
6
- border-top: ${(p) => `1px solid ${p.theme.color.uiLine}`};
7
6
  height: 100%;
8
7
  `;
9
8
 
@@ -3,7 +3,6 @@ import { FieldsBehavior } from "@ax/components";
3
3
 
4
4
  const Wrapper = styled.div`
5
5
  display: flex;
6
- border-top: ${(p) => `1px solid ${p.theme.color.uiLine}`};
7
6
  height: 100%;
8
7
  `;
9
8
 
@@ -2,7 +2,6 @@ import styled from "styled-components";
2
2
 
3
3
  const Wrapper = styled.div`
4
4
  border-top: 1px solid ${(p) => p.theme.color.uiLine};
5
- border-bottom: 1px solid ${(p) => p.theme.color.uiLine};
6
5
  margin: ${(p) => p.theme.spacing.m} 0;
7
6
  padding: ${(p) => p.theme.spacing.m} 0;
8
7
  `;