From aecec73f3e801597ac8e5e32e031d39affdcf5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabri=C3=A9l=20Ardean?= Date: Tue, 4 Jul 2023 17:42:34 +0200 Subject: [PATCH 1/2] Fixed JS bug --- yii2fullcalendar.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/yii2fullcalendar.php b/yii2fullcalendar.php index 9e2d492..f36fa6a 100644 --- a/yii2fullcalendar.php +++ b/yii2fullcalendar.php @@ -11,6 +11,8 @@ namespace yii2fullcalendar; use Yii; +use yii\helpers\Console; +use yii\helpers\Inflector; use yii\web\View; use yii\helpers\ArrayHelper; use yii\helpers\Html; @@ -172,6 +174,12 @@ class yii2fullcalendar extends elWidget */ public $select = ""; + /** + * The global variable name for the widget (used for update/filter calendar events) + * @var string valid JS variable name + */ + public $jsGlobalVar; + /** * Initializes the widget. * If you override this method, make sure you call the parent implementation first. @@ -179,14 +187,18 @@ class yii2fullcalendar extends elWidget public function init() { //checks for the element id + $this->setId(null); if (!isset($this->options['id'])) { - $this->options['id'] = $this->getId(); + $this->options['id'] = 'CalendarTasks'; } //checks for the class if (!isset($this->options['class'])) { $this->options['class'] = 'fullcalendar'; } + $this->jsGlobalVar = Inflector::id2camel($this->options['id']) . '_' . $this->id; + $this->options['id'] = $this->jsGlobalVar; + $this->view->registerJsVar($this->jsGlobalVar, 'undefined'); parent::init(); } @@ -259,9 +271,9 @@ protected function registerPlugin() $cleanOptions = $this->getClientOptions(); $js[] = <<jsGlobalVar = new FullCalendar.Calendar(calendarEl, $cleanOptions); +$this->jsGlobalVar.render(); EOCALENDAR; $view->registerJs(implode("\n", $js), View::POS_READY); @@ -324,3 +336,4 @@ protected function getClientOptions() return Json::encode($options); } } + From ae7dc061dcd464d1ef092b015668fd441fdb87bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabri=C3=A9l=20Ardean?= <91618515+elementallos@users.noreply.github.com> Date: Tue, 4 Jul 2023 17:54:39 +0200 Subject: [PATCH 2/2] Create CHANGELOG.md --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d571bf9 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +# CHANGELOG YII2 FULLCALENDAR + +6.0.1-dev +---------------- + +- Implemented uniqueness for widget id +- Globalization of the JS fullcalendar variable + +6.0.0 2023-07-04 +---------------- + +- Initial release for fullcalendar v6 assets