@mckit/schematics 0.0.13 → 0.0.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/package.json +1 -1
- package/src/add-table/files/__class__.component.html.template +2 -0
- package/src/add-table/files/__class__.component.ts.template +0 -1
- package/src/add-table/index.js +9 -4
- package/src/add-table/index.js.map +1 -1
- package/src/core/get-properties-by-class.d.ts +2 -1
- package/src/core/get-properties-by-class.js +29 -22
- package/src/core/get-properties-by-class.js.map +1 -1
package/package.json
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
[columns]="columns"
|
|
8
8
|
[searchFieldsKey]="searchFieldsKey" >
|
|
9
9
|
|
|
10
|
+
<ng-template mcThTemplate="actions"></ng-template>
|
|
11
|
+
|
|
10
12
|
<ng-template mcTdTemplate="actions" let-row>
|
|
11
13
|
<mc-actions-column [item]="row" (onEdit)="onClickEdit($event)" (onRemove)="onClickRemove($event)"></mc-actions-column>
|
|
12
14
|
</ng-template>
|
|
@@ -2,7 +2,6 @@ import { CommonModule } from '@angular/common';
|
|
|
2
2
|
import { Component, inject, OnInit, viewChild } from '@angular/core';
|
|
3
3
|
import { MCOdataPage } from '@mckit/odata';
|
|
4
4
|
import { MenuItem } from 'primeng/api';
|
|
5
|
-
import { Observable, of } from 'rxjs';
|
|
6
5
|
import { ButtonModule } from 'primeng/button';
|
|
7
6
|
import { MCActionsColumn, MCTdTemplateDirective, MCThTemplateDirective } from '@mckit/table';
|
|
8
7
|
|
package/src/add-table/index.js
CHANGED
|
@@ -22,26 +22,31 @@ function addTable(_options) {
|
|
|
22
22
|
let classNameCamel = nameComponent;
|
|
23
23
|
// Convertir nombre de la clase CamelCase a kebab-case
|
|
24
24
|
let classNameKebab = classNameCamel.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
|
|
25
|
+
// Verificar si el primer caracter de classNameKebab es un guion ( - )
|
|
26
|
+
if (classNameKebab.charAt(0) === '-') {
|
|
27
|
+
classNameKebab = classNameKebab.substring(1);
|
|
28
|
+
}
|
|
25
29
|
// Convertir nombre de la clase CamelCase a snake_case
|
|
26
30
|
//let classNameSnake = classNameCamel.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1_$2').toLowerCase();
|
|
27
31
|
// Get properties by class
|
|
28
32
|
let classProperty = (0, get_properties_by_class_1.getPropertiesByClass)(tree, _options.name);
|
|
29
33
|
// Create HTML file
|
|
30
|
-
(0, create_file_with_template_1.createFileWithTemplate)(tree, __dirname, `${path}/${classNameKebab}.component.html`, '__class__.component.html.template', {
|
|
34
|
+
(0, create_file_with_template_1.createFileWithTemplate)(tree, __dirname, `${path}/${classNameKebab}/${classNameKebab}.component.html`, '__class__.component.html.template', {
|
|
31
35
|
'className': classNameKebab
|
|
32
36
|
});
|
|
33
37
|
// Create SCSS file
|
|
34
|
-
(0, create_file_with_template_1.createFileWithTemplate)(tree, __dirname, `${path}/${classNameKebab}.component.scss`, '__class__.component.scss.template', {
|
|
38
|
+
(0, create_file_with_template_1.createFileWithTemplate)(tree, __dirname, `${path}/${classNameKebab}/${classNameKebab}.component.scss`, '__class__.component.scss.template', {
|
|
35
39
|
'className': classNameKebab
|
|
36
40
|
});
|
|
37
41
|
// Generate content for columns variable
|
|
38
42
|
let columns = '';
|
|
39
43
|
classProperty.properties.forEach((property) => {
|
|
40
|
-
columns += `{ field: '${property}', title: '${property}' }
|
|
44
|
+
columns += `{ field: '${property}', title: '${property}' },
|
|
45
|
+
`;
|
|
41
46
|
});
|
|
42
47
|
columns += "{ field: 'actions', title: 'Actions' }";
|
|
43
48
|
// Create TS file
|
|
44
|
-
(0, create_file_with_template_1.createFileWithTemplate)(tree, __dirname, `${path}/${classNameKebab}.component.ts`, '__class__.component.ts.template', {
|
|
49
|
+
(0, create_file_with_template_1.createFileWithTemplate)(tree, __dirname, `${path}/${classNameKebab}/${classNameKebab}.component.ts`, '__class__.component.ts.template', {
|
|
45
50
|
'className': classNameKebab,
|
|
46
51
|
'classNameCamel': classNameCamel,
|
|
47
52
|
'columns': columns
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAUA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAUA,4BA4DC;AArED,qDAAiD;AACjD,iFAA2E;AAC3E,6EAAkF;AAOlF,SAAgB,QAAQ,CAAC,QAAuB;IAC9C,OAAO,CAAC,IAAU,EAAE,QAA0B,EAAE,EAAE;QAEhD,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC;QAED,oCAAoC;QACpC,IAAA,wBAAU,EAAC,+EAA+E,EAAE,QAAQ,CAAC,CAAC;QAEtG,sCAAsC;QACtC,IAAI,aAAa,GAAG,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClD,IAAI,aAAa,GAAG,aAAa,CAAC,GAAG,EAAE,CAAC;QACxC,IAAI,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEnC,sDAAsD;QACtD,IAAI,cAAc,GAAG,aAAc,CAAC;QACpC,sDAAsD;QACtD,IAAI,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,8BAA8B,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QACnG,sEAAsE;QACtE,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACrC,cAAc,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;QACD,sDAAsD;QACtD,qGAAqG;QAErG,0BAA0B;QAC1B,IAAI,aAAa,GAAc,IAAA,8CAAoB,EAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEzE,mBAAmB;QACnB,IAAA,kDAAsB,EAAC,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,IAAI,cAAc,IAAI,cAAc,iBAAiB,EAAE,mCAAmC,EAAE;YACzI,WAAW,EAAE,cAAc;SAC5B,CAAC,CAAC;QAEH,mBAAmB;QACnB,IAAA,kDAAsB,EAAC,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,IAAI,cAAc,IAAI,cAAc,iBAAiB,EAAE,mCAAmC,EAAE;YACzI,WAAW,EAAE,cAAc;SAC5B,CAAC,CAAC;QAEH,wCAAwC;QACxC,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC5C,OAAO,IAAI,aAAa,QAAQ,cAAc,QAAQ;SACnD,CAAC;QACN,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,wCAAwC,CAAC;QAEpD,iBAAiB;QACjB,IAAA,kDAAsB,EAAC,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,IAAI,cAAc,IAAI,cAAc,eAAe,EAAE,iCAAiC,EAAE;YACrI,WAAW,EAAE,cAAc;YAC3B,gBAAgB,EAAE,cAAc;YAChC,SAAS,EAAE,OAAO;SACnB,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Tree } from '@angular-devkit/schematics';
|
|
2
2
|
export interface ClassData {
|
|
3
3
|
name: string;
|
|
4
|
+
path: string;
|
|
4
5
|
properties: string[];
|
|
5
6
|
}
|
|
6
|
-
export declare function getPropertiesByClass(tree: Tree,
|
|
7
|
+
export declare function getPropertiesByClass(tree: Tree, className: string): ClassData;
|
|
@@ -2,29 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPropertiesByClass = getPropertiesByClass;
|
|
4
4
|
const ts = require("typescript");
|
|
5
|
-
function getPropertiesByClass(tree,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
function getPropertiesByClass(tree, className) {
|
|
6
|
+
let classFilePath;
|
|
7
|
+
let properties = [];
|
|
8
|
+
tree.visit((filePath) => {
|
|
9
|
+
if (!filePath.endsWith('.ts'))
|
|
10
|
+
return;
|
|
11
|
+
const file = tree.read(filePath);
|
|
12
|
+
if (!file)
|
|
13
|
+
return;
|
|
14
|
+
const fileContent = file.toString('utf-8');
|
|
15
|
+
const sourceFile = ts.createSourceFile(filePath, fileContent, ts.ScriptTarget.Latest, true);
|
|
16
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
17
|
+
var _a;
|
|
18
|
+
if (ts.isClassDeclaration(node) && ((_a = node.name) === null || _a === void 0 ? void 0 : _a.text) === className) {
|
|
19
|
+
classFilePath = filePath;
|
|
20
|
+
node.members.forEach((member) => {
|
|
21
|
+
if (ts.isPropertyDeclaration(member) && member.name) {
|
|
22
|
+
properties.push(member.name.getText());
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
24
27
|
});
|
|
25
|
-
if (
|
|
26
|
-
throw new Error(`No se encontró
|
|
28
|
+
if (classFilePath == undefined) {
|
|
29
|
+
throw new Error(`No se encontró la clase ${className} en ningún archivo.`);
|
|
27
30
|
}
|
|
28
|
-
return
|
|
31
|
+
return {
|
|
32
|
+
name: className,
|
|
33
|
+
path: classFilePath,
|
|
34
|
+
properties
|
|
35
|
+
};
|
|
29
36
|
}
|
|
30
37
|
//# sourceMappingURL=get-properties-by-class.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-properties-by-class.js","sourceRoot":"","sources":["get-properties-by-class.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"get-properties-by-class.js","sourceRoot":"","sources":["get-properties-by-class.ts"],"names":[],"mappings":";;AASA,oDAoCC;AA5CD,iCAAiC;AAQjC,SAAgB,oBAAoB,CAAC,IAAU,EAAE,SAAiB;IAE9D,IAAI,aAA+B,CAAC;IACpC,IAAI,UAAU,GAAa,EAAE,CAAC;IAE9B,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,EAAE;QACpB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO;QAEtC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI;YAAE,OAAO;QAElB,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAE5F,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE;;YACjC,IAAI,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI,MAAK,SAAS,EAAE,CAAC;gBAC/D,aAAa,GAAG,QAAQ,CAAC;gBAEzB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;oBAC5B,IAAI,EAAE,CAAC,qBAAqB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;wBAClD,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;oBAC3C,CAAC;gBACL,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,IAAG,aAAa,IAAI,SAAS,EAAC,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,2BAA2B,SAAS,qBAAqB,CAAC,CAAC;IAC/E,CAAC;IAED,OAAO;QACH,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,aAAa;QACnB,UAAU;KACb,CAAC;AACN,CAAC"}
|