Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions publishable/assets/cms/icons/chevron-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
133 changes: 49 additions & 84 deletions resources/views/articles/_articles.blade.php
Original file line number Diff line number Diff line change
@@ -1,84 +1,49 @@
@forelse($articles as $article)
<tr class="relative overflow-hidden"
x-data="{
showConfirm: false,
deleteArticle(uuid) {
return fetch(`/articles/${uuid}`, {
method: 'POST',
body: JSON.stringify({
'_method': 'DELETE'
}),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
})
.then(response => response.json());
}
}"
x-cloak>
<td class="border-t border-gray-200 userId" :colspan="showConfirm === true ? 5 : 1">
<div x-show="!showConfirm" class="relative text-gray-700 px-6 py-3 flex items-center">
<div>
<div class="font-semibold text-lg truncate">
{{ $article->title }}
</div>

<div class="flex flex-wrap space-x-2 mt-1 text-sm">
<a data-turbolinks-action="replace" class="text-gray-600 underline" href="{{ route('flowcms::articles.edit', $article->uuid) }}">Edit</a>
<a target="_blank" class="text-gray-600 underline" href="{{ route('flowcms::blog.show', $article->slug) }}">Preview</a>
<a class="underline text-red-500" href="#" x-on:click.prevent="showConfirm = true">Delete</a>
</div>
</div>
</div>
<div x-show="showConfirm" class="bg-gray-100 flex-1">
<div class="flex items-center justify-between px-6 py-3">
<div>
<h3 class="font-semibold md:text-lg text-gray-700">Delete article: {{ $article->title }}?</h3>
<p class="text-xs truncate">Are you sure you want to delete this article?</p>
</div>
<div class="flex items-center pt-1">
<div>
<x-flowcms-button type="button" x-on:click="showConfirm = false" class="bg-white text-gray-600 mr-2 shadow-sm">Cancel</x-flowcms-button>
</div>

<x-flowcms-button
x-ref="deleteArticleButton"
x-on:click="$refs.deleteArticleButton.classList.add('base-spinner', 'cursor-not-allowed'); deleteArticle('{{ $article->uuid }}').then(result => $dispatch('reload'));"
type="button"
class="bg-red-500 text-white shadow-sm">Delete</x-flowcms-button>
</div>
</div>
</div>
</td>
<td x-show="!showConfirm" class="border-t border-gray-200">
<span class="text-gray-700 px-6 py-3 flex items-center">
{{ views($article)->unique()->count() ?? 0 }}
</span>
</td>
<td x-show="!showConfirm" class="border-t border-gray-200">
<span class="text-gray-700 px-6 py-3 flex items-center">
{{ $article->category->name }}
</span>
</td>
<td x-show="!showConfirm" class="border-t border-gray-200">
<span class="text-gray-700 px-6 py-3 flex items-center">
{{ $article->publish_date->format('d M, Y') }}
</span>
</td>
<td x-show="!showConfirm" class="border-t border-gray-200">
<span class="text-gray-700 px-6 py-3 flex items-center">
@if ($article->article_status == 'Published')
<x-flowcms-badge variant="success">{{ $article->article_status }}</x-flowcms-badge>
@else
<x-flowcms-badge>{{ $article->article_status }}</x-flowcms-badge>
@endif
</span>
</td>
</tr>
@empty
<tr>
<td colspan="5" class="px-6 py-10 text-center">No articles found.</td>
</tr>
@endforelse
@if ($articles->isNotEmpty())
<x-flowcms-base-datatable
:headings="['Title', 'Views', 'Category', 'Published Date', 'Status', 'Actions']"
:values="[
[
'key' => 'title',
'type' => 'data',
'width' => 'w-64'
],
[
'key' => 'article_views',
'type' => 'data',
],
[
'key' => 'category.name',
'type' => 'data',
],
[
'key' => 'publish_date',
'type' => 'date',
],
[
'key' => 'article_status',
'type' => 'data',
'theme' => [
'type' => 'badge',
'colors' => [
'Published' => 'bg-green-200 text-green-700',
'Draft' => 'bg-orange-200 text-orange-700',
]
]
],
[
'key' => 'action',
'type' => ['delete', 'edit']
]
]"
:data="$articles"
model="articles"
edit-route="flowcms::articles.edit"
edit-id="uuid"
delete-route="flowcms::articles.destroy"
delete-id="uuid"
table-striped
>
</x-flowcms-base-datatable>
@else
No articles found.
@endif
14 changes: 8 additions & 6 deletions resources/views/articles/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@
<img :src="featuredImage" alt="featuredImage" class="w-64 rounded-lg object-fit">
</div>
</div>

<div @error('body') class="ql-editor-haserror" @enderror>
<x-flowcms-quill-editor label="Body" name="body" value="" />
</div>


