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

_isLocked set via _lockType is overridden by trickle #584

Open
oliverfoster opened this issue Sep 25, 2024 · 0 comments
Open

_isLocked set via _lockType is overridden by trickle #584

oliverfoster opened this issue Sep 25, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@oliverfoster
Copy link
Member

oliverfoster commented Sep 25, 2024

Subject of the issue

We have a plugin that shows blocks in an article where the article has _lockType: sequential on its block models, the article also has trickle enabled at the article level.

The block models are set to _isLocked: true initially:

child.set('_isLocked', isLockedByPreviousChild);

Trickle then overrides the block models when it comes to set the _isLocked attributes on the course descendants:
https://github.com/adaptlearning/adapt-contrib-trickle/blob/6a84eb56fef11116860c4fabdd0d41281498fd14/js/models.js#L239

  // Apply only changed locking states
  Object.entries(locks).forEach(([ id, isModelLocked ]) => {
    const model = modelsById[id];
    const wasLocked = model.get('_isLocked');
    if (wasLocked === isModelLocked) return;
    model.set('_isLocked', isModelLocked);
  });

This can be fixed using the lockedAttributes for the AdaptModel, allowing trickle and core to force the model attribute to _isLocked: true until the same plugin unlocks it. Core essentially overrides trickle at the attribute level until core is ready to unlock the model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

1 participant