diff --git a/QUICK.md b/QUICK.md index 30270fce..945a45b1 100644 --- a/QUICK.md +++ b/QUICK.md @@ -463,6 +463,46 @@ class EmployeAdmin(admin.ModelAdmin): |type|按钮类型,参考:https://element.eleme.cn/#/zh-CN/component/button| |style|自定义css样式| ++ 链接按钮 + +> 在2.9或以上版本中生效 + +|字段|说明| +|------|------| +|action_type|按钮动作类型,0=当前页内打开,1=新tab打开,2=浏览器tab打开| +|action_url|按钮访问链接| + +demo: +```python + # 增加自定义按钮 + actions = ['custom_button'] + + def custom_button(self, request, queryset): + pass + + # 显示的文本,与django admin一致 + custom_button.short_description = '测试按钮' + # icon,参考element-ui icon与https://fontawesome.com + custom_button.icon = 'fas fa-audio-description' + + # 指定element-ui的按钮类型,参考https://element.eleme.cn/#/zh-CN/component/button + custom_button.type = 'danger' + + # 给按钮追加自定义的颜色 + custom_button.style = 'color:black;' + + # 链接按钮,设置之后直接访问该链接 + # 3中打开方式 + # action_type 0=当前页内打开,1=新tab打开,2=浏览器tab打开 + # 设置了action_type,不设置url,页面内将报错 + # 设置成链接类型的按钮后,custom_button方法将不会执行。 + + custom_button.action_type = 0 + custom_button.action_url = 'http://www.baidu.com' + +``` + + ## 离线模式 > 在2.1.3或以上的版本中生效 在settings.py中加入 diff --git a/doc/en/QUICK_en.md b/doc/en/QUICK_en.md index d2873772..d1257a4d 100644 --- a/doc/en/QUICK_en.md +++ b/doc/en/QUICK_en.md @@ -431,6 +431,15 @@ Configuration compatible with native admin |type|Button type,Reference:https://element.eleme.cn/#/zh-CN/component/button| |style|Customize CSS styles| ++ Link Button + +> Requires version 2.9 or above + +|Field|Description| +|------|------| +|action_type|0=The current page, 1=Simpleui New tab,2=Browser new tab| +|action_url|The url address| + ## Offline > Requires version 2.1.3 or above diff --git a/simpleui/__init__.py b/simpleui/__init__.py index 8ced7434..094f43c8 100644 --- a/simpleui/__init__.py +++ b/simpleui/__init__.py @@ -1,2 +1,2 @@ def get_version(): - return '2.8' + return '2.9' diff --git a/simpleui/static/admin/simpleui-x/js/index.js b/simpleui/static/admin/simpleui-x/js/index.js index 0fa0cee0..d005f179 100644 --- a/simpleui/static/admin/simpleui-x/js/index.js +++ b/simpleui/static/admin/simpleui-x/js/index.js @@ -4,8 +4,6 @@ } window.addEventListener('hashchange', function (e) { - // console.log(e) - // console.log('hash') if (e.newURL != e.oldURL) { openByHash() } @@ -25,7 +23,9 @@ } function changeUrl(data) { - location.href = '#' + (data.url || '/') + if(data.url.indexOf('http')!=0){ + location.href = '#' + (data.url || '/') + } } window.callback = function () { diff --git a/simpleui/templates/admin/actions.html b/simpleui/templates/admin/actions.html index 5cb6de71..4f5eaf87 100644 --- a/simpleui/templates/admin/actions.html +++ b/simpleui/templates/admin/actions.html @@ -32,7 +32,8 @@ {{ field.1 }} {% else %} - {{ field.1 }} {% endif %} @@ -58,7 +59,8 @@ {{ selection_note_all }} {% blocktrans with cl.result_count as total_count %}Select all {{ total_count }} {{ module_name }}{% endblocktrans %} + title="{% trans "Click here to select the objects across all pages" %}">{% blocktrans with cl.result_count as total_count %} + Select all {{ total_count }} {{ module_name }}{% endblocktrans %} {% trans "Clear selection" %} @@ -68,9 +70,12 @@ {% endblock %} - - - + + + @@ -80,13 +85,12 @@ {% else %} - +{# #} + {% endif %} diff --git a/simpleui/templates/admin/index.html b/simpleui/templates/admin/index.html index df0d5393..220ca653 100755 --- a/simpleui/templates/admin/index.html +++ b/simpleui/templates/admin/index.html @@ -312,7 +312,7 @@ - + {% load_analysis %} diff --git a/simpleui/templatetags/simpletags.py b/simpleui/templatetags/simpletags.py index 58401b5d..c26fceb6 100644 --- a/simpleui/templatetags/simpletags.py +++ b/simpleui/templatetags/simpletags.py @@ -353,14 +353,19 @@ def custom_button(context): # if hasattr(admin, 'actions'): # actions = admin.actions # 输出自定义按钮的属性 + if actions: + id = 0 for name in actions: values = {} fun = actions.get(name)[0] for key, v in fun.__dict__.items(): if key != '__len__' and key != '__wrapped__': values[key] = v + values['eid'] = id + id += 1 data[name] = values + return json.dumps(data, cls=LazyEncoder)