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

async function activityFactory(injector) {
    const dataService = injector.get(AXMCustomerManagementActivityEntityService);
    const i18n = RootConfig.config.i18n;
    const entityName = 'activity';
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.activity.name,
        title: RootConfig.entities.activity.title,
        icon: RootConfig.entities.activity.icon,
        formats: {
            individual: `t("${entityName}.individual-title", { scope: "${i18n}" })`,
            plural: `t("${entityName}.plural-title", { scope: "${i18n}" })`,
            searchResult: { title: '{{ subject }}', description: RootConfig.module.title },
        },
        groups: [{ id: 'basic-info', title: `t("${entityName}.basic-info", { scope: "${i18n}" })` }],
        properties: [
            { name: 'type', title: `t("${entityName}.type", { scope: "${i18n}" })`, 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: `t("${entityName}.subject", { scope: "${i18n}" })`, groupId: 'basic-info', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } }, validations: [{ rule: 'required' }] },
            { name: 'dueDate', title: `t("${entityName}.due-date", { scope: "${i18n}" })`, groupId: 'basic-info', schema: { dataType: 'date', interface: { type: AXPWidgetsCatalog.dateTime } } },
            { name: 'status', title: `t("${entityName}.status", { scope: "${i18n}" })`, 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: `t("${entityName}.outcome", { scope: "${i18n}" })`, groupId: 'basic-info', schema: { dataType: 'string', interface: { type: AXPWidgetsCatalog.text } } },
            { name: 'customerId', title: `t("customer", { scope: "${i18n}" })`, groupId: 'basic-info', schema: { dataType: 'string', hidden: true } },
            { name: 'opportunityId', title: `t("opportunity", { scope: "${i18n}" })`, groupId: 'basic-info', schema: { dataType: 'string', hidden: true } },
            { name: 'contactId', title: `t("contact", { scope: "${i18n}" })`, groupId: 'basic-info', schema: { dataType: 'string', hidden: true } },
        ],
        columns: [{ name: 'type' }, { name: 'subject' }, { name: 'dueDate' }, { name: 'status' }],
        commands: {
            create: { execute: async (data) => ({ id: await dataService.insertOne(data) }) },
            delete: { execute: async (id) => await dataService.deleteOne(id) },
            update: { execute: async (data) => await dataService.updateOne(data.id, data) },
        },
        queries: {
            byKey: { execute: async (id) => await dataService.getOne(id), type: AXPEntityQueryType.Single },
            list: { execute: async (e) => await dataService.query(e), type: AXPEntityQueryType.List },
        },
        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-Dt0EZWKR.mjs.map
