fix: view_assets — use actiontype:urlwidget + target + mode:replace
Replace custom JS fetch script with proper bricks-native pattern: - actiontype: urlwidget, target: app.rl_asset_results, mode: replace - method: POST in urlwidget options (required for form data) - Remove duplicate id from dspy response widgets (id belongs to container only)
This commit is contained in:
parent
f94207dd86
commit
7c3e77e612
@ -22,7 +22,6 @@ assets = result.get('assets', [])
|
||||
if not assets:
|
||||
return json.dumps({
|
||||
"widgettype": "VBox",
|
||||
"id": "rl_asset_results",
|
||||
"options": {"padding": "16px", "gap": "12px"},
|
||||
"subwidgets": [
|
||||
{
|
||||
@ -131,7 +130,6 @@ for a in assets:
|
||||
# Wrap cards in ResponsableBox for responsive grid
|
||||
result_widget = {
|
||||
"widgettype": "VBox",
|
||||
"id": "rl_asset_results",
|
||||
"options": {"padding": "16px", "gap": "12px"},
|
||||
"subwidgets": [
|
||||
{"widgettype": "Text", "options": {"text": f"共 {len(assets)} 个素材", "fontWeight": "bold"}},
|
||||
|
||||
@ -35,9 +35,13 @@
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "submit",
|
||||
"actiontype": "script",
|
||||
"target": "self",
|
||||
"script": "(async function(){var form=bricks.getWidgetById('view_assets_form',bricks.app);if(!form)return;var vals=form._getValue();var params=new URLSearchParams();for(var k in vals){if(vals[k]!==undefined&&vals[k]!==null)params.append(k,vals[k])}var url=bricks.app.baseUrl+'/reallife_asset/api/submit_list_assets.dspy?_webbricks_=1';var resp=await fetch(url,{method:'POST',body:params});var desc=await resp.json();var target=bricks.getWidgetById('rl_asset_results',bricks.app);if(!target)return;if(target.destroy_subwidgets)target.destroy_subwidgets();target.subwidgets=[];target.el.innerHTML='';if(desc&&desc.widgettype){await bricks.widgetBuild(desc,target)}})()"
|
||||
"actiontype": "urlwidget",
|
||||
"target": "app.rl_asset_results",
|
||||
"options": {
|
||||
"method": "POST",
|
||||
"url": "{{entire_url('api/submit_list_assets.dspy')}}"
|
||||
},
|
||||
"mode": "replace"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user