die-wegmeister / Wegmeister.DatabaseStorage

A Neos CMS plugin to store data into Database and export it as xlsx (and other table formats). Also compatible with the Neos FormBuilder (https://github.com/neos/form-builder).
GNU General Public License v3.0
5 stars 7 forks source link

Support for Sitegeist.PaperTiger? #34

Open lorenzulrich opened 9 months ago

lorenzulrich commented 9 months ago

Sitegeist.PaperTiger is a both Node- and Fusion Form-based Form Builder, therefore IMO a de-facto successor of Neos.Form.Builder.

While its sibling extension Sitegeist.StoneTablet has some nice ideas (e.g. bundling all uploaded files and the Excel export to an archive), Wegmeister.DatabaseStorage has far more features, e.g. a view of all values in the backend and the possibility to delete data.

Connecting PaperTiger with DatabaseStorage is quite simple, however DatabaseStorage cannot handle file uploads from PaperTiger.

This raises the following questions to @Benjamin-K:

Benjamin-K commented 9 months ago

Hi @lorenzulrich, Thanks for bringing this up. I love how you add new useful additions.

I think, we can add support for PaperTiger without adding it as a required dependency. Creating the Action NodeType is done quickly. But we need to check, if we need to add some special handling to it (I don't think so, but I must confirm this first).

The other option would be a new package that is used to connect both other packages. But I think, that is not necessary and we only need to define some of the existing NodeTypes as abstract NodeTypes again.

lorenzulrich commented 9 months ago

The configuration is easily done - apart from attachment handling which needs adjustments to the PHP code:

DatabaseStorage.Definition.fusion:

prototype(Sitegeist.PaperTiger:Action.DatabaseStorage.Definition) < prototype(Neos.Fusion:Component) {
    formIdentifier = ${q(node).property('formIdentifier')}

    renderer = Sitegeist.PaperTiger:Action {
        type = '\\Wegmeister\\DatabaseStorage\\FusionForm\\Runtime\\Action\\DatabaseStorageAction'
        options {
            identifier = ${props.formIdentifier}
            formValues = ${data}
        }
    }
}

DatabaseStorage.Preview.fusion:

prototype(Sitegeist.PaperTiger:Action.DatabaseStorage.Preview) < prototype(Neos.Fusion:Component) {
    formIdentifier = ${q(node).property('formIdentifier')}

    renderer = afx`
        <dl class="papertiger-action-email__list">
            <dt>Formularname</dt>
            <dd>{props.formIdentifier}</dd>
        </dl>
    `
}

DatabaseStorage.yaml:

Sitegeist.PaperTiger:Action.DatabaseStorage:
  superTypes:
    'Sitegeist.PaperTiger:Action': true
  ui:
    label: 'Datenbank-Speicher'
    icon: 'icon-database'
  properties:
    formIdentifier:
      type: string
      ui:
        label: 'Formularname'
        showInCreationDialog: true
        inspector:
          group: 'form'
        help:
          message: 'Wird im Modul Datenbank-Speicher verwendet.'
      validation:
        'Neos.Neos/Validation/NotEmptyValidator': []
        'Neos.Neos/Validation/StringLengthValidator':
          maximum: 255
        'Neos.Neos/Validation/RegularExpressionValidator':
          regularExpression: '/^[a-z0-9\-]+$/i'
          validationErrorMessage: 'Der Tabellen-Name darf nur aus Buchstaben, Zahlen und Bindestrich bestehen.'

But as you can see, we have Sitegeist.PaperTiger:Action as a superType here which will fail if PaperTiger isn't installed. Should we create a Webmeister.DatabaseStorage.PaperTigerAdaptor?

Benjamin-K commented 9 months ago

As you can see in the NodeTypes.yaml, we already have other abstract nodetypes defined to prevent the nodetypes from throwing an error. We can simply add Sitegeist.PaperTiger:Action there, too.

The attachment handling is hard to handle in a separate package i think, so I'd prefer doing it that way. What do you think?

lorenzulrich commented 9 months ago

Ah, this is nice! I think it's best to create a PR with my current changes, then we can discuss/review.