Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

[[ Bug 21503 ]] Tree widget - prevent value removal on key addition - #6643

Merged
livecodepanos merged 2 commits into
livecode:develop-9.0from
bwmilby:bwm-bugfix-21503
Aug 22, 2018
Merged

[[ Bug 21503 ]] Tree widget - prevent value removal on key addition#6643
livecodepanos merged 2 commits into
livecode:develop-9.0from
bwmilby:bwm-bugfix-21503

Conversation

@bwmilby

@bwmilby bwmilby commented Aug 18, 2018

Copy link
Copy Markdown
Contributor

Current operation of the tree widget will delete the value stored in a key
if the "+" is clicked to add a new sub-key and it is not already an array.

This change alters the behavior such that when the "+" is clicked, if the current key is not already an array, then a dialog will ask the user for how to proceed. The options are to move the existing value to the new sub-key that is created,replace the value with an empty array, or cancel the operation.

Current operation of the tree widget will delete the value stored in a key
if the "+" is clicked to add a new sub-key and it is not already an array.

This change alters the behavior such that when the "+" is clicked, if the
current key is not already an array, then the existing value is moved to
the new sub-key that is created.
variable tArray as Array
put the empty array into tArray
put "" into tArray[1 formatted as string]
put tElement into tArray[1 formatted as string]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bwmilby I wonder if rather than move the element which might be hard to recover from it should check if tElement is empty or not and post an error message if it's not. That way script can handle the message and ask the user if they want to move the current value to an array element. It could be they just clicked + on the wrong line and would like to back out.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could I guess add the reverse of this behavior so it's easy to back out but it's not all that intuitive to click the bin on an array element in an array with one key and have the value clobber the array.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered the error route (similar to the delete message) but thought this would be less intrusive for applications. The problem about the reverse is you have a key and a value to deal with so you will lose one anyway.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... yeah the way the delete message is done would work rather than a callback. I imagine the main choice people would want to make is between canceling and replacing the element with an array. Using the current element value as array key 1 is possibly more of an edge case... not sure. I guess it could be a third button on the dialog...

answer warning "The array element at path [" & <path> & "] is not empty. Would you like to replace it with an empty array or move it to the first element?" with "Cancel" or "Replace" or "Move"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great thanks @bwmilby

Adjust code to display a dialog box to allow the user to choose how to handle
the situation where a new array could remove an existing value.
@montegoulding

Copy link
Copy Markdown
Contributor

@livecode-vulcan review ok b70a409

@montegoulding montegoulding added this to the 9.0.2-rc-1 milestone Aug 22, 2018
@livecode-vulcan

Copy link
Copy Markdown
Contributor

💙 review by @montegoulding ok b70a409

livecode-vulcan added a commit that referenced this pull request Aug 22, 2018
[[ Bug 21503 ]] Tree widget - prevent value removal on key addition

Current operation of the tree widget will delete the value stored in a key
if the "+" is clicked to add a new sub-key and it is not already an array.

This change alters the behavior such that when the "+" is clicked, if the current key is not already an array, then a dialog will ask the user for how to proceed.  The options are to `move` the existing value to the new sub-key that is created,`replace` the value with an empty array, or `cancel` the operation.
@livecode-vulcan

Copy link
Copy Markdown
Contributor

😎 test success b70a409

  • try-community-armv6-android-sdk26_ndk16r15: success
  • try-community-armv7-android-sdk26_ndk16r15: success
  • try-community-arm64-android-sdk26_ndk16r15: success
  • try-community-x86-android-sdk26_ndk16r15: success
  • try-community-x86_64-android-sdk26_ndk16r15: success
  • try-community-js-emscripten-sdk1.35: success
  • try-community-universal-ios-iphoneos11.4: success
  • try-community-universal-ios-iphonesimulator11.4: success
  • try-community-universal-mac-macosx10.9: success
  • try-community-x86-linux-debian8: success
  • try-community-x86_64-linux-debian8: success
  • try-community-x86-win32: success
  • try-community-x86_64-win32: success

@livecodepanos
livecodepanos merged commit 867695e into livecode:develop-9.0 Aug 22, 2018
@bwmilby
bwmilby deleted the bwm-bugfix-21503 branch April 27, 2019 23:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants