@acorex/platform-generator 19.2.12 → 19.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generators.json +10 -0
- package/package.json +4 -1
- package/src/bin/interactive-entity-creator.js +448 -0
- package/src/bin/test-entity-creator.js +48 -0
- package/src/generators/app-module/files/src/app/app.module.ts.template +0 -3
- package/src/generators/app-module/files/src/app/modules/root/sample/sample.service.ts.template +1 -1
- package/src/generators/app-module/files/src/app/modules/root/sample/sample.types.ts.template +1 -1
- package/src/generators/create-app-module/files/__fileName__/src/index.ts__tmpl__ +9 -0
- package/src/generators/create-app-module/files/__fileName__/src/lib/__fileName__.module.ts__tmpl__ +44 -0
- package/src/generators/create-app-module/files/__fileName__/src/lib/const.ts__tmpl__ +19 -0
- package/src/generators/create-app-module/files/__fileName__/src/lib/entity.provider.ts__tmpl__ +33 -0
- package/src/generators/create-app-module/files/__fileName__/src/lib/menu.provider.ts__tmpl__ +29 -0
- package/src/generators/create-app-module/files/__fileName__/src/lib/permission.provider.ts__tmpl__ +13 -0
- package/src/generators/create-app-module/files/__fileName__/src/lib/search-command.provider.ts__tmpl__ +17 -0
- package/src/generators/create-app-module/files/__fileName__/src/lib/setting.provider.ts__tmpl__ +29 -0
- package/src/generators/create-module-entity/files/__entityFileName__.entity.ts__tmpl__ +150 -0
- package/src/generators/create-module-entity/files/__entityFileName__.service.ts__tmpl__ +16 -0
- package/src/generators/create-module-entity/files/__entityFileName__.types.ts__tmpl__ +6 -0
- package/src/generators/create-module-entity/files/index.ts__tmpl__ +3 -0
- package/src/generators/create-module-entity/generator.d.ts +11 -0
- package/src/generators/create-module-entity/generator.js +338 -20
- package/src/generators/create-module-entity/generator.js.map +1 -1
- package/src/generators/create-module-entity/schema.json +85 -2
- package/src/generators/create-tag-entity/files/index.ts__tmpl__ +3 -0
- package/src/generators/create-tag-entity/files/tag-__entityFileName__.entity.ts__tmpl__ +240 -0
- package/src/generators/create-tag-entity/files/tag-__entityFileName__.service.ts__tmpl__ +16 -0
- package/src/generators/create-tag-entity/files/tag-__entityFileName__.types.ts__tmpl__ +6 -0
- package/src/generators/create-tag-entity/generator.d.ts +7 -0
- package/src/generators/create-tag-entity/generator.js +111 -0
- package/src/generators/create-tag-entity/generator.js.map +1 -0
- package/src/generators/create-tag-entity/schema.json +16 -0
- package/src/generators/create-widget/files/__fileName__-widget-column.component.ts__tmpl__ +11 -0
- package/src/generators/create-widget/files/__fileName__-widget-edit.component.ts__tmpl__ +35 -0
- package/src/generators/create-widget/files/__fileName__-widget-filter.component.ts__tmpl__ +12 -0
- package/src/generators/create-widget/files/__fileName__-widget-print.component.ts__tmpl__ +11 -0
- package/src/generators/create-widget/files/__fileName__-widget-view.component.ts__tmpl__ +14 -0
- package/src/generators/create-widget/files/__fileName__-widget.config.ts__tmpl__ +44 -0
- package/src/generators/create-widget/files/index.ts__tmpl__ +6 -0
- package/src/generators/create-widget/generator.d.ts +8 -0
- package/src/generators/create-widget/generator.js +99 -0
- package/src/generators/create-widget/generator.js.map +1 -0
- package/src/generators/create-widget/schema.d.ts +6 -0
- package/src/generators/create-widget/schema.json +66 -0
- package/src/generators/index.d.ts +0 -0
- package/src/generators/index.js +1 -0
- package/src/generators/index.js.map +1 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { AXPEntity, AXPEntityCommandScope, AXPEntityQueryType ,createAllQueryView} from '@acorex/platform/common';
|
|
2
|
+
import { AXPWidgetsCatalog } from '@acorex/platform/layout/builder';
|
|
3
|
+
import { Injector } from '@angular/core';
|
|
4
|
+
import { RootConfig } from '../../const';
|
|
5
|
+
import { AXMTag<%= entityClassName %>Service } from './tag-<%= entityFileName %>.service';
|
|
6
|
+
|
|
7
|
+
export async function tag<%= entityClassName %>Factory(injector: Injector): Promise<AXPEntity | null> {
|
|
8
|
+
const dataService = injector.get(AXMTag<%= entityClassName %>Service);
|
|
9
|
+
|
|
10
|
+
const entityDef: AXPEntity = {
|
|
11
|
+
module: RootConfig.module.name,
|
|
12
|
+
name: RootConfig.entities.tag<%= entityClassName %>.name,
|
|
13
|
+
source: '',
|
|
14
|
+
title: RootConfig.entities.tag<%= entityClassName %>.title,
|
|
15
|
+
formats: {
|
|
16
|
+
individual: RootConfig.entities.tag<%= entityClassName %>.title,
|
|
17
|
+
plural: RootConfig.entities.tag<%= entityClassName %>.titlePlural,
|
|
18
|
+
searchResult: {
|
|
19
|
+
title: '{{ title }}',
|
|
20
|
+
description: RootConfig.module.title,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
relatedEntities: [],
|
|
24
|
+
groups: [
|
|
25
|
+
{
|
|
26
|
+
id: 'section',
|
|
27
|
+
title: RootConfig.entities.tag<%= entityClassName %>.title,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
properties: [
|
|
31
|
+
{
|
|
32
|
+
name: 'name',
|
|
33
|
+
title: 't("name", { scope: "common" })',
|
|
34
|
+
groupId: 'section',
|
|
35
|
+
options: {
|
|
36
|
+
sort: {
|
|
37
|
+
enabled: true,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
schema: {
|
|
41
|
+
dataType: 'string',
|
|
42
|
+
interface: {
|
|
43
|
+
type: AXPWidgetsCatalog.text,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
validations: [
|
|
47
|
+
{
|
|
48
|
+
rule: 'required',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'title',
|
|
54
|
+
title: 't("title", { scope: "common" })',
|
|
55
|
+
groupId: 'section',
|
|
56
|
+
schema: {
|
|
57
|
+
dataType: 'string',
|
|
58
|
+
interface: {
|
|
59
|
+
type: AXPWidgetsCatalog.text,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
validations: [
|
|
63
|
+
{
|
|
64
|
+
rule: 'required',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
columns: [{ name: 'name' }, { name: 'title' }],
|
|
70
|
+
commands: {
|
|
71
|
+
create: {
|
|
72
|
+
execute: async (data: any) => {
|
|
73
|
+
const res = await dataService.insertOne(data);
|
|
74
|
+
return { id: res };
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
delete: {
|
|
78
|
+
execute: async (id: any) => {
|
|
79
|
+
return await dataService.deleteOne(id);
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
update: {
|
|
83
|
+
execute: async (data: any) => {
|
|
84
|
+
return await dataService.updateOne(data.id, data);
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
queries: {
|
|
89
|
+
byKey: {
|
|
90
|
+
execute: async (id: string) => {
|
|
91
|
+
return await dataService.getOne(id);
|
|
92
|
+
},
|
|
93
|
+
type: AXPEntityQueryType.Single,
|
|
94
|
+
},
|
|
95
|
+
list: {
|
|
96
|
+
execute: async (e: any) => {
|
|
97
|
+
return await dataService.query({ skip: e.skip, take: e.take, filter: e.filter });
|
|
98
|
+
},
|
|
99
|
+
type: AXPEntityQueryType.List,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
interfaces: {
|
|
103
|
+
master: {
|
|
104
|
+
create: {
|
|
105
|
+
sections: [
|
|
106
|
+
{
|
|
107
|
+
id: 'section',
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
properties: [
|
|
111
|
+
{
|
|
112
|
+
name: 'name',
|
|
113
|
+
layout: {
|
|
114
|
+
positions: {
|
|
115
|
+
lg: {
|
|
116
|
+
colSpan: 6,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'title',
|
|
123
|
+
layout: {
|
|
124
|
+
positions: {
|
|
125
|
+
lg: {
|
|
126
|
+
colSpan: 6,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
update: {
|
|
134
|
+
sections: [
|
|
135
|
+
{
|
|
136
|
+
id: 'section',
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
properties: [
|
|
140
|
+
{
|
|
141
|
+
name: 'name',
|
|
142
|
+
layout: {
|
|
143
|
+
positions: {
|
|
144
|
+
lg: {
|
|
145
|
+
colSpan: 6,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'title',
|
|
152
|
+
layout: {
|
|
153
|
+
positions: {
|
|
154
|
+
lg: {
|
|
155
|
+
colSpan: 6,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
single: {
|
|
163
|
+
title: '{{title}}',
|
|
164
|
+
sections: [
|
|
165
|
+
{
|
|
166
|
+
id: 'section',
|
|
167
|
+
layout: {
|
|
168
|
+
positions: {
|
|
169
|
+
lg: {
|
|
170
|
+
colSpan: 12,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
properties: [
|
|
177
|
+
{
|
|
178
|
+
name: 'name',
|
|
179
|
+
layout: {
|
|
180
|
+
positions: {
|
|
181
|
+
lg: {
|
|
182
|
+
colSpan: 6,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'title',
|
|
189
|
+
layout: {
|
|
190
|
+
positions: {
|
|
191
|
+
lg: {
|
|
192
|
+
colSpan: 6,
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
actions: [],
|
|
199
|
+
},
|
|
200
|
+
list: {
|
|
201
|
+
actions: [
|
|
202
|
+
{
|
|
203
|
+
title: `t("create", { scope: "common" })`,
|
|
204
|
+
command: 'create-entity',
|
|
205
|
+
priority: 'primary',
|
|
206
|
+
type: 'create',
|
|
207
|
+
scope: AXPEntityCommandScope.TypeLevel,
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
title: 't("deleteItems", { scope: "common" })',
|
|
211
|
+
command: 'delete-entity',
|
|
212
|
+
priority: 'primary',
|
|
213
|
+
type: 'delete',
|
|
214
|
+
scope: AXPEntityCommandScope.Selected,
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
title: 't("detail", { scope: "common" })',
|
|
218
|
+
command: 'open-entity',
|
|
219
|
+
priority: 'secondary',
|
|
220
|
+
type: 'view',
|
|
221
|
+
scope: AXPEntityCommandScope.Individual,
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
title: 't("delete", { scope: "common" })',
|
|
225
|
+
command: 'delete-entity',
|
|
226
|
+
priority: 'secondary',
|
|
227
|
+
type: 'delete',
|
|
228
|
+
scope: AXPEntityCommandScope.Individual,
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
views: [
|
|
232
|
+
createAllQueryView({ sorts: [{ name: 'title', dir: 'asc' }] }),
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
return entityDef;
|
|
240
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AXMEntityCrudServiceImpl } from '@acorex/platform/layout/entity';
|
|
2
|
+
import { Injectable } from '@angular/core';
|
|
3
|
+
import { RootConfig } from '../../const';
|
|
4
|
+
import { AXMTag<%= entityClassName %>EntityModel } from './tag-<%= entityFileName %>.types';
|
|
5
|
+
|
|
6
|
+
export abstract class AXMTag<%= entityClassName %>Service extends AXMEntityCrudServiceImpl<
|
|
7
|
+
string,
|
|
8
|
+
AXMTag<%= entityClassName %>EntityModel
|
|
9
|
+
> {}
|
|
10
|
+
|
|
11
|
+
@Injectable()
|
|
12
|
+
export class AXMTag<%= entityClassName %>ServiceImpl extends AXMTag<%= entityClassName %>Service {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(`${RootConfig.module.name}.${RootConfig.entities.tag<%= entityClassName %>.name}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
function default_1(tree, schema) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const normalizedNames = generateNameVariants(schema.name, 'entity');
|
|
10
|
+
const normalizedModuleNames = generateNameVariants(schema.moduleName, 'module');
|
|
11
|
+
const targetDir = (0, devkit_1.joinPathFragments)('libs', 'modules', // Ensure 'modules' is part of the path
|
|
12
|
+
normalizedModuleNames.moduleFileName, 'src', 'lib', 'entities', `tag-${normalizedNames.entityFileName}`);
|
|
13
|
+
// Define the new menu item to add
|
|
14
|
+
const newMenuItem = `
|
|
15
|
+
{
|
|
16
|
+
text: \`\${scope}.Tag ${normalizedNames.entityPropertyName}\`,
|
|
17
|
+
path: '',
|
|
18
|
+
icon: ''
|
|
19
|
+
},
|
|
20
|
+
`;
|
|
21
|
+
const targetDirModule = (0, devkit_1.joinPathFragments)('libs', 'modules', normalizedModuleNames.moduleFileName);
|
|
22
|
+
(0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), targetDir, Object.assign(Object.assign(Object.assign(Object.assign({}, schema), normalizedModuleNames), normalizedNames), { tmpl: '' }));
|
|
23
|
+
function generateNameVariants(baseName, prefix) {
|
|
24
|
+
const formattedNames = (0, devkit_1.names)(baseName);
|
|
25
|
+
//const capitalizedPrefix = prefix.charAt(0).toUpperCase() + prefix.slice(1);
|
|
26
|
+
return {
|
|
27
|
+
[`${prefix}Name`]: formattedNames.name,
|
|
28
|
+
[`${prefix}ClassName`]: formattedNames.className,
|
|
29
|
+
[`${prefix}PropertyName`]: formattedNames.propertyName,
|
|
30
|
+
[`${prefix}FileName`]: formattedNames.fileName,
|
|
31
|
+
[`${prefix}ConstantName`]: formattedNames.constantName,
|
|
32
|
+
[`${prefix}HumanName`]: toSpacedString(formattedNames.name),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function toSpacedString(str) {
|
|
36
|
+
return str.replace(/([a-z0-9])([A-Z])/g, '$1 $2').toLowerCase();
|
|
37
|
+
}
|
|
38
|
+
// Update const.ts with the new entity key
|
|
39
|
+
const constFilePath = (0, devkit_1.joinPathFragments)(targetDirModule, 'src/lib/const.ts');
|
|
40
|
+
if (tree.exists(constFilePath)) {
|
|
41
|
+
if (tree.exists(constFilePath)) {
|
|
42
|
+
const originalContent = tree.read(constFilePath, 'utf-8');
|
|
43
|
+
// Construct the new entity object
|
|
44
|
+
const newEntityContent = `
|
|
45
|
+
tag${normalizedNames.entityClassName}: {
|
|
46
|
+
name: 'tag-${normalizedNames.entityPropertyName}',
|
|
47
|
+
title: \`t("tag-${normalizedNames.entityPropertyName}", { scope: "\${config.i18n}" })\`,
|
|
48
|
+
titlePlural: \`t("tag-${normalizedNames.entityPropertyName}Plural", { scope: "\${config.i18n}" })\`,
|
|
49
|
+
icon: 'fa-light fa-default',
|
|
50
|
+
},`;
|
|
51
|
+
// Check if `entities` object already exists
|
|
52
|
+
if (/entities:\s*\{[^}]*\}/.test(originalContent)) {
|
|
53
|
+
// Append the new entity inside the `entities` object
|
|
54
|
+
const newContent = originalContent.replace(/(entities:\s*\{)/, `$1${newEntityContent}`);
|
|
55
|
+
tree.write(constFilePath, newContent);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// If `entities` doesn't exist, add it before closing `RootConfig`
|
|
59
|
+
const newContent = originalContent.replace(/RootConfig\s*=\s*\{([^}]*config,\s*module:[^}]*)\}/, `RootConfig = {$1, entities: {${newEntityContent}}}`);
|
|
60
|
+
tree.write(constFilePath, newContent);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Append service provider to the existing module.ts file if it exists
|
|
65
|
+
const moduleFilePath = (0, devkit_1.joinPathFragments)(targetDirModule, `src/lib/${normalizedModuleNames.moduleFileName}.module.ts`);
|
|
66
|
+
// Define import and provider strings for the new entity
|
|
67
|
+
const serviceImport = `import { AXMTag${normalizedNames.entityClassName}Service, AXMTag${normalizedNames.entityClassName}ServiceImpl } from './entities';`;
|
|
68
|
+
const serviceProvider = `{
|
|
69
|
+
provide: AXMTag${normalizedNames.entityClassName}Service,
|
|
70
|
+
useClass: AXMTag${normalizedNames.entityClassName}ServiceImpl,
|
|
71
|
+
}`;
|
|
72
|
+
if (tree.exists(moduleFilePath)) {
|
|
73
|
+
const originalContent = tree.read(moduleFilePath, 'utf-8');
|
|
74
|
+
// Add the import if not already present
|
|
75
|
+
const updatedImports = originalContent.includes(serviceImport)
|
|
76
|
+
? originalContent
|
|
77
|
+
: originalContent.replace(/(@NgModule\(\{)/, `${serviceImport}\n$1`);
|
|
78
|
+
// Add the provider to the providers array if not already present
|
|
79
|
+
const updatedProviders = updatedImports.includes(serviceProvider)
|
|
80
|
+
? updatedImports
|
|
81
|
+
: updatedImports.replace(/providers:\s*\[/, `providers: [${serviceProvider}, `);
|
|
82
|
+
// Write the updated content back to the module file
|
|
83
|
+
tree.write(moduleFilePath, updatedProviders);
|
|
84
|
+
}
|
|
85
|
+
// Append new menu item to `children` array in `menu.provider.ts`
|
|
86
|
+
const menuProviderFilePath = (0, devkit_1.joinPathFragments)(targetDirModule, 'src/lib/menu.provider.ts');
|
|
87
|
+
if (tree.exists(menuProviderFilePath)) {
|
|
88
|
+
const originalContent = tree.read(menuProviderFilePath, 'utf-8');
|
|
89
|
+
// Find the placeholder in the children array and add the new menu item
|
|
90
|
+
const updatedContent = originalContent.replace(/children:\s*\[\s*<%= menuItems %>\s*\]/, `children: [${newMenuItem}<%= menuItems %>]`);
|
|
91
|
+
// Write the updated content back to the `menu.provider.ts` file
|
|
92
|
+
tree.write(menuProviderFilePath, updatedContent);
|
|
93
|
+
}
|
|
94
|
+
const indexFilePath = (0, devkit_1.joinPathFragments)(targetDirModule, 'src', 'lib', 'entities', 'index.ts');
|
|
95
|
+
// Define the new export line
|
|
96
|
+
const newExportLine = `export * from './tag-${normalizedNames.entityFileName}';\n`;
|
|
97
|
+
// Check if index.ts exists and append the new export line
|
|
98
|
+
if (tree.exists(indexFilePath)) {
|
|
99
|
+
const originalContent = tree.read(indexFilePath, 'utf-8');
|
|
100
|
+
const updatedContent = originalContent.includes(newExportLine)
|
|
101
|
+
? originalContent
|
|
102
|
+
: `${originalContent}${newExportLine}`;
|
|
103
|
+
tree.write(indexFilePath, updatedContent);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// If index.ts does not exist, create it with the new export line
|
|
107
|
+
tree.write(indexFilePath, newExportLine);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../generator/src/generators/create-tag-entity/generator.ts"],"names":[],"mappings":";;AAQA,4BA6IC;;AArJD,uCAA2E;AAC3E,6BAA6B;AAO7B,mBAA+B,IAAU,EAAE,MAAc;;QACvD,MAAM,eAAe,GAAG,oBAAoB,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACpE,MAAM,qBAAqB,GAAG,oBAAoB,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAChF,MAAM,SAAS,GAAG,IAAA,0BAAiB,EACjC,MAAM,EACN,SAAS,EAAE,uCAAuC;QAClD,qBAAqB,CAAC,cAAc,EACpC,KAAK,EACL,KAAK,EACL,UAAU,EACV,OAAO,eAAe,CAAC,cAAc,EAAE,CACxC,CAAC;QAEF,k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cAAc,GAAG,eAAe,CAAC,QAAQ,CAAC,aAAa,CAAC;gBAC5D,CAAC,CAAC,eAAe;gBACjB,CAAC,CAAC,GAAG,eAAe,GAAG,aAAa,EAAE,CAAC;YACzC,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,iEAAiE;YACjE,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"title": "Create Module Tag Entity",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"moduleName": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "The name of the module"
|
|
9
|
+
},
|
|
10
|
+
"name": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "The name of the tag entity"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"required": ["moduleName", "name"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AXPWidgetComponent } from '@acorex/platform/layout/builder';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
template: ``,
|
|
7
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
8
|
+
imports: [CommonModule],
|
|
9
|
+
inputs: []
|
|
10
|
+
})
|
|
11
|
+
export class AXP<%= className %>WidgetColumnComponent extends AXPWidgetComponent<any> { }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AXButtonModule } from '@acorex/components/button';
|
|
2
|
+
import { AXValueChangedEvent } from '@acorex/components/common';
|
|
3
|
+
import { AXDecoratorModule } from '@acorex/components/decorators';
|
|
4
|
+
import { AXFormModule } from '@acorex/components/form';
|
|
5
|
+
import { AXTextBoxModule } from '@acorex/components/text-box';
|
|
6
|
+
import { AXValidationModule } from '@acorex/core/validation';
|
|
7
|
+
import { AXPWidgetComponent } from '@acorex/platform/layout/builder';
|
|
8
|
+
import { CommonModule } from '@angular/common';
|
|
9
|
+
import { ChangeDetectionStrategy, Component, HostBinding, Signal, computed } from '@angular/core';
|
|
10
|
+
import { FormsModule } from '@angular/forms';
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'axp-<%= fileName %>-widget',
|
|
14
|
+
template: `
|
|
15
|
+
`,
|
|
16
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
17
|
+
imports: [
|
|
18
|
+
CommonModule,
|
|
19
|
+
AXTextBoxModule,
|
|
20
|
+
FormsModule,
|
|
21
|
+
AXFormModule,
|
|
22
|
+
AXDecoratorModule,
|
|
23
|
+
AXValidationModule,
|
|
24
|
+
AXButtonModule,
|
|
25
|
+
],
|
|
26
|
+
inputs: [],
|
|
27
|
+
})
|
|
28
|
+
export class AXP<%= className %>WidgetEditComponent extends AXPWidgetComponent<any> {
|
|
29
|
+
|
|
30
|
+
@HostBinding('class')
|
|
31
|
+
private get __class(): string {
|
|
32
|
+
const cls: any = {};
|
|
33
|
+
return cls;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AXPWidgetComponent } from '@acorex/platform/layout/builder';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
import { FormsModule } from '@angular/forms';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
template: ``,
|
|
8
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
9
|
+
imports: [CommonModule, FormsModule],
|
|
10
|
+
inputs: []
|
|
11
|
+
})
|
|
12
|
+
export class AXP<%= className %>WidgetFilterComponent extends AXPWidgetComponent<any> { }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AXPWidgetComponent } from '@acorex/platform/layout/builder';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
template: ``,
|
|
7
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
8
|
+
imports: [CommonModule],
|
|
9
|
+
inputs: []
|
|
10
|
+
})
|
|
11
|
+
export class AXP<%= className %>WidgetPrintComponent extends AXPWidgetComponent<any> { }
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AXPWidgetComponent } from '@acorex/platform/layout/builder';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { ChangeDetectionStrategy, Component, computed } from '@angular/core';
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'axp-<%= fileName %>-widget',
|
|
7
|
+
template: `
|
|
8
|
+
`,
|
|
9
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
10
|
+
imports: [CommonModule],
|
|
11
|
+
inputs: []
|
|
12
|
+
})
|
|
13
|
+
export class AXP<%= className %>WidgetViewComponent extends AXPWidgetComponent<any> {
|
|
14
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AXP_WIDGETS_EDITOR_GROUP, AXPWidgetConfig } from '@acorex/platform/layout/builder';
|
|
2
|
+
import { AXP_NAME_PROPERTY } from '../../../properties/general.props';
|
|
3
|
+
import {
|
|
4
|
+
AXP_DATA_PATH_PROPERTY,
|
|
5
|
+
} from '../../../properties';
|
|
6
|
+
|
|
7
|
+
export const AXP<%= className %>Widget: AXPWidgetConfig = {
|
|
8
|
+
name: '<%= fileName %>-editor',
|
|
9
|
+
title: '<%= className %>',
|
|
10
|
+
icon: '<%= icon %>',
|
|
11
|
+
description: '<%= description %>',
|
|
12
|
+
group: AXP_WIDGETS_EDITOR_GROUP,
|
|
13
|
+
type: 'editor',
|
|
14
|
+
defaultFilterWidgetName: 'string-filter',
|
|
15
|
+
properties: [
|
|
16
|
+
AXP_NAME_PROPERTY,
|
|
17
|
+
AXP_DATA_PATH_PROPERTY,
|
|
18
|
+
],
|
|
19
|
+
components: {
|
|
20
|
+
view: {
|
|
21
|
+
component: () => import('./<%= fileName %>-widget-view.component').then((c) => c.AXP<%= className %>WidgetViewComponent),
|
|
22
|
+
},
|
|
23
|
+
edit: {
|
|
24
|
+
component: () => import('./<%= fileName %>-widget-edit.component').then((c) => c.AXP<%= className %>WidgetEditComponent),
|
|
25
|
+
},
|
|
26
|
+
filter: {
|
|
27
|
+
component: () => import('./<%= fileName %>-widget-filter.component').then((c) => c.AXP<%= className %>WidgetFilterComponent),
|
|
28
|
+
},
|
|
29
|
+
column: {
|
|
30
|
+
component: () => import('./<%= fileName %>-widget-column.component').then((c) => c.AXP<%= className %>WidgetColumnComponent),
|
|
31
|
+
},
|
|
32
|
+
print: {
|
|
33
|
+
component: () => import('./<%= fileName %>-widget-print.component').then((c) => c.AXP<%= className %>WidgetPrintComponent),
|
|
34
|
+
},
|
|
35
|
+
designer: {
|
|
36
|
+
component: () => import('./<%= fileName %>-widget-edit.component').then((c) => c.AXP<%= className %>WidgetEditComponent),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
declare module '@acorex/platform/layout/builder' {
|
|
41
|
+
interface AXPWidgetTypesMap {
|
|
42
|
+
<%= propertyName %>: '<%= fileName %>-editor';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './<%= fileName %>-widget-view.component';
|
|
2
|
+
export * from './<%= fileName %>-widget-edit.component';
|
|
3
|
+
export * from './<%= fileName %>-widget-filter.component';
|
|
4
|
+
export * from './<%= fileName %>-widget-column.component';
|
|
5
|
+
export * from './<%= fileName %>-widget-print.component';
|
|
6
|
+
export * from './<%= fileName %>-widget.config';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
function normalizeOptions(options) {
|
|
8
|
+
const { fileName, className, propertyName } = (0, devkit_1.names)(options.name);
|
|
9
|
+
return Object.assign(Object.assign({}, options), { fileName, className: className, propertyName: propertyName, group: options.group || 'editors', icon: options.icon || 'fa-solid fa-cube', description: options.description || `Inputs ${options.name}` });
|
|
10
|
+
}
|
|
11
|
+
function default_1(tree, options) {
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const normalizedOptions = normalizeOptions(options);
|
|
14
|
+
const { fileName, className, group, icon, description, propertyName } = normalizedOptions;
|
|
15
|
+
// ایجاد مسیر پوشه برای ویجت جدید
|
|
16
|
+
const widgetDir = `libs/platform/widgets/src/lib/widgets/${group}/${fileName}`;
|
|
17
|
+
// ایجاد فایلها با استفاده از الگوها
|
|
18
|
+
(0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files'), widgetDir, {
|
|
19
|
+
fileName,
|
|
20
|
+
className,
|
|
21
|
+
icon,
|
|
22
|
+
description,
|
|
23
|
+
group,
|
|
24
|
+
propertyName,
|
|
25
|
+
tmpl: '',
|
|
26
|
+
});
|
|
27
|
+
// بروزرسانی فایل اصلی index.ts
|
|
28
|
+
const indexFile = 'libs/platform/widgets/src/lib/widgets/index.ts';
|
|
29
|
+
if (tree.exists(indexFile)) {
|
|
30
|
+
const content = tree.read(indexFile, 'utf-8');
|
|
31
|
+
const exportLine = `export * from './${group}/${fileName}';\n`;
|
|
32
|
+
// پیدا کردن محل مناسب برای اضافه کردن export جدید
|
|
33
|
+
// جستجو برای بخش گروه مرتبط (مثلاً export * from './editors/...)
|
|
34
|
+
const groupPattern = new RegExp(`export \\* from '\\.\\/${group}\\/`);
|
|
35
|
+
let updatedContent = content;
|
|
36
|
+
if (groupPattern.test(content)) {
|
|
37
|
+
// پیدا کردن آخرین export در این گروه
|
|
38
|
+
const lines = content.split('\n');
|
|
39
|
+
let lastIndex = -1;
|
|
40
|
+
for (let i = 0; i < lines.length; i++) {
|
|
41
|
+
if (groupPattern.test(lines[i])) {
|
|
42
|
+
lastIndex = i;
|
|
43
|
+
}
|
|
44
|
+
else if (lastIndex !== -1 && !lines[i].includes(`export * from './${group}/`)) {
|
|
45
|
+
// اگر به خط بعدی که دیگر export از این گروه نیست رسیدیم
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (lastIndex !== -1) {
|
|
50
|
+
// درج export جدید بعد از آخرین export از این گروه
|
|
51
|
+
lines.splice(lastIndex + 1, 0, exportLine);
|
|
52
|
+
updatedContent = lines.join('\n');
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// اگر گروه موجود نبود، آن را در آخر اضافه کنیم
|
|
56
|
+
updatedContent += `\n${exportLine}`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// اگر گروه موجود نبود، آن را در آخر اضافه کنیم
|
|
61
|
+
updatedContent += `\n// ${group}\n${exportLine}`;
|
|
62
|
+
}
|
|
63
|
+
tree.write(indexFile, updatedContent);
|
|
64
|
+
}
|
|
65
|
+
// بروزرسانی فایل widget-catalog.ts برای اضافه کردن ویجت جدید
|
|
66
|
+
const catalogFile = 'libs/platform/layout/builder/src/lib/builder/widget-catalog.ts';
|
|
67
|
+
if (tree.exists(catalogFile)) {
|
|
68
|
+
const content = tree.read(catalogFile, 'utf-8');
|
|
69
|
+
// پیدا کردن محل شروع آبجکت AXPWidgetsCatalog
|
|
70
|
+
const catalogStart = content.indexOf('const AXPWidgetsCatalog: AXPWidgetTypesMap = {');
|
|
71
|
+
if (catalogStart !== -1) {
|
|
72
|
+
// اضافه کردن ویجت جدید در ابتدای آبجکت
|
|
73
|
+
const newWidgetLine = ` ${propertyName}: '${fileName}-editor',\n`;
|
|
74
|
+
const insertPosition = catalogStart + 'const AXPWidgetsCatalog: AXPWidgetTypesMap = {'.length;
|
|
75
|
+
const updatedContent = content.substring(0, insertPosition) + '\n' + newWidgetLine + content.substring(insertPosition);
|
|
76
|
+
tree.write(catalogFile, updatedContent);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// بروزرسانی فایل widget-map.ts برای اضافه کردن ویجت جدید
|
|
80
|
+
const mapFile = 'libs/platform/layout/builder/src/lib/builder/widget-map.ts';
|
|
81
|
+
if (tree.exists(mapFile)) {
|
|
82
|
+
const content = tree.read(mapFile, 'utf-8');
|
|
83
|
+
// پیدا کردن محل پایان interface
|
|
84
|
+
const interfaceEnd = content.lastIndexOf('}');
|
|
85
|
+
if (interfaceEnd !== -1) {
|
|
86
|
+
// اضافه کردن ویجت جدید به interface
|
|
87
|
+
const newWidgetLine = ` ${propertyName}: '${fileName}-editor';\n`;
|
|
88
|
+
// اضافه کردن به آخر interface، قبل از '}'
|
|
89
|
+
const updatedContent = content.substring(0, interfaceEnd) +
|
|
90
|
+
(interfaceEnd > 0 && content[interfaceEnd - 1] !== '\n' ? '\n' : '') +
|
|
91
|
+
newWidgetLine +
|
|
92
|
+
content.substring(interfaceEnd);
|
|
93
|
+
tree.write(mapFile, updatedContent);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=generator.js.map
|