Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/7.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Sep 4, 2024
2 parents 7ee62f1 + 8063b92 commit 968d3b0
Show file tree
Hide file tree
Showing 23 changed files with 353 additions and 348 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## v7.8.0 (2024-08-14)

### What's new
* Added `{{ runway:count }}` tag #583 by @vJoeyz
* Resource Actions #564 by @edalzell

### What's improved
* Tidied up Vue components #585 by @duncanmcclean



## v7.7.5 (2024-08-09)

### What's fixed
* Prevent creating blueprint files when running in the console #581 by @BobWez98



## v7.7.4 (2024-08-06)

### What's fixed
Expand Down
2 changes: 1 addition & 1 deletion LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Statamic Rad Pack
Copyright (c) Statamic Rad Pack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 14 additions & 0 deletions docs/templating.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ As [with the collection tag](https://statamic.dev/tags/collection#scope), you ma
{{ /runway:post }}
```

## Count Tag

When you just want to know how many results you have, you can use the `{{ runway:count }}` tag.

```antlers
{{ runway:count from="posts" }}
```

You can use the `where` parameter to filter the results:

```antlers
{{ runway:count from="posts" where="author_name:duncan" }}
```

## Publish State

By default, when you're using Runway's [Publish States](/resources#publish-states) feature, only published models are included. Models can be queried against `published` or `draft` status with conditions on `status` like this:
Expand Down
22 changes: 0 additions & 22 deletions rector.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
<template>

<!--
This component is *mostly* the same as the one in Statamic Core, however with one difference:
it swaps out the 'fields' string with 'runway-fields' to avoid breaking the Fields filter on Entry Listing Tables.
See https://github.com/statamic-rad-pack/runway/pull/292 for more info.
-->

<div class="shadow-inner bg-gray-300 dark:bg-dark-600">
<div class="flex items-center flex-wrap px-3 border-b dark:border-dark-900 pt-2">

<!-- Field filter (requires custom selection UI) -->
<popover v-if="fieldFilter" placement="bottom-start" @closed="fieldFilterClosed">
<template slot="trigger">
<button class="filter-badge filter-badge-control mr-2 mb-2" @click="resetFilterPopover">
<button class="filter-badge filter-badge-control rtl:ml-2 ltr:mr-2 mb-2" @click="resetFilterPopover">
{{ fieldFilter.title }}
<svg-icon name="micro/chevron-down-xs" class="w-2 h-2 mx-2" />
</button>
</template>
<template #default="{ close: closePopover }">
<div class="flex flex-col text-left min-w-[18rem]">
<div class="flex flex-col rtl:text-right ltr:text-left min-w-[18rem]">
<div class="filter-fields text-sm">
<field-filter
ref="fieldFilter"
Expand All @@ -30,7 +38,7 @@
<!-- Standard pinned filters -->
<popover v-if="pinnedFilters.length" v-for="filter in pinnedFilters" :key="filter.handle" placement="bottom-start" :stop-propagation="false">
<template slot="trigger">
<button class="filter-badge filter-badge-control mr-2 mb-2">
<button class="filter-badge filter-badge-control rtl:ml-2 ltr:mr-2 mb-2">
{{ filter.title }}
<svg-icon name="micro/chevron-down-xs" class="w-2 h-2 mx-2" />
</button>
Expand All @@ -51,7 +59,7 @@
<!-- Standard unpinned filters -->
<popover v-if="unpinnedFilters.length" placement="bottom-start" :stop-propagation="false">
<template slot="trigger">
<button class="filter-badge filter-badge-control mr-2 mb-2" @click="resetFilterPopover">
<button class="filter-badge filter-badge-control rtl:ml-2 ltr:mr-2 mb-2" @click="resetFilterPopover">
{{ __('Filter') }}
<svg-icon name="micro/chevron-down-xs" class="w-2 h-2 mx-2" />
</button>
Expand Down Expand Up @@ -85,11 +93,11 @@
</popover>

<!-- Active filter badges -->
<div class="filter-badge mr-2 mb-2" v-for="(badge, handle) in fieldFilterBadges">
<div class="filter-badge rtl:ml-2 ltr:mr-2 mb-2" v-for="(badge, handle) in fieldFilterBadges">
<span>{{ badge }}</span>
<button @click="removeFieldFilter(handle)" v-tooltip="__('Remove Filter')">&times;</button>
</div>
<div class="filter-badge mr-2 mb-2" v-for="(badge, handle) in standardBadges">
<div class="filter-badge rtl:ml-2 ltr:mr-2 mb-2" v-for="(badge, handle) in standardBadges">
<span>{{ badge }}</span>
<button @click="removeStandardFilter(handle)" v-tooltip="__('Remove Filter')">&times;</button>
</div>
Expand Down Expand Up @@ -208,7 +216,7 @@ export default {
},
savingPresetHandle() {
return this.$slugify(this.savingPresetName, '_');
return snake_case(this.savingPresetName);
},
isUpdatingPreset() {
Expand Down Expand Up @@ -255,15 +263,15 @@ export default {
delete fields[handle];
this.$emit('changed', {handle: 'runway-fields', values: fields});
this.$emit('changed', { handle: 'runway-fields', values: fields });
},
removeStandardFilter(handle) {
this.$emit('changed', {handle: handle, values: null});
this.$emit('changed', { handle: handle, values: null });
},
save() {
if (! this.canSave || ! this.preferencesPayload) return;
if (!this.canSave || !this.preferencesPayload) return;
this.saving = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
:column-preferences-key="preferencesKey('columns')"
@sorted="sorted"
>
<template :slot="primaryColumn" slot-scope="{ row: model, value }">
<template :slot="`cell-${primaryColumn}`" slot-scope="{ row: model, value }">
<a class="title-index-field inline-flex items-center" :href="model.edit_url" @click.stop>
<span class="little-dot rtl:ml-2 ltr:mr-2" v-tooltip="getStatusLabel(model)" :class="getStatusClass(model)" v-if="hasPublishStates && ! columnShowing('status')" />
<span v-text="value" />
Expand All @@ -110,42 +110,15 @@
<div class="status-index-field select-none" v-tooltip="getStatusTooltip(model)" :class="`status-${model.status}`" v-text="getStatusLabel(model)" />
</template>

<template
slot="actions"
slot-scope="{ row, index }"
>
<dropdown-list
v-if="
canViewRow(row) ||
canEditRow(row) ||
row.actions.length
"
>
<dropdown-item
v-if="canViewRow(row)"
:text="__('View')"
:redirect="row.permalink"
/>

<dropdown-item
v-if="canEditRow(row)"
:text="__('Edit')"
:redirect="row.edit_url"
/>

<div
class="divider"
v-if="
(canViewRow(row) ||
canEditRow(row)) &&
row.actions.length
"
/>

<template slot="actions" slot-scope="{ row: model, index }">
<dropdown-list v-if="(model.viewable && model.permalink) || model.editable || model.actions.length">
<dropdown-item v-if="model.viewable && model.permalink" :text="__('View')" :external-link="model.permalink" />
<dropdown-item v-if="model.editable" :text="__('Edit')" :redirect="model.edit_url" />
<div v-if="((model.viewable && model.permalink) || model.editable) && model.actions.length" class="divider" />
<data-list-inline-actions
:item="row.id"
:item="model.id"
:url="actionUrl"
:actions="row.actions"
:actions="model.actions"
@started="actionStarted"
@completed="actionCompleted"
/>
Expand All @@ -154,18 +127,6 @@
</template>
</data-list-table>
</div>

<confirmation-modal
v-if="deletingRow !== false"
:title="__('Delete')"
:bodyText="
__('Are you sure you want to delete this item?')
"
:buttonText="__('Delete')"
:danger="true"
@confirm="deleteRow()"
@cancel="cancelDeleteRow"
></confirmation-modal>
</div>

<data-list-pagination
Expand All @@ -182,7 +143,7 @@

<script>
import Listing from '../../../../vendor/statamic/cms/resources/js/components/Listing.vue'
import DataListFilters from './DataListFilters.vue'
import DataListFilters from '../data-list/Filters.vue'
export default {
mixins: [Listing],
Expand All @@ -192,21 +153,16 @@ export default {
},
props: {
listingConfig: Object,
initialColumns: Array,
actionUrl: String,
initialPrimaryColumn: String,
resource: String,
primaryColumn: String,
hasPublishStates: Boolean,
},
data() {
return {
listingKey: 'id',
preferencesPrefix: this.listingConfig.preferencesPrefix ?? 'runway',
requestUrl: this.listingConfig.requestUrl,
columns: this.initialColumns,
meta: {},
primaryColumn: `cell-${this.initialPrimaryColumn}`,
listingKey: 'models',
preferencesPrefix: `runway.${this.resource}`,
requestUrl: cp_url(`runway/${this.resource}/listing-api`),
deletingRow: false,
}
},
Expand Down Expand Up @@ -239,56 +195,6 @@ export default {
columnShowing(column) {
return this.visibleColumns.find(c => c.field === column);
},
canViewRow(row) {
return row.viewable && row.permalink
},
canEditRow(row) {
return row.editable
},
confirmDeleteRow(id, index, deleteUrl) {
this.visibleColumns = this.columns.filter(
(column) => column.visible
)
this.deletingRow = { id, index, deleteUrl }
},
deleteRow(message) {
const id = this.deletingRow.id
message = message || __('Deleted')
this.$axios
.delete(this.deletingRow.deleteUrl)
.then(() => {
let i = _.indexOf(
this.items,
_.findWhere(this.rows, { id })
)
this.items.splice(i, 1)
this.deletingRow = false
this.$toast.success(message)
// location.reload()
})
.catch((e) => {
this.$toast.error(
e.response
? e.response.data.message
: __('Something went wrong')
)
})
},
cancelDeleteRow() {
this.deletingRow = false
setTimeout(() => {
this.visibleColumns = this.columns.filter(
(column) => column.visible
)
}, 50)
},
},
}
</script>
58 changes: 58 additions & 0 deletions resources/js/components/resources/View.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<template>
<div>
<header class="mb-6">
<div class="flex items-center">
<h1 class="flex-1" v-text="__(title)" />

<dropdown-list class="rtl:ml-2 ltr:mr-2" v-if="!!this.$scopedSlots.twirldown">
<slot name="twirldown" :actionCompleted="actionCompleted" />
</dropdown-list>

<div>
<a v-if="canCreate" class="btn-primary" :href="createUrl" v-text="createLabel" />
</div>
</div>
</header>

<runway-listing
:resource="handle"
:initial-columns="columns"
:filters="filters"
:action-url="actionUrl"
:primary-column="primaryColumn"
:has-publish-states="hasPublishStates"
></runway-listing>
</div>
</template>

<script>
import RunwayListing from './Listing.vue'
import HasActions from '../../../../vendor/statamic/cms/resources/js/components/publish/HasActions'
export default {
mixins: [HasActions],
components: {
RunwayListing,
},
props: {
title: { type: String, required: true },
handle: { type: String, required: true },
canCreate: { type: Boolean, required: true },
createUrl: { type: String, required: true },
createLabel: { type: String, required: true },
columns: { type: Array, required: true },
filters: { type: Array, required: true },
actionUrl: { type: String, required: true },
primaryColumn: { type: String, required: true},
hasPublishStates: { type: Boolean, required: true },
},
methods: {
afterActionSuccessfullyCompleted(response) {
if (!response.redirect) window.location.reload();
},
},
}
</script>
Loading

0 comments on commit 968d3b0

Please sign in to comment.