steirico / kirby-plugin-custom-add-fields

Custom fields for Kirby's add dialog.
MIT License
36 stars 4 forks source link

Skipping doesn't work #23

Open nilshoerrmann opened 4 years ago

nilshoerrmann commented 4 years ago

I'm using this plugin to skip the create page dialog for a specific page type. If I hit the "add page" button, I get his dialog:

grafik

There are no logs in the console.

This is the blueprint:

title: Wochendienste
addFields:
  __dialog:
    skip: true
    forcedTemplate: service
columns:
  primary:
    width: 2/3
    sections:
      published:
        type: pages
        headline: Veröffentlicht
        status: published
  secondary:
    width: 1/3
    sections:
      drafts:
        type: pages
        headline: Entwürfe
        status: draft
        limit: 5

This is what the API responds:

{
    "page": {
        "content": {
            "title": 1584608856
        },
        "slug": 1584608856,
        "template": "service"
    },
    "skipDialog": true
}

While this looks correct, no page is created on disk, no redirect happens.

steirico commented 4 years ago

Sorry for the late reply.

Basically, the properties skip and forcedTemplate control how parent pages/blueprints behave when adding subpages.

Let's say there is a blueprint called service-list and you intend to add pages based on blueprint service and skipping the add dialog. Then these properties have to be set on service-list.

For further assistance: Does the presented blueprint correspond to service.yml? What is the intended hierarchy of the pages/blueprints?

nilshoerrmann commented 4 years ago

Thanks for you feedback!

We've got two blueprints, services (the list view) and service (the page view):

services.yml

title: Wochendienste
addFields:
  title:
    label: Titel
    type: text
    required: false
    icon: title
  __dialog:
    redirect: true
    skip: true
    forcedTemplate: service
columns:
  primary:
    width: 2/3
    sections:
      published:
        type: pages
        headline: Veröffentlicht
        status: published
  secondary:
    width: 1/3
    sections:
      drafts:
        type: pages
        headline: Entwürfe
        status: draft
        limit: 5
        templates: service

service.yml

title: Wochendienst
fields:
  week:
    type: multiselect
    label: Kalenderwoche
    width: 2/3
    max: 1
    options: api
    api:
      url: "{{ kirby.url }}/fetch/weeks"
      fetch: weeks
  family:
    type: pages
    label: Familie
    width: 1/3
    query: site.find('kontakte')

Then these properties have to be set on service-list.

I thought to have done that by setting templates: service on my pages section. Is there another spot I've missed?

steirico commented 4 years ago

Please have a look at v1.3.2 which should solve this issue.

Furthermore, I discovered some other minor issues (#24, #25) which might effect you as well.

nilshoerrmann commented 4 years ago

Thanks I'll check that out next week.

steirico commented 4 years ago

@nilshoerrmann could you check this one?

nilshoerrmann commented 4 years ago

Skipping in general does work now: there is no dialog shown and the page is created directly. I see an error in console though:

{
  "_name": "NavigationDuplicated",
  "name": "NavigationDuplicated",
  "message": "Navigating to current location (\"/pages/begriffe\") is not allowed"
}