Skip to content

Commit

Permalink
Merge branch 'release/7.0.16' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
KasparRosin committed Oct 21, 2022
2 parents 1729ade + 371dc8b commit 60f546d
Show file tree
Hide file tree
Showing 8 changed files with 943 additions and 1,159 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [7.1.0] - 21-10-2022

### Added

- Custom menu items now have `getEnabledValue` function available. [#75]
- You can use this to override the enabled value set in database.
Useful when dealing with relationships inside menu items that might of have been deleted.

### Changed

- Updated the width of fields inside menu modal [#162]

## [7.0.5] - 15-09-2022

### Changed
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,19 @@ public static function getDisplayValue($value, ?array $data, $locale) {
return $value;
}

/**
* Get the enabled value
*
* @param $value
* @param $data The data from item fields.
* @param $locale
* @return string
*/
public static function getEnabledValue($value, ?array $data, $locale)
{
return true;
}

/**
* Get the value of the link visible to the front-end.
*
Expand Down
2 changes: 1 addition & 1 deletion dist/js/entry.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/js/entry.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

/*!
* vuex v4.0.2
* (c) 2021 Evan You
* vuex v4.1.0
* (c) 2022 Evan You
* @license MIT
*/

Expand Down
2,038 changes: 882 additions & 1,156 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions resources/js/components/modals/UpdateMenuItemModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<form @submit.prevent="$emit(update ? 'updateItem' : 'confirmItemCreate')" autocomplete="off">
<DefaultField
:errors="wrappedErrors"
:fullWidthContent="true"
:field="{
visible: true,
stacked: true,
Expand All @@ -41,6 +42,7 @@

<DefaultField
:errors="wrappedErrors"
:fullWidthContent="true"
:field="{
visible: true,
stacked: true,
Expand All @@ -64,6 +66,7 @@
<DefaultField
v-if="linkType.type === 'static-url'"
:errors="wrappedErrors"
:fullWidthContent="true"
:field="{
visible: true,
stacked: true,
Expand All @@ -87,6 +90,7 @@
v-if="linkType.type === 'select'"
class="option-select-field o1-menu-builder-multiselect-wrapper"
:errors="wrappedErrors"
:fullWidthContent="true"
:field="{
visible: true,
stacked: true,
Expand Down Expand Up @@ -129,6 +133,7 @@

<DefaultField
v-if="linkType.type && linkType.type !== 'text'"
:fullWidthContent="true"
:field="{
visible: true,
stacked: true,
Expand Down Expand Up @@ -164,6 +169,7 @@
:errors="wrappedErrors"
:show-errors="true"
class="menu-item-component"
:fullWidthContent="true"
/>
</template>
</form>
Expand Down
13 changes: 13 additions & 0 deletions src/MenuItemTypes/BaseMenuItemType.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ public static function getDisplayValue($value, ?array $data, $locale)
return $value;
}

/**
* Get the enabled value
*
* @param $value
* @param $data The data from item fields.
* @param $locale
* @return string
*/
public static function getEnabledValue($value, ?array $data, $locale)
{
return true;
}

/**
* Get the value of the link visible to the front-end.
*
Expand Down
14 changes: 14 additions & 0 deletions src/Models/MenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ public function scopeEnabled($query)
return $query->where('enabled', 1);
}

public function getEnabledAttribute()
{
if (!$this->attributes['enabled']) {
// Filter out already disabled menu items
return $this->attributes['enabled'];
}

if (method_exists($this->class, 'getEnabledValue')) {
return $this->class::getEnabledValue($this->value, $this->data, $this->locale);
}

return true;
}

public function getDisplayValueAttribute()
{
if (class_exists($this->class)) {
Expand Down

0 comments on commit 60f546d

Please sign in to comment.