fix: option funcs for trait pane
This commit is contained in:
parent
1c2103441c
commit
6a0c4461ed
|
@ -30,7 +30,7 @@ const EntityComponent = (props) => {
|
||||||
<div className="entity">
|
<div className="entity">
|
||||||
<div className="document-pane" />
|
<div className="document-pane" />
|
||||||
<div className="settings-pane">
|
<div className="settings-pane">
|
||||||
<Traits context={entity.context} target={json.uuid} traits={traits} />
|
<Traits context={entity.context} entity={entity} target={json.uuid} traits={traits} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -19,7 +19,7 @@ const ensureTraitComponents = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const makeTraitPaneRenderer = (context, dispatch, target, traitType) => (trait) => {
|
const makeTraitPaneRenderer = (context, dispatch, entity, target, traitType) => (trait) => {
|
||||||
ensureTraitComponents();
|
ensureTraitComponents();
|
||||||
const {params, state} = trait;
|
const {params, state} = trait;
|
||||||
const {[traitType]: TraitComponent} = TraitComponents;
|
const {[traitType]: TraitComponent} = TraitComponents;
|
||||||
|
@ -50,7 +50,7 @@ const makeTraitPaneRenderer = (context, dispatch, target, traitType) => (trait)
|
||||||
<Value.Component
|
<Value.Component
|
||||||
context={context}
|
context={context}
|
||||||
onChange={(value) => dispatch(setTraitProperty({...payload, value}))}
|
onChange={(value) => dispatch(setTraitProperty({...payload, value}))}
|
||||||
options={options}
|
options={'function' === typeof options ? options(entity) : options}
|
||||||
type={type}
|
type={type}
|
||||||
value={values[key]}
|
value={values[key]}
|
||||||
/>
|
/>
|
||||||
|
@ -69,6 +69,7 @@ const makeTraitPaneRenderer = (context, dispatch, target, traitType) => (trait)
|
||||||
const TraitPane = (props) => {
|
const TraitPane = (props) => {
|
||||||
const {
|
const {
|
||||||
context,
|
context,
|
||||||
|
entity,
|
||||||
target,
|
target,
|
||||||
trait,
|
trait,
|
||||||
type,
|
type,
|
||||||
|
@ -76,8 +77,8 @@ const TraitPane = (props) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
// TODO: dependency on context is too noisy
|
// TODO: dependency on context is too noisy
|
||||||
const renderTraitPane = useMemo(
|
const renderTraitPane = useMemo(
|
||||||
() => makeTraitPaneRenderer(context, dispatch, target, type),
|
() => makeTraitPaneRenderer(context, dispatch, entity, target, type),
|
||||||
[context, dispatch, target, type],
|
[context, dispatch, entity, target, type],
|
||||||
);
|
);
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() => renderTraitPane(trait),
|
() => renderTraitPane(trait),
|
||||||
|
|
|
@ -30,7 +30,7 @@ const decorate = compose(
|
||||||
// );
|
// );
|
||||||
|
|
||||||
const Traits = (props) => {
|
const Traits = (props) => {
|
||||||
const {context, target, traits} = props;
|
const {context, entity, target, traits} = props;
|
||||||
const [tabIndex, setTabIndex] = useState(0);
|
const [tabIndex, setTabIndex] = useState(0);
|
||||||
let listRef;
|
let listRef;
|
||||||
const entries = Object.entries(traits);
|
const entries = Object.entries(traits);
|
||||||
|
@ -62,6 +62,7 @@ const Traits = (props) => {
|
||||||
<TabPanel key={type}>
|
<TabPanel key={type}>
|
||||||
<TraitPane
|
<TraitPane
|
||||||
context={context}
|
context={context}
|
||||||
|
entity={entity}
|
||||||
key={type}
|
key={type}
|
||||||
target={target}
|
target={target}
|
||||||
trait={trait}
|
trait={trait}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user