From 5bb8c5b495635706180b04177d69185c35f7f5f4 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 29 Jun 2024 20:10:55 +0800 Subject: [PATCH] bugfix --- bricks/cols.js | 178 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 bricks/cols.js diff --git a/bricks/cols.js b/bricks/cols.js new file mode 100644 index 0000000..843db02 --- /dev/null +++ b/bricks/cols.js @@ -0,0 +1,178 @@ +bricks = window.bricks || {} + +bricks.Cols = class extends bricks.VBox { + /* + { + data_url: + data_params: + data_method: + col_width: + col_cwidth: + record_view:{ + } + } + event: + record_click + */ + constructor(opts){ + super(opts); + this.loading = false; + this.loader = new bricks.PageDataLoader({ + url:this.opts.data_url, + params:this.opts.data_params, + pagerows:this.opts.page_rows, + method:this.opts.data_method, + cache_pages:this.opts.cache_limit + }); + this.select_record = null; + this.container = new bricks.VScrollPanel({width:"100%"}); + this.container.set_css('filler'); + this.container.bind('min_threshold', this.load_previous_page.bind(this)); + this.container.bind('max_threshold', this.load_next_page.bind(this)); + if (this.title){ + this.title_w = new bricks.Title4({ + i18n:true, + otext:this.title, + dynsize:true + }); + this.add_widget(this.title_w); + } + if (this.description){ + this.desc_w = new bricks.MdWidget({mdtext:this.description}); + this.add_widget(this.desc_w); + } + if (this.toolbar){ + this.toolbar_w = new bricks.Toolbar(this.toolbar); + this.add_widget(this.toolbar_w); + this.toolbar_w.bind('command', this.command_handle.bind(this)); + } + this.add_widget(this.container); + schedule_once(this.load_first_page.bind(this), 0.5); + } + command_handle(event){ + var params = event.params; + this.dispatch(params.name); + } + + async handle_click(rw, event){ + var orev = null; + if (this.select_record){ + orev = this.select_record; + this.select_record.set_css('selected_record', true); + this.select_record = null; + if (rw == orev) return; + } + this.select_record = rw; + this.select_record.set_css('selected_record'); + } + async dataHandle(d){ + var data = d.rows; + var page = d.add_page; + if (!data){ + return; + } + if (! this.loader.is_max_page(page)){ + data.reverse(); + } + for (var i=0;i