bug fix: menu handling (tabs, window open)

v2.2
Steve Nyemba 3 weeks ago
parent 76b35b49a7
commit 1b3a458b23

@ -293,7 +293,7 @@ def create(folder:Annotated[str,typer.Argument(help="path of the project folder"
# #
# Build the configuration for the project # Build the configuration for the project
if not os.path.exists(folder) : if not os.path.exists(folder) :
root = 'www/html' root = f'www{os.sep}html'
_system = System() _system = System()
_layout = Layout() _layout = Layout()
_layout = _layout.build(root=root, order={'menu':[]}, footer = [{"text":term} for term in footer.split(',')],header={'title':title,'subtitle':subtitle} ) _layout = _layout.build(root=root, order={'menu':[]}, footer = [{"text":term} for term in footer.split(',')],header={'title':title,'subtitle':subtitle} )

@ -69,6 +69,12 @@ def _realpath (uri,_config) :
_layout = _config['layout'] _layout = _config['layout']
_uri = copy.copy(uri) _uri = copy.copy(uri)
if 'location' in _layout and _layout['location']: if 'location' in _layout and _layout['location']:
_loc = _layout['location'].strip()
if _loc.endswith(os.sep) and _uri.endswith(os.sep) :
_uri = os.sep.join(_uri.split(os.sep)[1:])
print (' *********************************** ')
_uri = os.sep.join([_layout['location'],_uri]) _uri = os.sep.join([_layout['location'],_uri])
return _uri return _uri

@ -72,23 +72,36 @@ qcms.menu.Basic = function (_layout,_outputId,_domId){
$(_div).on('click', function (){ $(_div).on('click', function (){
// //
// how do we process this ... // how do we process this ...
if(this.data.uri && this.data.type != 'open') { console.log(this.data)
if (this.data.type == 'redirect') {
if (this.data.type == 'dialog') { window.open(this.data.url,_me._format(this.data.text))
}else if (this.data.type == 'dialog'){
qcms.dialog.show(this.data) qcms.dialog.show(this.data)
}else{
_me._open(_me._format(this.data.text),this.data.uri,_parentId)
}
}else if (this.data.type == 'open'){
window.open(this.data.uri,'_self')
}else{ }else{
// _me._open(_me._format(this.data.text),this.data.uri,_parentId)
// redirecting
if (this.data.uri != null){
window.open(this.data.uri,'_self')
}else{
window.open(this.data.url,_format(this.data.text))
}
} }
// if(this.data.uri && this.data.type != 'open') {
// if (this.data.type == 'dialog') {
// qcms.dialog.show(this.data)
// }else{
// _me._open(_me._format(this.data.text),this.data.uri,_parentId)
// }
// }else{
// //
// // redirecting
// if (this.data.uri != null){
// window.open(this.data.uri,'_self')
// }else{
// window.open(this.data.url,_format(this.data.text))
// }
// }
}) })
@ -160,8 +173,10 @@ qcms.menu.Tabs = function (_layout,_outputId,_domId){
// var _parentId = this._parentId // var _parentId = this._parentId
var _me = this ; var _me = this ;
$(_label).on('click',function (){ $(_label).on('click',function (){
alert('....')
_me._open(this.data.id,this.data.uri,_me._parentId) // _me._open(this.data.id,this.data.uri,_me._parentId)
console.log([_me._format(this.data.text),this.data.uri,_parentId])
_me._open(_me._format(this.data.text),this.data.uri,_parentId)
}) })
return [_button,_label] return [_button,_label]
@ -170,10 +185,11 @@ qcms.menu.Tabs = function (_layout,_outputId,_domId){
var _names = _layout.order.menu.length > 0 ? _layout.order.menu : Object.keys(_layout.menu) var _names = _layout.order.menu.length > 0 ? _layout.order.menu : Object.keys(_layout.menu)
// Object.keys(_layout.menu). // Object.keys(_layout.menu).
_names.forEach(function(_key){ _names.forEach(function(_text){
_item = _layout.menu[_key] _item = _layout.menu[_text]
// console.log([_item]) // console.log([_item])
_tabItem = this._build(_key,_item) _tabItem = this._build(_text,_item)
$(tabs).append(_tabItem) $(tabs).append(_tabItem)
}) })

@ -22,20 +22,18 @@ qcms.page.Observer = function (_parentId,_domId,_uri){
_finalize = this.finalize _finalize = this.finalize
_domId = this._domId _domId = this._domId
var _id = `${this._parentId} #${this._domId}` var _id = `${this._parentId} #${this._domId}`.trim()
var http = HttpClient.instance() var http = HttpClient.instance()
http.setHeader('dom',this._domId) http.setHeader('dom',this._domId)
http.setHeader('uri',this._uri) http.setHeader('uri',this._uri)
var _uri = this._uri
http.post(`${qcms.context}/page`,function(x){ http.post(`${qcms.context}/page`,function(x){
var _dom = $(x.responseText) var _dom = $(x.responseText)
$(_id).append (_dom) $(_id).append (_dom)
_finalize(_id)
_finalize(_id) _caller.notify()
_caller.notify()
// // console.log(['*** ',_uri, ' on ',_domId])
}) })
@ -46,7 +44,11 @@ qcms.page.Observer = function (_parentId,_domId,_uri){
} }
qcms.page.loader = function(_parentId,_layout){ qcms.page.loader = function(_parentId,_layout){
// console.log(_parentId,_layout)
if (_parentId.constructor == Object) {
_layout = _parentId
_parentId = null
}
if (!_layout) { if (!_layout) {
return ; return ;
} }

Loading…
Cancel
Save