sonamu 0.1.4 → 0.1.5
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/dist/syncer/syncer.d.ts.map +1 -1
- package/dist/syncer/syncer.js.map +1 -1
- package/dist/templates/service.template.d.ts.map +1 -1
- package/dist/templates/service.template.js +4 -4
- package/dist/templates/service.template.js.map +1 -1
- package/dist/templates/view_enums_dropdown.template.d.ts +2 -2
- package/dist/templates/view_enums_dropdown.template.d.ts.map +1 -1
- package/dist/templates/view_enums_dropdown.template.js +14 -13
- package/dist/templates/view_enums_dropdown.template.js.map +1 -1
- package/dist/templates/view_enums_select.template.d.ts +1 -1
- package/dist/templates/view_enums_select.template.d.ts.map +1 -1
- package/dist/templates/view_enums_select.template.js +4 -4
- package/dist/templates/view_enums_select.template.js.map +1 -1
- package/dist/templates/view_form.template.d.ts +1 -4
- package/dist/templates/view_form.template.d.ts.map +1 -1
- package/dist/templates/view_form.template.js +14 -8
- package/dist/templates/view_form.template.js.map +1 -1
- package/dist/templates/view_list.template.d.ts +1 -4
- package/dist/templates/view_list.template.d.ts.map +1 -1
- package/dist/templates/view_list.template.js +17 -20
- package/dist/templates/view_list.template.js.map +1 -1
- package/dist/types/types.d.ts +0 -15
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +0 -3
- package/dist/types/types.js.map +1 -1
- package/package.json +1 -1
- package/src/shared/web.shared.ts.txt +21 -9
- package/src/syncer/syncer.ts +4 -1
- package/src/templates/service.template.ts +6 -4
- package/src/templates/view_enums_dropdown.template.ts +12 -17
- package/src/templates/view_enums_select.template.ts +4 -8
- package/src/templates/view_form.template.ts +16 -10
- package/src/templates/view_list.template.ts +16 -23
- package/src/types/types.ts +0 -3
|
@@ -6,6 +6,7 @@ import { EntityManager, EntityNamesRecord } from "../entity/entity-manager";
|
|
|
6
6
|
import { isEnumProp, isRelationProp, RelationProp } from "../types/types";
|
|
7
7
|
import { RenderedTemplate } from "../syncer/syncer";
|
|
8
8
|
import { Template } from "./base-template";
|
|
9
|
+
|
|
9
10
|
export class Template__view_list extends Template {
|
|
10
11
|
constructor() {
|
|
11
12
|
super("view_list");
|
|
@@ -55,20 +56,17 @@ export class Template__view_list extends Template {
|
|
|
55
56
|
}<img src={${colName}} />}</>`;
|
|
56
57
|
case "string-datetime":
|
|
57
58
|
if (col.nullable) {
|
|
58
|
-
return `<span className="text-tiny">{${colName} === null ? '-' :
|
|
59
|
+
return `<span className="text-tiny">{${colName} === null ? '-' : dateF(${colName})}</span>`;
|
|
59
60
|
} else {
|
|
60
|
-
return `<span className="text-tiny">{
|
|
61
|
+
return `<span className="text-tiny">{dateF(${colName})}</span>`;
|
|
61
62
|
}
|
|
62
63
|
case "boolean":
|
|
63
64
|
return `<>{${colName} ? <Label color='green' circular>O</Label> : <Label color='grey' circular>X</Label> }</>`;
|
|
64
65
|
case "enums":
|
|
65
|
-
const {
|
|
66
|
-
|
|
67
|
-
col.
|
|
68
|
-
|
|
69
|
-
return `<>{${col.nullable ? `${colName} && ` : ""}${
|
|
70
|
-
targetMDNames.constant
|
|
71
|
-
}.${name}[${colName}].ko}</>`;
|
|
66
|
+
const { id: enumId } = getEnumInfoFromColName(entityId, col.name);
|
|
67
|
+
return `<>{${
|
|
68
|
+
col.nullable ? `${colName} && ` : ""
|
|
69
|
+
}${enumId}Label[${colName}]}</>`;
|
|
72
70
|
case "array-images":
|
|
73
71
|
return `<>{ ${colName}.map(r => ${
|
|
74
72
|
col.nullable ? `r && ` : ""
|
|
@@ -110,13 +108,11 @@ export class Template__view_list extends Template {
|
|
|
110
108
|
names: EntityNamesRecord
|
|
111
109
|
): (string | null)[] {
|
|
112
110
|
if (col.renderType === "enums") {
|
|
113
|
-
const { modulePath,
|
|
111
|
+
const { modulePath, id: enumId } = getEnumInfoFromColName(
|
|
114
112
|
names.capital,
|
|
115
113
|
col.name
|
|
116
114
|
);
|
|
117
|
-
return [
|
|
118
|
-
`import { ${targetMDNames.constant} } from 'src/services/${modulePath}';`,
|
|
119
|
-
];
|
|
115
|
+
return [`import { ${enumId}Label } from 'src/services/${modulePath}';`];
|
|
120
116
|
} else if (col.renderType === "object") {
|
|
121
117
|
try {
|
|
122
118
|
const relProp = getRelationPropFromColName(entityId, col.name);
|
|
@@ -246,14 +242,16 @@ export class Template__view_list extends Template {
|
|
|
246
242
|
listParamsNode: RenderingNode
|
|
247
243
|
) {
|
|
248
244
|
const names = EntityManager.getNamesFromId(entityId);
|
|
245
|
+
const entity = EntityManager.get(entityId);
|
|
249
246
|
|
|
250
247
|
// 실제 리스트 컬럼
|
|
251
248
|
const columns = (columnsNode.children as RenderingNode[])
|
|
252
249
|
.filter((col) => col.name !== "id")
|
|
253
250
|
.map((col) => {
|
|
251
|
+
const propCandidate = entity.props.find((p) => p.name === col.name);
|
|
254
252
|
return {
|
|
255
253
|
name: col.name,
|
|
256
|
-
label: col.label,
|
|
254
|
+
label: propCandidate?.desc ?? col.label,
|
|
257
255
|
tc: `(row) => ${this.renderColumn(entityId, col, names)}`,
|
|
258
256
|
};
|
|
259
257
|
});
|
|
@@ -277,24 +275,21 @@ export class Template__view_list extends Template {
|
|
|
277
275
|
let key: TemplateKey;
|
|
278
276
|
let targetMdId = entityId;
|
|
279
277
|
let enumId: string | undefined;
|
|
280
|
-
let idConstant: string | undefined;
|
|
281
278
|
|
|
282
279
|
if (col.renderType === "enums") {
|
|
283
280
|
if (col.name === "search") {
|
|
284
281
|
key = "view_enums_dropdown";
|
|
285
282
|
enumId = `${names.capital}SearchField`;
|
|
286
283
|
targetMdId = names.capital;
|
|
287
|
-
idConstant = "SEARCH_FIELD";
|
|
288
284
|
} else {
|
|
289
285
|
key = "view_enums_select";
|
|
290
286
|
try {
|
|
291
|
-
const { targetMDNames, id
|
|
287
|
+
const { targetMDNames, id } = getEnumInfoFromColName(
|
|
292
288
|
entityId,
|
|
293
289
|
col.name
|
|
294
290
|
);
|
|
295
291
|
targetMdId = targetMDNames.capital;
|
|
296
292
|
enumId = id;
|
|
297
|
-
idConstant = name;
|
|
298
293
|
} catch {
|
|
299
294
|
continue;
|
|
300
295
|
}
|
|
@@ -317,7 +312,6 @@ export class Template__view_list extends Template {
|
|
|
317
312
|
options: {
|
|
318
313
|
entityId: targetMdId,
|
|
319
314
|
enumId,
|
|
320
|
-
idConstant,
|
|
321
315
|
},
|
|
322
316
|
});
|
|
323
317
|
}
|
|
@@ -362,7 +356,7 @@ import {
|
|
|
362
356
|
} from 'semantic-ui-react';
|
|
363
357
|
import classNames from 'classnames';
|
|
364
358
|
import { DateTime } from "luxon";
|
|
365
|
-
import { DelButton, EditButton, AppBreadcrumbs, AddButton, useSelection, useListParams, SonamuCol, numF } from '@sonamu-kit/react-sui';
|
|
359
|
+
import { DelButton, EditButton, AppBreadcrumbs, AddButton, useSelection, useListParams, SonamuCol, numF, dateF, datetimeF } from '@sonamu-kit/react-sui';
|
|
366
360
|
|
|
367
361
|
import { ${names.capital}SubsetA } from "src/services/${names.fs}/${
|
|
368
362
|
names.fs
|
|
@@ -391,11 +385,10 @@ export default function ${names.capital}List({}: ${names.capital}ListProps) {
|
|
|
391
385
|
});
|
|
392
386
|
|
|
393
387
|
// 리스트 쿼리
|
|
394
|
-
const { data, mutate, error } = ${names.capital}Service.use${
|
|
388
|
+
const { data, mutate, error, isLoading } = ${names.capital}Service.use${
|
|
395
389
|
names.capitalPlural
|
|
396
390
|
}('A', listParams);
|
|
397
391
|
const { rows, total } = data ?? {};
|
|
398
|
-
const isLoading = !error && !data;
|
|
399
392
|
|
|
400
393
|
// 삭제
|
|
401
394
|
const confirmDel = (ids: number[]) => {
|
|
@@ -424,7 +417,7 @@ export default function ${names.capital}List({}: ${names.capital}ListProps) {
|
|
|
424
417
|
// 현재 경로와 타이틀
|
|
425
418
|
const PAGE = {
|
|
426
419
|
route: '/admin/${names.fsPlural}',
|
|
427
|
-
title: '${names.capital}',
|
|
420
|
+
title: '${entity.title ?? names.capital}',
|
|
428
421
|
};
|
|
429
422
|
|
|
430
423
|
// 선택
|
package/src/types/types.ts
CHANGED
|
@@ -663,17 +663,14 @@ export const TemplateOptions = z.object({
|
|
|
663
663
|
view_enums_select: z.object({
|
|
664
664
|
entityId: z.string(),
|
|
665
665
|
enumId: z.string(),
|
|
666
|
-
idConstant: z.string(),
|
|
667
666
|
}),
|
|
668
667
|
view_enums_dropdown: z.object({
|
|
669
668
|
entityId: z.string(),
|
|
670
669
|
enumId: z.string(),
|
|
671
|
-
idConstant: z.string(),
|
|
672
670
|
}),
|
|
673
671
|
view_enums_buttonset: z.object({
|
|
674
672
|
entityId: z.string(),
|
|
675
673
|
enumId: z.string(),
|
|
676
|
-
idConstant: z.string(),
|
|
677
674
|
}),
|
|
678
675
|
});
|
|
679
676
|
export type TemplateOptions = z.infer<typeof TemplateOptions>;
|