<x-flowcms-quill-editor
label="Body"
name="body"
value=""
endpoint="/uploads" />

<x-flowcms-text-input label="SEO - Meta Title" name="seo_title" optional />
<x-flowcms-textarea-input label="SEO - Meta Description" name="seo_description" optional />

Expand All @@ -66,7 +68,7 @@
</x-flowcms-select-input>

<x-flowcms-switch label="Status" name="status" :value="false"/>
<x-flowcms-pikaday label="Publish date" name="publish_date" value="{{ now() }}" />
<x-flowcms-pikaday label="Publish date" name="publish_date" value="{{ now()->format('D M d Y') }}" />

<x-flowcms-button type="submit" class="bg-gray-800 text-white">Save Article</x-flowcms-button>

Expand Down
13 changes: 8 additions & 5 deletions resources/views/articles/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@
</div>
</div>

<div @error('body') class="ql-editor-haserror" @enderror>
<x-flowcms-quill-editor label="Body" name="body" value="{!! $article->body !!}" />
</div>


<x-flowcms-quill-editor
label="Body"
name="body"
value="{!! $article->body !!}"
endpoint="/uploads" />

<x-flowcms-text-input label="SEO - Meta Title" name="seo_title" optional />
<x-flowcms-textarea-input label="SEO - Meta Description" name="seo_description" optional />
</div>
Expand All @@ -74,7 +77,7 @@
<x-flowcms-pikaday
label="Publish date"
name="publish_date"
:value="$article->publish_date" />
:value="$article->publish_date->format('D M d Y')" />

<x-flowcms-button type="submit" class="bg-gray-800 text-white">Update Article</x-flowcms-button>
</div>
Expand Down
82 changes: 53 additions & 29 deletions resources/views/articles/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,71 @@
<a href="{{ route('flowcms::articles.create')}}" class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 rounded-lg text-gray-100 font-semibold">New Article</a>
</div>

<div class="overflow-x-auto bg-white rounded-lg shadow overflow-y-auto relative"
<div
x-data="{
query: new URLSearchParams(location.search).get('s') || '',
fetchArticles(url = null) {
const URL = url || '/partials/articles?s=' + this.query;
fetch(URL)
.then(response => response.text())
.then(html => {
document.querySelector('#js-article-body').innerHTML = html
})

fetchData(page = null) {
let currentPageFromUrl = location.search.match(/page=(\d+)/)
? location.search.match(/page=(\d+)/)[1]
: 1

if (this.query) {
currentPageFromUrl = 1;
history.pushState(null, null, '?page=1&s='+ this.query);
}

const endpointURL = page !== null
? `${page}&s=${this.query}`
: `/articles/all?page=${currentPageFromUrl}&s=${this.query}`;

if (page) {
const urlObj = new URL(page);
const params = new URLSearchParams(urlObj.search);
history.pushState(null, null, '?page=' + params.get('page') );
}

fetch(endpointURL, {
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(response => response.text())
.then(html => {
document.querySelector('#js-articles-body').innerHTML = html
})
}
}"
x-init="
fetchArticles();
$watch('query', (value) => {
console.log(value);
const url = new URL(window.location.href);
url.searchParams.set('s', value);
history.pushState(null, document.title, url.toString());
})

document.addEventListener('keypress',(e) => {
if (event.code == 'Slash') {
event.preventDefault();
$refs.searchInput.focus();
}
});
"
x-cloak
@reload.window="fetchArticles()"
>
<div class="px-5 pt-4">
<x-flowcms-search-input placeholder="Search article..." name="s" x-model="query" x-on:input.debounce.750="fetchArticles()" />
@goto-page="fetchData($event.detail.page)"
@reload.window="fetchData()"
x-cloak>

<div class="my-4">
<x-flowcms-search-input
placeholder='Search articles (Press "/" to focus)'
name="s"
x-model="query"
x-ref="searchInput"
x-on:input.debounce.750="fetchData()" />
</div>
<table class="border-collapse table-auto w-full whitespace-no-wrap bg-white table-striped relative">
<thead>
<tr class="text-left">
<x-flowcms-table.head>Title</x-flowcms-table.head>
<x-flowcms-table.head>Views</x-flowcms-table.head>
<x-flowcms-table.head>Category</x-flowcms-table.head>
<x-flowcms-table.head>Published Date</x-flowcms-table.head>
<x-flowcms-table.head>Status</x-flowcms-table.head>
</tr>
</thead>
<tbody id="js-article-body"></tbody>
</table>
</div>

<div class="my-10">{{ $articles->links('flowcms::partials.tailwindPagination') }}</div>
<div id="js-articles-body">
@include('flowcms::articles._articles')
</div>
</div>
</x-flowcms-section-centered>
@endsection
Loading