totaljs / framework4

Total.js framework v4
https://www.totaljs.com
Other
97 stars 36 forks source link

Schema addWorkflow return doesn't contains operation #10

Closed aalfiann closed 3 years ago

aalfiann commented 3 years ago

Hello,

Sorry to disturb you for many questions, because I'm in progress to migrate from totaljsv3 to totaljsv4.

This below schema is work fine in totaljsv3 but not in totaljsv4. What happened?

controller/default.js

ROUTE('/test/schema', ['post','*Test_route --> @render']);

models/default.js

NEWSCHEMA('Test_route').make(function(schema) {
    schema.define('description', 'string');

    schema.addWorkflow('render',function($) {
        var data = $.model;
        $.callback('success '+ data.description);
    });
});

Output Error

[
    {
        "name": "",
        "error": "Schema \"Test_route\" doesn't contain \"Render\" operation."
    }
]
petersirka commented 3 years ago

Hi @aalfiann. Sorry for delay, I forgot to answer.

Bad declaration:

Good:

ROUTE('POST /test/schema/   *Test_route --> render');
NEWSCHEMA('Test_route', function(schema) {

    schema.define('description', 'string');

    schema.addWorkflow('render',function($) {
        var data = $.model;
        $.callback('success '+ data.description);
    });
});