From ac227278a232cf35c7205cba0c8bdd02e5bf4c8b Mon Sep 17 00:00:00 2001 From: German Bisurgi Date: Wed, 11 Jan 2023 16:27:42 +0100 Subject: [PATCH 1/3] Suggest kdn:yii2-json-editor in composer.json --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index ad013bc..c603f83 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,9 @@ "homepage": "http://www.usrbin.de" } ], + "suggest": { + "kdn/yii2-json-editor": "JSON editor widget for Yii 2." + }, "require": { "cmrcx/phptidy": "^3.1", "dmstr/yii2-bootstrap": "^0.1.2 || ^0.2.1", From 75b0240c12ae8f691a14a30ae9678d4171a949dc Mon Sep 17 00:00:00 2001 From: German Bisurgi Date: Wed, 11 Jan 2023 16:27:59 +0100 Subject: [PATCH 2/3] Migrated callback from devgroup to kdn --- .../crud/callbacks/devgroup/Jsoneditor.php | 59 ---------------- .../crud/callbacks/kdn/Jsoneditor.php | 69 +++++++++++++++++++ 2 files changed, 69 insertions(+), 59 deletions(-) delete mode 100644 src/generators/crud/callbacks/devgroup/Jsoneditor.php create mode 100644 src/generators/crud/callbacks/kdn/Jsoneditor.php diff --git a/src/generators/crud/callbacks/devgroup/Jsoneditor.php b/src/generators/crud/callbacks/devgroup/Jsoneditor.php deleted file mode 100644 index 6ba4e71..0000000 --- a/src/generators/crud/callbacks/devgroup/Jsoneditor.php +++ /dev/null @@ -1,59 +0,0 @@ -'. -{$editor}::widget( - [ - 'editorOptions' => [ - 'modes' => ['code', 'form', 'text', 'tree', 'view'], // available modes - 'mode' => 'tree', // current mode - ], - 'model' => \$model, - 'attribute' => '{$attribute}', - 'options' => [ - 'id' => 'widget-{$attribute}', - 'class' => 'form-control', - ], - ] -). -'' -FORMAT; - }; - } - - public static function attribute() - { - return function ($attribute, $generator) { - $formattter = StringFormatter::className(); - $method = __METHOD__; - - return << 'html', - 'attribute' => '{$attribute}', - 'value'=> {$formattter}::contentJsonToHtml(\$model->{$attribute}) - -] -FORMAT; - }; - } -} diff --git a/src/generators/crud/callbacks/kdn/Jsoneditor.php b/src/generators/crud/callbacks/kdn/Jsoneditor.php new file mode 100644 index 0000000..45ac9c6 --- /dev/null +++ b/src/generators/crud/callbacks/kdn/Jsoneditor.php @@ -0,0 +1,69 @@ +
'. +{$editor}::widget( + [ + 'clientOptions' => [ + 'modes' => ['code', 'form', 'text', 'tree', 'view'], + 'mode' => 'tree', + ], + 'model' => \$model, + 'attribute' => '{$attribute}', + 'options' => [ + 'id' => 'widget-{$attribute}', + 'class' => 'form-control', + ] + ] +). +'
' +FORMAT; + }; + } + + public static function attribute() + { + return function ($attribute, $generator) { + $method = __METHOD__; + $editor = \kdn\yii2\JsonEditor::class; + return << 'raw', + 'attribute' => '{$attribute}', + 'headerOptions' => ['style' => 'min-width: 600px'], + 'value'=> function (\$model) { + return {$editor}::widget([ + 'name' => '_display', + 'value' => \$model->{$attribute}, + 'clientOptions' => [ + 'mode' => 'view', + 'modes' => [ + 'view', + 'code' + ] + ] + ]); + } +] +FORMAT; + }; + } +} From fdd0902bdca004adfcdb8dab029bbee2f7f4d419 Mon Sep 17 00:00:00 2001 From: German Bisurgi Date: Thu, 12 Jan 2023 15:00:26 +0100 Subject: [PATCH 3/3] Keeping deprecated devgroup callback. Added deprecation notice. --- .../crud/callbacks/devgroup/Jsoneditor.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/generators/crud/callbacks/devgroup/Jsoneditor.php diff --git a/src/generators/crud/callbacks/devgroup/Jsoneditor.php b/src/generators/crud/callbacks/devgroup/Jsoneditor.php new file mode 100644 index 0000000..3568674 --- /dev/null +++ b/src/generators/crud/callbacks/devgroup/Jsoneditor.php @@ -0,0 +1,56 @@ +'. +{$editor}::widget( + [ + 'editorOptions' => [ + 'modes' => ['code', 'form', 'text', 'tree', 'view'], // available modes + 'mode' => 'tree', // current mode + ], + 'model' => \$model, + 'attribute' => '{$attribute}', + 'options' => [ + 'id' => 'widget-{$attribute}', + 'class' => 'form-control', + ], + ] +). +'' +FORMAT; + }; + } + + public static function attribute() + { + return function ($attribute, $generator) { + $formattter = StringFormatter::className(); + $method = __METHOD__; + + return << 'html', + 'attribute' => '{$attribute}', + 'value'=> {$formattter}::contentJsonToHtml(\$model->{$attribute}) + +] +FORMAT; + }; + } +}