Skip to content

Commit

Permalink
Merge pull request #123 from newpanjing/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
newpanjing authored Jul 22, 2019
2 parents 67e0313 + 4fd3047 commit bd1e05f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
django_simpleui.egg-info
dist
2 changes: 1 addition & 1 deletion simpleui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def get_version():
return '2.5'
return '2.6'
26 changes: 24 additions & 2 deletions simpleui/static/admin/simpleui-x/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@
}
});
}
/*,
tabs: function (newValue, oldValue) {

//改变tab时把状态储存到sessionStorage
console.log(newValue)
}*/
},
created: function () {

Expand Down Expand Up @@ -245,12 +251,27 @@
fontEvents.push(handler);
}
}
var temp_tabs = sessionStorage['tabs'];

if(location.hash!=''){
if (temp_tabs && temp_tabs != '') {
this.tabs = JSON.parse(temp_tabs);
console.log(this.tabs)
}
if (location.hash != '') {
openByHash();
}

//elementui布局问题导致页面不能正常撑开调用resize使其重新计算
if(window.onresize){
window.onresize();
}
},
methods: {
syncTabs: function () {
if (window.sessionStorage) {
sessionStorage['tabs'] = JSON.stringify(this.tabs);
}
},
reset: function () {
this.fontSlider = 14;
fontConfig.fontSize = 0;
Expand Down Expand Up @@ -350,6 +371,7 @@
if (targetName != 0) {
this.tabs = this.tabs.filter(tab => tab.id !== targetName);
}
this.syncTabs();
}
}
,
Expand Down Expand Up @@ -380,7 +402,7 @@
this.tabModel = data.id;
}
changeUrl(data)

this.syncTabs();
}
,
foldClick: function () {
Expand Down
4 changes: 2 additions & 2 deletions simpleui/templates/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
@tab-click="tabClick">

<el-tab-pane v-for="(item,index) in tabs" :closable="index!=0" :label="item.name" :name="item.id"
:key="item.id">
:key="item.id" lazy="true">

{% home_page %}

Expand Down Expand Up @@ -310,7 +310,7 @@
<script type="text/javascript" src="{% static '/admin/simpleui-x/js/cookie.js' %}"></script>
<script type="text/javascript" src="{% static '/admin/simpleui-x/theme/theme.js' %}"></script>
<script type="text/javascript" src="{% static '/admin/simpleui-x/waves/waves.min.js' %}?_=2.0.5"></script>
<script type="text/javascript" src="{% static '/admin/simpleui-x/js/index.js' %}?_=2.3"></script>
<script type="text/javascript" src="{% static '/admin/simpleui-x/js/index.js' %}?_=2.6"></script>

{% load_analysis %}
{% block script %}
Expand Down
9 changes: 6 additions & 3 deletions simpleui/templatetags/simpletags.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def custom_button(context):
values = {}
fun = actions.get(name)[0]
for key, v in fun.__dict__.items():
if key != '__len__':
if key != '__len__' and key != '__wrapped__':
values[key] = v
data[name] = values
return json.dumps(data, cls=LazyEncoder)
Expand All @@ -381,8 +381,6 @@ def get_model_fields(model, base=None):
list.append(('{}__{}'.format(base, f.name), label))
else:
list.append((f.name, label))
if isinstance(f, ForeignKey):
list.extend(get_model_fields(f.related_model, f.name))

return list

Expand All @@ -391,8 +389,13 @@ def get_model_fields(model, base=None):
def search_placeholder(context):
cl = context.get('cl')

# 取消递归,只获取2级
fields = get_model_fields(cl.model)

for f in cl.model._meta.fields:
if isinstance(f, ForeignKey):
fields.extend(get_model_fields(f.related_model, f.name))

verboses = []

for s in cl.search_fields:
Expand Down

0 comments on commit bd1e05f

Please sign in to comment.