Skip to content

Commit

Permalink
Merge pull request #179 from newpanjing/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
newpanjing authored Nov 16, 2019
2 parents 5c86aad + fefc733 commit 9d96b8b
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 61 deletions.
13 changes: 13 additions & 0 deletions QUICK.md
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,19 @@ class EmployeAdmin(admin.ModelAdmin):
|icon|按钮图标,参考https://element.eleme.cn/#/zh-CN/component/icon与https://fontawesome.com,把class 复制进来即可|
|type|按钮类型,参考:https://element.eleme.cn/#/zh-CN/component/button|
|style|自定义css样式|
|confirm|弹出确认框,在3.4或以上版本中生效|

+ confirm 例子

```python
def message_test(self, request, queryset):
messages.add_message(request, messages.SUCCESS, '操作成功123123123123')
# 给按钮增加确认
message_test.confirm = '你是否执意要点击这个按钮?'
```



+ 链接按钮

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,6 @@ simpleui的发展离不开以下优秀贡献者的支持。如果您想为simple
|[@shouyong](https://github.com/shouyong)|bug修复|
|[@Roddy1219](https://github.com/Roddy1219)|bug修复|
|[@WalkerWang731](https://github.com/WalkerWang731)|优质代码贡献|
# 致谢
开发工具由[Jetbrains](https://www.jetbrains.com/)赞助的Pycharm
12 changes: 12 additions & 0 deletions doc/en/QUICK_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,18 @@ Configuration compatible with native admin
|icon|Button icon,Reference:https://element.eleme.cn/#/zh-CN/component/icon and https://fontawesome.com,copy class|
|type|Button type,Reference:https://element.eleme.cn/#/zh-CN/component/button|
|style|Customize CSS styles|
|confirm|Requires version 3.4 or above|

+ confirm demo

```python
def message_test(self, request, queryset):
messages.add_message(request, messages.SUCCESS, 'Success')
# Add confirmation to button
message_test.confirm = 'Are you sure?'
```


+ Link Button

Expand Down
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 '3.3'
return '3.4'
4 changes: 1 addition & 3 deletions simpleui/static/admin/simpleui-x/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,6 @@
if (data.breadcrumbs) {
this.breadcrumbs = data.breadcrumbs;
}


//如果data没有eid就直接打开或者添加根据url
if (!data.eid) {
data.eid = new Date().getTime() + "" + Math.random();
Expand All @@ -465,7 +463,7 @@
//判断是否存在存在就直接打开
for (var i = 0; i < this.tabs.length; i++) {
var tab = this.tabs[i];
if (tab.id == data.eid) {
if (tab.eid == data.eid) {
exists = tab;
continue;
}
Expand Down
117 changes: 67 additions & 50 deletions simpleui/templates/admin/actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
{% else %}
<el-button :eid="customButton.{{ field.0 }}.eid"
:icon="customButton.{{ field.0 }}.icon" :style="customButton.{{ field.0 }}.style"
:confirm="customButton.{{ field.0 }}.confirm"
:type="customButton.{{ field.0 }}.type" data-name="{{ field.0 }}">{{ field.1 }}
</el-button>
{% endif %}
Expand Down Expand Up @@ -236,64 +237,80 @@
$(".actions button[data-name!='delete_selected']").click(function () {
var url = $(this).attr("url");
var eid = $(this).attr('eid');
if (eid) {
for (var i in _action.customButton) {
var temp = _action.customButton[i];
if (temp.eid == eid) {
var confirm = $(this).attr('confirm');

if (typeof(temp.action_type)!='undefined') {
if (confirm) {
new Vue().$confirm(confirm, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => done());

if (!temp.action_url) {
this.$notify({
title: 'error',
message: 'action must contain attributes:action_url! ',
type: 'error',
dangerouslyUseHTMLString: true
});
return;
}
} else {
done();
}

switch (temp.action_type) {
case 0:
window.location.href = temp.action_url;
break;
case 1:
parent.window.app.openTab({
url: temp.action_url,
icon: temp.icon || 'fa fa-file',
name: temp.short_description,
breadcrumbs: []
function done() {

if (eid) {
for (var i in _action.customButton) {
var temp = _action.customButton[i];
if (temp.eid == eid) {

if (typeof (temp.action_type) != 'undefined') {

if (!temp.action_url) {
this.$notify({
title: 'error',
message: 'action must contain attributes:action_url! ',
type: 'error',
dangerouslyUseHTMLString: true
});
break;
case 2:
window.open(temp.action_url)
break;
return;
}

switch (temp.action_type) {
case 0:
window.location.href = temp.action_url;
break;
case 1:
parent.window.app.openTab({
url: temp.action_url,
icon: temp.icon || 'fa fa-file',
name: temp.short_description,
breadcrumbs: []
});
break;
case 2:
window.open(temp.action_url)
break;
}
console.log('中断后续操作')
return;
}
console.log('中断后续操作')
return;
}
}
}
}
console.log('执行了')
if (url) {
window.location.href = url;
return;
} else if ($(this).attr('data-name')) {
var name = $(this).attr("data-name");
$("#changelist-form input[name='action']").val(name);

$("#changelist-form [name='_save']").removeAttr('name');

$("#changelist-form [name!='']").each(function () {
var obj = $(this);
if (obj.attr('name') && obj.attr('name').indexOf('form-') == 0) {
obj.removeAttr('name');
}
});
$("#changelist-form").submit();
} else {
$("#changelist-form").submit();
console.log('执行了')
if (url) {
window.location.href = url;
return;
} else if ($(this).attr('data-name')) {
var name = $(this).attr("data-name");
$("#changelist-form input[name='action']").val(name);

$("#changelist-form [name='_save']").removeAttr('name');

$("#changelist-form [name!='']").each(function () {
var obj = $(this);
if (obj.attr('name') && obj.attr('name').indexOf('form-') == 0) {
obj.removeAttr('name');
}
});
$("#changelist-form").submit();
} else {
$("#changelist-form").submit();
}
}
});
});
Expand Down
14 changes: 8 additions & 6 deletions simpleui/templates/admin/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@
var self = this;

messages.forEach(item => {
self.$notify({
title: getLanuage('Tips'),
message: item.msg,
type: item.tag,
dangerouslyUseHTMLString: true
});
setTimeout(function () {
self.$notify({
title: getLanuage('Tips'),
message: item.msg,
type: item.tag,
dangerouslyUseHTMLString: true
});
}, 200);
});

}
Expand Down
2 changes: 1 addition & 1 deletion simpleui/templates/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
<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>
{% block index_js %}
<script type="text/javascript" src="{% static '/admin/simpleui-x/js/index.js' %}?_=3.3"></script>
<script type="text/javascript" src="{% static '/admin/simpleui-x/js/index.js' %}?_=3.4"></script>
{% endblock %}
{% block autoupdate %}
{% if not "SIMPLEUI_STATIC_OFFLINE"|get_config %}
Expand Down

0 comments on commit 9d96b8b

Please sign in to comment.