Skip to content

Commit

Permalink
4.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ryssbowh committed Sep 8, 2022
1 parent 2a93945 commit 80cdde0
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 13 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# ryssbowh/craft-themes Changelog

## 4.2.4 - 2022-09-08

### Fixed
- Fixed error when changing a field's type
- Fixed ajax url for overriden templates utility
- Added missing register form block options
- Fixed potential issue with block cache strategies

## 4.2.3 - 2022-08-08

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/assets/dist/utilities.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/assets/js/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ var ThemesUtility = {
this.$resultContainer.html('');
this.toggleSpinner(true);
let data = {
theme: this.$select.val()
theme: this.$select.val(),
action: 'themes/cp-themes/overridden-templates'
};
data[Craft.csrfTokenName] = Craft.csrfTokenValue;
$.ajax({
method: 'post',
url: '/?action=themes/cp-themes/overridden-templates',
url: Craft.getActionUrl('/'),
data: data
}).done((data) => {
this.$resultContainer.html(data);
Expand Down
7 changes: 4 additions & 3 deletions src/blockCache/GlobalBlockCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ public function getDuration(): ?int
public function buildKey(BlockInterface $block): array
{
$key = [self::CACHE_TAG];
$identity = \Craft::$app->user->identity;
if ($this->options->cachePerAuthenticated) {
$key[] = \Craft::$app->user ? 'auth' : 'noauth';
$key[] = $identity ? 'auth' : 'noauth';
}
if ($this->options->cachePerViewport) {
$key[] = 'view-port-' . $this->getViewPort();
}
if ($this->options->cachePerUser and $user = \Craft::$app->user) {
$key[] = 'user-id-' . $user->getIdentity()->id;
if ($this->options->cachePerUser and $identity) {
$key[] = 'user-id-' . $identity->id;
}
if ($this->options->cachePerSite) {
$site = \Craft::$app->sites->getCurrentSite();
Expand Down
7 changes: 4 additions & 3 deletions src/blockCache/PathBlockCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ public function getDescription(): string
public function buildKey(BlockInterface $block): array
{
$key = [self::CACHE_TAG, 'path-' . \Craft::$app->request->getFullPath()];
$identity = \Craft::$app->user->identity;
if ($this->options->cachePerAuthenticated) {
$key[] = \Craft::$app->user ? 'auth' : 'noauth';
$key[] = $identity ? 'auth' : 'noauth';
}
if ($this->options->cachePerViewport) {
$key[] = 'view-port-' . $this->getViewPort();
}
if ($this->options->cachePerUser and $user = \Craft::$app->user) {
$key[] = 'user-id-' . $user->getIdentity()->id;
if ($this->options->cachePerUser and $identity) {
$key[] = 'user-id-' . $identity->id;
}
if ($this->options->cachePerSite) {
$site = \Craft::$app->sites->getCurrentSite();
Expand Down
7 changes: 4 additions & 3 deletions src/blockCache/QueryBlockCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ public function getDescription(): string
public function buildKey(BlockInterface $block): array
{
$key = [self::CACHE_TAG, 'query- ' . \Craft::$app->request->getFullPath() . '?' . \Craft::$app->request->getQueryStringWithoutPath()];
$identity = \Craft::$app->user->identity;
if ($this->options->cachePerAuthenticated) {
$key[] = \Craft::$app->user ? 'auth' : 'noauth';
$key[] = $identity ? 'auth' : 'noauth';
}
if ($this->options->cachePerViewport) {
$key[] = 'view-port-' . $this->getViewPort();
}
if ($this->options->cachePerUser and $user = \Craft::$app->user) {
$key[] = 'user-id-' . $user->getIdentity()->id;
if ($this->options->cachePerUser and $identity) {
$key[] = 'user-id-' . $identity->id;
}
if ($this->options->cachePerSite) {
$site = \Craft::$app->sites->getCurrentSite();
Expand Down
32 changes: 32 additions & 0 deletions src/models/blockOptions/RegisterFormBlockOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,36 @@
*/
class RegisterFormBlockOptions extends BlockOptions
{
/**
* @inheritDoc
*/
public function defineOptions(): array
{
return [
'onlyIfNotAuthenticated' => [
'field' => 'lightswitch',
'label' => \Craft::t('themes', 'Show only if the user is not authenticated')
]
];
}

/**
* @inheritDoc
*/
public function defineDefaultValues(): array
{
return [
'onlyIfNotAuthenticated' => true,
];
}

/**
* @inheritDoc
*/
public function defineRules(): array
{
return array_merge(parent::defineRules(), [
['onlyIfNotAuthenticated', 'boolean', 'trueValue' => true, 'falseValue' => false],
]);
}
}
2 changes: 1 addition & 1 deletion src/services/FieldsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function onCraftFieldSaved(FieldEvent $event)
'visuallyHidden' => $field->labelVisuallyHidden,
'labelVisuallyHidden' => $field->labelVisuallyHidden,
'hidden' => $newField->hidden ?: $field->hidden,
'display' => $display
'display_id' => $display->id
]);
$this->save($newField);
} else {
Expand Down

0 comments on commit 80cdde0

Please sign in to comment.