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-business-core.mjs';

//#region ----   Imports   ----
//#endregion
//#region ----   Entity Factory   ----
async function businessTypeFactory(injector) {
    const sections = [{ id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } }];
    const propertyLayouts = [
        { name: 'code', layout: { positions: { lg: { colSpan: 4, order: 1 } } } },
        { name: 'title', layout: { positions: { lg: { colSpan: 8, order: 2 } } } },
        { name: 'description', layout: { positions: { lg: { colSpan: 12, order: 3 } } } },
    ];
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.businessType.name,
        title: RootConfig.entities.businessType.title,
        icon: RootConfig.entities.businessType.icon,
        formats: {
            individual: RootConfig.entities.businessType.title,
            plural: RootConfig.entities.businessType.titlePlural,
            searchResult: {
                title: '{{ title }}',
                description: '{{ code }}',
            },
        },
        plugins: [{ name: 'history' }, { name: 'compare' }, { name: 'clone' }, { name: 'disable' }],
        groups: [{ id: 'basic-info', title: '@business-core:business-types.entities.business-type.groups.basic-info' }],
        properties: [
            {
                name: 'id',
                title: '@general:terms.common.id',
                groupId: 'basic-info',
                schema: {
                    dataType: 'uuid',
                    visible: false,
                    readonly: true,
                    unique: { enabled: true },
                },
            },
            {
                name: 'code',
                title: '@general:terms.common.code',
                groupId: 'basic-info',
                options: {
                    sort: { enabled: true },
                    filter: {
                        advance: { enabled: true },
                        inline: { enabled: true },
                    },
                },
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.TextBox,
                        options: {
                            placeholder: '@business-core:business-types.entities.business-type.fields.code.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'title',
                title: '@general:terms.common.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: '@business-core:business-types.entities.business-type.fields.title.placeholder',
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'description',
                title: '@general:terms.common.description',
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsList.Editors.LargeTextBox,
                        options: {
                            rows: 3,
                            placeholder: '@business-core:business-types.entities.business-type.fields.description.placeholder',
                        },
                    },
                },
            },
        ],
        columns: [
            { name: 'code', options: { width: '120px', order: 1 } },
            { name: 'title', options: { width: '220px', order: 2 } },
        ],
        interfaces: {
            master: {
                create: {
                    sections,
                    properties: propertyLayouts,
                },
                update: {
                    sections,
                    properties: propertyLayouts,
                },
                single: {
                    title: '{{ title }}',
                    sections,
                    properties: propertyLayouts,
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'code', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}
//#endregion

export { businessTypeFactory };
//# sourceMappingURL=acorex-modules-business-core-business-type.entity-DEy8LvEV.mjs.map
