This commit is contained in:
yumoqing 2021-06-10 08:45:49 +08:00
parent c4b29927e9
commit 940171bf9d

View File

@ -389,7 +389,7 @@ class Blocks(EventDispatcher):
alert("actiontype(%s) invalid" % acttype,title='error') alert("actiontype(%s) invalid" % acttype,title='error')
def eventAction(self, widget, desc, *args): def eventAction(self, widget, desc, *args):
target = Blocks.getWidgetById(desc.get('target','self'),widget) target = self.get_target(widget, desc)
event = desc.get('dispatch_event') event = desc.get('dispatch_event')
if not event: if not event:
Logger.info('Block: eventAction():desc(%s) miss dispatch_event', Logger.info('Block: eventAction():desc(%s) miss dispatch_event',
@ -405,9 +405,14 @@ class Blocks(EventDispatcher):
Logger.info(f'Block: eventAction():dispatch {event} error') Logger.info(f'Block: eventAction():dispatch {event} error')
print_exc() print_exc()
return return
def get_target(self, widget, desc):
if not desc.get('target'):
return None
return Blocks.getWidgetById(desc.get('target'),from_widget=widget)
def blocksAction(self,widget,desc, *args): def blocksAction(self,widget,desc, *args):
target = Blocks.getWidgetById(desc.get('target','self'),widget) target = self.get_target(widget, desc)
add_mode = desc.get('mode','replace') add_mode = desc.get('mode','replace')
opts = desc.get('options').copy() opts = desc.get('options').copy()
d = self.getActionData(widget,desc) d = self.getActionData(widget,desc)
@ -432,7 +437,7 @@ class Blocks(EventDispatcher):
b.widgetBuild(opts) b.widgetBuild(opts)
def urlwidgetAction(self,widget,desc, *args): def urlwidgetAction(self,widget,desc, *args):
target = Blocks.getWidgetById(desc.get('target','self'),widget) target = self.get_target(widget, desc)
add_mode = desc.get('mode','replace') add_mode = desc.get('mode','replace')
opts = desc.get('options').copy() opts = desc.get('options').copy()
p = opts.get('params',{}).copy() p = opts.get('params',{}).copy()
@ -480,8 +485,7 @@ class Blocks(EventDispatcher):
return data return data
def registedfunctionAction(self, widget, desc, *args): def registedfunctionAction(self, widget, desc, *args):
target = Blocks.getWidgetById(desc.get('target','self'), target = self.get_target(widget, desc)
from_widget=widget)
rf = RegisterFunction() rf = RegisterFunction()
name = desc.get('rfname') name = desc.get('rfname')
func = rf.get(name) func = rf.get(name)
@ -502,8 +506,7 @@ class Blocks(EventDispatcher):
Logger.info('Block: scriptAction():desc(%s) target not found', Logger.info('Block: scriptAction():desc(%s) target not found',
str(desc)) str(desc))
return return
target = Blocks.getWidgetById(desc.get('target','self'), target = self.get_target(widget, desc)
from_widget=widget)
d = self.getActionData(widget,desc) d = self.getActionData(widget,desc)
ns = { ns = {
"self":target, "self":target,
@ -519,7 +522,7 @@ class Blocks(EventDispatcher):
def methodAction(self, widget, desc, *args): def methodAction(self, widget, desc, *args):
method = desc.get('method') method = desc.get('method')
target = Blocks.getWidgetById(desc.get('target','self'),widget) target = self.get_target(widget, desc)
if target is None: if target is None:
Logger.info('Block: methodAction():desc(%s) target not found', Logger.info('Block: methodAction():desc(%s) target not found',
str(desc)) str(desc))