Skip to content

Commit 0167092

Browse files
committed
fix: COM-313
1 parent 403a63e commit 0167092

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@ec.components/ui": "*",
5757
"ace-builds": "^1.4.3",
5858
"core-js": "^2.6.5",
59-
"ec.sdk": "^0.21.13",
59+
"ec.sdk": "^0.21.16",
6060
"googlemaps": "^1.12.0",
6161
"lerna": "^3.13.1",
6262
"medium-editor": "^5.23.2",

packages/data/src/lib/crud/crud.component.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { EntryPopComponent } from '../entry-pop/entry-pop.component';
1414
import { WithLoader } from '@ec.components/ui';
1515
import { Notification, WithNotifications, SymbolService } from '@ec.components/ui';
1616
import { ModelConfigService } from '../model-config/model-config.service';
17+
import EntryResource from 'ec.sdk/lib/resources/publicAPI/EntryResource';
1718

1819
/** The CrudComponent takes at least a model name to render an entry list with create/edit/delete functionality out of the box.
1920
* ```html
@@ -25,13 +26,13 @@ import { ModelConfigService } from '../model-config/model-config.service';
2526
selector: 'ec-crud',
2627
templateUrl: './crud.component.html',
2728
})
28-
export class CrudComponent<T> implements OnInit, WithLoader, WithNotifications {
29+
export class CrudComponent implements OnInit, WithLoader, WithNotifications {
2930
/** The model that should be crud'ed. */
3031
@Input() model: string;
3132
/** CrudConfig for customization of the crud's UI.*/
32-
@Input() config: CrudConfig<T> = {};
33+
@Input() config: CrudConfig<EntryResource> = {};
3334
/** The selection that should be used */
34-
@Input() selection: Selection<T>;
35+
@Input() selection: Selection<EntryResource>;
3536
/** The EntryList inside the template. */
3637
@ViewChild(EntryListComponent, { static: false }) list: EntryListComponent;
3738
/** The Pop inside the template. */
@@ -71,6 +72,12 @@ export class CrudComponent<T> implements OnInit, WithLoader, WithNotifications {
7172
this.config.methods = methods;
7273
this.cdr.markForCheck();
7374
});
75+
this.modelConfig.generateConfig(this.model).then(config => {
76+
this.config = {
77+
...config,
78+
...this.config
79+
};
80+
});
7481
}
7582

7683
/** Returns true if the given method is part of the methods array (or if there is no methods array) */

packages/data/src/lib/entry-list/entry-list.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ResourceService } from '../resource-config/resource.service';
1010
import { ResourceListComponent } from '../resource-list/resource-list.component';
1111
import { SdkService } from '../sdk/sdk.service';
1212
import { EntryList } from './entry-list';
13+
import { CrudConfig } from '../crud/crud-config.interface';
1314

1415
/** The EntryListComponent is a thin holder of an EntryList instance. It extends the ListComponent
1516
* <example-url>https://components.entrecode.de/entries/entry-list?e=1</example-url>
@@ -72,7 +73,7 @@ export class EntryListComponent extends ResourceListComponent implements OnDestr
7273
});
7374
return this.modelConfig
7475
.generateConfig(this.model, (this.config || {}).fields)
75-
.then((config: ListConfig<EntryResource>) => {
76+
.then((config: CrudConfig<EntryResource>) => {
7677
this.config = Object.assign(this.config || {}, config);
7778
this.initFilter();
7879
return new EntryList(this.model, this.config, this.sdk);

packages/data/src/lib/model-config/model-config.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,10 @@ export class ModelConfigService extends Config {
216216
* or just specific components. */
217217
async generateConfig(model: string, customFieldConfig?: FieldConfig): Promise<CrudConfig<EntryResource>> {
218218
const lightModel = await this.getLightModel(model);
219+
const { singularLabel } = lightModel.config;
219220
// first step: merge global model config with default entry config
220221
const modelConfig = Object.assign(this.get(model) || {}, {
222+
singularLabel,
221223
identifier: 'id',
222224
identifierPattern: /^[0-9A-Za-z-_]{7,14}$/, // shortID pattern
223225
label: '_entryTitle',

src/app/crud/crud-demo.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class CrudDemoComponent {
1212
defaultFilter: 'name',
1313
disableHeader: false,
1414
develop: true,
15-
singularLabel: 'Muffin',
15+
/* singularLabel: 'Muffin', */ // now handled by publicConfig
1616
createLabel: 'Neuer Muffin',
1717
size: 15,
1818
levels: 2,

0 commit comments

Comments
 (0)