import { createAllQueryView } from '@acorex/platform/common';
import { entityMasterCrudActions, entityMasterRecordActions } from '@acorex/platform/layout/entity';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { RootConfig } from './acorex-modules-customer-management.mjs';

async function activityFactory(injector) {
    const i18n = RootConfig.config.i18n + ':activities.entities.activity';
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.activity.name,
        title: RootConfig.entities.activity.title,
        icon: RootConfig.entities.activity.icon,
        formats: {
            individual: RootConfig.entities.activity.title,
            plural: RootConfig.entities.activity.titlePlural,
            searchResult: { title: '{{ subject }}', description: RootConfig.module.title },
        },
        groups: [{ id: 'basic-info', title: `@${i18n}.groups.basic-info` }],
        properties: [
            {
                name: 'type',
                title: `@${i18n}.fields.type.title`,
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.select,
                        options: {
                            valueField: 'id',
                            dataSource: [
                                { id: 'call', title: 'Call' },
                                { id: 'meeting', title: 'Meeting' },
                                { id: 'task', title: 'Task' },
                                { id: 'email', title: 'Email' },
                            ],
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'subject',
                title: `@${i18n}.fields.subject.title`,
                groupId: 'basic-info',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'dueDate',
                title: `@${i18n}.fields.due-date.title`,
                groupId: 'basic-info',
                schema: { dataType: 'date', interface: { type: AXPWidgetsCatalog.dateTime } },
            },
            {
                name: 'status',
                title: `@${i18n}.fields.status.title`,
                groupId: 'basic-info',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.select,
                        options: {
                            valueField: 'id',
                            dataSource: [
                                { id: 'open', title: 'Open' },
                                { id: 'completed', title: 'Completed' },
                                { id: 'canceled', title: 'Canceled' },
                            ],
                        },
                    },
                },
            },
            {
                name: 'outcome',
                title: `@${i18n}.fields.outcome.title`,
                groupId: 'basic-info',
                schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } },
            },
            {
                name: 'customerId',
                title: `@${i18n}.fields.customer.title`,
                groupId: 'basic-info',
                schema: { dataType: 'string', visible: false },
            },
            {
                name: 'opportunityId',
                title: `@${i18n}.fields.opportunity.title`,
                groupId: 'basic-info',
                schema: { dataType: 'string', visible: false },
            },
            {
                name: 'contactId',
                title: `@${i18n}.fields.contact.title`,
                groupId: 'basic-info',
                schema: { dataType: 'string', visible: false },
            },
        ],
        columns: [{ name: 'type' }, { name: 'subject' }, { name: 'dueDate' }, { name: 'status' }],
        interfaces: {
            master: {
                create: {
                    sections: [{ id: 'basic-info' }],
                    properties: [
                        { name: 'type', layout: { positions: { lg: { colSpan: 4 } } } },
                        { name: 'subject', layout: { positions: { lg: { colSpan: 8 } } } },
                        { name: 'dueDate', layout: { positions: { lg: { colSpan: 4 } } } },
                        { name: 'status', layout: { positions: { lg: { colSpan: 4 } } } },
                        { name: 'outcome', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                },
                update: {
                    sections: [{ id: 'basic-info' }],
                    properties: [
                        { name: 'type', layout: { positions: { lg: { colSpan: 4 } } } },
                        { name: 'subject', layout: { positions: { lg: { colSpan: 8 } } } },
                        { name: 'dueDate', layout: { positions: { lg: { colSpan: 4 } } } },
                        { name: 'status', layout: { positions: { lg: { colSpan: 4 } } } },
                        { name: 'outcome', layout: { positions: { lg: { colSpan: 12 } } } },
                    ],
                },
                single: {
                    title: '{{subject}}',
                    sections: [{ id: 'basic-info', layout: { positions: { lg: { colSpan: 12 } } } }],
                    properties: [
                        { name: 'type', layout: { positions: { lg: { colSpan: 4, order: 1 } } } },
                        { name: 'subject', layout: { positions: { lg: { colSpan: 8, order: 2 } } } },
                        { name: 'dueDate', layout: { positions: { lg: { colSpan: 4, order: 3 } } } },
                        { name: 'status', layout: { positions: { lg: { colSpan: 4, order: 4 } } } },
                        { name: 'outcome', layout: { positions: { lg: { colSpan: 12, order: 5 } } } },
                    ],
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [...entityMasterCrudActions()],
                    views: [createAllQueryView({ sorts: [{ name: 'dueDate', dir: 'asc' }] })],
                },
            },
        },
    };
    return entityDef;
}

export { activityFactory };
//# sourceMappingURL=acorex-modules-customer-management-activity.entity-DzzNvZ8E.mjs.map
