Skip to content

Commit

Permalink
Merge pull request #173 from ndrez-outl1ne/bugfix/4.24.0
Browse files Browse the repository at this point in the history
Sync ResourceTableRow with Nova 4.24.0
  • Loading branch information
Tarpsvo authored Jun 30, 2023
2 parents 4ec83e0 + 880d131 commit e655343
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Uses Spatie's [eloquent-sortable](https://github.com/spatie/eloquent-sortable) u
## Requirements

- `php: >=8.0`
- `laravel/nova: ^4.20.0`
- `laravel/nova: ^4.24.0`

## Features

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"require": {
"php": ">=8.0",
"spatie/eloquent-sortable": "^3.10.0|^4.0",
"laravel/nova": "^4.20.2",
"laravel/nova": "^4.24.0",
"outl1ne/nova-translations-loader": "^5.0"
},
"repositories": [
Expand Down
2 changes: 1 addition & 1 deletion dist/js/entry.js

Large diffs are not rendered by default.

48 changes: 44 additions & 4 deletions resources/js/components/ResourceTableRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
'o1-px-2': index != 0 || shouldShowCheckboxes,
'o1-py-2': !shouldShowTight,
'o1-whitespace-nowrap': !field.wrapping,
'o1-cursor-pointer':
resource.authorizedToView && clickAction !== 'ignore',
'o1-cursor-pointer': clickableRow,
}"
class="dark:bg-gray-800 group-hover:bg-gray-50 dark:group-hover:bg-gray-900"
>
Expand All @@ -76,6 +75,7 @@
class="o1-flex o1-items-center o1-justify-end o1-space-x-0 text-gray-400"
>
<InlineActionDropdown
v-if="shouldShowActionDropdown"
:actions="availableActions"
:endpoint="actionsEndpoint"
:resource="resource"
Expand Down Expand Up @@ -220,8 +220,8 @@

<script>
import filter from 'lodash/filter'
import { Inertia } from '@inertiajs/inertia'
import ReordersResources from '../mixins/ReordersResources'
import { mapGetters } from 'vuex'
export default {
emits: ['actionExecuted'],
Expand Down Expand Up @@ -329,6 +329,9 @@ export default {
},
navigateToPreviewView(e) {
if (!this.resource.authorizedToView) {
return
}
this.openPreviewModal()
},
Expand Down Expand Up @@ -368,6 +371,8 @@ export default {
},
computed: {
...mapGetters(['currentUser']),
updateURL() {
return this.$url(
`/resources/${this.resourceName}/${this.resource.id.value}/edit`,
Expand All @@ -390,7 +395,42 @@ export default {
},
shouldShowTight() {
return this.tableStyle == 'tight'
return this.tableStyle === 'tight'
},
clickableRow() {
if (this.clickAction === 'edit') {
return this.resource.authorizedToUpdate
} else if (this.clickAction === 'select') {
return this.shouldShowCheckboxes
} else if (this.clickAction === 'ignore') {
return false
} else if (this.clickAction === 'detail') {
return this.resource.authorizedToView
} else if (this.clickAction === 'preview') {
return this.resource.authorizedToView
} else {
return this.resource.authorizedToView
}
},
shouldShowActionDropdown() {
return this.availableActions.length > 0 || this.userHasAnyOptions
},
shouldShowPreviewLink() {
return this.resource.authorizedToView && this.resource.previewHasFields
},
userHasAnyOptions() {
return (
this.resource.authorizedToReplicate ||
this.shouldShowPreviewLink ||
this.canBeImpersonated
)
},
canBeImpersonated() {
return (
this.currentUser.canImpersonate && this.resource.authorizedToImpersonate
)
},
},
}
Expand Down

0 comments on commit e655343

Please sign in to comment.