Local development, what is the correct way to update property value?

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [x] Documentation issue or request

Current behavior

I’m doing local development, In frontend how could I update property value for specific record?

  1. I’m getting the content record using
    this.contentsService.getContent(this.appsState.appName, this.schemasState.schemaName, 'ID').subscribe( data => {});

  2. Then trying to set the value like this:
    data.data.order = someValue;

  3. Then I got this compile error:
    Index signature in type 'Readonly<{ [fieldName: string]: Readonly<{ [partition: string]: any; }>; }>' only permits reading.

  4. Finally I’m calling this.contentsState.update

What is the correct way to do that?

Expected behavior

Minimal reproduction of the problem

Environment

App Name: localhost

Angular CLI: 13.1.4
Node: 16.13.0
Package Manager: npm 8.1.0
OS: win32 x64

Angular: 13.1.1
… animations, cdk, cdk-experimental, common, core, elements
… forms, localize, platform-browser, platform-browser-dynamic
… platform-server, router

Package Version

angular-devkit/architect 0.1303.9
angular-devkit/build-angular 13.1.4
angular-devkit/core 13.3.9
angular-devkit/schematics 13.1.4
angular/cli 13.1.4
angular/compiler 13.3.11
angular/compiler-cli 13.1.3
schematics/angular 13.1.4
rxjs 7.5.1
typescript 4.5.5

Version: 7.0.0-rc2

Browser:

  • [x] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Version: 7.0.0-rc2

Browser:

  • [x] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:

Hi,

I am not sure what you try to achieve.

I’m building a custom frontend component that extends ResourceOwner class,
Inside this component I need to update some content by Id, what is the correct way to do that?

In general it is only a typescript thing that stops you from doing that, you could just cast it do any and then make the change.

const anyContent = content as any;

anyContent.data.field = { iv: 123 }; 

But still, why do you want to write a component? It would make your live easier if you just write a custom editor or a webhook.

I have a tree structure content (parent, child structure), I’m just building a tree view component for it

I would have a look to extensions instead: https://docs.squidex.io/02-documentation/developer-guides/editors