import { AXPWidgetsList } from '@acorex/modules/common';
import { createAllQueryView } from '@acorex/platform/common';
import { entityMasterCrudActions, entityMasterRecordActions } from '@acorex/platform/layout/entity';
import { RootConfig } from './acorex-modules-person-core.mjs';

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Factory   ----
async function personRelationshipTypeFactory(injector) {
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.personRelationshipType.name,
        title: RootConfig.entities.personRelationshipType.title,
        icon: RootConfig.entities.personRelationshipType.icon,
        plugins: [{ name: 'history' }, { name: 'compare' }, { name: 'clone' }],
        formats: {
            individual: RootConfig.entities.personRelationshipType.title,
            plural: RootConfig.entities.personRelationshipType.titlePlural,
            searchResult: {
                title: RootConfig.entities.personRelationshipType.title,
                description: '@person-core:person-relationship-types.entities.person-relationship-type.search-result-description',
            },
        },
        groups: [
            { id: 'basic-info', title: '@general:terms.interface.basic-info' },
            { id: 'settings', title: '@general:terms.interface.settings' },
        ],
        properties: [
            {
                name: 'id',
                title: '@general:terms.common.id',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    readonly: true,
                    unique: { enabled: true },
                },
            },
            {
                name: 'title',
                title: '@general:terms.common.title',
                groupId: 'basic-info',
                options: { sort: { enabled: true }, filter: { advance: { enabled: true }, inline: { enabled: true } } },
                schema: {
                    dataType: 'string',
                    interface: { type: AXPWidgetsList.Editors.TextBox },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                options: { sort: { enabled: false }, filter: { advance: { enabled: true }, inline: { enabled: false } } },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: { rows: 3 },
                    },
                },
            },
            {
                name: 'isDirectional',
                title: '@person-core:person-relationship-types.entities.person-relationship-type.fields.is-directional',
                groupId: 'settings',
                options: { sort: { enabled: true }, filter: { advance: { enabled: true }, inline: { enabled: true } } },
                schema: {
                    dataType: 'boolean',
                    interface: { type: AXPWidgetsList.Editors.ToggleSwitch },
                },
            },
        ],
        columns: [
            { name: 'title', options: { width: '220px', order: 1 } },
            { name: 'isDirectional', options: { width: '120px', order: 2 } },
        ],
        interfaces: {
            master: {
                create: {
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'title', layout: { positions: { lg: { colSpan: 12, order: 1 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 2 } } } },
                        { name: 'isDirectional', layout: { positions: { lg: { colSpan: 3, order: 3 } } } },
                    ],
                },
                update: {
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'title', layout: { positions: { lg: { colSpan: 12, order: 1 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'isDirectional', layout: { positions: { lg: { colSpan: 3, order: 4 } } } },
                    ],
                },
                single: {
                    title: '{{title}}',
                    sections: [{ id: 'basic-info' }, { id: 'settings' }],
                    properties: [
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'isDirectional', layout: { positions: { lg: { colSpan: 3, order: 4 } } } },
                    ],
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [createAllQueryView({ sorts: [{ name: 'title', dir: 'asc' }] })],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

export { personRelationshipTypeFactory };
//# sourceMappingURL=acorex-modules-person-core-person-relationship-type.entity-2qysKjU5.mjs.map
