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-learning-management.mjs';

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Factory   ----
async function factory(injector) {
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.skillLevel.name,
        title: RootConfig.entities.skillLevel.title,
        icon: RootConfig.entities.skillLevel.icon,
        plugins: [{ name: 'history' }, { name: 'lock' }, { name: 'compare' }],
        formats: {
            individual: RootConfig.entities.skillLevel.title,
            plural: RootConfig.entities.skillLevel.titlePlural,
            searchResult: {
                title: '{{ name }}',
                description: '{{ levelNumber }}',
            },
        },
        groups: [{ id: 'basic-info', title: '@learning-management:skills.entities.skill-level.groups.basic-info' }],
        properties: [
            {
                name: 'id',
                title: 'ID',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    nullable: false,
                    readonly: true,
                    unique: { enabled: true },
                },
            },
            {
                name: 'name',
                title: '@learning-management:skills.entities.skill-level.fields.name.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: true } },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@learning-management:skills.entities.skill-level.fields.name.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'levelNumber',
                title: '@learning-management:skills.entities.skill-level.fields.level-number.title',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: { advance: { enabled: true }, inline: { enabled: true } },
                },
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsList.Editors.NumberBox,
                        options: {
                            minValue: 1,
                            placeholder: '@learning-management:skills.entities.skill-level.fields.level-number.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@learning-management:skills.entities.skill-level.fields.description.title',
                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,
                            placeholder: '@learning-management:skills.entities.skill-level.fields.description.placeholder',
                        },
                    },
                },
            },
        ],
        columns: [{ name: 'levelNumber' }, { name: 'name' }, { name: 'description' }],
        interfaces: {
            master: {
                create: {
                    sections: [{ id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } }],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 8, order: 1 } } } },
                        { name: 'levelNumber', layout: { positions: { lg: { colSpan: 4, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                    ],
                },
                update: {
                    sections: [{ id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } }],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 8, order: 1 } } } },
                        { name: 'levelNumber', layout: { positions: { lg: { colSpan: 4, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                    ],
                },
                single: {
                    title: '{{ name }}',
                    sections: [{ id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } }],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 8, order: 1 } } } },
                        { name: 'levelNumber', layout: { positions: { lg: { colSpan: 4, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                    ],
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [createAllQueryView({ sorts: [{ name: 'levelNumber', dir: 'asc' }] })],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

export { factory };
//# sourceMappingURL=acorex-modules-learning-management-skill-level.entity-DXOWslpB.mjs.map
