-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#2093 combine s group menus and remove generic s group #2140
Merged
KonstantinEpam23
merged 6 commits into
master
from
#2093-combine-s-group-menus-and-remove-generic-s-group
Feb 10, 2023
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f7b0dce
Combine sdata to sgroup modal
yuleicul c82bdd0
Remove s-group data from left toolbar
yuleicul 7e62522
Remove Data S-Group modal
yuleicul 6f8b3cf
Merge branch 'master' into #2093-combine-s-group-menus-and-remove-gen…
yuleicul 22f2ce1
Make code more readable
yuleicul 580c95d
Merge branch 'master' into #2093-combine-s-group-menus-and-remove-gen…
yuleicul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/ketcher-react/src/script/ui/dialog/toolbox/SDataFieldset.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/**************************************************************************** | ||
* Copyright 2021 EPAM Systems | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
***************************************************************************/ | ||
|
||
import { Field } from '../../component/form/form/form' | ||
import { getSelectOptionsFromSchema } from '../../utils' | ||
import Select from '../../component/form/Select' | ||
import { sdataCustomSchema } from '../../data/schema/sdata-schema' | ||
|
||
function SDataFieldset({ formState }) { | ||
const { result } = formState | ||
const formSchema = sdataCustomSchema | ||
|
||
return ( | ||
<fieldset className="sdata"> | ||
<Field | ||
name="context" | ||
options={getSelectOptionsFromSchema(formSchema.properties.context)} | ||
component={Select} | ||
/> | ||
<Field name="fieldName" placeholder="Enter name" /> | ||
{content( | ||
formSchema, | ||
result.context, | ||
result.fieldName, | ||
result.fieldValue, | ||
result.radiobuttons | ||
)} | ||
</fieldset> | ||
) | ||
} | ||
|
||
const content = (schema, context, fieldName, fieldValue, checked) => | ||
Object.keys(schema.properties) | ||
.filter( | ||
(prop) => prop !== 'type' && prop !== 'context' && prop !== 'fieldName' | ||
) | ||
.map((prop) => { | ||
return prop === 'radiobuttons' ? ( | ||
<Field | ||
name={prop} | ||
checked={checked} | ||
type="radio" | ||
key={`${context}-${fieldName}-${prop}-radio`} | ||
labelPos={false} | ||
/> | ||
) : prop === 'fieldValue' ? ( | ||
<Field | ||
name={prop} | ||
key={`${context}-${fieldName}-${prop}-select`} | ||
placeholder="Enter value" | ||
/> | ||
) : ( | ||
<Field | ||
name={prop} | ||
type="textarea" | ||
key={`${context}-${fieldName}-${prop}-select`} | ||
/> | ||
) | ||
}) | ||
|
||
export default SDataFieldset |
58 changes: 58 additions & 0 deletions
58
packages/ketcher-react/src/script/ui/dialog/toolbox/SGroupFieldset.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/**************************************************************************** | ||
* Copyright 2021 EPAM Systems | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
***************************************************************************/ | ||
|
||
import { Field } from '../../component/form/form/form' | ||
import Select from '../../component/form/Select' | ||
import { sgroupMap as schemes } from '../../data/schema/struct-schema' | ||
import { getSelectOptionsFromSchema } from '../../utils' | ||
import classes from './sgroup.module.less' | ||
|
||
function SGroupFieldset({ formState }) { | ||
const { result } = formState | ||
|
||
const type = result.type | ||
|
||
return ( | ||
<fieldset className={type === 'DAT' ? classes.data : 'base'}> | ||
{content(type)} | ||
</fieldset> | ||
) | ||
} | ||
|
||
const content = (type) => | ||
Object.keys(schemes[type].properties) | ||
.filter((prop) => prop !== 'type') | ||
.map((prop) => { | ||
const props = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small proposal, may be the following can be better:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Really good suggestions, thank you so much. |
||
if (prop === 'name') props.maxLength = 15 | ||
if (prop === 'fieldName') props.maxLength = 30 | ||
if (prop === 'fieldValue') props.type = 'textarea' | ||
if (prop === 'radiobuttons') props.type = 'radio' | ||
if (prop === 'connectivity') | ||
return ( | ||
<Field | ||
name={prop} | ||
key={`${type}-${prop}`} | ||
{...props} | ||
component={Select} | ||
options={getSelectOptionsFromSchema(schemes[type].properties[prop])} | ||
/> | ||
) | ||
|
||
return <Field name={prop} key={`${type}-${prop}`} {...props} /> | ||
}) | ||
|
||
export default SGroupFieldset |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to don't use two nested ternary operators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thank you.