listAttrAccessor get implemented
parent
7903855fec
commit
9d39bab8ca
|
|
@ -46,6 +46,39 @@ function simpleAttrAccessor(attrPred: any) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function listAttrAccessor(attrPred: any) {
|
||||||
|
let { attribKey, pred, lens } = attrPred;
|
||||||
|
// let def = (value: any) => ({ _: value, $: { [attribKey]: attribVal } });
|
||||||
|
return {
|
||||||
|
get: (li: any) => {
|
||||||
|
let def: any = [];
|
||||||
|
let morphProps = _.get<any>(li, lens, def);
|
||||||
|
let morphExps = _.filter<any>(morphProps, (m) => {
|
||||||
|
return pred(m);
|
||||||
|
});
|
||||||
|
let mEs = morphExps.map((me) => {
|
||||||
|
let value = _.get<any>(me, '_', '');
|
||||||
|
let key = _.get<any>(me, '$.' + attribKey, '');
|
||||||
|
return { value, key };
|
||||||
|
});
|
||||||
|
return mEs;
|
||||||
|
},
|
||||||
|
// set: (li: any, value: string) => {
|
||||||
|
// let lexItem = _.cloneDeep(li);
|
||||||
|
// let allProps = _.get<any>(lexItem, lens, []);
|
||||||
|
// if (allProps.length > 0) {
|
||||||
|
// let prop = _.filter<any>(allProps, (m) => {
|
||||||
|
// return pred(m);
|
||||||
|
// });
|
||||||
|
// _.set(prop, '[0]._', value);
|
||||||
|
// } else {
|
||||||
|
// _.set(lexItem, lens, def(value));
|
||||||
|
// }
|
||||||
|
// return lexItem;
|
||||||
|
// }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// function attribListAccessor(lens: string, attrib: string, pred: any) {
|
// function attribListAccessor(lens: string, attrib: string, pred: any) {
|
||||||
// let def = (value: any) => ({ _: value, $: { form: attrib } });
|
// let def = (value: any) => ({ _: value, $: { form: attrib } });
|
||||||
// return {
|
// return {
|
||||||
|
|
@ -90,6 +123,13 @@ const mcParams = attrPredGen(
|
||||||
_.isEqual
|
_.isEqual
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const meParams = attrPredGen(
|
||||||
|
'lexprops[0].morphology[0].morph',
|
||||||
|
'form',
|
||||||
|
'morphclass',
|
||||||
|
_.negate(_.isEqual)
|
||||||
|
);
|
||||||
|
|
||||||
const frParams = attrPredGen(
|
const frParams = attrPredGen(
|
||||||
'syntacticprops[0].property',
|
'syntacticprops[0].property',
|
||||||
'id',
|
'id',
|
||||||
|
|
@ -118,20 +158,21 @@ const fieldMetaMap = {
|
||||||
},
|
},
|
||||||
morphexceptions: {
|
morphexceptions: {
|
||||||
type: 'list',
|
type: 'list',
|
||||||
get: (li: any) => {
|
...listAttrAccessor(meParams)
|
||||||
let lens = 'lexprops[0].morphology[0].morph';
|
// get: (li: any) => {
|
||||||
let def: any = [];
|
// let lens = 'lexprops[0].morphology[0].morph';
|
||||||
let morphProps = _.get<any>(li, lens, def);
|
// let def: any = [];
|
||||||
let morphExps = _.filter<any>(morphProps, (m) => {
|
// let morphProps = _.get<any>(li, lens, def);
|
||||||
return _.get<any>(m, '$.form', '') !== 'morphclass';
|
// let morphExps = _.filter<any>(morphProps, (m) => {
|
||||||
});
|
// return _.get<any>(m, '$.form', '') !== 'morphclass';
|
||||||
let mEs = morphExps.map((me) => {
|
// });
|
||||||
let value = _.get<any>(me, '_', '');
|
// let mEs = morphExps.map((me) => {
|
||||||
let key = _.get<any>(me, '$.form', '');
|
// let value = _.get<any>(me, '_', '');
|
||||||
return { value, key };
|
// let key = _.get<any>(me, '$.form', '');
|
||||||
});
|
// return { value, key };
|
||||||
return mEs;
|
// });
|
||||||
}
|
// return mEs;
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
stats: { type: 'text', ...simpleAccessor('stats[0].property[0]._'), },
|
stats: { type: 'text', ...simpleAccessor('stats[0].property[0]._'), },
|
||||||
lang: {
|
lang: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue