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

CrudManager allows a load operation to append records. But they are then syncable #7398

Closed
ExtAnimal opened this issue Aug 30, 2023 · 0 comments
Assignees
Labels
bug Something isn't working forum Issues from forum large-account Reported by large customer OEM OEM customer resolved Fixed but not yet released (available in the nightly builds)
Milestone

Comments

@ExtAnimal
Copy link

Forum post

If in an before load event handler or callback, you set options.events = { append : true } the CrudManager will add the loaded events to the EventStore.

But the add operation adds the new records to the added Bag, and they are then synced to the server in the next sync call, and then receive new IDs. This should not happen. If they are loaded by the CrudManager, they should be loaded "clean". and not be synced.

AbstractCrudManagerMixin.js has this where you can see the append option being processed

        loadCrudStore(store, data, options) {
            const rows = data?.rows;

            if (options?.append || data?.append) {
                store.add(rows);
            }
            else {
                store.data = rows;
            }

            store.trigger('load', { data : rows });
        }

One (rather nasty) solution could be

        loadCrudStore(store, data, options) {
            const rows = data?.rows;

            if (options?.append || data?.append) {
                // Temporarily inject a transient added Bag so that these records are clean
                const { added } = store.added;
                store.added = { add(){} };
                store.add(rows);
                added && (store.added = added);
            }
            else {
                store.data = rows;
            }

            store.trigger('load', { data : rows });
        }

Perhaps there could be an option passed into Store.add to mean "addClean" which would tell the store to not add the incoming records to the added Bag

@ExtAnimal ExtAnimal added bug Something isn't working forum Issues from forum large-account Reported by large customer OEM OEM customer labels Aug 30, 2023
@ExtAnimal ExtAnimal self-assigned this Aug 30, 2023
@ExtAnimal ExtAnimal modified the milestones: 5.5.2, 5.5.3 Aug 30, 2023
@ExtAnimal ExtAnimal added ready for review Issue is fixed, the pull request is being reviewed resolved Fixed but not yet released (available in the nightly builds) and removed ready for review Issue is fixed, the pull request is being reviewed resolved Fixed but not yet released (available in the nightly builds) labels Aug 30, 2023
@isglass isglass added resolved Fixed but not yet released (available in the nightly builds) and removed ready for review Issue is fixed, the pull request is being reviewed labels Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working forum Issues from forum large-account Reported by large customer OEM OEM customer resolved Fixed but not yet released (available in the nightly builds)
Projects
None yet
Development

No branches or pull requests

2 participants