-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent overlapping drop placements #92
Prevent overlapping drop placements #92
Conversation
Thanks for the pull request, @e-kolpakov! It looks like you're a member of a company that does contract work for edX. If you're doing this work as part of a paid contract with edX, you should talk to edX about who will review this pull request. If this work is not part of a paid contract with edX, then you should ensure that there is an OSPR issue to track this work in JIRA, so that we don't lose track of your pull request. To automatically create an OSPR issue for this pull request, just visit this link: https://openedx-webhooks.herokuapp.com/github/process_pr?repo=edx-solutions%2Fxblock-drag-and-drop-v2&number=92 |
@@ -46,6 +47,8 @@ | |||
"y": 210, | |||
"width": 340, | |||
"height": 138, | |||
"align": "center" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@e-kolpakov Nit: Remove extra blank line
@@ -708,6 +690,7 @@ function DragAndDropBlock(runtime, element, configuration) { | |||
releaseItem($selectedItem); | |||
} else if (isActionKey(evt)) { | |||
evt.preventDefault(); | |||
evt.stopPropagation(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itsjeyd FYI without this stopPropagation
dropping an item using keyboard closed error popup before user could see it, resulting in item being returned to item bank without any explanation why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@e-kolpakov Thanks for the explanation, I had wondered about that briefly but somehow forgot to comment about it - you read my mind :)
In this screenshot, the left-aligned items retain a nice small automatic size, but the centered ones grow to fill their zone width - is there a way to use the "left" sizing behavior in both cases? Also, on the sandbox I wasn't able to see the warning in red when dragging too many items onto a zone. Finally, can you please enable the XBlock view on the sandbox so we can test how this works on small devices / in the mobile app? http://studio-dndv2-sandbox9.opencraft.hosting/xblock/block-v1:OpenCraft+DnDv2+demos+type@vertical+block@28ae4b11831b42949d8815c86671424b should work but seems to need |
def submission_success(submission): | ||
submission['max_items_per_zone'] = 1 | ||
submission['data']['items'] = [ | ||
{'zones': ['1'], 'title': 'item 1'}, {'zones': ['2'], 'title': 'item 2'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@e-kolpakov For consistency with the other submission modification methods, should zones be called 'Zone 1'
and 'Zone 2'
here as well?
@itsjeyd, actually, hold off a bit - there's some stuff that automerge didn't catch. |
@itsjeyd, sorry for the delay. This is set up in the sandbox and ready for review. |
""" | ||
attributes_to_remove = ['x_percent', 'y_percent', 'left', 'top', 'absolute'] | ||
for attribute in attributes_to_remove: | ||
del[attribute] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@haikuginger This should be del item[attribute]
, otherwise item
will be returned unmodified.
@itsjeyd @haikuginger I just noticed the state migration related changes in this PR - #98 is somewhat related. |
Well spotted, @itsjeyd. I've switched that to a |
@@ -127,6 +129,13 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin): | |||
default="", | |||
) | |||
|
|||
max_items_per_zone = Integer( | |||
display_name=_("Maximum items per zone"), | |||
help=_("This setting limits the number of items that can be dropped into a single zone"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@haikuginger Please add a period to make this consistent with help messages for other fields, and update the translation files.
@haikuginger I tested on the sandbox, and most everything is working as expected. The only issue I found was:
I also had a look at the commits you've pushed so far. They look good (although the commit message of 074a857 is fairly cryptic ;)) |
@itsjeyd, I'll investigate that and see what I can figure out. As for the commit message, apparently git does special things with parts of a commit message wrapped in backticks. |
@itsjeyd, those changes are deployed. We seem to be down to pretty minor stuff, so if it's all right, I'll wait to update the sandbox until we've got a 👍. |
a58f72d
to
68417c3
Compare
Rebased from a58f72d. |
@haikuginger Thanks for the updates, they fix the problem. In my capacity as sprint firefighter I took the liberty to push this forward some more: I rebased the branch, cleaned up the test code post-rebase, deployed the updated code to the sandbox, and tested everything again according to the PR description (including behavior for legacy zones with "none" alignment -- this I verified in my local dev env, since it requires working with different branches). This is ready for upstream review now. 👍
|
@itsjeyd Is this PR ready for TNL re-review? |
Hi @cahrens, yes, this PR is ready for TNL re-review. Thanks! |
@@ -315,12 +325,34 @@ def studio_submit(self, submissions, suffix=''): | |||
self.weight = float(submissions['weight']) | |||
self.item_background_color = submissions['item_background_color'] | |||
self.item_text_color = submissions['item_text_color'] | |||
# Possible ValueError should be catched in _validate_submissions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is no longer relevant, correct?
Nit: the following scenario feels a bit odd:
I wouldn't expect an error message because I'm not adding new items to the zone, just "moving them around". |
48f4fea
to
4beaba2
Compare
@cahrens Notes about comments addressed, showing error message when dropping an item to the same zone is fixed, sandbox is updated |
I've finished my review, just one small comment:
|
👍 on review feedback commits. I still have not reviewed the migration and test code, but I trust your internal reviews. Please do see @sstack22's comment above though about documentation. |
4beaba2
to
fabb8f6
Compare
@e-kolpakov - great, confirmed the fix! 👍 |
* "No alignment" zone option removed * Max items per zone setting added * Zone and state migrations are moved to a dedicated class
fabb8f6
to
de5ac0c
Compare
Squashed commits - previous revision fabb8f6 |
Description: This PR updates item placement logic:
JIRA: SOL-1979
Discussions: SOL-1979 and #83 (comment)
Sandboxes:
Note: at the moment #86 was merged, but #87 was not, and this PR does not include changes from #87; as a result, DnDv2 on sandbox show "Submit" button, but it does not do anything - this is an expected behavior until #87 is merged
Testing instructions:
Items alignment:
Max items per zone:
zero orempty string has no further effect (make sure you can put as much items into a single dropzone as you wish in LMS)should cause validation errorswill result in value being set to empty stringSetting "max items per zone" to positive value will validate item placement. If any zone has more "correct" items than "max items per zone" a validation error will be shown, and XBlock will not be updated.and passing the validation, publish the unit and open it in LMS. Expected: can only put up to "max items per zone" items into a single zone.Screenshots:
Studio "Zones" tab:
Studio "Items" tab:
LMS - item alignment:
Attempting to exceed max items per zone:
Reviewers:
a11y: @cptvitamina11y review will be performed later, for all changes in v2.1: SOL-1978Checklist: