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

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

Open
JeremyFuhrmann opened this issue Nov 19, 2019 · 2 comments
Open
Labels

Comments

@JeremyFuhrmann
Copy link

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.

  • Package Version: 5.0.0
  • Express Version: 4.17.1
  • Sequelize Version: 5.21.2
  • Database Dialect: postgres
  • Database Version: 10.9
@arnaudbesnier
Copy link
Member

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants