mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-09-06 10:26:22 +08:00
Recordthread: Allow declaring dynamic labels for fields
This commit is contained in:
parent
d6a7496395
commit
279d23968e
6 changed files with 24 additions and 3 deletions
|
@ -30,6 +30,8 @@ import {FieldLogicMap} from '../actions/field-logic-action.model';
|
|||
export interface ViewFieldDefinition {
|
||||
name?: string;
|
||||
label?: string;
|
||||
labelKey?: string;
|
||||
dynamicLabelKey?: string;
|
||||
link?: boolean;
|
||||
type?: string;
|
||||
display?: string;
|
||||
|
|
|
@ -56,6 +56,7 @@ export interface FieldDefinition {
|
|||
name?: string;
|
||||
type?: string; // label key to use
|
||||
vname?: string; // original label
|
||||
dynamicLabelKey?: string;
|
||||
options?: string;
|
||||
reportable?: boolean;
|
||||
required?: boolean;
|
||||
|
@ -94,6 +95,8 @@ export interface FieldDefinition {
|
|||
modes?: ViewMode[];
|
||||
relationship?: string;
|
||||
relationshipMetadata?: RelationshipMetadata
|
||||
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface RelationshipMetadata {
|
||||
|
@ -115,6 +118,8 @@ export interface FieldMetadata {
|
|||
format?: boolean;
|
||||
target?: string;
|
||||
link?: boolean;
|
||||
linkRoute?: string;
|
||||
linkAsyncAction?: string;
|
||||
rows?: number;
|
||||
cols?: number;
|
||||
digits?: number;
|
||||
|
@ -124,6 +129,8 @@ export interface FieldMetadata {
|
|||
extraOptions?: Option[];
|
||||
onClick?: FieldClickCallback;
|
||||
tinymce?: any;
|
||||
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface FieldAttributeMap {
|
||||
|
@ -153,6 +160,7 @@ export interface Field {
|
|||
name?: string;
|
||||
label?: string;
|
||||
labelKey?: string;
|
||||
dynamicLabelKey?: string;
|
||||
parentKey?: string;
|
||||
attributes?: FieldAttributeMap;
|
||||
items?: Record[];
|
||||
|
@ -179,6 +187,7 @@ export class BaseField implements Field {
|
|||
name?: string;
|
||||
label?: string;
|
||||
labelKey?: string;
|
||||
dynamicLabelKey?: string;
|
||||
display?: string;
|
||||
defaultDisplay?: string;
|
||||
source?: 'field' | 'attribute';
|
||||
|
|
|
@ -64,6 +64,11 @@
|
|||
[labelKey]="field.labelKey"
|
||||
[ngClass]="getLabelClass(col)">
|
||||
</scrm-label>
|
||||
|
||||
<scrm-dynamic-label *ngIf="field.dynamicLabelKey"
|
||||
[labelKey]="field.dynamicLabelKey"
|
||||
[fields]="record.fields">
|
||||
</scrm-dynamic-label>
|
||||
</div>
|
||||
|
||||
</ng-container>
|
||||
|
@ -74,6 +79,7 @@
|
|||
<scrm-field [field]="field"
|
||||
[klass]="getFieldClass(col)"
|
||||
[mode]="mode"
|
||||
[record]="record"
|
||||
[type]="field.type">
|
||||
</scrm-field>
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ export class RecordFlexboxComponent implements OnInit, OnDestroy {
|
|||
return null;
|
||||
}
|
||||
|
||||
return record.fields[field.name] || null;
|
||||
return record.fields[field.name] ?? null;
|
||||
}
|
||||
|
||||
getFieldClass(col: FieldFlexboxCol): { [key: string]: any } {
|
||||
|
|
|
@ -31,6 +31,7 @@ import {ButtonModule} from '../button/button.module';
|
|||
import {LabelModule} from '../label/label.module';
|
||||
import {RecordFlexboxComponent} from './record-flexbox.component';
|
||||
import {ActionGroupMenuModule} from '../action-group-menu/action-group-menu.module';
|
||||
import {DynamicLabelModule} from '../dynamic-label/dynamic-label.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [RecordFlexboxComponent],
|
||||
|
@ -42,7 +43,8 @@ import {ActionGroupMenuModule} from '../action-group-menu/action-group-menu.modu
|
|||
ButtonModule,
|
||||
FieldModule,
|
||||
LabelModule,
|
||||
ActionGroupMenuModule
|
||||
ActionGroupMenuModule,
|
||||
DynamicLabelModule
|
||||
]
|
||||
})
|
||||
export class RecordFlexboxModule {
|
||||
|
|
|
@ -40,6 +40,7 @@ import {
|
|||
import {AsyncValidatorFn, FormArray, FormControl, ValidatorFn} from '@angular/forms';
|
||||
import {LanguageStore} from '../../../store/language/language.store';
|
||||
import get from 'lodash-es/get';
|
||||
import {merge} from 'lodash-es';
|
||||
|
||||
|
||||
@Injectable({
|
||||
|
@ -165,7 +166,7 @@ export class FieldBuilder {
|
|||
|
||||
const formattedValue = this.typeFormatter.toUserFormat(viewField.type, value, {mode: 'edit'});
|
||||
|
||||
const metadata = viewField.metadata || definition.metadata || {};
|
||||
const metadata = merge(definition?.metadata ?? {}, viewField?.metadata ?? {});
|
||||
|
||||
if (viewField.link) {
|
||||
metadata.link = viewField.link;
|
||||
|
@ -181,6 +182,7 @@ export class FieldBuilder {
|
|||
field.metadata = metadata;
|
||||
field.definition = definition;
|
||||
field.labelKey = viewField.label || definition.vname || '';
|
||||
field.dynamicLabelKey = viewField.dynamicLabelKey || definition.dynamicLabelKey || '';
|
||||
|
||||
field.validators = validators;
|
||||
field.asyncValidators = asyncValidators;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue