import { AXPWidgetsList } from '@acorex/modules/common';
import { createAllQueryView } from '@acorex/platform/common';
import { entityMasterCrudActions, entityMasterDeleteAction } 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.jobDefinition.name,
        plugins: [{ name: 'history' }, { name: 'lock' }, { name: 'compare' }, { name: 'clone' }, { name: 'category' }],
        title: RootConfig.entities.jobDefinition.title,
        icon: RootConfig.entities.jobDefinition.icon,
        formats: {
            individual: '@organization-management:job-definitions.entities.job-definition.title',
            plural: '@organization-management:job-definitions.entities.job-definition.plural',
            searchResult: {
                title: '{{ title }}',
                description: RootConfig.module.title,
            },
        },
        relatedEntities: [],
        groups: [
            {
                id: 'basic-info',
                title: `@general:terms.interface.basic-info`,
            },
            {
                id: 'responsibilities',
                title: '@organization-management:job-definitions.entities.job-definition.groups.responsibilities',
            },
            {
                id: 'skills',
                title: '@organization-management:job-definitions.entities.job-definition.groups.skills',
            },
        ],
        properties: [
            {
                name: 'id',
                title: 'ID',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    nullable: false,
                    readonly: true,
                    unique: {
                        enabled: true,
                    },
                },
            },
            {
                name: 'title',
                title: `@general:terms.common.title`,
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.text,
                    },
                },
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: true,
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'jobLevelIds',
                title: '@organization-management:job-definitions.entities.job-definition.fields.job-levels.title',
                groupId: 'basic-info',
                schema: {
                    dataType: 'array',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.jobLevel.name}`,
                            textField: 'title',
                            valueField: 'id',
                            multiple: true,
                            look: 'select',
                            hasClearButton: true,
                            expose: [
                                { source: 'id', target: 'jobLevels.{id}' },
                                { source: 'title', target: 'jobLevels.{title}' },
                            ],
                        },
                    },
                },
                options: {
                    sort: {
                        enabled: true,
                    },
                    filter: {
                        advance: {
                            enabled: true,
                        },
                        inline: {
                            enabled: true,
                        },
                    },
                },
                validations: [
                    {
                        rule: 'required',
                    },
                ],
            },
            {
                name: 'responsibilities',
                title: '@organization-management:job-definitions.entities.job-definition.fields.responsibilities.title',
                groupId: 'responsibilities',
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsList.Editors.ResponsibilitiesMatrix,
                        options: {
                            titles: '{{ context.eval("jobLevels") }}',
                        },
                    },
                },
            },
            {
                name: 'skillRequirements',
                title: '@organization-management:job-definitions.entities.job-definition.fields.skills.title',
                groupId: 'skills',
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsList.Editors.SkillMatrix,
                        options: {
                            titles: '{{ context.eval("jobLevels") }}',
                        },
                    },
                },
            },
            {
                name: 'description',
                title: `@general:terms.common.description`,
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.largeText,
                    },
                },
            },
        ],
        columns: [
            { name: 'title' },
            { name: 'description' },
            { name: 'jobLevelIds', options: { dataPath: 'jobLevels' } },
        ],
        interfaces: {
            master: {
                create: {
                    sections: [
                        {
                            id: 'basic-info',
                        },
                        {
                            id: 'responsibilities',
                        },
                        {
                            id: 'skills',
                        },
                    ],
                    properties: [
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'responsibilityLevelIds',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'responsibilities',
                            layout: {
                                label: {
                                    visible: false,
                                },
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'jobLevelIds',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'skillRequirements',
                            layout: {
                                label: {
                                    visible: false,
                                },
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'description',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                    ],
                },
                update: {
                    sections: [
                        {
                            id: 'basic-info',
                        },
                        {
                            id: 'responsibilities',
                        },
                        {
                            id: 'skills',
                        },
                    ],
                    properties: [
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'responsibilityLevelIds',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'responsibilities',
                            layout: {
                                label: {
                                    visible: false,
                                },
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'jobLevelIds',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'skillRequirements',
                            layout: {
                                label: {
                                    visible: false,
                                },
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'description',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                    ],
                },
                single: {
                    title: '{{title}}',
                    sections: [
                        {
                            id: 'basic-info',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'responsibilities',
                            layout: {
                                label: {
                                    visible: false,
                                },
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            id: 'skills',
                            layout: {
                                label: {
                                    visible: false,
                                },
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                    ],
                    properties: [
                        {
                            name: 'title',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'responsibilityLevelIds',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'responsibilities',
                            layout: {
                                label: {
                                    visible: false,
                                },
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'jobLevelIds',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'skillRequirements',
                            layout: {
                                label: {
                                    visible: false,
                                },
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                        {
                            name: 'description',
                            layout: {
                                positions: {
                                    lg: {
                                        colSpan: 12,
                                    },
                                },
                            },
                        },
                    ],
                    actions: [entityMasterDeleteAction()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [createAllQueryView({ sorts: [{ name: 'title', dir: 'asc' }] })],
                },
            },
        },
    };
    return entityDef;
}

export { factory };
//# sourceMappingURL=acorex-modules-organization-management-job-definition.entity-C3caBCMy.mjs.map
