totaljs/framework4

Schema addWorkflow return doesn't contains operation

Closed this issue · 1 comments

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."
    }
]

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

Bad declaration:

  • ROUTE('/test/schema', ['post','*Test_route --> @render']);
  • NEWSCHEMA('Test_route').make(function(schema) {

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);
    });
});