Skip to content

Commit 122bc1d

Browse files
authored
Merge pull request #34 from zhangchunlin/master
Sync
2 parents e278122 + d8e44ab commit 122bc1d

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

demo/apps/apijson_demo/templates/index.html

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
{{use "ui.vue"}}
77
{{use "ui.iview"}}
88

9+
<style>
10+
.notice
11+
{
12+
color:red;
13+
font-size:150%;
14+
}
15+
</style>
16+
917
<div id="app" class='box'>
1018
<div class="box-body">
1119
<tabs v-model:value="tab_current" type="card" :animated="false">
@@ -29,10 +37,10 @@
2937
<i-col span="8"><i-input value="/apijson/get" readonly/></i-col>
3038
</Row>
3139
<Row v-if="tab_current==='tab_get'">
32-
<i-col span="3"><div align="center"><strong>apijson get</strong> request examples</div></i-col>
40+
<i-col span="3"><div align="center"><strong>apijson get</strong> request <span class="notice">{request_get.length}</span> examples</div></i-col>
3341
<i-col span="8">
3442
<i-select v-model="select_current">
35-
<i-option v-for="item in request_get" :value="item.value" :key="item.value">{ item.label }</i-option>
43+
<i-option v-for="(item,index) in request_get" :value="item.value" :key="item.value">{index+1}. {item.label}</i-option>
3644
</i-select>
3745
</i-col>
3846
</Row>
@@ -42,10 +50,10 @@
4250
<i-col span="8"><i-input value="/apijson/head" readonly/></i-col>
4351
</Row>
4452
<Row v-if="tab_current==='tab_head'">
45-
<i-col span="3"><div align="center"><strong>apijson head</strong> request examples</div></i-col>
53+
<i-col span="3"><div align="center"><strong>apijson head</strong> request <span class="notice">{request_head.length}</span> examples</div></i-col>
4654
<i-col span="8">
4755
<i-select v-model="select_current">
48-
<i-option v-for="item in request_head" :value="item.value" :key="item.value">{ item.label }</i-option>
56+
<i-option v-for="(item,index) in request_head" :value="item.value" :key="item.value">{index+1}. {item.label}</i-option>
4957
</i-select>
5058
</i-col>
5159
</Row>
@@ -55,10 +63,10 @@
5563
<i-col span="8"><i-input value="/apijson/post" readonly/></i-col>
5664
</Row>
5765
<Row v-if="tab_current==='tab_post'">
58-
<i-col span="3"><div align="center"><strong>apijson post</strong> request examples</div></i-col>
66+
<i-col span="3"><div align="center"><strong>apijson post</strong> request <span class="notice">{request_post.length}</span> examples</div></i-col>
5967
<i-col span="8">
6068
<i-select v-model="select_current">
61-
<i-option v-for="item in request_post" :value="item.value" :key="item.value">{ item.label }</i-option>
69+
<i-option v-for="(item,index) in request_post" :value="item.value" :key="item.value">{index+1}. {item.label}</i-option>
6270
</i-select>
6371
</i-col>
6472
</Row>
@@ -68,10 +76,10 @@
6876
<i-col span="8"><i-input value="/apijson/put" readonly/></i-col>
6977
</Row>
7078
<Row v-if="tab_current==='tab_put'">
71-
<i-col span="3"><div align="center"><strong>apijson put</strong> request examples</div></i-col>
79+
<i-col span="3"><div align="center"><strong>apijson put</strong> request <span class="notice">{request_put.length}</span> examples</div></i-col>
7280
<i-col span="8">
7381
<i-select v-model="select_current">
74-
<i-option v-for="item in request_put" :value="item.value" :key="item.value">{ item.label }</i-option>
82+
<i-option v-for="(item,index) in request_put" :value="item.value" :key="item.value">{index+1}. {item.label}</i-option>
7583
</i-select>
7684
</i-col>
7785
</Row>
@@ -81,10 +89,10 @@
8189
<i-col span="8"><i-input value="/apijson/delete" readonly/></i-col>
8290
</Row>
8391
<Row v-if="tab_current==='tab_delete'">
84-
<i-col span="3"><div align="center"><strong>apijson delete</strong> request examples</div></i-col>
92+
<i-col span="3"><div align="center"><strong>apijson delete</strong> request <span class="notice">{request_delete.length}</span> examples</div></i-col>
8593
<i-col span="8">
8694
<i-select v-model="select_current">
87-
<i-option v-for="item in request_delete" :value="item.value" :key="item.value">{ item.label }</i-option>
95+
<i-option v-for="(item,index) in request_delete" :value="item.value" :key="item.value">{index+1}. {item.label}</i-option>
8896
</i-select>
8997
</i-col>
9098
</Row>

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def fpath(name):
1313
def read(fname, default=''):
1414
filename = fpath(fname)
1515
if os.path.exists(filename):
16-
return open(fpath(fname)).read()
16+
return open(fpath(fname),encoding="utf8").read()
1717
else:
1818
return default
1919

uliweb_apijson/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.1.3'
1+
__version__ = '0.2.0'
22
__url__ = 'https://github.com/zhangchunlin/uliweb-apijson'
33
__author__ = 'Chunlin Zhang'
44
__email__ = '[email protected]'

uliweb_apijson/apijson/templates/vue/inc_apijson_table.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
"@page":thisp.current_page-1,
176176
"@query":2
177177
}
178-
arr_params[this.model_name] = {
178+
arr_params[thisp.model_name] = {
179179
"@order":thisp.sort_key+thisp.sort_order,
180180
"@role":"{{=role}}"
181181
}
@@ -194,6 +194,10 @@
194194
thisp.loading = false
195195
if (data.code==200) {
196196
var arr = data["[]"]
197+
for (var i=0;i<arr.length;i++) {
198+
arr[i] = arr[i][thisp.model_name]
199+
}
200+
197201
if (!thisp.tcolumns_init) {
198202
if (thisp.config_table_fields!=null){
199203
thisp.tcolumns = thisp.config_table_fields
@@ -210,6 +214,7 @@
210214
var col = {title:k,key:k}
211215
if (typeof item[k] ==="boolean") {
212216
col["width"] = 80
217+
col["component"] = "checkbox"
213218
}
214219
else if (typeof item[k] ==="number") {
215220
col["width"] = 100

uliweb_apijson/apijson/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ def _get_array(self,key):
237237
q = q.order_by(getattr(column,sort_order)())
238238

239239
def _get_info(i):
240+
resultd = {}
240241
d = i.to_dict()
241242
if secret_fields:
242243
for k in secret_fields:
@@ -246,7 +247,8 @@ def _get_info(i):
246247
for k in keys:
247248
if k not in model_column_set:
248249
del d[k]
249-
return d
250+
resultd[model_name] = d
251+
return resultd
250252
l = [_get_info(i) for i in q]
251253
self.rdict[key] = l
252254

0 commit comments

Comments
 (0)