From 0426723a3e512b93eb84228ba43f7c852f172bb5 Mon Sep 17 00:00:00 2001 From: Gihovani Filipp Date: Thu, 27 May 2021 10:55:00 -0300 Subject: [PATCH] feat: configuracao para tempo de remover cookie --- Helper/Data.php | 5 +- Model/Config/Source/Icon.php | 12 +-- Model/Config/Source/Position.php | 16 ++-- Model/Config/Source/TextAlignment.php | 8 +- Model/Config/Source/Transition.php | 8 +- README.md | 7 +- composer.json | 2 +- etc/adminhtml/system.xml | 104 +++++++++++++------------- etc/config.xml | 1 + etc/module.xml | 2 +- i18n/en_US.csv | 46 +++++++++--- i18n/pt_BR.csv | 64 ++++++++++------ view/frontend/web/js/toast-message.js | 14 ++-- 13 files changed, 171 insertions(+), 118 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 36f18b1..6a30abd 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -14,6 +14,7 @@ class Data extends AbstractHelper const TYPE_INFO = 'info'; const XML_PATH_ACTIVE = 'gg2_toast/%s/active'; + const XML_PATH_REMOVECOOKIEAFTER = 'gg2_toast/%s/removeCookieAfter'; const XML_PATH_POSITION = 'gg2_toast/%s/position'; const XML_PATH_BGCOLOR = 'gg2_toast/%s/bgColor'; const XML_PATH_ICON = 'gg2_toast/%s/icon'; @@ -53,7 +54,9 @@ public function getSettings(): array return []; } - $options = []; + $options = [ + 'removeCookieAfter' => $this->getConfig('general', self::XML_PATH_REMOVECOOKIEAFTER), + ]; foreach (['success', 'notice', 'warning', 'error', 'info'] as $type) { $options[$type] = [ 'position' => $this->getConfig($type, self::XML_PATH_POSITION), diff --git a/Model/Config/Source/Icon.php b/Model/Config/Source/Icon.php index f00943c..c39efe5 100644 --- a/Model/Config/Source/Icon.php +++ b/Model/Config/Source/Icon.php @@ -9,18 +9,18 @@ class Icon extends DataObject implements OptionSourceInterface { /** - * Generate list of email templates + * Generate list of email Icons * * @return array */ public function toOptionArray(): array { return [ - ['value' => '', 'label' => 'No Icon'], - ['value' => 'success', 'label' => 'Success'], - ['value' => 'error', 'label' => 'Error'], - ['value' => 'warning', 'label' => 'Warning'], - ['value' => 'info', 'label' => 'Info'], + ['value' => '', 'label' => __('No Icon')], + ['value' => 'success', 'label' => __('Success')], + ['value' => 'error', 'label' => __('Error')], + ['value' => 'warning', 'label' => __('Warning')], + ['value' => 'info', 'label' => __('Info')], ]; } } diff --git a/Model/Config/Source/Position.php b/Model/Config/Source/Position.php index d97cf9c..c604819 100644 --- a/Model/Config/Source/Position.php +++ b/Model/Config/Source/Position.php @@ -8,20 +8,20 @@ class Position extends DataObject implements OptionSourceInterface { /** - * Generate list of email templates + * Generate list of Positions * * @return array */ public function toOptionArray(): array { return [ - ['value' => 'top-left', 'label' => 'Top Left'], - ['value' => 'top-center', 'label' => 'Top Center'], - ['value' => 'top-right', 'label' => 'Top Right'], - ['value' => 'mid-center', 'label' => 'Center'], - ['value' => 'bottom-left', 'label' => 'Bottom Left'], - ['value' => 'bottom-center', 'label' => 'Bottom Center'], - ['value' => 'bottom-right', 'label' => 'Bottom Right'] + ['value' => 'top-left', 'label' => __('Top Left')], + ['value' => 'top-center', 'label' => __('Top Center')], + ['value' => 'top-right', 'label' => __('Top Right')], + ['value' => 'mid-center', 'label' => __('Center')], + ['value' => 'bottom-left', 'label' => __('Bottom Left')], + ['value' => 'bottom-center', 'label' => __('Bottom Center')], + ['value' => 'bottom-right', 'label' => __('Bottom Right')] ]; } } diff --git a/Model/Config/Source/TextAlignment.php b/Model/Config/Source/TextAlignment.php index bd4d541..e6a113c 100644 --- a/Model/Config/Source/TextAlignment.php +++ b/Model/Config/Source/TextAlignment.php @@ -8,16 +8,16 @@ class TextAlignment extends DataObject implements OptionSourceInterface { /** - * Generate list of email templates + * Generate list of Text Alignment * * @return array */ public function toOptionArray(): array { return [ - ['value' => 'left', 'label' => 'Left'], - ['value' => 'right', 'label' => 'Right'], - ['value' => 'center', 'label' => 'Center'], + ['value' => 'left', 'label' => __('Left')], + ['value' => 'right', 'label' => __('Right')], + ['value' => 'center', 'label' => __('Center')], ]; } } diff --git a/Model/Config/Source/Transition.php b/Model/Config/Source/Transition.php index 6cd271c..884d402 100644 --- a/Model/Config/Source/Transition.php +++ b/Model/Config/Source/Transition.php @@ -8,16 +8,16 @@ class Transition extends DataObject implements OptionSourceInterface { /** - * Generate list of email templates + * Generate list of Transitions * * @return array */ public function toOptionArray(): array { return [ - ['value' => 'fade', 'label' => 'Fade'], - ['value' => 'slide', 'label' => 'Slide'], - ['value' => 'plain', 'label' => 'Plain'], + ['value' => 'fade', 'label' => __('Fade')], + ['value' => 'slide', 'label' => __('Slide')], + ['value' => 'plain', 'label' => __('Plain')], ]; } } diff --git a/README.md b/README.md index 1e2afab..6c42119 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,11 @@ Changelog - Configuração das cores via painel admin 1.1.0 -- Adicionado o toast nas mensagens de checkout - +- Adicionado o toast nas mensagens de checkout +1.1.1 +- Adicionado timer para remover o cookie e eliminar mensagens duplicadas +1.1.2 +- Criado configuracao para remover o cookie, ajustes na tradução Contribuições ------------- diff --git a/composer.json b/composer.json index 94d2b17..85cb2d8 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "php": "~7.3.0|~7.4.0" }, "type": "magento2-module", - "version": "1.1.1", + "version": "1.1.2", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index e78a544..dcf3b6b 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -12,224 +12,228 @@ Magento\Config\Model\Config\Source\Yesno + + + in ms + - + - + Default Top Center Gg2\ToastMessage\Model\Config\Source\Position - + Default: #02c23c Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + Default: #fff Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + Default: None Gg2\ToastMessage\Model\Config\Source\Icon - + Magento\Config\Model\Config\Source\Yesno - + Default: #fff Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + in ms - + Default: Slide Gg2\ToastMessage\Model\Config\Source\Transition - + - + - + Default Bottom Center Gg2\ToastMessage\Model\Config\Source\Position - + Default: #f79200 Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + Default: #fff Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + Default: None Gg2\ToastMessage\Model\Config\Source\Icon - + Magento\Config\Model\Config\Source\Yesno - + Default: #fff Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + in ms - + Default: Slide Gg2\ToastMessage\Model\Config\Source\Transition - + - + - + Default Bottom Center Gg2\ToastMessage\Model\Config\Source\Position - + Default: #f79200 Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + Default: #fff Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + Default: None Gg2\ToastMessage\Model\Config\Source\Icon - + Magento\Config\Model\Config\Source\Yesno - + Default: #fff Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + in ms - + Default: Slide Gg2\ToastMessage\Model\Config\Source\Transition - + - + - + Default Bottom Center Gg2\ToastMessage\Model\Config\Source\Position - + Default: #e61c24 Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + Default: #fff Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + Default: None Gg2\ToastMessage\Model\Config\Source\Icon - + Magento\Config\Model\Config\Source\Yesno - + Default: #fff Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + in ms - + Default: Slide Gg2\ToastMessage\Model\Config\Source\Transition - + - + - + Default Bottom Center Gg2\ToastMessage\Model\Config\Source\Position - + Default: #0085d6 Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + Default: #fff Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + Default: None Gg2\ToastMessage\Model\Config\Source\Icon - + Magento\Config\Model\Config\Source\Yesno - + Default: #fff Gg2\ToastMessage\Block\Adminhtml\System\Config\ColorPicker - + in ms - + Default: Slide Gg2\ToastMessage\Model\Config\Source\Transition - + diff --git a/etc/config.xml b/etc/config.xml index c066120..8bb811a 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -4,6 +4,7 @@ 1 + 3000 top-center diff --git a/etc/module.xml b/etc/module.xml index 9970a48..1294d18 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,4 +1,4 @@ - + diff --git a/i18n/en_US.csv b/i18n/en_US.csv index b13167b..e9b1073 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -1,22 +1,44 @@ -"Enable Toast Message","Enable Toast Message" +"No Icon","No Icon" +Success,Success +Error,Error +Warning,Warning +Info,Info +"Top Left","Top Left" +"Top Center","Top Center" +"Top Right","Top Right" +Center,Center +"Bottom Left","Bottom Left" +"Bottom Center","Bottom Center" +"Bottom Right","Bottom Right" +Left,Left +Right,Right +Fade,Fade +Slide,Slide +Plain,Plain "General Options","General Options" +"Enable Toast Message","Enable Toast Message" +"Remove the Cookie After","Remove the Cookie After" +"in ms","in ms" "Success Message Options","Success Message Options" Position,Position -"Default Bottom Center","Default Bottom Center" +"Default Top Center","Default Top Center" "Background Color","Background Color" -"Default Green: #e5efe5","Default Green: #e5efe5" +"Default: #02c23c","Default: #02c23c" "Font Color","Font Color" -"Default Green: #006400","Default Green: #006400" +"Default: #fff","Default: #fff" "Display Icon","Display Icon" +"Default: None","Default: None" +Loader,Loader +"Loader Background Color","Loader Background Color" +"Hide After","Hide After" +Transition,Transition +"Default: Slide","Default: Slide" +Heading,Heading "Notice Message Options","Notice Message Options" -"Default Brown: #e5efe5","Default Brown: #e5efe5" -"Default Brown: #6f4400","Default Brown: #6f4400" +"Default Bottom Center","Default Bottom Center" +"Default: #f79200","Default: #f79200" "Warning Message Options","Warning Message Options" -"Default Yellow: #fdf0d5","Default Yellow: #fdf0d5" -"Default Yellow: #6f4400","Default Yellow: #6f4400" "Error Message Options","Error Message Options" -"Default Red: #fae5e5","Default Red: #fae5e5" -"Default Red: #e02b27","Default Red: #e02b27" +"Default: #e61c24","Default: #e61c24" "Info Message Options","Info Message Options" -"Default Blue: #fdf0d5","Default Blue: #fdf0d5" -"Default Blue: #6f4400","Default Blue: #6f4400" +"Default: #0085d6","Default: #0085d6" diff --git a/i18n/pt_BR.csv b/i18n/pt_BR.csv index e895379..a9bf42f 100644 --- a/i18n/pt_BR.csv +++ b/i18n/pt_BR.csv @@ -1,22 +1,44 @@ -"Enable Toast Message","Habilitar Toast Message" -"General Options","Opções Gerais" -"Success Message Options","Conf. Mensagem de Sucesso" -Position,"Posição" -"Default Bottom Center","Padrão Bottom Center" -"Background Color","Cor do Fundo" -"Default Green: #e5efe5","Padrão Verde: #e5efe5" +"No Icon","Sem ícone" +"Success","Sucesso" +"Error","Erro" +"Warning","Aviso" +"Info","Informações" +"Top Left","Canto Superior Esquerdo" +"Top Center","Centro Superior" +"Top Right","Canto Superior Direito" +"Center","Centro" +"Bottom Left","Inferior Esquerdo" +"Bottom Center","Centro Inferior" +"Bottom Right","Canto Inferior Direito" +"Left","Esquerda" +"Right","Direito" +"Fade","Desaparecer" +"Slide","Slide" +"Plain","Simples" +"General Options","Opções Ggerais" +"Enable Toast Message","Habilitar Mensagem de Toast" +"Remove the Cookie After","Remova o Cookie Após" +"in ms","em ms" +"Success Message Options","Opções de Mensagem de Sucesso" +"Position","Posição" +"Default Top Center","Centro Superior Padrão" +"Background Color","Cor de Fundo" +"Default: #02c23c","Padrão: #02c23c" "Font Color","Cor da Fonte" -"Default Green: #006400","Padrão Verde: #006400" -"Display Icon","Mostrar Ícone" -"Notice Message Options","Conf. Mensagem de Notificação" -"Default Brown: #e5efe5","Padrão Marrom: #e5efe5" -"Default Brown: #6f4400","Padrão Marrom: #6f4400" -"Warning Message Options","Conf. Mensagem de Alerta" -"Default Yellow: #fdf0d5","Padrão Amarelo: #fdf0d5" -"Default Yellow: #6f4400","Padrão Amarelo: #6f4400" -"Error Message Options","Conf. Mensagem de Erro" -"Default Red: #fae5e5","Padrão Vermelho: #fae5e5" -"Default Red: #e02b27","Padrão Vermelho: #e02b27" -"Info Message Options","Conf. Mensagem de Informação" -"Default Blue: #fdf0d5","Padrão Azul: #fdf0d5" -"Default Blue: #6f4400","Padrão Azul: #6f4400" +"Default: #fff","Padrão: #fff" +"Display Icon","Ícone de Exibição" +"Default: None","Padrão: Nenhum" +"Loader","Carregador" +"Loader Background Color","Cor de Fundo do Carregador" +"Hide After","Esconder Depois" +"Transition","Transição" +"Default: Slide","Padrão: Slide" +"Heading","Cabeçalho" +"Notice Message Options","Opções de Mensagem de Aviso" +"Default Bottom Center","Centro inferior Padrão" +"Default: #f79200","Padrão: #f79200" +"Warning Message Options","Opções de Mensagem de Aviso" +"Error Message Options","Opções de Mensagem de Erro" +"Default: #e61c24","Padrão: #e61c24" +"Info Message Options","Opções de Mensagem Informativa" +"Default: #0085d6","Padrão: #0085d6" diff --git a/view/frontend/web/js/toast-message.js b/view/frontend/web/js/toast-message.js index 7837e3a..b6da501 100644 --- a/view/frontend/web/js/toast-message.js +++ b/view/frontend/web/js/toast-message.js @@ -43,14 +43,12 @@ define([ }, delayClearCookie: function () { let defaultDelay = 1000; - for (let type in this.settings) { - if ( - this.settings.hasOwnProperty(type) && - this.settings[type].hasOwnProperty('hideAfter') && - defaultDelay < parseInt(this.settings[type]['hideAfter']) - ) { - defaultDelay = parseInt(this.settings[type]['hideAfter']); - } + if ( + this.settings.hasOwnProperty('general') && + this.settings['general'].hasOwnProperty('removeCookieAfter') && + defaultDelay < parseInt(this.settings['general']['removeCookieAfter']) + ) { + defaultDelay = parseInt(this.settings['general']['removeCookieAfter']); } return defaultDelay; },