bugfix
This commit is contained in:
parent
1e6acc19ca
commit
91e24f567f
@ -105,8 +105,10 @@ bricks.AudioRecorder = class extends bricks.HBox {
|
||||
this.add_widget(this.rec_btn);
|
||||
this.add_widget(this.rec_time);
|
||||
this.recordData = null;
|
||||
if (this.upload_url){
|
||||
this.bind('record_ended', this.upload.bind(this));
|
||||
}
|
||||
}
|
||||
rec_btn_pressed(){
|
||||
bricks.debug(this.rec_btn.url, ':url:', this.start_icon, this.stop_icon);
|
||||
if(this.rec_btn.url == this.start_icon){
|
||||
|
@ -214,7 +214,7 @@ bricks.buildEventHandler = async function(w, desc, event){
|
||||
return null
|
||||
}
|
||||
var rtdata = {};
|
||||
|
||||
desc.event_params = event.params || {} ;
|
||||
if (desc.rtdata) rtdata = desc.rtdata;
|
||||
else if (desc.datawidget){
|
||||
var data_desc = {
|
||||
@ -225,9 +225,15 @@ bricks.buildEventHandler = async function(w, desc, event){
|
||||
}
|
||||
rtdata = await bricks.getRealtimeData(w, data_desc);
|
||||
}
|
||||
/*
|
||||
if (typeof event.params == typeof {}){
|
||||
rtdata = bricks.extend(rtdata, event.params);
|
||||
} else if (event.params instanceof FormData){
|
||||
for ( const [key, value] of Object.entries(rtdata)){
|
||||
params.append(key, value);
|
||||
}
|
||||
}
|
||||
*/
|
||||
switch (desc.actiontype){
|
||||
case 'urlwidget':
|
||||
return bricks.buildUrlwidgetHandler(w, target, rtdata, desc);
|
||||
@ -312,8 +318,21 @@ bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){
|
||||
}
|
||||
var options = objcopy(desc.options||{});
|
||||
var params = options.params || {};
|
||||
if (desc.event_params instanceof FormData){
|
||||
var params = desc.event_params;
|
||||
for ( const [key, value] of Object.entries(rtdata)){
|
||||
params.append(key, value);
|
||||
}
|
||||
options = bricks.apply_data(options, rtdata);
|
||||
for ( const [key, value] of Object.entries(options.params||{})){
|
||||
params.append(key, value);
|
||||
}
|
||||
options.params = params;
|
||||
} else {
|
||||
rtdata = bricks.extend(rtdata, desc.event_params);
|
||||
options = bricks.apply_data(options, rtdata);
|
||||
options.params = bricks.extend(params, rtdata);
|
||||
}
|
||||
|
||||
var opts = {
|
||||
"widgettype":"urlwidget",
|
||||
|
@ -8,7 +8,7 @@ SOURCES=" page_data_loader.js factory.js uitypesdef.js utils.js uitype.js \
|
||||
floaticonbar.js miniform.js wterm.js dynamicaccordion.js \
|
||||
binstreaming.js streaming_audio.js vadtext.js rtc.js docxviewer.js \
|
||||
llm_dialog.js llm.js websocket.js datarow.js tabular.js \
|
||||
line.js pie.js bar.js gobang.js period.js "
|
||||
line.js pie.js bar.js gobang.js period.js pdfviewer.js"
|
||||
echo ${SOURCES}
|
||||
cat ${SOURCES} > ../dist/bricks.js
|
||||
# uglifyjs --compress --mangle -- ../dist/bricks.js > ../dist/bricks.min.js
|
||||
|
@ -177,6 +177,12 @@ bricks.FormBase = class extends bricks.Layout {
|
||||
}
|
||||
}
|
||||
getValue(){
|
||||
if (this.data) {
|
||||
var ret = this.data;
|
||||
this.data = null;
|
||||
return ret;
|
||||
}
|
||||
return this.get_formdata();
|
||||
var data = {};
|
||||
for (var name in this.name_inputs){
|
||||
if (! this.name_inputs.hasOwnProperty(name)){
|
||||
@ -204,11 +210,12 @@ bricks.FormBase = class extends bricks.Layout {
|
||||
var w = this.name_inputs[name];
|
||||
var d = w.getValue();
|
||||
if (w.required && ( d[name] == '' || d[name] === null)){
|
||||
bricks.debug('data=', data, 'd=', d);
|
||||
new bricks.Error({title:'Requirement', message:'required field must input"' + w.label + '"'})
|
||||
w.focus();
|
||||
return;
|
||||
}
|
||||
w.set_formdata(data);
|
||||
/*
|
||||
if (bricks.need_formdata_fields.includes(w.uitype)){
|
||||
var files = w.get_files();
|
||||
for (var i=0;i<files.length;i++){
|
||||
@ -218,23 +225,28 @@ bricks.FormBase = class extends bricks.Layout {
|
||||
} else {
|
||||
data.append(name, d[name]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
this.data = data;
|
||||
return data;
|
||||
}
|
||||
async validation(){
|
||||
var running = new bricks.Running({target:this});
|
||||
try {
|
||||
var data;
|
||||
data = this.get_formdata();
|
||||
/*
|
||||
if (this.need_formdata){
|
||||
data = this.get_formdata();
|
||||
} else {
|
||||
data = this.getValue();
|
||||
}
|
||||
*/
|
||||
if (! data) {
|
||||
running.dismiss();
|
||||
return;
|
||||
}
|
||||
data = bricks.delete_null_values(data);
|
||||
// data = bricks.delete_null_values(data);
|
||||
this.dispatch('submit', data);
|
||||
if (this.submit_url){
|
||||
var rc = new bricks.HttpResponse();
|
||||
|
@ -18,7 +18,9 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.7/dist/bundle.min.js"></script>
|
||||
<script src="https://unpkg.com/docx-js@3.2.0/lib/docx.min.js"></script>
|
||||
-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/js-docx-viewer/dist/js-docx-viewer.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.14.305/pdf.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mammoth/1.4.2/mammoth.browser.min.js"></script>
|
||||
<script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.5.1/files/dist/echarts.min.js"></script>
|
||||
|
||||
<script src="/bricks/3parties/marked.min.js"></script>
|
||||
|
@ -17,6 +17,9 @@ bricks.UiType =class extends bricks.Layout {
|
||||
}
|
||||
return o;
|
||||
}
|
||||
set_formdata(formdata){
|
||||
formdata.append(this.name, this.resultValue());
|
||||
}
|
||||
resultValue(){
|
||||
return this.value;
|
||||
}
|
||||
@ -71,7 +74,8 @@ bricks.UiAudioText = class extends bricks.UiType {
|
||||
this.text_w.setValue('');
|
||||
}
|
||||
getValue(){
|
||||
return this.text_w.getValue();
|
||||
this.value = this.text_w.getValue();
|
||||
return this.value;
|
||||
}
|
||||
setValue(v){
|
||||
this.text_w.setValue(v);
|
||||
@ -265,6 +269,7 @@ bricks.UiFloat =class extends bricks.UiInt {
|
||||
this.dom_element.step = step;
|
||||
}
|
||||
resultValue(){
|
||||
super.resultValue();
|
||||
return parseFloat(this.value);
|
||||
}
|
||||
setValue(v){
|
||||
@ -403,6 +408,9 @@ bricks.UiImage =class extends bricks.VBox {
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
set_formdata(formdata){
|
||||
formdata.append(this.name, this.value);
|
||||
}
|
||||
getValue(){
|
||||
var ret = {}
|
||||
if (this.imgw){
|
||||
|
@ -77,8 +77,6 @@ bricks.HttpText = class {
|
||||
return await resp.text();
|
||||
}
|
||||
add_own_params(params){
|
||||
if (! params)
|
||||
params = {};
|
||||
var session = bricks.app.get_session();
|
||||
if (params instanceof FormData){
|
||||
for ( const [key, value] of Object.entries(this.params)){
|
||||
@ -89,6 +87,8 @@ bricks.HttpText = class {
|
||||
}
|
||||
return params;
|
||||
}
|
||||
if (! params)
|
||||
params = {};
|
||||
var p = bricks.extend({}, this.params);
|
||||
p = bricks.extend(p, params);
|
||||
if (session){
|
||||
@ -109,13 +109,13 @@ bricks.HttpText = class {
|
||||
var _params = {
|
||||
method:method
|
||||
}
|
||||
// _params.headers = headers;
|
||||
if (data instanceof FormData){
|
||||
method = 'POST';
|
||||
_params.body = data;
|
||||
} else {
|
||||
if (method == 'GET' || method == 'HEAD') {
|
||||
let pstr = url_params(data);
|
||||
url = url + '?' + pstr;
|
||||
} else {
|
||||
if (data instanceof FormData){
|
||||
_params.body = data;
|
||||
} else {
|
||||
_params.body = JSON.stringify(data);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ bricks.PDFviewer = class extends bricks.VBox {
|
||||
this.curpage = null;
|
||||
this.pdf = null;
|
||||
bricks.app.bind('keydown', this.key_action.bind(this));
|
||||
schedule_once(this.renderPage(1), 0.2);
|
||||
schedule_once(this.renderPage(1), 1);
|
||||
}
|
||||
key_action(e){
|
||||
if (!this.curpage) return;
|
||||
|
Loading…
Reference in New Issue
Block a user