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.certificateType.name,
        title: RootConfig.entities.certificateType.title,
        icon: RootConfig.entities.certificateType.icon,
        plugins: [{ name: 'history' }, { name: 'lock' }, { name: 'compare' }],
        formats: {
            individual: RootConfig.entities.certificateType.title,
            plural: RootConfig.entities.certificateType.titlePlural,
            searchResult: {
                title: '{{ name }}',
                description: '{{ validityDays }} days',
            },
        },
        groups: [
            { id: 'basic-info', title: '@learning-management:certificates.entities.certificate-type.groups.basic-info' },
            { id: 'template', title: '@learning-management:certificates.entities.certificate-type.groups.template' },
        ],
        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:certificates.entities.certificate-type.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:certificates.entities.certificate-type.fields.name.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@learning-management:certificates.entities.certificate-type.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:certificates.entities.certificate-type.fields.description.placeholder',
                        },
                    },
                },
            },
            {
                name: 'validityDays',
                title: '@learning-management:certificates.entities.certificate-type.fields.validity-days.title',
                groupId: 'basic-info',
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsList.Editors.NumberBox,
                        options: {
                            minValue: 0,
                            placeholder: '@learning-management:certificates.entities.certificate-type.fields.validity-days.placeholder',
                        },
                    },
                },
            },
            {
                name: 'templateId',
                title: '@learning-management:certificates.entities.certificate-type.fields.template-id.title',
                groupId: 'template',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: 'DocumentManagement.DocumentTemplate',
                        },
                    },
                },
            },
        ],
        columns: [{ name: 'name' }, { name: 'validityDays' }, { name: 'templateId' }],
        interfaces: {
            master: {
                create: {
                    sections: [
                        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'template', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'validityDays', layout: { positions: { lg: { colSpan: 4, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'templateId', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
                    ],
                },
                update: {
                    sections: [
                        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'template', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'validityDays', layout: { positions: { lg: { colSpan: 4, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'templateId', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
                    ],
                },
                single: {
                    title: '{{ name }}',
                    sections: [
                        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'template', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                    properties: [
                        { name: 'name', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'validityDays', layout: { positions: { lg: { colSpan: 4, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'templateId', layout: { positions: { lg: { colSpan: 12, order: 4 } } } },
                    ],
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [createAllQueryView({ sorts: [{ name: 'name', dir: 'asc' }] })],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

export { factory };
//# sourceMappingURL=acorex-modules-learning-management-certificate-type.entity-CBM6N-PD.mjs.map
