如何允许删除Apostrophe数组对象中的数组项

问题描述 投票:0回答:1

我在Apostrophe-CMS的基础上建立了一个相当广泛的站点,大量使用对象模式和管理编辑器界面。很长时间以来,我一直在与数组有关的问题,而且我永远无法弄清楚正在发生什么。我定义的每个数组似乎都会发生这种情况,但这是一个特定的示例(这是撇号用户的附加字段):

{
name: 'subscriptions',
label: 'Memberships',
type: 'array',
titleField: 'subscriptionYear',
schema: [
    {
        name: '_subscription',
        withType: 'subscription-type',
        type: 'joinByOne',
        idField: 'subscriptionId',
        filters: {
            projection: {
                type: 1,
                name: 1,
                description: 1,
                agreement: 1,
                familyMembers: 1,
                title: 1,
                _allowedGroup: 1,
                allowedGroupId: 1,
                price: 1
            }
        }
    },
    {
        name: 'expirationDate',
        label: 'Expiration Date',
        type: 'date',
        required: false
    },
    {
        name: 'waiverSignature',
        label: 'Waiver Signature',
        type: 'string',
        readOnly: true
    },
    {
        name: '_payment',
        withType: 'payments',
        type: 'joinByOne',
        idField: 'paymentId',
        titleField: 'subscriptionType',
        filters: {
            projection: {
                paymentDate: 1,
                userEmail: 1,
                paymentAmount: 1,
                subscriptionType: 1,
                subscriptionYear: 1,
                receiptEmail: 1
            }
        }
    },
    {
        name: 'familyMembers',
        label: 'Family Members',
        type: 'array',
        titleField: 'familyMemberName',
        schema: [
            {
                name: 'familyMemberName',
                label: 'Family Member Name',
                type: 'string'
            },
            {
                name: 'familyMemberBirthDate',
                label: 'Family Member Birth Date',
                type: 'date'
            }
        ]
    }
]
}

我遇到的问题是,除非首先保存对象,否则从此数组中删除项目将不起作用。如果我尝试从数组中删除一项而不先保存用户,则该条目在列表中闪烁(消失并且几乎立即重新出现)。没有控制台错误。但是,如果我打开用户,保存用户(即使未进行任何更改),然后在不关闭用户件清单的情况下再次打开用户,则可以从数组中删除项目并再次保存。为什么会发生这种情况的任何想法?

谢谢!

apostrophe-cms
1个回答
0
投票

是否存在放置代码以将ID添加到片段数组的好地方,如果还没有的话?

© www.soinside.com 2019 - 2024. All rights reserved.