Skip to content

Commit 4ad6f5d

Browse files
committed
feature: schema selector field #2217
1 parent f6c1a02 commit 4ad6f5d

5 files changed

Lines changed: 69 additions & 15 deletions

File tree

apps/sensenet/src/components/dialogs/dialogs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const ChangePasswordDialog = lazy(() => import('./change-password'))
2424
const DateRangePicker = lazy(() => import('./date-range-picker'))
2525
const AddDeleteUserGroups = lazy(() => import('./add-delete-user-groups'))
2626
const ColumnSettings = lazy(() => import('./column-settings'))
27-
const Operations = lazy(() => import('./operations'))
27+
const Operations = lazy(() => import('./operations/operations'))
2828

2929
function dialogRenderer(dialog: DialogWithProps) {
3030
switch (dialog.name) {

apps/sensenet/src/components/dialogs/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ export * from './restore'
1919
export * from './save-query'
2020
export * from './add-delete-user-groups'
2121
export * from './column-settings'
22-
export * from './operations'
22+
export * from './operations/operations'
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from 'react'
2+
3+
export type TInfluenceField = {
4+
name?: string
5+
description?: string
6+
radioOptions: Array<{ optionTitle: string; influencedFieldId: string; value: string }>
7+
}
8+
9+
export const InfluenceField: React.FC<TInfluenceField> = ({ name, description, radioOptions }) => {
10+
return (
11+
<div className="input-container">
12+
<h3>{name}</h3>
13+
<p>{description}</p>
14+
15+
{radioOptions.map((option) => {
16+
const { optionTitle, value, influencedFieldId } = option
17+
18+
return (
19+
<>
20+
<input
21+
type="radio"
22+
id={optionTitle}
23+
name={name}
24+
value={optionTitle}
25+
onClick={() => {
26+
const element = document.getElementById(influencedFieldId) as HTMLInputElement
27+
28+
if (!element) {
29+
return
30+
}
31+
32+
element.value = value
33+
}}
34+
/>
35+
<label htmlFor={optionTitle}>{optionTitle}</label>
36+
</>
37+
)
38+
})}
39+
</div>
40+
)
41+
}

apps/sensenet/src/components/dialogs/operations.tsx renamed to apps/sensenet/src/components/dialogs/operations/operations.tsx

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { Button, createStyles, DialogActions, DialogContent, makeStyles, TextFie
22
import { GenericContent } from '@sensenet/default-content-types'
33
import { useLogger, useRepository } from '@sensenet/hooks-react'
44
import React, { useEffect, useRef, useState } from 'react'
5-
import { useCurrentUser } from '../../context'
6-
import { useGlobalStyles } from '../../globalStyles'
7-
import { useLocalization } from '../../hooks'
8-
import { Icon } from '../Icon'
9-
import { DialogTitle, useDialog } from '.'
5+
import { DialogTitle, useDialog } from '..'
6+
import { useCurrentUser } from '../../../context'
7+
import { useGlobalStyles } from '../../../globalStyles'
8+
import { useLocalization } from '../../../hooks'
9+
import { Icon } from '../../Icon'
10+
import { InfluenceField, TInfluenceField } from './influenceField'
1011

1112
export interface OperationsDialogProps {
1213
content: GenericContent
@@ -15,16 +16,23 @@ export interface OperationsDialogProps {
1516
/*Ezt itt jól ki kell dolgozni!!! nem végleges csak demora van egyszerűsítve
1617
Valószínüleg nem is itt lesz a végleges helye hanem ott ahol a GenericContent van
1718
*/
18-
type UIDescription = {
19+
20+
type baseDescriptionFields = {
1921
title?: string
2022
submitTitle?: string
21-
elements: Array<{
22-
name?: string
23-
description?: string
24-
inputProps: React.HTMLProps<HTMLInputElement>
25-
}>
2623
}
2724

25+
type simpleInputField = {
26+
name?: string
27+
description?: string
28+
inputProps: React.HTMLProps<HTMLInputElement>
29+
}
30+
31+
type UIDescription =
32+
| baseDescriptionFields & {
33+
elements: Array<simpleInputField | TInfluenceField>
34+
}
35+
2836
type OperationResult = {
2937
ToastMessage?: string
3038
}
@@ -133,6 +141,10 @@ export function OperationsDialog(props: OperationsDialogProps) {
133141
submitAction(e)
134142
}}>
135143
{UIDescription?.elements.map((field, index) => {
144+
if ('radioOptions' in field) {
145+
return <InfluenceField {...field} key={index} />
146+
}
147+
136148
const { inputProps, description, name } = field
137149

138150
return (

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
},
4646
"scripts": {
4747
"postinstall": "husky install",
48-
"cy:run:dms": "cypress run --project ./examples/sn-dms-demo",
48+
"cy:run:dms": "cypress run --project ./examples/sn-dms-demo",
4949
"start:dms:e2e": "cross-env NODE_OPTIONS=--openssl-legacy-provider yarn workspace sn-dms-demo start:e2e",
5050
"test:dms:e2e": "cross-env NODE_OPTIONS=--openssl-legacy-provider start-server-and-test start:dms:e2e http-get://localhost:3000 cy:run:dms",
5151
"snapp": "yarn workspace @app/sensenet",
@@ -78,5 +78,6 @@
7878
"prettier --write"
7979
]
8080
},
81-
"dependencies": {}
81+
"dependencies": {},
82+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
8283
}

0 commit comments

Comments
 (0)