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.certificateDefinition.name,
        title: RootConfig.entities.certificateDefinition.title,
        icon: RootConfig.entities.certificateDefinition.icon,
        plugins: [{ name: 'history' }, { name: 'lock' }, { name: 'compare' }, { name: 'clone' }, { name: 'archive' }, { name: 'category' }],
        formats: {
            individual: RootConfig.entities.certificateDefinition.title,
            plural: RootConfig.entities.certificateDefinition.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ certificateType.name }}',
            },
        },
        groups: [
            { id: 'basic-info', title: '@general:terms.interface.basic-info' },
            {
                id: 'configuration',
                title: '@learning-management:certificates.entities.certificate-definition.groups.configuration',
            },
        ],
        properties: [
            {
                name: 'id',
                title: 'ID',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    nullable: false,
                    readonly: true,
                    unique: { enabled: true },
                },
            },
            {
                name: 'title',
                title: '@learning-management:certificates.entities.certificate-definition.fields.title.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-definition.fields.title.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@learning-management:certificates.entities.certificate-definition.fields.description.title',
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 3,
                            placeholder: '@learning-management:certificates.entities.certificate-definition.fields.description.placeholder',
                        },
                    },
                },
            },
            {
                name: 'certificateTypeId',
                title: '@learning-management:certificates.entities.certificate-definition.fields.certificate-type-id.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.certificateType.name}`,
                            look: 'select',
                            expose: [
                                { source: 'id', target: 'certificateType.id' },
                                { source: 'name', target: 'certificateType.name' },
                            ],
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'courseId',
                title: '@learning-management:certificates.entities.certificate-definition.fields.course-id.title',
                groupId: 'configuration',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: `${RootConfig.module.name}.${RootConfig.entities.course.name}`,
                            look: 'select',
                            expose: [
                                { source: 'id', target: 'course.id' },
                                { source: 'title', target: 'course.title' },
                            ],
                        },
                    },
                },
            },
            {
                name: 'validityDays',
                title: '@learning-management:certificates.entities.certificate-definition.fields.validity-days.title',
                groupId: 'configuration',
                schema: {
                    dataType: 'number',
                    interface: {
                        type: AXPWidgetsList.Editors.NumberBox,
                        options: {
                            minValue: 0,
                            placeholder: '@learning-management:certificates.entities.certificate-definition.fields.validity-days.placeholder',
                        },
                    },
                },
            },
            {
                name: 'templateId',
                title: '@learning-management:certificates.entities.certificate-definition.fields.template-id.title',
                groupId: 'configuration',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LookupBox,
                        options: {
                            entity: 'DocumentManagement.DocumentTemplate',
                        },
                    },
                },
            },
            {
                name: 'isActive',
                title: '@learning-management:certificates.entities.certificate-definition.fields.is-active.title',
                groupId: 'configuration',
                schema: {
                    dataType: 'boolean',
                    defaultValue: true,
                    interface: {
                        type: AXPWidgetsList.Editors.ToggleSwitch,
                    },
                },
            },
        ],
        columns: [
            { name: 'title' },
            { name: 'certificateTypeId', options: { dataPath: 'certificateType.name' } },
            { name: 'courseId', options: { dataPath: 'course.title' } },
            { name: 'isActive' },
        ],
        interfaces: {
            master: {
                create: {
                    sections: [
                        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'configuration', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                    properties: [
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'certificateTypeId', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'courseId', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'validityDays', layout: { positions: { lg: { colSpan: 3, order: 5 } } } },
                        { name: 'templateId', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 3, order: 7 } } } },
                    ],
                },
                update: {
                    sections: [
                        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'configuration', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                    properties: [
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'certificateTypeId', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'courseId', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'validityDays', layout: { positions: { lg: { colSpan: 3, order: 5 } } } },
                        { name: 'templateId', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 3, order: 7 } } } },
                    ],
                },
                single: {
                    title: '{{ title }}',
                    sections: [
                        { id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } },
                        { id: 'configuration', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                    properties: [
                        { name: 'title', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'certificateTypeId', layout: { positions: { lg: { colSpan: 6, order: 2 } } } },
                        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
                        { name: 'courseId', layout: { positions: { lg: { colSpan: 6, order: 4 } } } },
                        { name: 'validityDays', layout: { positions: { lg: { colSpan: 3, order: 5 } } } },
                        { name: 'templateId', layout: { positions: { lg: { colSpan: 6, order: 6 } } } },
                        { name: 'isActive', layout: { positions: { lg: { colSpan: 3, order: 7 } } } },
                    ],
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [createAllQueryView({ sorts: [{ name: 'title', dir: 'asc' }] })],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

export { factory };
//# sourceMappingURL=acorex-modules-learning-management-certificate-definition.entity-27VKYxw1.mjs.map
