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

ApplyChangeset On Event Store Not Change Custom Fields #6268

Closed
marciogurka opened this issue Feb 27, 2023 · 3 comments
Closed

ApplyChangeset On Event Store Not Change Custom Fields #6268

marciogurka opened this issue Feb 27, 2023 · 3 comments
Assignees
Labels
bug Something isn't working example forum Issues from forum high-priority Urgent to have fixed OEM OEM customer premium resolved Fixed but not yet released (available in the nightly builds)
Milestone

Comments

@marciogurka
Copy link

Forum post

"Hi I use scheduler 5.2.10 with angular 14.

I found that the event store applyChangeset not change the custom fields that was added to event model.
If I use the "=" operator works fine.

My project definitions:

  1. Custom class definition:

export class MyEventClass extends EventModel {
    static get $name() {
        return 'MyEventClass';
    }

isChanged: boolean;
someObject: { isChanged: boolean };


// Add my new fields.
static get fields() {
    return [
        { name: 'isChanged', type: 'boolean' },

        { name: 'someObject', convert: value => value as { isChanged: boolean } }
    ];
}
}
  1. Project definition:
    project: {
        eventStore: {
            modelClass: MyEventClass
        }
    },

All my event initialized like this:

{
            resourceId: 'r1',
            startDate: new Date(2017, 0, 1, 10),
            endDate: new Date(2017, 0, 1, 12),
            name: 'Click me',
            iconCls: 'b-fa b-fa-mouse-pointer',
            isChanged: false,
            someObject: { isChanged:false }

    },

The custom fields is false.

Then when I click to update button I change the fields to true like this:

 chengeAllEvents() {

    const newEvents = this.schedulerConfig.events.map((event: Partial<MyEventClass>) => {
        const item = { ...event };
        item.isChanged = true;
        item.someObject.isChanged = true;
        return item;
    });
    this.scheduler.project.eventStore.applyChangeset({
        updated: newEvents
    });

And after check found that this fields still with false values.

I create simple demo that reproduce the problem.

How to reproduce:

  1. click on some event and in the console you will see the current values:
    firstclick.png

  2. Click on update button and in the console you will see the data that enter to update:
    update.png

  3. Click on the same event and in the console you will see that the values not changed.:
    secondclick.png

"

angular14-5.2.10.zip

@marciogurka marciogurka added bug Something isn't working example premium forum Issues from forum OEM OEM customer labels Feb 27, 2023
@marciogurka
Copy link
Author

User added a note

After one more check I fount that it not change only the fields that are objects

@yakeer
Copy link

yakeer commented Jun 29, 2023

Any update on this?

@matsbryntse matsbryntse added the high-priority Urgent to have fixed label Jun 29, 2023
@canonic-epicure canonic-epicure self-assigned this Jul 4, 2023
@canonic-epicure
Copy link

It seems this issue is caused by the absence of the type on the custom someObject field. If you set it to object, it will work correctly:

{ name: 'someObject', type : 'object', convert: value => value as { isChanged: boolean } }

We'll fix this, in the meantime, please apply the workaround above.

Note, that with object type, the changes will be applied "inside" of the someObject's object and will not replace the object instance itself. So if you'll need to delete some key, you might need to provide it with null value.

@canonic-epicure canonic-epicure added ready for review Issue is fixed, the pull request is being reviewed and removed in progress labels Jul 5, 2023
@canonic-epicure canonic-epicure 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 Jul 19, 2023
@canonic-epicure canonic-epicure added this to the 5.4.2 milestone Jul 19, 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 example forum Issues from forum high-priority Urgent to have fixed OEM OEM customer premium resolved Fixed but not yet released (available in the nightly builds)
Projects
None yet
Development

No branches or pull requests

4 participants