jase_mc

It then sends a xhr request for a graphql query, with operationName: "ReadHistoryViewerResource", but it sends the ID of the elemental block in the params.

jase_mc

And it looks like, when the block page is loaded (via Resource/EditForm/field/Resource/item/7/ItemEditForm/field/ElementalArea/item/15/edit/

jase_mc

So the parent Dataobject is named Resource, and it has a custom graphql query ReadHistoryViewerResource

jase_mc

Hello, I have another query please.

Issue: Currently I am trying to view History for inline editable blocks created in a Dataobject, via the 'Block history link' in the Dataobject's history. The block detail page loads, but when History tab is clicked, the page just gets stuck on loading.

Observation: From my limited understanding, the graphql call that is trying to load the block's history when the block edit page is loaded, looks to be passing the elemental block ID, but actually is sending the operationName of the parent Dataobject, thus not actually loading the history correctly

So the parent Dataobject is named Resource, and it has a custom graphql query ReadHistoryViewerResource 

And it looks like, when the block page is loaded (via Resource/EditForm/field/Resource/item/7/ItemEditForm/field/ElementalArea/item/15/edit/

It then sends a xhr request for a graphql query, with operationName: "ReadHistoryViewerResource", but it sends the ID of the elemental block in the params (15). And the response is: readOneResource: null

  1.  
robbieaverill

have you customised anything related to the history tab for the element?

jase_mc

Well, there is the custom history viewer stuff for the dataobjects https://docs.silverstripe.org/en/4/developer_guides/model/versioning/#configure-the-necessary-graphql-queries-and-mutations

Show 2 attachment(s)
docs.silverstripe.org  
Versioning

Developer and user documentation for the Silverstripe CMS and framework.

docs.silverstripe.org  
Versioning

Developer and user documentation for the Silverstripe CMS and framework.

Hide attachment content
jase_mc

So the custom graphql query set for the Dataobject in question follows those instructions

robbieaverill

there's a bug somewhere that means you can't use history viewer on a dataobject twice. CMS is fine from memory but other parts don't work. i'm trying to find the issue though...

robbieaverill

https://github.com/dnadesign/silverstripe-elemental/issues/497 here you go

Show 1 attachment(s)
robbieaverill

Affected versions: 3.x and 4.x

The history viewer GraphQL query readOneBlockQuery is applied to a context for ModelAdmin which is far too broad:

  Injector.transform(
    'elements-history',
    (updater) => {
      // Add content block history to the HistoryViewer
      updater.component(
        'HistoryViewer.Form_ItemEditForm', // <--------- context is too broad
        readOneBlockQuery,
        'ElementHistoryViewer'
      );
    }
  );

Essentially this means that the transformation is applied to all GridFields under the "HistoryViewer" context, regardless of the class type. We need to customise this somehow so it's unique for elemental.

The problem happens when you try to add history viewer to another versioned DataObject (other than SiteTree), and elemental's read query is being applied to it instead.

When fixing this issue, please ensure that the example of the same thing in the documentation at https://github.com/silverstripe/silverstripe-framework/pull/8606|silverstripe/silverstripe-framework#8606 is updated so it's also not too broad.

cc https://github.com/unclecheese|@unclecheese

Hide attachment content
jase_mc

I am starting to look into creating a custom element, with custom template. This may be a satisfactory path 🤞

jase_mc

I have a specific list of titles that need to be defined

jase_mc

e.g. I would like to be able to add a block that has an editable html table for user to add content to, and that block has a specific title that can be viewed / referred to programmatically

jase_mc

Hello all, I am pretty new with the elemental blocks. I was wondering whether it's viable to have blocks with preset html content and titles/labels ?

e.g. I would like to be able to add a block that has an editable prefilled html table for user to add content to, and that block has a specific title that can be viewed / referred to programmatically (I have a specific list of titles that need to be defined)

I am starting to look into creating a custom element, with custom template. This may be a satisfactory path 🤞

robbieaverill

Yep you can do this with either an extension or a custom block type. Add some logic to on before write like “if there is no ID then define some content by default” - before it saves to the db

👍 (1)
nightjarnz

using config or defining in your custom block the defaults key will do this for newly created blocks. e.g.

  1. private static $defaults = [
  2. 'Title' => 'The default title',
  3. 'ShowTitle' => true,
  4. 'HTML' => '<p>This is my default content</p>',
  5. 'SomeOtherPropertyName' => 'default value',
  6. ];

You could also do this with Injector, mapping a prototype to create an instance of the block you want, with the data filled in already. I don't think that would show up on the menu of blocks to add in the CMS though, but could be a programmatic way to do this.

👍 (1)