本文整理汇总了TypeScript中jb-core.jb.writeValue方法的典型用法代码示例。如果您正苦于以下问题:TypeScript jb.writeValue方法的具体用法?TypeScript jb.writeValue怎么用?TypeScript jb.writeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jb-core.jb
的用法示例。
在下文中一共展示了jb.writeValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: addProperty
addProperty(path) {
var parent = profileFromPath(parentPath(path));
if (this.paramType(path) == 'data')
return jb.writeValue(profileRefFromPath(path),'');
var param = this.paramDef(path);
jb.writeValue(profileRefFromPath(path),param.defaultValue || {$: ''});
}
示例2: addArrayItem
addArrayItem(path,args) {
var val = profileFromPath(path);
var toAdd = args.toAdd || {$:''};
if (Array.isArray(val)) {
val.push(toAdd);
return { newPath: path + '~' + (val.length-1) }
}
else if (!val) {
jb.writeValue(profileRefFromPath(path),toAdd);
} else {
jb.writeValue(profileRefFromPath(path),[val].concat(toAdd));
return { newPath: path + '~1' }
}
}
示例3: makeLocal
makeLocal(path) {
var compName = this.compName(path);
var comp = compName && getComp(compName);
if (!compName || !comp || typeof comp.impl != 'object') return;
var res = JSON.stringify(comp.impl, (key, val) => typeof val === 'function' ? ''+val : val , 4);
var profile = profileFromPath(path);
// inject conditional param values
jb_compParams(comp).forEach(p=>{
var pUsage = '%$'+p.id+'%';
var pVal = '' + (profile[p.id] || p.defaultValue || '');
res = res.replace(new RegExp('{\\?(.*?)\\?}','g'),(match,condition_exp)=>{ // conditional exp
if (condition_exp.indexOf(pUsage) != -1)
return pVal ? condition_exp : '';
return match;
});
});
// inject param values
jb_compParams(comp).forEach(p=>{
var pVal = '' + (profile[p.id] || p.defaultValue || ''); // only primitives
res = res.replace(new RegExp(`%\\$${p.id}%`,'g') , pVal);
});
jb.writeValue(profileRefFromPath(path),evalProfile(res));
}
示例4: wrapWithArray
wrapWithArray(path) {
var val = profileFromPath(path);
if (val && !Array.isArray(val)) {
jb.writeValue(profileRefFromPath(path),[val]);
return { newPath: path + '~0' }
}
}
示例5: wrap
wrap(path,args) {
var comp = getComp(args.compName);
var firstParam = jb_compParams(comp).filter(p=>p.composite)[0];
if (firstParam) {
var result = jb.extend({ $: args.compName }, jb.obj(firstParam.id, [profileFromPath(path)]));
jb.writeValue(profileRefFromPath(path),result);
}
}
示例6: closest
impl: (ctx,pathRef) => {
var path = jb.val(pathRef);
var closest_path = closest(path);
if (path && path != closest_path) {
jb.writeValue(pathRef,closest_path);
// jb_ui.apply(ctx);
}
}
示例7: setComp
setComp(path,args) {
var compName = args.comp;
var comp = compName && getComp(compName);
if (!compName || !comp) return;
var result = { $: compName };
var existing = profileFromPath(path);
jb_compParams(comp).forEach(p=>{
if (p.composite)
result[p.id] = [];
if (existing && existing[p.id])
result[p.id] = existing[p.id];
if (p.defaultValue && typeof p.defaultValue != 'object')
result[p.id] = p.defaultValue;
if (p.defaultValue && typeof p.defaultValue == 'object' && (p.forceDefaultCreation || Array.isArray(p.defaultValue)))
result[p.id] = JSON.parse(JSON.stringify(p.defaultValue));
})
jb.writeValue(profileRefFromPath(path),result);
}
示例8: wrapWithGroup
wrapWithGroup(path) {
var result = { $: 'group', controls: [ profileFromPath(path) ] };
jb.writeValue(profileRefFromPath(path),result);
}
示例9: writeValue
writeValue(path,args) {
jb.writeValue(profileRefFromPath(path),args.value);
}
示例10:
.subscribe(e=>
jb.writeValue(data_ref,true)