Code Monkey home page Code Monkey logo

datocms-plugin-computed-fields's People

Contributors

hatched-grzegorz avatar siilwyn avatar stefanoverna avatar velomovies avatar vvandijck avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

datocms-plugin-computed-fields's Issues

How to access values within multi-link field?

Hello, I wondered if you could help me?
I would like to access the values within a multi-link field. How should I go about this within your plug-in?
E.g. retrieving the title(string) value of each link of the multi-link field - so I can create an array of titles as a single string.
Thank you for any advice.

Usage on an Single Asset field causes Display Editor to become locked; unable to switch back to default

Hi @voorhoede, and thank you so much for this useful plug-in! I've used it many times in the past, as a former Dato customer :) I recently joined DatoCMS as a support agent, and am trying to resolve an issue another customer is now facing.

They've accidentally added this plug-in to a Single Asset field (instead of a separate text field), and are unable to switch back to the default editor without uninstalling the plugin first.

It looks like they'd previously set the computed field to return some string, and now can't figure out what to actually return it to make a valid output, so they get stuck in an error loop when trying to revert back to the default editor.

I'm looking into this issue on our end too, to see if it's something related to the plugin SDK or elsewhere in Dato. But I just wanted to mention it here too in case you have any quick ideas or workarounds :)

image

Steps to reproduce

  • Have a single asset field
  • Add the Computed Fields plugin
  • Set the single asset field display type to the Computed Field
  • In the Computed Field code, have it return some simple string like return 'test' and click Save.
  • Edit the schema again and try to change the field type back to Default editor. It errors out.

Computing a link field

Thanks for this awesome plugin!

Would it be possible to compute a link field? if possible, what should be returned?

Problem with supporting multiple locales.

If a computed field is configured to support multiple locales, then it is not actively listening to another field (also supports multiple locales); for the script to work, you need to reload the page.

Current version
2.5.1

RTL behaviour of the field

When I enabled the computed field plugin datocms enabled RTL behaviour for the field from which I am computing the value. For reference attaching the screenshot here.
Trial ISO Project - Dato CMS 8-4-2021 5-44-17 PM

Script not firing on field value change.

Hi.

Thank you for the awesome plugin!!!

I've noticed that when editing a text field in a block that is placed on a list the script is not firing.
Only after collapsing the block and expanding back again the field gets updated.

Is there something wrong I am doing?

Please see attached video

Screen.Recording.2023-06-29.at.17.10.19.mov

Get ID of current record

Hi there,

Is it possible to access the ID of the current record?

For example I have an optional title field named "title".
I want to compute a slug from the title, but if no title is provided I want to use the ID of the record.

return `${title ? title : 'untitled'} ${id}`

But ID (id) is undefined.

Where does console.log show up?

We are trying to investigate the value of fields from the computed fields. Usually, when coding we use console.log to see the proposed output before returning it. We try to use, console.log in the code area, but the value doesn't show up anywhere. how do we access console.log value?

Not returning anything

I tried a few slightly more complicated ideas, to access an objects sub-components. Then I tried just returning a string:
return 'SomeText'

I tried giving the plugin readonly and then full rights with different API keys. I've tried in chrome and firefox always the same an empty box.

This should be a really amazing adition. Was hoping to use to make a api query on a datetime object and put write back a string of particular format. If I can't even write back a string literal it's not looking so hopeful.

Computed field is not recalculated when modifying fields of sibling (block)

@velomovies
I am afraid that recent update removed triggering of the script when sibling is a block and its field is being modified.

{
  computed-field
  block-list {
    some-block {
      edited-text-field
    }
  }
}

The computed-field is not being recalculated when edited-text-field is changed.
Only saving the whole record and reopening it recalculates the field.
This worked on previous version.

Does not work as part of Blocks

We use a number of fields to generate templated text in our current CMS. I was looking at leveraging different blocks as a way to allow adding 1 of a few options for producing the templated text. However, I found that this computed fields plugin does not work with blocks.

I tried adding all the fields feeding into the calculated field, plus the calculated field, then added that to another model and there is a console error about not being available.

Next, I tried to reference the fields in the block from a calculated field directly on the model, but that didn't have access to the block's fields either.

Example:

Block
image

Calculated field:

return `${custom_shipping_text} | ${shipping_price}`

Error:
image

Adding computed fields for existing content

When adding a new computed field to an already existing content, we need to go over each record in DatoCMS enter it and save it, so that the field will be computed. Is there an easier way to compute the value of the field for all existing content?

Properly hide or disable the field

Hi,

I noticed that the computed field is non editable but not indicated to the editor. DatoCMS supports marking the field as disabled.

Same for hiding the field, in DatoCMS its possible to remove the field completely by not rendering anything.

Example from a plugin I once made

https://github.com/novemberfiveco/datocms-plugin-nanoid/blob/fba8a22bbf336c37995cd47c741702f0996d0a28/src/entrypoints/FieldExtension.tsx#L29

Would you be open to accept a PR for this?

Regards

How to access Local based content?

Hello Folks,
Hope you are doing great. I am using the Datocms computed fields plugin for my project. It's really awesome.
Just one doubt. how can I access current locale fields when localization is enabled.
I tried following way but what I am looking for is a more dynamic way to handle this thing:
return ${title['en-IN']}

Missing environment ID causes issues in non-primary environments

I noticed that computed fields were not working in non-primary environments when using the plugin helper functions, e.g. getModel, because it is making the request using the primary/default environment instead of the active sandbox environment.

I created a branch that adds the current environment in addition to the currentUserAccessToken when initializing the SiteClient which seems to fix the problem.

 if (ctx.currentUserAccessToken) {
    datoClient = new datocmsClient.SiteClient(ctx.currentUserAccessToken, { environment: ctx.environment },)
  }

I'm happy to open a PR to help resolve the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.