Skip to content
Merged

Sync #30

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update apijson document; remove custom_tcolumns_render_generator in a…
…pijson-viewedit; add custom_viewedit_componet block
  • Loading branch information
zhangchunlin committed May 31, 2019
commit 12b87c3f0f42d410a309dcddac5ff920c9930b65
2 changes: 1 addition & 1 deletion demo/apps/apijson_demo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def index():
"@column":"id,username,nickname,email",
"@order":"id-",
"@role":"ADMIN",
"@expr":[["username$","&","email$"],"&",["!","nickname$"]],,
"@expr":[["username$","&","email$"],"&",["!","nickname$"]],
"username$":"%b%",
"nickname$":"%Admin%",
"email$":"%local%"
Expand Down
62 changes: 60 additions & 2 deletions uliweb_apijson/apijson/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

uliweb-apijson is a subset and slightly different variation of [apijson](https://github.com/TommyLemon/APIJSON/blob/master/Document.md)

# Difference with original apijson

| feature | apijson(java) | uliweb-apijson | comment |
| -------- | ------------- | -------------- | ------------------------------------------------------------ |
| @combine | ✔️ | ✖️ | Example: "@combine":"&key0,&key1,\|key2,key3" |
| @expr | ✖️ | ✔️ | Example: "@expr":[["username$","&","email$"],"&",["!","nickname$"]] |



# apijson model configuration

## example
Expand All @@ -13,9 +22,16 @@ user = {
"secret_fields" : ["password"],
"GET" : { "roles" : ["ADMIN","OWNER"] },
"HEAD" : { "roles" : ["ADMIN","OWNER"] },
"POST" : { "roles" : ["ADMIN","OWNER"] },
"POST" : { "roles" : ["ADMIN"] },
"PUT" : { "roles" : ["ADMIN","OWNER"] },
"DELETE" : { "roles" : ["ADMIN","OWNER"] },
"DELETE" : { "roles" : ["ADMIN"] },
}
usergroup = {
"GET" : { "roles" : ["ADMIN","LOGIN"] },
"HEAD" : { "roles" : ["ADMIN"] },
"POST" : { "roles" : ["ADMIN"] },
"PUT" : { "roles" : ["ADMIN"] },
"DELETE" : { "roles" : ["ADMIN"] },
}
```

Expand Down Expand Up @@ -58,6 +74,48 @@ request types currently support: POST, PUT

request configuration currently support: ADD,DISALLOW,NECESSARY (still not fully support [all the configuration items](https://github.com/TommyLemon/APIJSON/wiki#%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86))

# apijson table configuration

## example

```
[APIJSON_TABLES]
roles = {
"@model_name" : "role",
"editable" : "auto",
"table_fields" : [
{"title":"#","key":"id","width":80,"component":"id"},
{"title":"Name","key":"name","component":"name_link"},
{"title":"Description","key":"description"},
{"title":"Is reserved","key":"reserve","component":"checkbox"},
],
"viewedit_fields" : [
{"title":"#","key":"id","editable":False},
{"title":"Name","key":"name"},
{"title":"Description","key":"description"},
{"title":"Is reserved","key":"reserve","component":"checkbox"},
],
"add_fields" : [
{"title":"Name","key":"name"},
{"title":"Description","key":"description"},
{"title":"Is reserved","key":"reserve","component":"checkbox"},
],
}
```

## document

Provide 2 vue component about table:

| | apijson-table | apijson-viewedit |
| ----------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| uliweb template include | {{include "vue/inc_apijson_table.html"}} | {{include "vue/inc_apijson_viewedit.html"}} |
| example: | ```<apijson-table model_name="permission" :config="tconfig" :custom_tcolumns_render_generator="custom_tcolumns_render_generator" ref="table"></apijson-table>``` | ```<apijson-viewedit model_name="permission" request_tag="{{=request_tag}}" :id="id_" :config="tconfig"></apijson-viewedit>``` |






# Supported API Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"request_tag",
"id",
"config",
"custom_tcolumns_render_generator",
"hook_init",
"hook_ajax_params"
],
Expand All @@ -16,6 +15,7 @@
<i-input v-if="item.component=='input'" v-model="item.value" :readonly="!editable(item)"></i-input>
<checkbox v-if="item.component=='checkbox'" v-model="item.value" :disabled="!editable(item)"></checkbox>
<i-input v-if="item.component=='textarea'" v-model="item.value" type="textarea" :autosize="{minRows: 2,maxRows: 5}"></i-input>
{{block custom_viewedit_componet}}{{end custom_viewedit_componet}}
</form-item>
<form-item v-if="config_editable" label="Action">
<i-button type="info" icon="ios-download" size="large" @click="save">Save</i-button>
Expand Down