drop down list from servicve
This commit is contained in:
parent
54a1796725
commit
e4f302fd62
dmp-frontend/src/app
|
@ -14,6 +14,7 @@ export class FieldBase<T>{
|
|||
description:string;
|
||||
attributes: Attribute;
|
||||
regex:string;
|
||||
url: any;
|
||||
|
||||
constructor(options: {
|
||||
value?: T,
|
||||
|
@ -27,7 +28,8 @@ export class FieldBase<T>{
|
|||
group?: string
|
||||
description?: string,
|
||||
attributes?: Attribute,
|
||||
regex?:string
|
||||
regex?:string,
|
||||
url?: any
|
||||
} = {}) {
|
||||
this.value = options.value;
|
||||
this.key = options.key || '';
|
||||
|
@ -41,5 +43,6 @@ export class FieldBase<T>{
|
|||
this.description = options.description || '';
|
||||
this.attributes = options.attributes || new Attribute();
|
||||
this.regex = options.regex || '';
|
||||
this.url = options.url || {"url":null, "fieldpath":null, "data":null};
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import { GroupBase } from '../form/dynamic-form-group/group-base';
|
|||
import { Attribute } from '../entities/model/attribute';
|
||||
import { Param } from '../entities/model/param';
|
||||
import { Section } from '../entities/model/section';
|
||||
import { RestBase } from '../services/rest-base';
|
||||
|
||||
@Injectable()
|
||||
export class dataModelBuilder {
|
||||
|
@ -17,6 +18,8 @@ export class dataModelBuilder {
|
|||
private dataModel: DataModel;
|
||||
private fields: FieldBase<any>[];
|
||||
|
||||
constructor(private restBase: RestBase) { }
|
||||
|
||||
public getDataModel(data) {
|
||||
|
||||
if (this.dataModel != null)
|
||||
|
@ -221,7 +224,34 @@ export class dataModelBuilder {
|
|||
|
||||
if (attr.sources) {
|
||||
newAttribute.sources.push(attr.sources.source);
|
||||
|
||||
if (attr.sources.source.url !== undefined) {
|
||||
|
||||
|
||||
|
||||
fields.find(x => x.key == newAttribute.id).url.url = attr.sources.source.url._value;
|
||||
|
||||
this.restBase.proxy_get(attr.sources.source.url._value).subscribe((data) => {
|
||||
|
||||
|
||||
|
||||
console.log(data);
|
||||
newAttribute.sources.forEach(src => {
|
||||
src.params = new Array();
|
||||
data.data.forEach(data => {
|
||||
let prm = new Param();
|
||||
prm.key = data.id;
|
||||
prm.value = data.attributes.name;
|
||||
src.params.push(prm);
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
} else {
|
||||
newAttribute.sources.forEach(src => {
|
||||
|
||||
src.params = new Array();
|
||||
for (var i = 0, len = attr.sources.source.value.length; i < len; i++) {
|
||||
let prm = new Param();
|
||||
|
@ -230,9 +260,12 @@ export class dataModelBuilder {
|
|||
src.params.push(prm);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (attr.validation.rule.length)
|
||||
for (var i = 0, len = attr.validation.rule.length; i < len; i++) {
|
||||
|
@ -273,6 +306,7 @@ export class dataModelBuilder {
|
|||
}
|
||||
|
||||
attribute.push(newAttribute);
|
||||
//if (fields.find(x => x.key == newAttribute.id).url.url == null)
|
||||
fields.find(x => x.key == newAttribute.id).attributes.sources = newAttribute.sources;
|
||||
fields.find(x => x.key == newAttribute.id).attributes.validation = newAttribute.validation;
|
||||
});
|
||||
|
@ -304,4 +338,11 @@ export class dataModelBuilder {
|
|||
return sects;
|
||||
}
|
||||
|
||||
getValuesFromEestore(url: string, fieldPath: string) {
|
||||
this.restBase.proxy_get(url).subscribe((data) => {
|
||||
data.data.forEach(data => {
|
||||
console.log(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue