import { AXPWidgetsList } from '@acorex/modules/common';
import { entityMasterRecordActions } from '@acorex/platform/layout/entity';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { RootConfig } from './acorex-modules-organization-management.mjs';

async function factory(injector) {
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.teamMember.name,
        title: '@organization-management:team-members.entities.team-member.title',
        icon: 'fa-light fa-users',
        formats: {
            individual: '@organization-management:team-members.entities.team-member.title',
            plural: '@organization-management:team-members.entities.team-member.plural',
            searchResult: {
                title: '@organization-management:team-members.entities.team-member.title',
                description: RootConfig.module.title,
            },
        },
        groups: [
            {
                id: 'basic-info',
                title: '@general:terms.interface.basic-info',
            },
        ],
        properties: [
            {
                name: 'id',
                title: 'ID',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    nullable: false,
                    readonly: true,
                    unique: {
                        enabled: true,
                    },
                },
            },
            {
                name: 'teamId',
                title: '@organization-management:team-members.entities.team-member.fields.team.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: true } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.lookup,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.team.name}`,
                            textField: 'title',
                            valueField: 'id',
                            expose: [
                                { source: 'id', target: 'team.id' },
                                { source: 'title', target: 'team.title' },
                            ],
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'employeeId',
                title: '@organization-management:team-members.entities.team-member.fields.employee.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: true } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.lookup,
                        options: {
                            entity: `HumanCapitalManagement.Employee`,
                            textField: 'person.displayName',
                            valueField: 'id',
                            expose: [
                                { source: 'id', target: 'employee.id' },
                                { source: 'person.displayName', target: 'employee.person.displayName' },
                            ],
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'roleId',
                title: '@organization-management:team-members.entities.team-member.fields.role.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: true } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.teamMemberRole.name}`,
                            textField: 'title',
                            valueField: 'id',
                            expose: [
                                { source: 'id', target: 'role.id' },
                                { source: 'title', target: 'role.title' },
                                { source: 'name', target: 'role.name' },
                            ],
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
        ],
        columns: [
            { name: 'employeeId', options: { dataPath: 'employee.person.displayName' } },
            { name: 'roleId', options: { dataPath: 'role.title' } },
        ],
        interfaces: {
            master: {
                create: {
                    sections: [
                        {
                            id: 'basic-info',
                        },
                    ],
                    properties: [
                        {
                            name: 'teamId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'employeeId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 2,
                                    },
                                },
                            },
                        },
                        {
                            name: 'roleId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 3,
                                    },
                                },
                            },
                        },
                    ],
                },
                update: {
                    sections: [
                        {
                            id: 'basic-info',
                        },
                    ],
                    properties: [
                        {
                            name: 'employeeId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'roleId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 2,
                                    },
                                },
                            },
                        },
                    ],
                },
                single: {
                    title: '{{employee.person.displayName}} - {{role.title}}',
                    sections: [
                        {
                            id: 'basic-info',
                        },
                    ],
                    properties: [
                        {
                            name: 'employeeId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 1,
                                    },
                                },
                            },
                        },
                        {
                            name: 'roleId',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 6,
                                        order: 2,
                                    },
                                },
                            },
                        },
                    ],
                    actions: [...entityMasterRecordActions()],
                },
                // No list interface - this entity is only accessible as a related entity
            },
        },
    };
    return entityDef;
}

export { factory };
//# sourceMappingURL=acorex-modules-organization-management-team-member.entity-B8tU_XhJ.mjs.map
