This commit is contained in:
yumoqing 2024-05-14 17:14:30 +08:00
parent 220eb8bf1a
commit e39214e606
9 changed files with 201 additions and 166 deletions

View File

@ -133,7 +133,7 @@ bricks.DataRow = class extends bricks.HBox {
var opts = bricks.extend({ var opts = bricks.extend({
margin:'3px' margin:'3px'
}, f); }, f);
if (header){ if (header || ! this.user_data){
opts.value = f.label || f.name; opts.value = f.label || f.name;
} else { } else {
opts.value = this.user_data[f.name]; opts.value = this.user_data[f.name];

View File

@ -64,11 +64,6 @@ bricks.Message = class extends bricks.Modal {
{ {
title: title:
message: message:
params:
auto_open:
auto_dismiss:
archor:cc
timeout:
} }
*/ */
constructor(opts){ constructor(opts){

View File

@ -2,15 +2,14 @@ var bricks = window.bricks || {};
bricks.Tabular = class extends bricks.DynamicAccordion { bricks.Tabular = class extends bricks.DynamicAccordion {
constructor(opts){ constructor(opts){
super(opts); super(opts);
// this.fields = this.record_view.options.fields;
this.get_edit_fields(); this.get_edit_fields();
} }
get_edit_fields(){ get_edit_fields(){
var fs = this.record_view.options.fields; var fs = this.row_options.fields;
this.fields = []; this.fields = [];
var exclouded = []; var exclouded = [];
if (this.record_view.options.editexclouded){ if (this.row_options.editexclouded){
exclouded = this.record_view.options.editexclouded; exclouded = this.row_options.editexclouded;
} }
fs.forEach(f => { fs.forEach(f => {
if (!exclouded.includes(f.name)){ if (!exclouded.includes(f.name)){
@ -20,29 +19,17 @@ bricks.Tabular = class extends bricks.DynamicAccordion {
} }
async build_info(item, record){ async build_info(item, record){
if (this.record_view.widgettype != 'DataRow'){ var header = true;
console.log('record_view must be DataRow'); var options = bricks.extend({cheight:this.cheight}, this.row_options);
return
}
if (record){ if (record){
/* data row
*/
var options = bricks.extend({cheight:this.cheight}, this.record_view.options);
var desc = bricks.extend({}, this.record_view);
options.user_data = record; options.user_data = record;
desc.options = options header = false;
var dr = await bricks.widgetBuild(desc, this);
dr.render(this.editable, this.checkable, false);
dr.event_names.forEach(e => {
dr.toolbar_w.bind(e, this.record_event_handle.bind(this, e, record, dr, item));
});
} else {
var dr = await bricks.widgetBuild(this.record_view, this);
dr.render(this.editable, this.checkable, true);
dr.event_names.forEach(e => {
dr.toolbar_w.bind(e, this.record_event_handle.bind(this, e, record, dr, item));
});
} }
var dr = new bricks.DataRow(options);
dr.render(this.editable, this.checkable, header);
dr.event_names.forEach(e => {
dr.toolbar_w.bind(e, this.record_event_handle.bind(this, e, record, dr, item));
});
item.add_widget(dr); item.add_widget(dr);
return dr; return dr;
} }

View File

@ -0,0 +1,33 @@
# AudioPlayer
音频播放器
## 父类
[JsWidget](jswidget.md)
## 构建参数
options = {
* url:音频源的url
* autoplay自动播放如果是true音频在导入后自动播放
}
## 方法
### set_urlurl
此方法设置新的音频源如果autoplay为真新设置的资源会立即播放
### toggle_play
如果当前资源正在播放,则停止播放,否则开始播放
### play
播放资源
## 事件
## 使用例子
```
{
"id":"audioplayer",
"widgettype":"AudioPlayer",
"options":{
"autoplay":true,
"url":"http://kimird.com/songs/sample-mp3-file.mp3"
}
}
```

View File

@ -0,0 +1,56 @@
# 录制音频
音频录制器
## widgettype值
AudioRecorder
## 父类
[bricks.HBox](hbox.md)
## 构建参数
{
"upload_url":音频上传url
“icon_rate”录音按钮比例设置录音图标显示多少个字符大小。
}
## 方法
### start_recording()
### stop_recording()
### async upload()
## 事件
### uploaded
上传成功事件事件参数是fetch返回的response
### record_started
录音开始事件,无参数
### record_ended
录音结束事件,参数为:
var d = {
data:blob,
url:localURL,
duration:duration
}
## 使用例子
```
{
"id":"recorder",
"widgettype":"AudioRecorder",
"options":{
"height":"40px",
"upload_url":"{{entire_url('stt.dspy')}}"
},
"binds":[
{
"wid":"self",
"event":"uploaded",
"actiontype":"script",
"script":"alert(event.params)"
}
]
}
```

View File

@ -0,0 +1,34 @@
# 确认控件
弹出式用户确认控件显示标题以及消息并在下方提供确认和放弃两个按钮。点击确认后关闭窗口并触发“comformed”事件
## widgettype值
Conform
## 父类
[bricks.Message](message.md)
## 构建参数
同bircks.Message控件的参数
## 方法
## 事件
### conformed
用户点击确认按钮触发的事件
### cancelled
用户点击discard按钮触发的事件
## 使用例子
```
{
"id":"uuuu",
"widgettype":"Conform",
"options":{
"width":"40%",
"height":"40%",
"archor":"cc",
"title":"Test Title",
"message":"This is a test message"
}
}
```

View File

@ -0,0 +1,30 @@
# Tabular
表格形式的数据展现控件
## widgettype值
Tabular
## 父类
bricks.VScrollPanel
## 构建参数
* "data_url":数据获取url用来获取条目数据返回数据须符合[页数据要求](pagingdata.md)
* "data_method":数据获取的方法缺省是“GET”
* "data_params",获取数据需要带的参数
* "cache_limit",缓存数据页数
* "page_rows",每页数据条数
* "row_cheight":每条目显示按字符大小为单位的高度
* "row_options":条目数据显示控件的构建参数,参数需要符合要求
* "content_view": 内容显示的控件描述,当用户点击条目后会在条目后面显示此控件描述生成的控件,在其中可以使用${name}的形式调用后台返回数据当前记录字段数据
### row_options格式
* toolbar: 格式要求参看[工具条](toolbar.md)
* fields:数组,数据字段说明,数组中每个数据要素请参看[字段规范](field_spec.md)
* browserfields条目显示字段约束是一个字典类型数据
* editexclouded: 数组编辑是蓄意排除的数据字段名
## 方法
## 事件
## 使用例子

View File

@ -1,143 +1,34 @@
# Message # 消息控件
一个Modal类型控件用于显示提示信息
## 用法 ## widgettype值
Message
```html ## 父类
<html> bricks.Modal
<head> ## 构建参数
<link rel="stylesheet" href="/bricks/css/bricks.css"> * title 在标题栏上显示的内容
</head>
<body> * message 在正文栏内显示的正文
<script src="/bricks/bricks.js"></script>
<script>
const opts =
{
"widget": {
"widgettype": "Tree",
"options": {
"idField": "id",
"textField": "text",
"data": [
{
"id": 1,
"text": "node1",
"is_leaf": false,
"children": [
{
"id": 11,
"text": "node11",
"is_leaf": false,
"children": [
{
"id": 112,
"text": "node.12",
"is_leaf": false,
"children": [
{
"id": 1112,
"text": "node1112",
"is_leaf": true
},
{
"id": 1113,
"text": "node113",
"is_leaf": true
}
]
},
{
"id": 113,
"text": "node113",
"is_leaf": true
}
]
},
{
"id": 12,
"text": "node12",
"is_leaf": true
},
{
"id": 13,
"text": "node13",
"is_leaf": true
}
]
},
{
"id": 2,
"text": "node2",
"is_leaf": false,
"children": [
{
"id": 21,
"text": "node21",
"is_leaf": true
},
{
"id": 22,
"text": "node22",
"is_leaf": true
},
{
"id": 23,
"text": "node23",
"is_leaf": true
}
]
},
{
"id": 3,
"text": "node3",
"is_leaf": true
}
]
}
}
}
;
const app = new BricksApp(opts);
app.run();
var m = new Message({
"title": "TEst Message",
"message": "This is a test message",
"auto_open": true,
"timeout": 3
})
</script>
</body>
</html>
```
## 示例
![](F:\mh\bricks\docs\images\message.png)
## 参数说明
### widget.type
控件的类型.(控件有多种类型,如:Form,Image...等等)
### widget.options参数说明
| 参数 | 说明 | 类型 | 是否必填 | 可选值 | 默认值 |
| --------- | -------------------- | ------- | -------- | ---------- | ------ |
| idField | 当前节点的唯一标识 | String | 是 | --- | --- |
| textField | 当前节点的label | String | 是 | --- | --- |
| is_leaf | 是否可以展开 | Boolean | 否 | true/false | --- |
| data | 文件夹具体信息的集合 | Array | 否 | --- | --- |
#### options.data参数说明
options.data参数的key必须和widget.options参数的value一致,比如widget.options.idField="id",那么options.data参数的key就是"options.data.id" .另外多了一个children参数,是对象形式,参数与options.data的参数保持一致.
注意:**如果想下写一级目录,就添加children参数对象**
## 方法
## 事件 ## 事件
无新增事件
none ## 例子
```
{
"id":"uuuu",
"widgettype":"Message",
"options":{
"width":"40%",
"height":"40%",
"archor":"cc",
"title":"Test Title",
"timeout":2,
"message":"This is a test message"
}
}
```

9
docs/cn/widgets/tmpl.md Normal file
View File

@ -0,0 +1,9 @@
# component name
音频播放器
## widgettype值
## 父类
## 构建参数
## 方法
## 事件
## 使用例子