bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
52 stars 6 forks source link

Simplify data binding in frameworks #3598

Open isglass opened 2 years ago

isglass commented 2 years ago

We need a recommended and well documented way of how to use an external data source (as in not using CrudManager) with Project.

Should work as users of each framework would expect it to.

Related https://github.com/bryntum/support/issues/2092

javascript-programming commented 2 years ago

To get an idea how it is solved in Odoo

https://github.com/bryntum/odoo-app/blob/dev/advanced/src/lib/ProjectModel.js

bmblb commented 2 years ago

Use case

I need to load the data to the project using 3rd party framework which I don't have control over. I need to load/sync changes automatically.

Problem

Project (crud manager) API assume we always have a URL which can serve/receive data according to a specific protocol. There is a way to override a transport layer, but it is not very convenient: you need to override 4 methods, rebuild project model class and instantiate it (which is tricky if you're working with react). Another part of the problem is that we only can auto sync crud changes with project: { autoSync: true }, there is no way to do same by listening events on the project. E.g. when you're editing task in task editor you get hasChanges event on every change, and those changes can be reverted. TaskEditor feature suspends auto sync on the project only.

Suggestion

Use dependency injection to avoid all the unnesessary step assumed for ajax transport. All crud manager should do it output a change set package using current protocol and pass it to some entity which would handle everything else.

// was
// keep active request details
me.activeRequests.sync = {
    type : 'sync',
    pack,
    resolve,
    reject,
    id   : pack.requestId,
    desc : me.sendRequest({
        id      : pack.requestId,
        data    : me.encode(pack),
        type    : 'sync',
        success : me.onCrudRequestSuccess,
        failure : me.onCrudRequestFailure,
        thisObj : me
    })
};

// should be
await me.proxy.sync(pack)