cwUi.cpp : Fixed bug where 'title' element type had the wrong type string.

This commit is contained in:
kevin.larke 2020-04-28 20:51:18 -04:00
parent 239f9c1916
commit fab87f7050
2 changed files with 19 additions and 9 deletions

View File

@ -366,7 +366,7 @@ namespace cw
// form the create json message string // form the create json message string
//unsigned i = snprintf( p->buf, p->bufN, "{ \"op\":\"create\", \"parent\":\"%s\", \"children\":{ \"%s\":{ \"eleName\":\"%s\", \"appId\":%i, \"uuId\":%i, \"class\":\"%s\", \"title\":\"%s\" ", parentEleName, eleTypeStr, eleName, appId, newEle->uuId, clas, title ); //unsigned i = snprintf( p->buf, p->bufN, "{ \"op\":\"create\", \"parent\":\"%s\", \"children\":{ \"%s\":{ \"eleName\":\"%s\", \"appId\":%i, \"uuId\":%i, \"class\":\"%s\", \"title\":\"%s\" ", parentEleName, eleTypeStr, eleName, appId, newEle->uuId, clas, title );
unsigned i = snprintf( p->buf, p->bufN, "{ \"op\":\"create\", \"parentUuId\":\"%i\", \"type\":\"%s\", \"eleName\":\"%s\", \"appId\":\"%i\", \"uuId\":%i, \"className\":\"%s\", \"title\":\"%s\" ", parentEle->uuId, eleTypeStr, eleName==nullptr ? "" : eleName, appId, newEle->uuId, clas, title ); unsigned i = snprintf( p->buf, p->bufN, "{ \"op\":\"create\", \"parentUuId\":\"%i\", \"type\":\"%s\", \"eleName\":\"%s\", \"appId\":\"%i\", \"uuId\":%i, \"className\":\"%s\", \"title\":\"%s\" ", parentEle->uuId, eleTypeStr, eleName==nullptr ? "" : eleName, appId, newEle->uuId, clas==nullptr ? " " : clas, title==nullptr ? " " : title );
// add the UI specific attributes // add the UI specific attributes
@ -1034,7 +1034,7 @@ cw::rc_t cw::ui::createDiv( handle_t h, unsigned& uuIdRef, unsigned wsSessId, un
{ return _createOneEle( _handleToPtr(h), uuIdRef, "div", wsSessId, parentUuId, eleName, appId, clas, title ); } { return _createOneEle( _handleToPtr(h), uuIdRef, "div", wsSessId, parentUuId, eleName, appId, clas, title ); }
cw::rc_t cw::ui::createTitle( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title ) cw::rc_t cw::ui::createTitle( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title )
{ return _createOneEle( _handleToPtr(h), uuIdRef, "option", wsSessId, parentUuId, eleName, appId, clas, title ); } { return _createOneEle( _handleToPtr(h), uuIdRef, "title", wsSessId, parentUuId, eleName, appId, clas, title ); }
cw::rc_t cw::ui::createButton( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title ) cw::rc_t cw::ui::createButton( handle_t h, unsigned& uuIdRef, unsigned wsSessId, unsigned parentUuId, const char* eleName, unsigned appId, const char* clas, const char* title )
{ return _createOneEle( _handleToPtr(h), uuIdRef, "button", wsSessId, parentUuId, eleName, appId, clas, title ); } { return _createOneEle( _handleToPtr(h), uuIdRef, "button", wsSessId, parentUuId, eleName, appId, clas, title ); }

View File

@ -310,11 +310,16 @@ function ui_create_ctl( parent_ele, ele_type, label, d, dfltEleClassName )
// if label is not null then create an enclosing 'label' element // if label is not null then create an enclosing 'label' element
if( label != null ) if( label != null )
{ {
label_ele = dom_create_ele("label"); label = label.trim();
label_ele.innerHTML = label; if( label.length > 0)
{
label_ele = dom_create_ele("label");
div_ele.appendChild(label_ele) label_ele.innerHTML = label;
div_ele.appendChild(label_ele)
}
} }
return ui_create_ele( div_ele, ele_type, d, dfltEleClassName ); return ui_create_ele( div_ele, ele_type, d, dfltEleClassName );
@ -327,13 +332,18 @@ function ui_create_div( parent_ele, d )
if( div_ele != null ) if( div_ele != null )
{ {
if( d.title != null && d.title.length > 0 ) if( d.title != null )
{ {
var p_ele = dom_create_ele("p") var title = d.title.trim()
p_ele.innerHTML = d.title if( title.length > 0 )
{
var p_ele = dom_create_ele("p")
div_ele.appendChild( p_ele ) p_ele.innerHTML = title
div_ele.appendChild( p_ele )
}
} }
} }