Skip to content

Commit 064c423

Browse files
committed
SimpleChatTC:ShowObjPropsEdit:Any depth trapping of ui setup - t2
Fix up the oversights wrt any depth trapping flow Remember to start the propWithTree being checked/trapped with : to indicate the root of the prop hierarchy and also use : as sep between the elements of the props hierarchy tree Also had forgotten about the goof up possible with using in in a condition statement to check for array to contain a entry of interest in JS, fixed it now.
1 parent dcbe837 commit 064c423

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

tools/server/public_simplechat/simplechat.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,20 +1110,20 @@ class Me {
11101110
* @param {HTMLDivElement} elDiv
11111111
*/
11121112
show_settings(elDiv) {
1113-
ui.ui_show_obj_props_edit(elDiv, "", this, ["baseURL", "headers", "bStream", "tools", "apiRequestOptions", "TRAPME-apiEP", "TRAPME-iRecentUserMsgCnt", "bTrimGarbage", "bCompletionFreshChatAlways", "bCompletionInsertStandardRolePrefix"], "Settings", (prop, elProp)=>{
1113+
ui.ui_show_obj_props_edit(elDiv, "", this, ["baseURL", "headers", "bStream", "tools", "apiRequestOptions", "apiEP", "iRecentUserMsgCnt", "bTrimGarbage", "bCompletionFreshChatAlways", "bCompletionInsertStandardRolePrefix"], "Settings", (prop, elProp)=>{
11141114
if (prop == "headers:Authorization") {
11151115
// @ts-ignore
11161116
elProp.placeholder = "Bearer OPENAI_API_KEY";
11171117
}
1118-
}, ["apiEP", "iRecentUserMsgCnt"], (propWithPath, prop, elParent)=>{
1119-
if (propWithPath == "apiEP") {
1118+
}, [":apiEP", ":iRecentUserMsgCnt"], (propWithPath, prop, elParent)=>{
1119+
if (propWithPath == ":apiEP") {
11201120
let sel = ui.el_creatediv_select("SetApiEP", "ApiEndPoint", ApiEP.Type, this.apiEP, (val)=>{
11211121
// @ts-ignore
11221122
this.apiEP = ApiEP.Type[val];
11231123
});
11241124
elParent.appendChild(sel.div);
11251125
}
1126-
if (propWithPath == "iRecentUserMsgCnt") {
1126+
if (propWithPath == ":iRecentUserMsgCnt") {
11271127
let sel = ui.el_creatediv_select("SetChatHistoryInCtxt", "ChatHistoryInCtxt", this.sRecentUserMsgCnt, this.iRecentUserMsgCnt, (val)=>{
11281128
this.iRecentUserMsgCnt = this.sRecentUserMsgCnt[val];
11291129
});

tools/server/public_simplechat/ui.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,13 @@ export function el_creatediv_input(id, label, type, defaultValue, cb, className=
242242
* The fRefiner callback even helps work with Obj with-in Obj scenarios.
243243
*
244244
* For some reason if caller wants to handle certain properties on their own
245-
* * prefix the prop name in lProps with sTrapTag
245+
* * specify the prop name of interest along with its prop-tree-hierarchy in lTrapThese
246+
* * always start with : when ever refering to propWithPath,
247+
* as it indirectly signifies root of properties tree
248+
* * remember to seperate the properties tree hierarchy members using :
246249
* * fTrapper will be called with the parent ui element
247-
* into which the new ui elements created for editting the prop, if any, should be attached
250+
* into which the new ui elements created for editting the prop, if any, should be attached,
251+
* along with the current prop of interest and its full propWithPath representation.
248252
* @param {HTMLDivElement|HTMLFieldSetElement} elParent
249253
* @param {string} propsTreeRoot
250254
* @param {any} oObj
@@ -267,7 +271,7 @@ export function ui_show_obj_props_edit(elParent, propsTreeRoot, oObj, lProps, sL
267271
for(const k of lProps) {
268272
let propsTreeRootNew = `${propsTreeRoot}:${k}`
269273
if (lTrapThese) {
270-
if (propsTreeRootNew in lTrapThese) {
274+
if (lTrapThese.indexOf(propsTreeRootNew) != -1) {
271275
if (fTrapper) {
272276
fTrapper(propsTreeRootNew, k, elFS)
273277
}

0 commit comments

Comments
 (0)