SimpleChatTC:ObjPropsEdit: Obj within Obj aware fRefiner
Use same to set a placeholder for Authorization entry in headers
This commit is contained in:
parent
f874c69983
commit
3e0cf2a2df
|
|
@ -1112,8 +1112,12 @@ class Me {
|
||||||
* @param {HTMLDivElement} elDiv
|
* @param {HTMLDivElement} elDiv
|
||||||
*/
|
*/
|
||||||
show_settings(elDiv) {
|
show_settings(elDiv) {
|
||||||
|
ui.ui_show_obj_props_edit(elDiv, this, ["baseURL", "headers", "bStream", "bTools", "apiRequestOptions", "TRAPME-apiEP", "TRAPME-iRecentUserMsgCnt", "bTrimGarbage", "bCompletionFreshChatAlways", "bCompletionInsertStandardRolePrefix"], "Settings", (prop, elProp)=>{
|
||||||
ui.ui_show_obj_props_edit(elDiv, this, ["baseURL", "headers", "bStream", "bTools", "apiRequestOptions", "TRAPME-apiEP", "TRAPME-iRecentUserMsgCnt", "bTrimGarbage", "bCompletionFreshChatAlways", "bCompletionInsertStandardRolePrefix"], "Settings", "TRAPME-", (tag, elParent)=>{
|
if (prop == "headers:Authorization") {
|
||||||
|
// @ts-ignore
|
||||||
|
elProp.placeholder = "Bearer OPENAI_API_KEY";
|
||||||
|
}
|
||||||
|
}, "TRAPME-", (tag, elParent)=>{
|
||||||
if (tag == "TRAPME-apiEP") {
|
if (tag == "TRAPME-apiEP") {
|
||||||
let sel = ui.el_creatediv_select("SetApiEP", "ApiEndPoint", ApiEP.Type, this.apiEP, (val)=>{
|
let sel = ui.el_creatediv_select("SetApiEP", "ApiEndPoint", ApiEP.Type, this.apiEP, (val)=>{
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,11 @@ export function el_creatediv_input(id, label, type, defaultValue, cb, className=
|
||||||
* Auto create ui input elements for specified fields/properties in given object
|
* Auto create ui input elements for specified fields/properties in given object
|
||||||
* Currently supports text, number, boolean field types.
|
* Currently supports text, number, boolean field types.
|
||||||
* Also supports recursing if a object type field is found.
|
* Also supports recursing if a object type field is found.
|
||||||
|
*
|
||||||
|
* If for any reason the caller wants to refine the created ui element for a specific prop,
|
||||||
|
* they can define a fRefiner callback, which will be called back with prop name and ui element.
|
||||||
|
* The fRefiner callback even helps work with Obj with-in Obj scenarios.
|
||||||
|
*
|
||||||
* For some reason if caller wants to handle certain properties on their own
|
* For some reason if caller wants to handle certain properties on their own
|
||||||
* * prefix the prop name in lProps with sTrapTag
|
* * prefix the prop name in lProps with sTrapTag
|
||||||
* * fTrapper will be called with the parent ui element
|
* * fTrapper will be called with the parent ui element
|
||||||
|
|
@ -244,7 +249,7 @@ export function el_creatediv_input(id, label, type, defaultValue, cb, className=
|
||||||
* @param {any} oObj
|
* @param {any} oObj
|
||||||
* @param {Array<string>} lProps
|
* @param {Array<string>} lProps
|
||||||
* @param {string} sLegend
|
* @param {string} sLegend
|
||||||
* @param {((prop:string, elUI: HTMLElement)=>void)| undefined} fRefiner
|
* @param {((prop:string, elProp: HTMLElement)=>void)| undefined} fRefiner
|
||||||
* @param {string | undefined} sTrapTag
|
* @param {string | undefined} sTrapTag
|
||||||
* @param {((tagPlusProp: string, elParent: HTMLFieldSetElement)=>void) | undefined} fTrapper
|
* @param {((tagPlusProp: string, elParent: HTMLFieldSetElement)=>void) | undefined} fTrapper
|
||||||
*/
|
*/
|
||||||
|
|
@ -289,7 +294,12 @@ export function ui_show_obj_props_edit(elDiv, oObj, lProps, sLegend, fRefiner=un
|
||||||
}
|
}
|
||||||
fs.appendChild(bbtn.div);
|
fs.appendChild(bbtn.div);
|
||||||
} else if (type == "object") {
|
} else if (type == "object") {
|
||||||
ui_show_obj_props_edit(fs, val, Object.keys(val), k)
|
ui_show_obj_props_edit(fs, val, Object.keys(val), k, (prop, elProp)=>{
|
||||||
|
if (fRefiner) {
|
||||||
|
let theProp = `${k}:${prop}`
|
||||||
|
fRefiner(theProp, elProp)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue