Code Monkey home page Code Monkey logo

yii2-widget-alert's Introduction

Krajee Logo
yii2-widget-alert
Donate       kartikv

Stable Version Unstable Version License Total Downloads Monthly Downloads Daily Downloads

This extension contains a couple of useful widgets. The Alert widget extends the \yii\bootstrap\Alert widget with more easy styling and auto fade out options. In addition, it includes a AlertBlock widget that groups multiple \kartik\widget\Alert or kartik\widget\Growl widgets in one single block and renders them stacked vertically on the current page. You can choose the TYPE_ALERT style or the TYPE_GROWL style for your notifications. You can also set the widget to automatically read and display session flash messages (which is the default setting). Alternatively, you can setup and configure your own block of custom alerts.

NOTE: This extension is a sub repo split of yii2-widgets. The split has been done since 08-Nov-2014 to allow developers to install this specific widget in isolation if needed. One can also use the extension the previous way with the whole suite of yii2-widgets.

Installation

The preferred way to install this extension is through composer. Check the composer.json for this extension's requirements and dependencies. Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json.

To install, either run

$ php composer.phar require kartik-v/yii2-widget-alert "*"

or add

"kartik-v/yii2-widget-alert": "*"

to the require section of your composer.json file.

NOTE: Using Growl is optional and it is not automatically installed with this extension. If you want to use it in your project, you need to either run

$ php composer.phar require kartik-v/yii2-widget-growl "*"

or add

"kartik-v/yii2-widget-growl": "*"

to the require section of your composer.json file.

Refer the CHANGE LOG for details on changes to various releases.

Demo

You can refer detailed documentation and demos for Alert and AlertBlock widgets on usage of the extension.

Usage

Alert

use kartik\alert\Alert;

echo Alert::widget([
	'type' => Alert::TYPE_INFO,
	'title' => 'Note',
	'titleOptions' => ['icon' => 'info-sign'],
	'body' => 'This is an informative alert'
]);

AlertBlock

use kartik\alert\AlertBlock;

echo AlertBlock::widget([
	'type' => AlertBlock::TYPE_ALERT,
	'useSessionFlash' => true
]);

License

yii2-widget-alert is released under the BSD-3-Clause License. See the bundled LICENSE.md for details.

yii2-widget-alert's People

Contributors

beowulfenator avatar kartik-v avatar yasserhassan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

yii2-widget-alert's Issues

alert widget not displaying in an is statement

I"m trying to implement the Array widget inside an if statement:

if ($alert == "Duplication") { file_put_contents("/home2/nitzanha/public_html/testYair.log", "alertXXX: " . print_r($alert, true) . "\n" , FILE_APPEND); echo Alert::widget([ 'type' => Alert::TYPE_SUCCESS, 'title' => 'Well done!', 'icon' => 'glyphicon glyphicon-ok-sign', 'body' => 'You successfully read this important alert message.', 'showSeparator' => true, 'delay' => 9000 ]); file_put_contents("/home2/nitzanha/public_html/testYair.log", "YYYYYYYYYYYY: " . "\n" , FILE_APPEND); }

As I can see in the log file the application enters the if statement but does not invokes the Alert.
When moving the Alert widget outside the if statement it is being displayed.

Please assist,
Yair

Render Problem

Whenever an alert is displayed and at the same time if the mouse is moved on the screen, the alert starts flickering. Although there are no errors generated, so my guess is that there is some rendering problem with fade out.

Please take a look into this. Thank you..

Install Growl automatically

It seems that it's intentional that Alert Block does not install Growl automatically with itself (based on the composer.json file). I suggest installing Growl automatically to avoid the need for troubleshooting after installation. For the record, I tried installing Alert Block with composer via command line using "*" and "dev-master" and in both cases it gave the following error message:

The class '\kartik\growl\Growl' was not found and is required for rendering Growl notifications in the alert block.

Please ensure you have installed the 'yii2-widget-growl' extension. To install, you can run this console command from your application root:

