[CORD-1630] Adding model verbose_name and description
Change-Id: If50b38f0328f59852c6ac0a925fb724fdf86782e
diff --git a/src/app/views/crud/crud.ts b/src/app/views/crud/crud.ts
index 325790f..bcac6a9 100644
--- a/src/app/views/crud/crud.ts
+++ b/src/app/views/crud/crud.ts
@@ -22,7 +22,7 @@
import * as _ from 'lodash';
import {IXosResourceService} from '../../datasources/rest/model.rest';
import {IStoreHelpersService} from '../../datasources/helpers/store.helpers';
-import {IXosModelDiscovererService} from '../../datasources/helpers/model-discoverer.service';
+import {IXosModelDiscovererService, IXosModel} from '../../datasources/helpers/model-discoverer.service';
import './crud.scss';
import {IXosCrudRelationService} from './crud.relations.service';
import {IXosDebugService, IXosDebugStatus} from '../../core/debug/debug.service';
@@ -57,9 +57,12 @@
public formCfg: any;
public baseUrl: string;
public list: boolean;
- public title: string;
+ public modelName: string;
+ public pluralTitle: string;
+ public singularTitle: string;
public tableData: any[];
- public model: any;
+ public model: any; // holds the real model
+ public modelDef: IXosModel;
public related: {manytoone: IXosModelRelation[], onetomany: IXosModelRelation[]} = {
manytoone: [],
onetomany: []
@@ -87,16 +90,18 @@
this.$log.info('[XosCrud] Setup', $state.current.data);
this.data = this.$state.current.data;
- this.model = this.XosModelDiscovererService.get(this.data.model);
- this.title = this.ConfigHelpers.pluralize(this.data.model);
+ this.modelDef = this.XosModelDiscovererService.get(this.data.model);
+ this.modelName = this.modelDef.verbose_name ? this.modelDef.verbose_name : this.modelDef.name;
+ this.pluralTitle = this.ConfigHelpers.pluralize(this.modelName);
+ this.singularTitle = this.ConfigHelpers.pluralize(this.modelName, 1);
this.list = true;
// TODO get the proper URL from model discoverer
- this.baseUrl = '#/' + this.model.clientUrl.replace(':id?', '');
+ this.baseUrl = '#/' + this.modelDef.clientUrl.replace(':id?', '');
- this.tableCfg = this.model.tableCfg;
- this.formCfg = this.model.formCfg;
+ this.tableCfg = this.modelDef.tableCfg;
+ this.formCfg = this.modelDef.formCfg;
this.debugTab = this.XosDebug.status.modelsTab;
this.$scope.$on('xos.debug.status', (e, status: IXosDebugStatus) => {
@@ -109,7 +114,6 @@
(event) => {
// NOTE Observable mess with $digest cycles, we need to schedule the expression later
$scope.$evalAsync(() => {
- this.title = this.ConfigHelpers.pluralize(this.data.model, event.length);
this.tableData = event;
// if it is a detail page for an existing model