diff --git a/src/actions/EditComponentData.php b/src/actions/EditComponentData.php index 0f90725..c4646b1 100644 --- a/src/actions/EditComponentData.php +++ b/src/actions/EditComponentData.php @@ -14,7 +14,11 @@ public function handle(Component $component, array $data) return $component; } - $component + // Touch the component so we log that the data has updated + $component->touch(); + + // Save the data + $componentData = $component ->maybeDuplicateData() ->merge($data) ->save(); diff --git a/src/base/ComponentType.php b/src/base/ComponentType.php index 450a13d..56749aa 100644 --- a/src/base/ComponentType.php +++ b/src/base/ComponentType.php @@ -77,6 +77,11 @@ public function render(array $variables = []): string abstract public function getTemplatePath(): string; + public function hasSlots(): bool + { + return $this->getSlotDefinitions()->isNotEmpty(); + } + /** * @return Collection */ diff --git a/src/models/Component.php b/src/models/Component.php index 672dbf6..451e3c0 100644 --- a/src/models/Component.php +++ b/src/models/Component.php @@ -5,6 +5,7 @@ use craft\base\ElementInterface; use craft\base\FieldInterface; use craft\db\ActiveQuery; +use craft\helpers\DateTimeHelper; use Illuminate\Support\Collection; use markhuot\keystone\actions\GetComponentType; use markhuot\keystone\actions\NormalizeFieldDataForComponent; @@ -144,6 +145,14 @@ public function refresh() return parent::refresh(); } + public function touch() + { + $this->dateUpdated = DateTimeHelper::now(); + $this->save(); + + return $this; + } + public function __get($name) { $value = parent::__get($name); diff --git a/src/templates/field.twig b/src/templates/field.twig index bcab5a7..a22e57a 100644 --- a/src/templates/field.twig +++ b/src/templates/field.twig @@ -15,7 +15,7 @@ {% endif %}