Skip to content
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

Fix #5592 : Enable submit button after linking items in Drag & Drop Sort Interaction #5597

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,12 @@ class DragAndDropSortInteractionViewModel private constructor(
dragDropInteractionContentViewModel.itemIndex = index
dragDropInteractionContentViewModel.listSize = _choiceItems.size
}
// to update the content of grouped item

// To update the list
(adapter as BindableAdapter<*>).setDataUnchecked(_choiceItems)

// *Trigger pending answer check* to re-enable submit button
checkPendingAnswerError(AnswerErrorCategory.REAL_TIME)
}

fun unlinkElement(itemIndex: Int, adapter: RecyclerView.Adapter<RecyclerView.ViewHolder>) {
Expand All @@ -246,15 +250,24 @@ class DragAndDropSortInteractionViewModel private constructor(
dragDropInteractionContentViewModel.itemIndex = index
dragDropInteractionContentViewModel.listSize = _choiceItems.size
}
// to update the list

// *Update the list*
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here and below: please format comment correctly. Asterisks are only used in kdocs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

(adapter as BindableAdapter<*>).setDataUnchecked(_choiceItems)

// *Trigger pending answer check* to re-enable submit button
checkPendingAnswerError(AnswerErrorCategory.REAL_TIME)
}

private fun getSubmitTimeError(): DragAndDropSortInteractionError {
return if (_originalChoiceItems == _choiceItems) {
val hasItemsChanged = _originalChoiceItems.size != _choiceItems.size ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
val hasItemsChanged = _originalChoiceItems.size != _choiceItems.size ||
val haveItemsChanged = _originalChoiceItems.size != _choiceItems.size ||

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

_originalChoiceItems.zip(_choiceItems).any { (originalItem, currentItem) ->
originalItem.htmlContent != currentItem.htmlContent
}
return if (!hasItemsChanged) {
DragAndDropSortInteractionError.EMPTY_INPUT
} else
} else {
DragAndDropSortInteractionError.VALID
}
}

/** Implementation of [StateItemViewModel.InteractionItemFactory] for this view model. */
Expand Down
Loading