@@ -279,14 +279,22 @@ function EditingTypeAction(props: {
279279 pendingChanges : PendingChange [ ]
280280 setPendingChanges : React . Dispatch < React . SetStateAction < PendingChange [ ] > >
281281} ) {
282- if ( ! props . userEditOperation . buttonType ) return null
283-
284- const getPendingState = ( operationId : string ) => {
285- const pendingChange = props . pendingChanges . find ( ( change ) => change . operationId === operationId )
282+ const getPendingState = ( ) => {
283+ const pendingChange = props . pendingChanges . find ( ( change ) => change . operationId === props . userEditOperation . id )
286284 return pendingChange ?. switchState
287285 }
288286
287+ const [ hasBeenEdited , setHasBeenEdited ] = React . useState < boolean > (
288+ getPendingState ( ) !== undefined && getPendingState ( ) !== props . userEditOperation . isActive
289+ )
290+
291+ React . useEffect ( ( ) => {
292+ setHasBeenEdited ( getPendingState ( ) !== undefined && getPendingState ( ) !== props . userEditOperation . isActive )
293+ } , [ props . userEditOperation . id , props . pendingChanges ] )
294+
295+ if ( ! props . userEditOperation . buttonType ) return null
289296 const addPendingChange = ( ) => {
297+ setHasBeenEdited ( ! hasBeenEdited )
290298 props . setPendingChanges ( ( prev ) => {
291299 // Find if there's an existing pending change for this operation
292300 const existingChangeIndex = prev . findIndex ( ( change ) => change . operationId === props . userEditOperation . id )
@@ -328,10 +336,15 @@ function EditingTypeAction(props: {
328336 )
329337 case UserEditingButtonType . SWITCH :
330338 return (
331- < div className = "propertiespanel-pop-up__action" >
339+ < div
340+ className = { classNames (
341+ 'propertiespanel-pop-up__action' ,
342+ hasBeenEdited ? 'properties-panel-pop-up__has-been-edited' : ''
343+ ) }
344+ >
332345 < a
333346 className = { classNames ( 'propertiespanel-pop-up__switchbutton' , 'switch-button' , {
334- 'sb-on' : getPendingState ( props . userEditOperation . id ) ?? ( props . userEditOperation . isActive || false ) ,
347+ 'sb-on' : getPendingState ( ) ?? ( props . userEditOperation . isActive || false ) ,
335348 } ) }
336349 role = "button"
337350 onClick = { addPendingChange }
@@ -409,6 +422,21 @@ function EditingTypeChangeSourceLayerSource(props: {
409422 props . userEditOperation . currentValues . value
410423 )
411424
425+ const getPendingState = ( ) => {
426+ const pendingChange = props . pendingChanges . find ( ( change ) => change . operationId === props . userEditOperation . id )
427+ return pendingChange ?. value
428+ }
429+
430+ const [ hasBeenEdited , setHasBeenEdited ] = React . useState < boolean > (
431+ getPendingState ( ) !== undefined && getPendingState ( ) !== props . userEditOperation . currentValues . value
432+ )
433+
434+ React . useEffect ( ( ) => {
435+ setHasBeenEdited (
436+ getPendingState ( ) !== undefined && getPendingState ( ) !== props . userEditOperation . currentValues . value
437+ )
438+ } , [ props . userEditOperation . id , props . pendingChanges ] )
439+
412440 const jsonSchema = Object . values < UserEditingSourceLayer > ( props . userEditOperation . schemas ) . find (
413441 ( layer ) => layer . sourceLayerType === selectedSourceGroup
414442 ) ?. schema
@@ -424,6 +452,7 @@ function EditingTypeChangeSourceLayerSource(props: {
424452
425453 const handleSourceChange = ( ) => {
426454 setSelectedValues ( selectedValues )
455+ setHasBeenEdited ( true )
427456 // Add to pending changes instead of executing immediately
428457 props . setPendingChanges ( ( prev ) => {
429458 const filtered = prev . filter (
@@ -474,19 +503,24 @@ function EditingTypeChangeSourceLayerSource(props: {
474503 } ) }
475504 </ div >
476505 { selectedGroupSchema && (
477- < >
506+ < div
507+ className = { classNames (
508+ 'properties-panel-pop-up__form' ,
509+ hasBeenEdited ? 'properties-panel-pop-up__has-been-edited' : ''
510+ ) }
511+ >
478512 < a className = "propertiespanel-pop-up__label" > { t ( 'Source' ) } :</ a >
513+ < br />
479514 < div onChange = { handleSourceChange } >
480515 < SchemaFormInPlace
481516 schema = { selectedGroupSchema }
482517 object = { selectedValues }
483518 translationNamespaces = { props . userEditOperation . translationNamespaces }
484519 />
485- < br />
486- < hr />
487520 </ div >
488- </ >
521+ </ div >
489522 ) }
523+ < hr />
490524 </ >
491525 )
492526}
0 commit comments