Small tweeks to foreignkey type
This commit is contained in:
@@ -79,7 +79,7 @@ export class ForeignkeyTypeComponent extends FieldType<FieldTypeConfig> implemen
|
|||||||
public foreignLabel: string = ""
|
public foreignLabel: string = ""
|
||||||
public foreignResource : string = "";
|
public foreignResource : string = "";
|
||||||
public foreignSchema : string = "";
|
public foreignSchema : string = "";
|
||||||
public displayedFields = [];
|
public displayedFields: string[] = [];
|
||||||
public errorMsg: string = "";
|
public errorMsg: string = "";
|
||||||
|
|
||||||
constructor(private crudService: CrudService,
|
constructor(private crudService: CrudService,
|
||||||
@@ -90,19 +90,15 @@ export class ForeignkeyTypeComponent extends FieldType<FieldTypeConfig> implemen
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
typeaheadLoading: boolean = false;
|
|
||||||
dataSource: Observable<any> = new Observable();
|
|
||||||
|
|
||||||
formatter = (foreignModel: any) => foreignModel.label;
|
formatter = (foreignModel: any) => foreignModel.label;
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.foreignResource = this.field.foreignKey.reference.resource;
|
const reference: {resource: string, schema: string, displayedFields: string[] } = this.field.foreignKey.reference;
|
||||||
// @ts-ignore
|
this.foreignResource = reference.resource;
|
||||||
this.foreignSchema = this.field.foreignKey.reference.schema;
|
this.foreignSchema = reference.schema;
|
||||||
// @ts-ignore
|
this.displayedFields = reference.displayedFields;
|
||||||
this.displayedFields = this.field.foreignKey.reference.displayedFields;
|
|
||||||
|
|
||||||
|
|
||||||
this.formControl.valueChanges.pipe(
|
this.formControl.valueChanges.pipe(
|
||||||
@@ -196,14 +192,14 @@ export class ForeignkeyTypeComponent extends FieldType<FieldTypeConfig> implemen
|
|||||||
{
|
{
|
||||||
for (let i in form.fieldGroup) {
|
for (let i in form.fieldGroup) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
let f = form["fieldGroup"]![i]
|
let f = form["fieldGroup"][i]
|
||||||
// @ts-ignore
|
|
||||||
if (this.displayedFields.indexOf(f.key) == -1) {
|
if (this.displayedFields.indexOf(f.key) == -1) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
delete form["fieldGroup"]![i]
|
delete form["fieldGroup"][i]
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore
|
f.props.disabled = true;
|
||||||
form["fieldGroup"]![i].props.disabled = true
|
f.props.readonly = true;
|
||||||
|
f.props.hideRequiredMarker = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete form.props
|
delete form.props
|
||||||
|
|||||||
Reference in New Issue
Block a user