apostrophecms / apostrophe-workflow

Provides approval-based workflow and localization capabilities for projects that need them. An optional component of the Apostrophe CMS.
MIT License
36 stars 20 forks source link

Allow workflow-exempt types to have outgoing joins pointing to workflow-based types #303

Open RyamBaCo opened 4 years ago

RyamBaCo commented 4 years ago

Hey there,

I'm experiencing issues regarding storing images within an array of a piece. The special use case is that the piece itself is excluded from translations, but I guess that the apostrophe-image inside of the array is not. When switching the locales the attachment url is missing, which should not happen.

My piece looks like:

addFields: [
...
{
      name: "sponsors",
      label: "Sponsors",
      type: "array",
      titleField: "title",
      schema: [
        {
          name: "title",
          type: "string",
          label: "Title"
        },
        {
          name: "url",
          type: "url",
          label: "Url"
        },
        {
          name: "image",
          type: "singleton",
          label: "Bild",
          widgetType: "apostrophe-images",
          required: true
        },
        {
          name: "approved",
          label: "Freigegeben",
          type: "boolean"
        },
        {
          name: "header",
          label: "Im Header anzeigen",
          type: "boolean"
        }
      ]
    }
...
]
boutell commented 4 years ago

Outgoing joins from a piece excluded from workflow may not point to types that are included in workflow. Basically because there is nowhere to store the multiple image ids for the different locales.

This is a frustrating limitation but it is unlikely to change in Apostrophe 2.x due to the fact that when 2.x was first designed, it was not on our radar to include locale information directly in the _id property. In 3.x we intend to fix that.

You could possibly work around it by storing the workflowGuid properties of the images in a property via a beforeSave handler for the piece, and implementing a custom fetch of the images via their workflowGuid when the piece is loaded (a custom cursor filter could do that).

But if you can I would make the piece type in question subject to workflow. If a type depends on something subject to workflow, it should probably be subject to workflow as well.

boutell commented 4 years ago

Tagged as a 3.0 issue. One of the reasons why we must overhaul _id in 3.0, even if it makes migration a bit of a pain.

boutell commented 4 years ago

In 3.0 _id could look like:

xyzxyzxyz-en-draft
xyzxyzxyz-fr-draft
abcabcabc-en-draft
abcabcabc-fr-draft
RyamBaCo commented 4 years ago

Thank you for your feedback! I managed to make it work by the workaround of using an attachment type instead of apostrophe-image, but good to know that it's taken in consideration for 3.0.

boutell commented 4 years ago

Oh that's an excellent workaround, I should have thought to suggest it. 💯

On Sat, Feb 22, 2020, 11:05 AM Ryam BaCo notifications@github.com wrote:

Thank you for your feedback! I managed to make it work by the workaround of using an attachment type instead of apostrophe-image, but good to know that it's taken in consideration for 3.0.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/apostrophecms/apostrophe-workflow/issues/303?email_source=notifications&email_token=AAAH27OGJWSF4AGJRM3GGIDREFEMJA5CNFSM4KX4YTI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMVDVJA#issuecomment-589970084, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27J6ZEW25QWOVGVSEJDREFEMJANCNFSM4KX4YTIQ .

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.