diff --git a/client/js/templates/Source.jsx b/client/js/templates/Source.jsx index c91275d12e..359187462a 100644 --- a/client/js/templates/Source.jsx +++ b/client/js/templates/Source.jsx @@ -317,6 +317,11 @@ function SourceEditForm({ [updateEditedSource] ); + const iconOnChange = useCallback( + (event) => updateEditedSource({ icon: event.target.value }), + [updateEditedSource] + ); + const spoutOnChange = useCallback( (event) => handleSpoutChange({ @@ -370,6 +375,22 @@ function SourceEditForm({ const _ = useContext(LocalizationContext); + const [showAdvanced, setShowAdvanced] = useState(false); + const [filterUsed, setFilterUsed] = useState(source.filter !== ''); + // TODO: Remove undefined check once we implement it server side. + const [iconUsed, setIconUsed] = useState(source.icon !== '' && source.icon !== undefined); + + const toggleShowAdvanced = useCallback( + () => { + setShowAdvanced((advanced) => !advanced); + console.log(source.filter); + setFilterUsed(source.filter !== ''); + // TODO: Remove undefined check once we implement it server side. + setIconUsed(source.icon !== '' && source.icon !== undefined); + }, + [source.filter, source.icon] + ); + const sourceParamsContent = ( sourceParamsLoading ? ( @@ -451,22 +472,24 @@ function SourceEditForm({ {/* filter */} -
  • - - - {sourceErrors['filter'] ? ( - {sourceErrors['filter']} - ) : null} -
  • + {showAdvanced || filterUsed ? ( +
  • + + + {sourceErrors['filter'] ? ( + {sourceErrors['filter']} + ) : null} +
  • + ) : null} {/* type */}
  • @@ -497,6 +520,26 @@ function SourceEditForm({ ) : null}
  • + {showAdvanced || iconUsed ? ( +
  • + + + {sourceErrors['icon'] ? ( + {sourceErrors['icon']} + ) : null} +
  • + ) : null} + {/* settings */} {sourceParamsContent ? (
  • @@ -513,6 +556,16 @@ function SourceEditForm({ {/* save/delete */}
  • + + {' • '}