cwUi* : Added set/get visible/enable() functions. Added parentAndAppIdToUuId() removed findElementUuId(parentUuId,appId/eleName).
This commit is contained in:
parent
0c8fad2425
commit
9848068d3c
116
cwUi.cpp
116
cwUi.cpp
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#define UI_CLICKABLE_LABEL "clickable"
|
#define UI_CLICKABLE_LABEL "clickable"
|
||||||
#define UI_SELECT_LABEL "select"
|
#define UI_SELECT_LABEL "select"
|
||||||
|
#define UI_VISIBLE_LABEL "visible"
|
||||||
|
#define UI_ENABLE_LABEL "enable"
|
||||||
|
|
||||||
namespace cw
|
namespace cw
|
||||||
{
|
{
|
||||||
@ -31,7 +33,8 @@ namespace cw
|
|||||||
|
|
||||||
typedef struct ele_str
|
typedef struct ele_str
|
||||||
{
|
{
|
||||||
struct ele_str* parent; // pointer to parent ele - or nullptr if this ele is attached to the root ui ele
|
struct ele_str* parent; // pointer to parent ele - or nullptr if this ele is the root ui ele
|
||||||
|
unsigned parentAppId;
|
||||||
unsigned uuId; // UI unique id - automatically generated and unique among all elements that are part of this ui_t object.
|
unsigned uuId; // UI unique id - automatically generated and unique among all elements that are part of this ui_t object.
|
||||||
unsigned appId; // application assigned id - application assigned id
|
unsigned appId; // application assigned id - application assigned id
|
||||||
unsigned chanId; //
|
unsigned chanId; //
|
||||||
@ -351,13 +354,31 @@ namespace cw
|
|||||||
ele_t* _createBaseEle( ui_t* p, ele_t* parent, unsigned appId, unsigned chanId, const char* eleName, const char* eleTypeStr=nullptr, const char* eleClass=nullptr, const char* eleTitle=nullptr )
|
ele_t* _createBaseEle( ui_t* p, ele_t* parent, unsigned appId, unsigned chanId, const char* eleName, const char* eleTypeStr=nullptr, const char* eleClass=nullptr, const char* eleTitle=nullptr )
|
||||||
{
|
{
|
||||||
ele_t* e = mem::allocZ<ele_t>();
|
ele_t* e = mem::allocZ<ele_t>();
|
||||||
|
unsigned parentAppId = kInvalidId;
|
||||||
|
|
||||||
e->parent = parent;
|
// Go up the tree looking for the first parent with a valid appId
|
||||||
e->uuId = p->eleN;
|
// This is useful to cover the situation where the parent is an unamed div (e.g. row, col, panel)
|
||||||
e->appId = appId;
|
// and the appIdMap gives the panel name as the parent.
|
||||||
e->chanId = chanId;
|
|
||||||
e->eleName = eleName==nullptr ? nullptr : mem::duplStr(eleName);
|
if( parent != nullptr )
|
||||||
e->attr = newDictObject();
|
{
|
||||||
|
parentAppId = parent->appId;
|
||||||
|
for(const ele_t* par=parent; par!=nullptr; par=par->parent)
|
||||||
|
if( par->appId != kInvalidId )
|
||||||
|
{
|
||||||
|
parentAppId = par->appId;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
e->parent = parent;
|
||||||
|
e->parentAppId = parentAppId;
|
||||||
|
e->uuId = p->eleN;
|
||||||
|
e->appId = appId;
|
||||||
|
e->chanId = chanId;
|
||||||
|
e->eleName = eleName==nullptr ? nullptr : mem::duplStr(eleName);
|
||||||
|
e->attr = newDictObject();
|
||||||
|
|
||||||
if( eleTypeStr != nullptr )
|
if( eleTypeStr != nullptr )
|
||||||
e->attr->insert_pair("type",eleTypeStr);
|
e->attr->insert_pair("type",eleTypeStr);
|
||||||
@ -368,6 +389,9 @@ namespace cw
|
|||||||
if( eleTitle != nullptr )
|
if( eleTitle != nullptr )
|
||||||
e->attr->insert_pair("title",eleTitle);
|
e->attr->insert_pair("title",eleTitle);
|
||||||
|
|
||||||
|
// elements default to visible and enabled
|
||||||
|
e->attr->insert_pair("visible",true);
|
||||||
|
e->attr->insert_pair("enable",true);
|
||||||
|
|
||||||
if( p->eleN == p->eleAllocN )
|
if( p->eleN == p->eleAllocN )
|
||||||
{
|
{
|
||||||
@ -383,19 +407,8 @@ namespace cw
|
|||||||
{
|
{
|
||||||
appIdMapRecd_t* m;
|
appIdMapRecd_t* m;
|
||||||
|
|
||||||
// Go up the tree looking for the first parent with a valid appId
|
|
||||||
// This is useful to cover the situation where the parent is an unamed div (e.g. row, col, panel)
|
|
||||||
// and the appIdMap gives the panel name as the parent.
|
|
||||||
unsigned parentAppId = parent->appId;
|
|
||||||
for(const ele_t* par=parent; par!=nullptr; par=par->parent)
|
|
||||||
if( par->appId != kInvalidId )
|
|
||||||
{
|
|
||||||
parentAppId = par->appId;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ... then try to look it up from the appIdMap.
|
// ... then try to look it up from the appIdMap.
|
||||||
if((m = _findAppIdMap(p, parentAppId, eleName)) != nullptr )
|
if((m = _findAppIdMap(p, e->parentAppId, eleName)) != nullptr )
|
||||||
e->appId = m->appId;
|
e->appId = m->appId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1022,9 +1035,7 @@ cw::rc_t cw::ui::onReceive( handle_t h, unsigned wsSessId, const void* msg, unsi
|
|||||||
cwLogError(kOpFailRC,"UI Value message parse failed.");
|
cwLogError(kOpFailRC,"UI Value message parse failed.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned parentEleAppId = ele->parent == nullptr ? kInvalidId : ele->parent->appId;
|
p->uiCbFunc( p->uiCbArg, wsSessId, opId, ele->parentAppId, ele->uuId, ele->appId, ele->chanId, &value );
|
||||||
|
|
||||||
p->uiCbFunc( p->uiCbArg, wsSessId, opId, parentEleAppId, ele->uuId, ele->appId, ele->chanId, &value );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1034,9 +1045,7 @@ cw::rc_t cw::ui::onReceive( handle_t h, unsigned wsSessId, const void* msg, unsi
|
|||||||
cwLogError(kOpFailRC,"UI Value message parse failed.");
|
cwLogError(kOpFailRC,"UI Value message parse failed.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned parentEleAppId = ele->parent == nullptr ? kInvalidId : ele->parent->appId;
|
p->uiCbFunc( p->uiCbArg, wsSessId, opId, ele->parentAppId, ele->uuId, ele->appId, ele->chanId, &value );
|
||||||
|
|
||||||
p->uiCbFunc( p->uiCbArg, wsSessId, opId, parentEleAppId, ele->uuId, ele->appId, ele->chanId, &value );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1045,9 +1054,7 @@ cw::rc_t cw::ui::onReceive( handle_t h, unsigned wsSessId, const void* msg, unsi
|
|||||||
cwLogError(kOpFailRC,"UI Echo message parse failed.");
|
cwLogError(kOpFailRC,"UI Echo message parse failed.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned parentEleAppId = ele->parent == nullptr ? kInvalidId : ele->parent->appId;
|
p->uiCbFunc( p->uiCbArg, wsSessId, opId, ele->parentAppId, ele->uuId, ele->appId, ele->chanId,nullptr );
|
||||||
|
|
||||||
p->uiCbFunc( p->uiCbArg, wsSessId, opId, parentEleAppId, ele->uuId, ele->appId, ele->chanId,nullptr );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1068,35 +1075,35 @@ cw::rc_t cw::ui::onReceive( handle_t h, unsigned wsSessId, const void* msg, unsi
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned cw::ui::findElementAppId( handle_t h, unsigned parentUuId, const char* eleName )
|
unsigned cw::ui::findElementAppId( handle_t h, unsigned parentAppId, const char* eleName )
|
||||||
{
|
{
|
||||||
ui_t* p = _handleToPtr(h);
|
ui_t* p = _handleToPtr(h);
|
||||||
|
|
||||||
for(unsigned i=0; i<p->eleN; ++i)
|
for(unsigned i=0; i<p->eleN; ++i)
|
||||||
if( p->eleA[i]->parent->uuId==parentUuId && strcmp(p->eleA[i]->eleName,eleName) == 0 )
|
if( p->eleA[i]->parentAppId==parentAppId && strcmp(p->eleA[i]->eleName,eleName) == 0 )
|
||||||
return p->eleA[i]->appId;
|
return p->eleA[i]->appId;
|
||||||
|
|
||||||
return kInvalidId;
|
return kInvalidId;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned cw::ui::findElementUuId( handle_t h, unsigned parentUuId, const char* eleName )
|
unsigned cw::ui::parentAndNameToUuId( handle_t h, unsigned parentAppId, const char* eleName )
|
||||||
{
|
{
|
||||||
ui_t* p = _handleToPtr(h);
|
ui_t* p = _handleToPtr(h);
|
||||||
|
|
||||||
for(unsigned i=0; i<p->eleN; ++i)
|
for(unsigned i=0; i<p->eleN; ++i)
|
||||||
if( p->eleA[i]->parent->uuId==parentUuId && strcmp(p->eleA[i]->eleName,eleName) == 0 )
|
if( p->eleA[i]->parentAppId==parentAppId && strcmp(p->eleA[i]->eleName,eleName) == 0 )
|
||||||
return p->eleA[i]->uuId;
|
return p->eleA[i]->uuId;
|
||||||
|
|
||||||
return kInvalidId;
|
return kInvalidId;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned cw::ui::findElementUuId( handle_t h, unsigned parentUuId, unsigned appId )
|
unsigned cw::ui::parentAndAppIdToUuId( handle_t h, unsigned parentAppId, unsigned appId )
|
||||||
{
|
{
|
||||||
ui_t* p = _handleToPtr(h);
|
ui_t* p = _handleToPtr(h);
|
||||||
|
|
||||||
for(unsigned i=0; i<p->eleN; ++i)
|
for(unsigned i=0; i<p->eleN; ++i)
|
||||||
if(((p->eleA[i]->parent==nullptr && parentUuId==kRootUuId) ||
|
if(((p->eleA[i]->parent==nullptr && parentAppId==kRootAppId) ||
|
||||||
(p->eleA[i]->parent!=nullptr && p->eleA[i]->parent->uuId==parentUuId))
|
(p->eleA[i]->parentAppId==parentAppId))
|
||||||
&& p->eleA[i]->appId == appId )
|
&& p->eleA[i]->appId == appId )
|
||||||
return p->eleA[i]->uuId;
|
return p->eleA[i]->uuId;
|
||||||
return kInvalidId;
|
return kInvalidId;
|
||||||
@ -1379,6 +1386,42 @@ bool cw::ui::isSelected( handle_t h, unsigned uuId )
|
|||||||
return selectFl;
|
return selectFl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cw::rc_t cw::ui::setVisible( handle_t h, unsigned uuId, bool enableFl )
|
||||||
|
{ return _setPropertyFlag( h, UI_VISIBLE_LABEL, uuId, enableFl ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::ui::clearVisible( handle_t h, unsigned uuId )
|
||||||
|
{ return setVisible(h,uuId,false); }
|
||||||
|
|
||||||
|
bool cw::ui::isVisible( handle_t h, unsigned uuId )
|
||||||
|
{
|
||||||
|
ui_t* p = _handleToPtr(h);
|
||||||
|
ele_t* ele = nullptr;
|
||||||
|
bool visibleFl = false;
|
||||||
|
|
||||||
|
if((ele = _uuIdToEle(p,uuId)) != nullptr )
|
||||||
|
visibleFl = _get_attribute_bool(ele,UI_VISIBLE_LABEL);
|
||||||
|
|
||||||
|
return visibleFl;
|
||||||
|
}
|
||||||
|
|
||||||
|
cw::rc_t cw::ui::setEnable( handle_t h, unsigned uuId, bool enableFl )
|
||||||
|
{ return _setPropertyFlag( h, UI_ENABLE_LABEL, uuId, enableFl ); }
|
||||||
|
|
||||||
|
cw::rc_t cw::ui::clearEnable( handle_t h, unsigned uuId )
|
||||||
|
{ return setEnable(h,uuId,false); }
|
||||||
|
|
||||||
|
bool cw::ui::isEnabled( handle_t h, unsigned uuId )
|
||||||
|
{
|
||||||
|
ui_t* p = _handleToPtr(h);
|
||||||
|
ele_t* ele = nullptr;
|
||||||
|
bool enableFl = false;
|
||||||
|
|
||||||
|
if((ele = _uuIdToEle(p,uuId)) != nullptr )
|
||||||
|
enableFl = _get_attribute_bool(ele,UI_ENABLE_LABEL);
|
||||||
|
|
||||||
|
return enableFl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cw::rc_t cw::ui::registerAppIdMap( handle_t h, const appIdMap_t* map, unsigned mapN )
|
cw::rc_t cw::ui::registerAppIdMap( handle_t h, const appIdMap_t* map, unsigned mapN )
|
||||||
@ -1433,10 +1476,9 @@ void cw::ui::report( handle_t h )
|
|||||||
const ele_t* e = p->eleA[i];
|
const ele_t* e = p->eleA[i];
|
||||||
|
|
||||||
unsigned parUuId = e->parent==NULL ? kInvalidId : e->parent->uuId;
|
unsigned parUuId = e->parent==NULL ? kInvalidId : e->parent->uuId;
|
||||||
unsigned parAppId = e->parent==NULL ? kInvalidId : e->parent->appId;
|
|
||||||
const char* parEleName = e->parent==NULL || e->parent->eleName == NULL ? "" : e->parent->eleName;
|
const char* parEleName = e->parent==NULL || e->parent->eleName == NULL ? "" : e->parent->eleName;
|
||||||
|
|
||||||
printf("uu:%5i app:%5i %20s : parent uu:%5i app:%5i %20s ", e->uuId, e->appId, e->eleName == NULL ? "" : e->eleName, parUuId, parAppId, parEleName );
|
printf("uu:%5i app:%5i %20s : parent uu:%5i app:%5i %20s ", e->uuId, e->appId, e->eleName == NULL ? "" : e->eleName, parUuId, e->parentAppId, parEleName );
|
||||||
|
|
||||||
for(unsigned i=0; i<e->attr->child_count(); ++i)
|
for(unsigned i=0; i<e->attr->child_count(); ++i)
|
||||||
{
|
{
|
||||||
|
14
cwUi.h
14
cwUi.h
@ -45,9 +45,9 @@ namespace cw
|
|||||||
rc_t onReceive( handle_t h, unsigned wsSessId, const void* msg, unsigned byteN );
|
rc_t onReceive( handle_t h, unsigned wsSessId, const void* msg, unsigned byteN );
|
||||||
|
|
||||||
// Locate an element whose parent uuid is 'parentUuId' with a child named 'eleName'.
|
// Locate an element whose parent uuid is 'parentUuId' with a child named 'eleName'.
|
||||||
unsigned findElementAppId( handle_t h, unsigned parentUuId, const char* eleName );
|
unsigned findElementAppId( handle_t h, unsigned parentAppId, const char* eleName );
|
||||||
unsigned findElementUuId( handle_t h, unsigned parentUuId, const char* eleName );
|
unsigned parentAndNameToUuId( handle_t h, unsigned parentAppId, const char* eleName );
|
||||||
unsigned findElementUuId( handle_t h, unsigned parentUuId, unsigned appId );
|
unsigned parentAndAppIdToUuId( handle_t h, unsigned parentAppId, unsigned appId );
|
||||||
|
|
||||||
const char* findElementName( handle_t h, unsigned uuId );
|
const char* findElementName( handle_t h, unsigned uuId );
|
||||||
unsigned findElementAppId( handle_t h, unsigned uuId );
|
unsigned findElementAppId( handle_t h, unsigned uuId );
|
||||||
@ -125,6 +125,14 @@ namespace cw
|
|||||||
rc_t clearSelect( handle_t h, unsigned uuId );
|
rc_t clearSelect( handle_t h, unsigned uuId );
|
||||||
bool isSelected( handle_t h, unsigned uuId );
|
bool isSelected( handle_t h, unsigned uuId );
|
||||||
|
|
||||||
|
rc_t setVisible( handle_t h, unsigned uuId, bool enableFl=true );
|
||||||
|
rc_t clearVisible( handle_t h, unsigned uuId );
|
||||||
|
bool isVisible( handle_t h, unsigned uuId );
|
||||||
|
|
||||||
|
rc_t setEnable( handle_t h, unsigned uuId, bool enableFl=true );
|
||||||
|
rc_t clearEnable( handle_t h, unsigned uuId );
|
||||||
|
bool isEnabled( handle_t h, unsigned uuId );
|
||||||
|
|
||||||
// Register parent/child/name app id's
|
// Register parent/child/name app id's
|
||||||
rc_t registerAppIdMap( handle_t h, const appIdMap_t* map, unsigned mapN );
|
rc_t registerAppIdMap( handle_t h, const appIdMap_t* map, unsigned mapN );
|
||||||
|
|
||||||
|
35
cwUiTest.cpp
35
cwUiTest.cpp
@ -59,6 +59,7 @@ namespace cw
|
|||||||
|
|
||||||
// Resource Based elements
|
// Resource Based elements
|
||||||
kQuitBtnId,
|
kQuitBtnId,
|
||||||
|
kUiRptBtnId,
|
||||||
kPanelDivId,
|
kPanelDivId,
|
||||||
kPanelBtn1Id,
|
kPanelBtn1Id,
|
||||||
kPanelCheck1Id,
|
kPanelCheck1Id,
|
||||||
@ -169,6 +170,10 @@ namespace cw
|
|||||||
p->quitFl.store(true);
|
p->quitFl.store(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kUiRptBtnId:
|
||||||
|
ui::report(srv::uiHandle(p->wsUiSrvH));
|
||||||
|
break;
|
||||||
|
|
||||||
case kCheckId:
|
case kCheckId:
|
||||||
printf("Check:%i\n", v->u.b);
|
printf("Check:%i\n", v->u.b);
|
||||||
p->appCheckFl = v->u.b;
|
p->appCheckFl = v->u.b;
|
||||||
@ -193,7 +198,7 @@ namespace cw
|
|||||||
p->appInteger = v->u.i;
|
p->appInteger = v->u.i;
|
||||||
|
|
||||||
handle_t uiH = srv::uiHandle(p->wsUiSrvH);
|
handle_t uiH = srv::uiHandle(p->wsUiSrvH);
|
||||||
unsigned progUuId = findElementUuId( uiH, p->myPanelUuId, kProgressId );
|
unsigned progUuId = parentAndAppIdToUuId( uiH, kDivId, kProgressId );
|
||||||
sendValueInt( uiH, progUuId, v->u.i );
|
sendValueInt( uiH, progUuId, v->u.i );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -204,15 +209,29 @@ namespace cw
|
|||||||
|
|
||||||
|
|
||||||
case kPanelBtn1Id:
|
case kPanelBtn1Id:
|
||||||
printf("Button 1\n");
|
{
|
||||||
_print_state(p);
|
handle_t uiH = srv::uiHandle(p->wsUiSrvH);
|
||||||
|
unsigned btnUuId = parentAndAppIdToUuId( uiH, kPanelDivId, kPanelBtn2Id );
|
||||||
|
|
||||||
|
printf("Button 1 %i\n",btnUuId);
|
||||||
|
_print_state(p);
|
||||||
|
|
||||||
|
|
||||||
|
bool enableFl = isEnabled( uiH, btnUuId );
|
||||||
|
setEnable( uiH, btnUuId, !enableFl );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kPanelCheck1Id:
|
case kPanelCheck1Id:
|
||||||
printf("check 1: %i\n",v->u.b);
|
{
|
||||||
p->appCheck1Fl = v->u.b;
|
printf("check 2: %i\n",v->u.b);
|
||||||
ui::report( srv::uiHandle(p->wsUiSrvH) );
|
p->appCheck1Fl = v->u.b;
|
||||||
|
|
||||||
|
handle_t uiH = srv::uiHandle(p->wsUiSrvH);
|
||||||
|
unsigned progUuId = parentAndAppIdToUuId( uiH, kDivId, kProgressId );
|
||||||
|
bool visibleFl = isVisible( uiH, progUuId );
|
||||||
|
setVisible( uiH, progUuId, !visibleFl );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kPanelBtn2Id:
|
case kPanelBtn2Id:
|
||||||
@ -235,6 +254,9 @@ namespace cw
|
|||||||
printf("sel: %i\n",v->u.i);
|
printf("sel: %i\n",v->u.i);
|
||||||
p->appSelId = v->u.i;
|
p->appSelId = v->u.i;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
cwLogWarning("Unhandled value message: uuid:%i appId:%i\n",uuId,appId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@ -360,6 +382,7 @@ cw::rc_t cw::ui::test( const object_t* cfg )
|
|||||||
{ kSelId, kOpt1Id, "myOpt1" },
|
{ kSelId, kOpt1Id, "myOpt1" },
|
||||||
{ kSelId, kOpt2Id, "myOpt2" },
|
{ kSelId, kOpt2Id, "myOpt2" },
|
||||||
{ kSelId, kOpt3Id, "myOpt3" },
|
{ kSelId, kOpt3Id, "myOpt3" },
|
||||||
|
{ kPanelDivId, kUiRptBtnId, "uiRptBtnId" },
|
||||||
{ kPanelDivId, kListId, "myListId" }
|
{ kPanelDivId, kListId, "myListId" }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -41,6 +41,13 @@
|
|||||||
button:{ name: saveBtnId, title:"Save" },
|
button:{ name: saveBtnId, title:"Save" },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
row: {
|
||||||
|
number:{ name: insertLocId, title:"End Loc", min:0, max:100000, step:1, decpl:0 },
|
||||||
|
button:{ name: insertBtnId, title:"Insert" },
|
||||||
|
button:{ name: deleteBtnId, title:"Delete" },
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
row: {
|
row: {
|
||||||
list:{ name: presetLocListId, title:"Preset Locations" },
|
list:{ name: presetLocListId, title:"Preset Locations" },
|
||||||
},
|
},
|
||||||
|
@ -870,20 +870,27 @@ function ui_set_value( d )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ui_set_select( ele, enableFl )
|
function _ui_modify_class( ele, classLabelArg, enableFl )
|
||||||
{
|
{
|
||||||
let selectClassLabel = " uiSelected"
|
let classLabel = " " + classLabelArg; // prefix the class label with a space
|
||||||
let isSelectSetFl = ele.className.includes(selectClassLabel)
|
|
||||||
|
|
||||||
if( enableFl != isSelectSetFl )
|
let isEnabledFl = ele.className.includes(classLabel)
|
||||||
|
|
||||||
|
// if the class is not already enabled/disabled
|
||||||
|
if( enableFl != isEnabledFl )
|
||||||
{
|
{
|
||||||
if( enableFl )
|
if( enableFl )
|
||||||
ele.className += selectClassLabel;
|
ele.className += classLabel;
|
||||||
else
|
else
|
||||||
ele.className = ele.className.replace(selectClassLabel, "");
|
ele.className = ele.className.replace(classLabel, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ui_set_select( ele, enableFl )
|
||||||
|
{
|
||||||
|
_ui_modify_class("uiSelected")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function ui_set_clickable( ele, enableFl )
|
function ui_set_clickable( ele, enableFl )
|
||||||
{
|
{
|
||||||
@ -895,10 +902,35 @@ function ui_set_clickable( ele, enableFl )
|
|||||||
ele.onclick = null
|
ele.onclick = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ui_set_visible( ele, enableFl )
|
||||||
|
{
|
||||||
|
if(enableFl)
|
||||||
|
{
|
||||||
|
if(ele.hasOwnProperty("style_display") )
|
||||||
|
{
|
||||||
|
ele.style.display = ele.style_display;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ele.style.display = "block";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ele.style_display = ele.style.display;
|
||||||
|
ele.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ui_set_enable( ele, enableFl )
|
||||||
|
{
|
||||||
|
ele.disabled = !enableFl
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function ui_set( d )
|
function ui_set( d )
|
||||||
{
|
{
|
||||||
//console.log(d)
|
console.log(d)
|
||||||
var ele = dom_id_to_ele(d.uuId.toString())
|
var ele = dom_id_to_ele(d.uuId.toString())
|
||||||
|
|
||||||
if( ele == null )
|
if( ele == null )
|
||||||
@ -923,6 +955,15 @@ function ui_set( d )
|
|||||||
case "clickable":
|
case "clickable":
|
||||||
ui_set_clickable(ele,d.enableFl)
|
ui_set_clickable(ele,d.enableFl)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case "visible":
|
||||||
|
ui_set_visible(ele,d.enableFl)
|
||||||
|
break
|
||||||
|
|
||||||
|
case "enable":
|
||||||
|
ui_set_enable(ele,d.enableFl)
|
||||||
|
break
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
option:{ name: myOpt3, title:"Sel 3" }
|
option:{ name: myOpt3, title:"Sel 3" }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
button:{ name: uiRptBtnId, title:"UI Report" },
|
||||||
},
|
},
|
||||||
|
|
||||||
row: {
|
row: {
|
||||||
|
Loading…
Reference in New Issue
Block a user