From 181f163cb559e4dd7420f95ed612f81253d08714 Mon Sep 17 00:00:00 2001 From: Ivan Kristianto Date: Sat, 12 Feb 2022 10:40:37 +0700 Subject: [PATCH] Move render showEmpty into function --- frontend/js/app/nginx/redirection/main.js | 28 +++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/frontend/js/app/nginx/redirection/main.js b/frontend/js/app/nginx/redirection/main.js index 8d1a5da9..1f5351a7 100644 --- a/frontend/js/app/nginx/redirection/main.js +++ b/frontend/js/app/nginx/redirection/main.js @@ -38,6 +38,21 @@ module.exports = Mn.View.extend({ console.error(err); }, + showEmpty: function() { + let manage = App.Cache.User.canManage('redirection_hosts'); + + this.showChildView('list_region', new EmptyView({ + title: App.i18n('redirection-hosts', 'empty'), + subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}), + link: manage ? App.i18n('redirection-hosts', 'add') : null, + btn_color: 'yellow', + permission: 'redirection_hosts', + action: function () { + App.Controller.showNginxRedirectionForm(); + } + })); + }, + regions: { list_region: '@ui.list_region' }, @@ -78,18 +93,7 @@ module.exports = Mn.View.extend({ if (response && response.length) { view.showData(response); } else { - let manage = App.Cache.User.canManage('redirection_hosts'); - - view.showChildView('list_region', new EmptyView({ - title: App.i18n('redirection-hosts', 'empty'), - subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}), - link: manage ? App.i18n('redirection-hosts', 'add') : null, - btn_color: 'yellow', - permission: 'redirection_hosts', - action: function () { - App.Controller.showNginxRedirectionForm(); - } - })); + view.showEmpty(); } } })