ForestAdmin / forest-express-sequelize

🌱 Express/Sequelize agent for Forest Admin to integrate directly to your existing Express/Sequelize backend application.
https://www.forestadmin.com
GNU General Public License v3.0
190 stars 48 forks source link

default values for smart action fields are not taken into account #336

Open JeremyFuhrmann opened 4 years ago

JeremyFuhrmann commented 4 years ago

Expected behavior

The form fields for a smart action should be pre-filled with the object returned by the ' values' method.

Actual behavior

These default values are ignored, the form fields are empty. I tried also with this example from the documentation:


const liana = require('forest-express-sequelize');

liana.collection('Organization', {
  actions: [
    {
      name: 'Charge credit card',
      type: 'single',
      fields: [
        {
          field: 'amount',
          isRequired: true,
          description: 'The amount (USD) to charge the credit card. Example: 42.50',
          type: 'Number',
        },
        {
          field: 'description',
          isRequired: true,
          description: 'Explain the reason why you want to charge manually the customer here',
          type: 'String',
        },
        {
          // we added a field to show the full potential of prefilled values in this example
          field: 'stripe_id',
          isRequired: true,
          type: 'String',
        },
      ],
      // In values you define the appropriate prefilled value of each field
      values: () => {
        return {
          amount: 4520,
          stripe_id: 'blabla',
        };
      },
    },
  ],
});

But it doesn't work either:

Capture d’écran 2019-11-19 à 17 59 20

Failure Logs

no error log

Context

Created a project with forest-express-sequelize middleware. Created a smart action with some fields default values computed with the 'values' syntax. The same code worked a few months ago, maybe I am missing something.

arnaudbesnier commented 4 years ago

Hi @JeremyFuhrmann,

I cannot reproduce your issue (I tried in v5.0.0 and v5.2.0).

Screenshot 2019-11-22 at 14 46 09

Can you share your package.json to see if everything is fine with your dependencies?

JeremyFuhrmann commented 4 years ago

Hi @arnaudbesnier

My bad, the issue occurs only when I set a custom endpoint for my smart action: endpoint: '/actions/organization/charge-credit-card'

I tested with both v5.0.0 and v5.2.0

Here's my dependencies:

"dependencies": {
    "@sentry/node": "^5.9.0",
    "@slack/interactive-messages": "^1.4.0",
    "@slack/web-api": "^5.5.0",
    "@slack/webhook": "^5.0.2",
    "apollo-server-express": "^2.9.9",
    "archiver": "^3.0.0",
    "auth0": "^2.20.0",
    "aws-sdk": "^2.575.0",
    "body-parser": "^1.19.0",
    "camelcase": "^5.3.1",
    "common-tags": "^1.8.0",
    "content-disposition": "^0.5.3",
    "cors": "^2.8.5",
    "csv-parse": "^4.8.2",
    "csv-stringify": "^5.3.0",
    "deep-diff": "^1.0.2",
    "dotenv": "^8.2.0",
    "draft-convert": "^2.1.5",
    "draft-js": "^0.11.2",
    "express": "^4.17.1",
    "express-jwt": "^5.3.1",
    "forest-express-sequelize": "5.0.0",
    "graphql": "^14.5.8",
    "graphql-date": "^1.0.3",
    "graphql-type-json": "^0.3.1",
    "html-to-text": "^5.1.1",
    "jsonwebtoken": "^8.5.1",
    "jwks-rsa": "^1.5.1",
    "lodash": "^4.17.11",
    "moment": "^2.24.0",
    "node-cache": "^5.0.2",
    "node-mailjet": "^3.3.1",
    "node-pdftk": "^2.0.3",
    "pdfkit": "^0.10.0",
    "pdftk-bin": "^0.0.4",
    "pg": "^7.13.0",
    "pg-hstore": "^2.3.3",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "request": "^2.88.0",
    "request-promise": "^4.2.5",
    "sequelize": "^5.21.2",
    "sequelize-cli": "^5.5.1",
    "shortid": "^2.2.15",
    "stream-transform": "^2.0.1",
    "uuid": "^3.3.3"
  },
  "devDependencies": {
    "eslint": "^5.16.0",
    "eslint-config-airbnb-base": "^13.2.0",
    "eslint-config-prettier": "^5.1.0",
    "eslint-plugin-import": "^2.17.2",
    "jest": "^24.9.0",
    "localtunnel": "^2.0.0",
    "nodemon": "^1.19.4",
    "prettier": "^1.19.1"
  }