From afaba9f1b1a302700c19f5aa1c6ce6e85e96258a Mon Sep 17 00:00:00 2001 From: Ymox Date: Fri, 8 Dec 2017 10:46:19 +0100 Subject: [PATCH 1/5] Adds a missing `use` statement --- views/default/_message-tabs.php | 1 + 1 file changed, 1 insertion(+) diff --git a/views/default/_message-tabs.php b/views/default/_message-tabs.php index 1dfca04..90f9f6e 100644 --- a/views/default/_message-tabs.php +++ b/views/default/_message-tabs.php @@ -2,6 +2,7 @@ use yii\helpers\Html; use yii\bootstrap\Tabs; +use uran1980\yii\modules\i18n\Module; $items = []; From a8c5b9bea428912deee4d7529af4963a32aec84f Mon Sep 17 00:00:00 2001 From: Ymox Date: Fri, 8 Dec 2017 10:47:57 +0100 Subject: [PATCH 2/5] Use parent::findModel in restore and delete actions --- controllers/DefaultController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/DefaultController.php b/controllers/DefaultController.php index cb79739..354be90 100644 --- a/controllers/DefaultController.php +++ b/controllers/DefaultController.php @@ -128,7 +128,7 @@ public function actionDelete($id) ); // -------------------- DELETE TRANSLATION BY ID ----------------------- - $model = $this->findModel($id); + $model = parent::findModel($id); $model->message = '@@' . $model->message . '@@'; if ( $model->save() ) { // clear cache @@ -166,7 +166,7 @@ public function actionRestore($id) ); // -------------------- RESTORE TRANSLATION BY ID ---------------------- - $model = $this->findModel($id); + $model = parent::findModel($id); $model->message = trim($model->message, '@@'); if ( $model->save() ) { // clear cache From 76ddcbdc581ecf78193f43038b5991db42f8b84e Mon Sep 17 00:00:00 2001 From: Ymox Date: Thu, 28 Dec 2017 01:42:18 +0100 Subject: [PATCH 3/5] Adds an index existence verification --- views/default/_message-tabs.php | 2 +- views/default/update.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/views/default/_message-tabs.php b/views/default/_message-tabs.php index 90f9f6e..8ab0f65 100644 --- a/views/default/_message-tabs.php +++ b/views/default/_message-tabs.php @@ -18,7 +18,7 @@ 'dir' => (in_array($lang, ['ar', 'fa']) ? 'rtl' : 'ltr'), 'rows' => 3, ]; - if (!Yii::$app->i18n->translations[$model->category]->forceTranslation && Yii::$app->sourceLanguage == $lang) { + if (isset(Yii::$app->i18n->translations[$model->category]) && !Yii::$app->i18n->translations[$model->category]->forceTranslation && Yii::$app->sourceLanguage == $lang) { $parameters['disabled'] = 'disabled'; $parameters['title'] = Module::t('Please set [forceTranslation] to true to be able to edit this field'); } diff --git a/views/default/update.php b/views/default/update.php index d87e79b..74d3f4d 100644 --- a/views/default/update.php +++ b/views/default/update.php @@ -29,7 +29,7 @@ ? $model->message : $message->translation); echo $form->field($message, '[' . $language . ']translation', ['options' => ['class' => 'form-group col-sm-6']]) ->textInput( - (!Yii::$app->i18n->translations[$model->category]['forceTranslation'] && Yii::$app->sourceLanguage == $language) + (isset(Yii::$app->i18n->translations[$model->category]['forceTranslation']) && !Yii::$app->i18n->translations[$model->category]['forceTranslation'] && Yii::$app->sourceLanguage == $language) ? ['disabled' => 'disabled', 'title' => Module::t('Please set [forceTranslation] to true to be able to edit this field')] : [] )->label(strtoupper($language)); From 33277085bb9443d41ace1e6f249c548f61382b47 Mon Sep 17 00:00:00 2001 From: Ymox Date: Thu, 28 Dec 2017 01:43:07 +0100 Subject: [PATCH 4/5] Remove confirmation toggle I couldn't make it work --- views/default/index.php | 44 ++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/views/default/index.php b/views/default/index.php index 0462c8a..d4986e5 100644 --- a/views/default/index.php +++ b/views/default/index.php @@ -194,16 +194,18 @@ return '' . Html::a('', str_replace('delete', 'restore', $url), [ 'class' => 'btn btn-xs btn-info btn-ajax', 'action' => 'translation-restore', -// 'title' => Module::t('Restore'), -// 'data-confirm' => Module::t('Are you sure you want to restore this item?'), - 'data-toggle' => 'confirmation', - 'data-singleton' => 'true', - 'data-placement' => 'top', - 'data-btn-ok-lable' => Module::t('Yes'), - 'data-btn-ok-class' => 'btn-xs btn-success', - 'data-btn-cancel' => Module::t('No'), - 'data-btn-cancel-class' => 'btn-xs btn-warning', - 'data-popout' => 'true', + 'data' => [ + //'toggle' => 'confirmation', + 'popout' => true, + 'singleton' => true, + 'placement' => 'left', + 'title' => Module::t('Are you sure you want to restore this item?'), + 'method' => 'post', + 'btn-ok-label' => Module::t('Yes'), + 'btn-ok-class' => 'btn-xs btn-success', + 'btn-cancel' => Module::t('No'), + 'btn-cancel-class' => 'btn-xs btn-warning', + ], 'before-send-title' => Module::t('Request sent'), 'before-send-message' => Module::t('Please, wait...'), 'success-title' => Module::t('Server Response'), @@ -213,16 +215,18 @@ return '' . Html::a('', $url, [ 'class' => 'btn btn-xs btn-danger btn-ajax', 'action' => 'translation-delete', -// 'title' => Module::t('Delete'), -// 'data-confirm' => Module::t('Are you sure you want to delete this item?'), - 'data-toggle' => 'confirmation', - 'data-singleton' => 'true', - 'data-placement' => 'top', - 'data-btn-ok-lable' => Module::t('Yes'), - 'data-btn-ok-class' => 'btn-xs btn-success', - 'data-btn-cancel' => Module::t('No'), - 'data-btn-cancel-class' => 'btn-xs btn-warning', - 'data-popout' => 'true', + 'data' => [ + //'toggle' => 'confirmation', + 'popout' => true, + 'singleton' => true, + 'placement' => 'left', + 'title' => Module::t('Are you sure you want to restore this item?'), + 'method' => 'post', + 'btn-ok-label' => Module::t('Yes'), + 'btn-ok-class' => 'btn-xs btn-success', + 'btn-cancel' => Module::t('No'), + 'btn-cancel-class' => 'btn-xs btn-warning', + ], 'before-send-title' => Module::t('Request sent'), 'before-send-message' => Module::t('Please, wait...'), 'success-title' => Module::t('Server Response'), From fe7c47ee4994d67035e1c07f32e25d3e14b00bbb Mon Sep 17 00:00:00 2001 From: Ymox Date: Thu, 28 Dec 2017 01:43:40 +0100 Subject: [PATCH 5/5] Update composer version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 882a002..f27935a 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name" : "uran1980/yii2-translate-panel", "description" : "Yii2 Translate Panel makes the translation of your application awesome!", - "version" : "0.1.30", + "version" : "0.1.31", "type" : "yii2-extension", "keywords" : [ "yii2",