import { createAllQueryView, AXPEntityCommandScope, AXPEntityQueryType } from '@acorex/platform/common';
import { AXMEntityCrudServiceImpl, entityMasterCrudActions, entityMasterRecordActions } from '@acorex/platform/layout/entity';
import { AXPWidgetsCatalog } from '@acorex/platform/layout/widget-core';
import { RootConfig } from './acorex-modules-meeting-management.mjs';
import * as i0 from '@angular/core';
import { Injectable } from '@angular/core';

class AXMMeetingScheduleService extends AXMEntityCrudServiceImpl {
}
class AXMMeetingScheduleServiceImpl extends AXMMeetingScheduleService {
    constructor() {
        super(`${RootConfig.module.name}.${RootConfig.entities.meetingSchedule.name}`);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMMeetingScheduleServiceImpl, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMMeetingScheduleServiceImpl }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.4", ngImport: i0, type: AXMMeetingScheduleServiceImpl, decorators: [{
            type: Injectable
        }], ctorParameters: () => [] });

async function meetingScheduleFactory(injector) {
    const dataService = injector.get(AXMMeetingScheduleService);
    const entityDef = {
        module: RootConfig.module.name,
        name: RootConfig.entities.meetingSchedule.name,
        title: RootConfig.entities.meetingSchedule.title,
        icon: RootConfig.entities.meetingSchedule.icon,
        formats: {
            individual: RootConfig.entities.meetingSchedule.title,
            plural: RootConfig.entities.meetingSchedule.titlePlural,
            searchResult: {
                title: '{{ meetingId.title }}',
                description: RootConfig.module.title,
            },
        },
        relatedEntities: [],
        groups: [{ id: 'section', title: RootConfig.entities.meetingSchedule.title }],
        properties: [
            {
                name: 'meetingId',
                title: '@meeting-management:meeting-schedule.meetingId',
                groupId: 'section',
                schema: {
                    dataType: 'object',
                    interface: {
                        type: AXPWidgetsCatalog.lookup,
                        options: {
                            look: 'select',
                            entity: `${RootConfig.module.name}.${RootConfig.entities.meeting.name}`,
                            expose: [
                                { source: 'id', target: 'meeting.id' },
                                { source: 'title', target: 'meeting.title' },
                            ],
                        },
                    },
                },
                validations: [{ rule: 'required' }],
            },
            {
                name: 'scheduleRule',
                title: '@meeting-management:meeting-schedule.scheduleRule',
                groupId: 'section',
                schema: {
                    dataType: 'string',
                    interface: {
                        type: AXPWidgetsCatalog.largeText,
                        options: { rows: 3 },
                    },
                },
                validations: [{ rule: 'required' }],
            },
        ],
        columns: [{ name: 'meetingId' }, { name: 'scheduleRule' }],
        commands: {
            create: { execute: async (data) => ({ id: await dataService.insertOne(data) }) },
            delete: { execute: async (id) => dataService.deleteOne(id) },
            update: { execute: async (data) => dataService.updateOne(data.id, data) },
        },
        queries: {
            byKey: { execute: async (id) => dataService.getOne(id), type: AXPEntityQueryType.Single },
            list: {
                execute: async (e) => dataService.query(e),
                type: AXPEntityQueryType.List,
            },
        },
        interfaces: {
            master: {
                create: {
                    sections: [{ id: 'section' }],
                    properties: [
                        { name: 'meetingId', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'scheduleRule', layout: { positions: { lg: { colSpan: 12, order: 2 } } } },
                    ],
                },
                update: {
                    sections: [{ id: 'section' }],
                    properties: [
                        { name: 'meetingId', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'scheduleRule', layout: { positions: { lg: { colSpan: 12, order: 2 } } } },
                    ],
                },
                single: {
                    title: '{{meeting.title}}',
                    sections: [{ id: 'section' }],
                    properties: [
                        { name: 'meetingId', layout: { positions: { lg: { colSpan: 6, order: 1 } } } },
                        { name: 'scheduleRule', layout: { positions: { lg: { colSpan: 12, order: 2 } } } },
                    ],
                    actions: [...entityMasterRecordActions()],
                },
                list: {
                    actions: [
                        ...entityMasterCrudActions(),
                        {
                            title: '@general:actions.edit.title',
                            command: 'quick-modify-entity',
                            priority: 'secondary',
                            type: 'update',
                            scope: AXPEntityCommandScope.Individual,
                        },
                    ],
                    views: [
                        createAllQueryView({
                            sorts: [{ name: 'meetingId', dir: 'asc' }],
                        }),
                    ],
                },
            },
        },
    };
    return entityDef;
}

export { meetingScheduleFactory };
//# sourceMappingURL=acorex-modules-meeting-management-meeting-schedule.entity-BCZrXy1s.mjs.map