php composer.phar require kartik-v/yii2-widget-growl: "@dev"

Eventually I installed Growl manually and it worked fine.

AlertBlock is not automatically closed

Prerequisites

  • [X ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [X ] The issue still exists against the latest master branch of yii2-widget-alert.
  • This is not an usage question. I confirm having gone through and read the documentation and demos.
  • This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
  • I have attempted to find the simplest possible steps to reproduce the issue.
  • I have included a failing test as a pull request (Optional).

Steps to reproduce the issue

  1. In controller I add this flash:
    ... if ($model->save()) { Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Product is successfully added.')); ...
  2. In view, I add this,
    `
true, 'type' => AlertBlock::TYPE_ALERT ]); ?>
<?=
DetailView::widget([

...
`

Expected behavior and actual behavior

When I follow those steps, I see the flash message, but it does not disappear by itself. I want it to disappear after 2 seconds.

Environment

Browsers

  • [ X] Google Chrome
  • Mozilla Firefox
  • Internet Explorer
  • Safari

Operating System

  • Windows
  • Mac OS X
  • Linux
  • Mobile

Libraries

  • jQuery version: Yii2 2.0.14dev
  • yii2-widget-alert version: latest

Isolating the problem

  • This bug happens on the demos page
  • The bug happens consistently across all tested browsers
  • This bug happens when using yii2-widget-alert without other plugins.

Updating alert

I have the kartik-v/yii2-widget-alert v1.1.1 and I want to update at 1.1.4, I can’t because 1.1.4 requires kartik-v/yii2-widget-growl: >=1.1.2.
But the last version of growl is 1.1.1.

Release v1.1.1

This is not a technical question or bug report, so I allowed myself to remove the pre-set issue text.

Dear Kartik,
could you please make a new release, so we can update it through composer? I got v1.1.0 via composer and you fixed so many things meanwhile. I don't want to patch it local via copy and paste from the repo here as this surely will be bad practice.

Thank you for your great work!

AlertBlock type growl not shown & how to setup flash messages

Prerequisites

  • [X ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest master branch of yii2-widget-alert.
  • [X ] This is not an usage question. I confirm having gone through and read the documentation and demos.
  • [ X] This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
  • [ X] I have attempted to find the simplest possible steps to reproduce the issue.
  • I have included a failing test as a pull request (Optional).

Steps to reproduce the issue

  1. In controller, add this line
    Yii::$app->getSession()->setFlash('success', $name . Yii::t('app', ' is successfully deleted.'));

Somehow, I cannot use array on flash message.

  1. In view, I add this line in gridview generated by johnivtn -> ajaxcrud.
    'panel' => [ 'type' => 'primary', 'heading' => Html::icon('glyphicon glyphicon-list') . ' ' . Yii::t('app', '{title} listing', ['title' => $this->title, 'titleId' => strtolower($this->title)]), 'before' => AlertBlock::widget([ 'useSessionFlash' => true, 'type' => AlertBlock::TYPE_GROWL ]),

But nothing is shown

Expected behavior and actual behavior

I was expecting to see the growl like notification but nothing. Actually, I can display it if it is alert not growl.

Environment

Browsers

  • Google Chrome
  • Mozilla Firefox
  • Internet Explorer
  • Safari

Operating System

  • Windows
  • Mac OS X
  • [X ] Linux
  • Mobile

Libraries

  • jQuery version:
  • yii2-widget-alert version:

Isolating the problem

  • This bug happens on the demos page
  • The bug happens consistently across all tested browsers
  • This bug happens when using yii2-widget-alert without other plugins.

TIA

Daniel

Fatal Error - Class 'kartik\alert\Growl' not found

The following code displays a fatal error:

<?= AlertBlock::widget([
    'useSessionFlash' => true,
    'type' => AlertBlock::TYPE_GROWL
]) ?>

kartik-v-alertblock-error

composer configuration:

"require": {
  "kartik-v/yii2-widgets": "*",
  "kartik-v/yii2-checkbox-x": "dev-master",
  "kartik-v/yii2-helpers": "*",
  "kartik-v/yii2-builder": "*",
  "kartik-v/yii2-grid": "*",
  "kartik-v/yii2-nav-x": "*",
  "kartik-v/yii2-dropdown-x": "*",
  "kartik-v/yii2-datecontrol": "*",
  "kartik-v/yii2-date-range": "*",
  "kartik-v/yii2-popover-x": "*",
  "kartik-v/yii2-field-range": "*",
  "kartik-v/yii2-detail-view": "*",
  "kartik-v/yii2-label-inplace": "*",
  "kartik-v/yii2-money": "*",
  "kartik-v/yii2-tabs-x": "*",
  "kartik-v/yii2-mpdf": "*"
}

Error on latest update

I got an error message like this

{"name":"PHP Compile Error","message":"Cannot use yii\\bootstrap\\Alert as Alert because the name is already in use","code":64,"type":"yii\\base\\ErrorException","file":"/home/steve/projects/estate/vendor/kartik-v/yii2-widget-alert/src/Bs3Alert.php","line":13,"stack-trace":["#0 [internal function]: yii\\base\\ErrorHandler->handleFatalError()","#1 {main}"]}

My app is working fine until the update. My current workaround is

<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2018
* @package yii2-widgets
* @subpackage yii2-widget-alert
* @version 1.1.2
*/

namespace kartik\alert;

use Yii;

/**
* Alert widget extends the [[Alert]] widget with an easier configuration and additional styling options including
* auto fade out.
*
* @author Kartik Visweswaran <[email protected]>
* @since 1.0
*/
class Bs3Alert extends \yii\bootstrap\Alert implements AlertInterface {

`use AlertMethodsTrait;`

}

But I don't know whether this is your intention. Can you help on this Kartik?

Empty alert on every page load, with no alerts in array

I have revived an older project, where I am a bit rusty on where I left off. The client ran out of funds and just got back with me a few months later. So to your defense, I have code laying around in there that I don't know why it's there or why I did it. I try to keep a clean house, but I abandoned ship :)

I originally had snagged your Alert widget from yii2-app-practical for a prettier Bootstrap alert. It worked nicely. I have stumbled across this package though, and would prefer to use something via Composer than just throwing an extra file in my project when I don't need to.

So I added this to my composer, updated, and attempted to use the alert widget. When going to a page, I get a broken (half height) blue alert window, with no title or message. There shouldn't be an alert at all, there is nothing there.

I confirmed there shouldn't be an alert by dumping the array:

$session = \Yii::$app->getSession();
$flashes = $session->getAllFlashes();
die( var_dump($flashes) );

The array was empty.

Your instructions on the README show passing options to it (type: warning, info, etc, title, message)... However, that isn't very dynamic.

I assumed this Alert widget should know whether it should show itself or not.

FWIW Here is how I loaded it:

use kartik\alert\Alert;
<?= Alert::widget() ?>

I didn't pass any options to it, however it worked just like that with the copy from your yii2-app-practical

I just don't get why the alert box is showing, when there are no alerts to show.

Yii2 2.0.6

Feature request

Hi,

it would be nice if you add the possibility to play an error sound.

Have a nice day

Sven

Growl requirement

Prerequisites

  • [x ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [x ] The issue still exists against the latest master branch of yii2-widget-alert.
  • [x ] This is not an usage question. I confirm having gone through and read the documentation and demos.
  • [x ] This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
  • [x ] I have attempted to find the simplest possible steps to reproduce the issue.
  • [n] I have included a failing test as a pull request (Optional).

I was reviewing the diff from v1.1.2 to master and I noticed the composer.json was modified to require a newer version of Growl. On Growl v1.1.3 does not exist

"require": {
    "kartik-v/yii2-widget-growl": ">=1.1.2"	        "kartik-v/yii2-widget-growl": ">=1.1.3"
},	    },

v1.1.2...master

https://github.com/kartik-v/yii2-widget-growl/releases

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.