From dd78092669a51b357e8f4f421f7a261821425c98 Mon Sep 17 00:00:00 2001 From: soul11201 Date: Tue, 28 May 2019 20:41:52 +0800 Subject: [PATCH] localizations support copy from https://github.com/mdmsoft/yii2-admin/pull/368 in ./views/assignnets/view.php and ./views/item/view.php add $labels - localization support js. Update _script.js too. --- views/assignment/_script.js | 7 +++++-- views/assignment/view.php | 6 ++++++ views/item/_script.js | 7 ++++--- views/item/view.php | 8 ++++++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/views/assignment/_script.js b/views/assignment/_script.js index 7db4674c..a9958b84 100644 --- a/views/assignment/_script.js +++ b/views/assignment/_script.js @@ -31,10 +31,13 @@ function search(target) { $list.html(''); var q = $('.search[data-target="' + target + '"]').val(); + var groups = { - role: [$(''), false], - permission: [$(''), false], + role: [$(''), false], + permission: [$(''), false], }; + + $.each(_opts.items[target], function (name, group) { if (name.indexOf(q) >= 0) { diff --git a/views/assignment/view.php b/views/assignment/view.php index 82e91c7c..43c3c786 100644 --- a/views/assignment/view.php +++ b/views/assignment/view.php @@ -26,7 +26,13 @@ $opts = Json::htmlEncode([ 'items' => $model->getItems(), ]); +$labels = Json::htmlEncode([ + 'Roles' => Yii::t('rbac-admin', 'Roles'), + 'Permissions' => Yii::t('rbac-admin', 'Permissions'), +]); + $this->registerJs("var _opts = {$opts};"); +$this->registerJs("var _labels = {$labels};"); $this->registerJs($this->render('_script.js')); $animateIcon = ' '; ?> diff --git a/views/item/_script.js b/views/item/_script.js index 6736f733..3c1537d1 100644 --- a/views/item/_script.js +++ b/views/item/_script.js @@ -33,10 +33,11 @@ function search(target) { var q = $('.search[data-target="' + target + '"]').val(); var groups = { - role: [$(''), false], - permission: [$(''), false], - route: [$(''), false], + role: [$(''), false], + permission: [$(''), false], + route: [$(''), false], }; + $.each(_opts.items[target], function (name, group) { if (name.indexOf(q) >= 0) { diff --git a/views/item/view.php b/views/item/view.php index a8b7b565..ea20dc2b 100644 --- a/views/item/view.php +++ b/views/item/view.php @@ -22,6 +22,14 @@ 'items' => $model->getItems(), ]); $this->registerJs("var _opts = {$opts};"); + +$labels = Json::htmlEncode([ + 'Roles' => Yii::t('rbac-admin', 'Roles'), + 'Permissions' => Yii::t('rbac-admin', 'Permissions'), + 'Routes' => Yii::t('rbac-admin', 'Routes'), +]); +$this->registerJs("var _labels = {$labels};"); + $this->registerJs($this->render('_script.js')); $animateIcon = ' '; ?>