-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Combine sdata to sgroup modal * Remove s-group data from left toolbar * Remove Data S-Group modal * Make code more readable
- Loading branch information
Showing
24 changed files
with
217 additions
and
233 deletions.
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
80 changes: 80 additions & 0 deletions
80
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,80 @@ | ||
/**************************************************************************** | ||
* 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) => { | ||
if (prop === 'radiobuttons') { | ||
return ( | ||
<Field | ||
name={prop} | ||
checked={checked} | ||
type="radio" | ||
key={`${context}-${fieldName}-${prop}-radio`} | ||
labelPos={false} | ||
/> | ||
) | ||
} else if (prop === 'fieldValue') { | ||
return ( | ||
<Field | ||
name={prop} | ||
key={`${context}-${fieldName}-${prop}-select`} | ||
placeholder="Enter value" | ||
/> | ||
) | ||
} else { | ||
return ( | ||
<Field | ||
name={prop} | ||
type="textarea" | ||
key={`${context}-${fieldName}-${prop}-select`} | ||
/> | ||
) | ||
} | ||
}) | ||
|
||
export default SDataFieldset |
61 changes: 61 additions & 0 deletions
61
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,61 @@ | ||
/**************************************************************************** | ||
* 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 propMapping = { | ||
name: { maxLength: 15 }, | ||
fieldName: { maxLength: 30 }, | ||
fieldValue: { type: 'textarea' }, | ||
radiobuttons: { type: 'radio' } | ||
} | ||
|
||
const content = (type) => | ||
Object.keys(schemes[type].properties) | ||
.filter((prop) => prop !== 'type') | ||
.map((prop) => { | ||
if (prop === 'connectivity') { | ||
return ( | ||
<Field | ||
name={prop} | ||
key={`${type}-${prop}`} | ||
component={Select} | ||
options={getSelectOptionsFromSchema(schemes[type].properties[prop])} | ||
/> | ||
) | ||
} | ||
|
||
const props = propMapping[prop] || {} | ||
return <Field name={prop} key={`${type}-${prop}`} {...props} /> | ||
}) | ||
|
||
export default SGroupFieldset |
Oops, something went wrong.