@omniumretail/component-library 1.1.73 → 1.1.74
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/dist/bundle.js +1 -1
- package/package.json +1 -1
- package/src/components/Category/CategoryContent/index.tsx +0 -2
- package/src/components/Category/CategorySidebar/index.tsx +30 -19
- package/src/components/Category/index.tsx +1 -1
- package/src/locales/en.json +2 -1
- package/src/locales/es.json +2 -1
- package/src/locales/pt.json +2 -1
package/package.json
CHANGED
|
@@ -81,8 +81,6 @@ export const CategoryContent = (props: categoryContent) => {
|
|
|
81
81
|
setSwitchYesOrNoAnswStatus(initialValues?.isYesOrNo || false);
|
|
82
82
|
}, [form, initialValues]);
|
|
83
83
|
|
|
84
|
-
console.log();
|
|
85
|
-
|
|
86
84
|
return (
|
|
87
85
|
<div className={styles.categoryContent}>
|
|
88
86
|
<div className={styles.title}>{t('components.categoryContent.editCategory')}</div>
|
|
@@ -82,11 +82,11 @@ function remove_nested_element(data: DataNode[], index: string | number): DataNo
|
|
|
82
82
|
export const CategorySidebar = (props: SidebarProps) => {
|
|
83
83
|
const {
|
|
84
84
|
categoryContentData,
|
|
85
|
-
categoryContentFinalData,
|
|
86
85
|
data,
|
|
87
86
|
hasHeader
|
|
88
87
|
} = props;
|
|
89
88
|
|
|
89
|
+
const [sidebarInfo, setSidebarInfo] = useState<any>(hasHeader ? ["0"] : undefined);
|
|
90
90
|
const [gData, setGData] = useState<DataNode[]>(() => {
|
|
91
91
|
// Adiciona a categoria "Header" se hasHeader for true
|
|
92
92
|
if (hasHeader && data?.length === 0) {
|
|
@@ -127,7 +127,6 @@ export const CategorySidebar = (props: SidebarProps) => {
|
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
const [expandedKeys] = useState([]);
|
|
130
|
-
const [sidebarInfo, setSidebarInfo] = useState<any>(undefined);
|
|
131
130
|
|
|
132
131
|
const onDragEnter: TreeProps['onDragEnter'] = (info) => {
|
|
133
132
|
// drag entered
|
|
@@ -242,6 +241,8 @@ export const CategorySidebar = (props: SidebarProps) => {
|
|
|
242
241
|
...prevCategories,
|
|
243
242
|
{ title: t('components.category.newCategory'), key: `${gData.length}` },
|
|
244
243
|
])
|
|
244
|
+
|
|
245
|
+
setSidebarInfo([`${gData.length}`]);
|
|
245
246
|
}
|
|
246
247
|
|
|
247
248
|
const removeCategory = () => {
|
|
@@ -257,28 +258,36 @@ export const CategorySidebar = (props: SidebarProps) => {
|
|
|
257
258
|
selectKey: sidebarInfo,
|
|
258
259
|
data: get_element_by_index(gData, sidebarInfo && sidebarInfo[0]),
|
|
259
260
|
});
|
|
261
|
+
|
|
260
262
|
}, [sidebarInfo]);
|
|
261
263
|
|
|
262
|
-
|
|
264
|
+
function updateCategoryTitles(categories: any[]): any[] {
|
|
265
|
+
return categories.map((category: any, index: number) => {
|
|
266
|
+
if (category?.data) {
|
|
267
|
+
const titleWithoutCounts = category.title.replace(/\(Q: \d+\)/g, '').replace(/\(G: \d+\)/g, '').trim();
|
|
268
|
+
const updatedTitle = `${titleWithoutCounts} ${category.data.questions ? '(Q: ' + category.data.questions.length + ')' : ''} ${category.data.grade ? '(G: ' + category.data.grade + ')' : ''}`;
|
|
269
|
+
const updatedChildren = category.children ? updateCategoryTitles(category.children) : null;
|
|
263
270
|
|
|
264
|
-
|
|
271
|
+
return { ...category, title: updatedTitle, children: updatedChildren };
|
|
272
|
+
}
|
|
273
|
+
return category;
|
|
274
|
+
});
|
|
275
|
+
}
|
|
265
276
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const updatedChildren = category.children ? updateCategoryTitles(category.children) : null;
|
|
272
|
-
|
|
273
|
-
return { ...category, title: updatedTitle, children: updatedChildren };
|
|
274
|
-
}
|
|
275
|
-
return category;
|
|
276
|
-
});
|
|
277
|
-
}
|
|
277
|
+
useEffect(() => {
|
|
278
|
+
if (hasHeader) {
|
|
279
|
+
if (categoryContentData?.categoryName) {
|
|
280
|
+
const newGData = addPropertyByIndex(gData, sidebarInfo && sidebarInfo[0], "data", categoryContentData);
|
|
281
|
+
const updatedGData: any[] = updateCategoryTitles(newGData);
|
|
278
282
|
|
|
279
|
-
|
|
283
|
+
setGData(updatedGData);
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
const newGData = addPropertyByIndex(gData, sidebarInfo && sidebarInfo[0], "data", categoryContentData);
|
|
287
|
+
const updatedGData: any[] = updateCategoryTitles(newGData);
|
|
280
288
|
|
|
281
|
-
|
|
289
|
+
setGData(updatedGData);
|
|
290
|
+
}
|
|
282
291
|
}, [categoryContentData]);
|
|
283
292
|
|
|
284
293
|
useEffect(() => {
|
|
@@ -292,7 +301,7 @@ export const CategorySidebar = (props: SidebarProps) => {
|
|
|
292
301
|
|
|
293
302
|
return (
|
|
294
303
|
<div className={styles.categorySidebar}>
|
|
295
|
-
<div className={styles.title}>
|
|
304
|
+
<div className={styles.title}>{t('components.categorySidBar.categories')}</div>
|
|
296
305
|
<Button icon={<PlusOutlined />} onClick={addCategory}>
|
|
297
306
|
{t('components.categorySidBar.addCategory')}
|
|
298
307
|
</Button>
|
|
@@ -307,6 +316,7 @@ export const CategorySidebar = (props: SidebarProps) => {
|
|
|
307
316
|
|
|
308
317
|
<div className={styles.categoryViewer}>
|
|
309
318
|
<Tree
|
|
319
|
+
defaultSelectedKeys={hasHeader ? ["0"] : undefined}
|
|
310
320
|
className="draggable-tree"
|
|
311
321
|
defaultExpandedKeys={expandedKeys}
|
|
312
322
|
draggable
|
|
@@ -315,6 +325,7 @@ export const CategorySidebar = (props: SidebarProps) => {
|
|
|
315
325
|
onDrop={onDrop}
|
|
316
326
|
treeData={gData}
|
|
317
327
|
onSelect={onSelect}
|
|
328
|
+
selectedKeys={sidebarInfo}
|
|
318
329
|
/>
|
|
319
330
|
</div>
|
|
320
331
|
</div>
|
package/src/locales/en.json
CHANGED
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
},
|
|
62
62
|
"categorySidBar": {
|
|
63
63
|
"addCategory": "Add Category",
|
|
64
|
-
"removeCategory": "Remove Category"
|
|
64
|
+
"removeCategory": "Remove Category",
|
|
65
|
+
"categories": "Categories"
|
|
65
66
|
},
|
|
66
67
|
"categoryContent": {
|
|
67
68
|
"message": "Please select a category in the sidebar",
|
package/src/locales/es.json
CHANGED
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
},
|
|
62
62
|
"categorySidBar": {
|
|
63
63
|
"addCategory": "Agregar Categoría",
|
|
64
|
-
"removeCategory": "Eliminar Categoría"
|
|
64
|
+
"removeCategory": "Eliminar Categoría",
|
|
65
|
+
"categories": "Categorías"
|
|
65
66
|
},
|
|
66
67
|
"categoryContent": {
|
|
67
68
|
"message": "Por favor, seleccione una categoría en la barra lateral",
|
package/src/locales/pt.json
CHANGED
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
},
|
|
62
62
|
"categorySidBar": {
|
|
63
63
|
"addCategory": "Adicionar categoria",
|
|
64
|
-
"removeCategory": "Remover categoria"
|
|
64
|
+
"removeCategory": "Remover categoria",
|
|
65
|
+
"categories": "Categorias"
|
|
65
66
|
},
|
|
66
67
|
"categoryContent": {
|
|
67
68
|
"message": "Por favor selecione uma categoria na barra lateral",
|