Changing tag list to load content by ajax (fix #49) and updating the default sort order of backend lists (fix #49)
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
$(() => {
|
||||
var obj = {};
|
||||
if (typeof tagPartial !== 'string') obj = { '@tags': '#taglist' }
|
||||
else obj[tagPartial] = '#taglist'
|
||||
|
||||
$.request('TagList::onAjaxDataRequested', {
|
||||
complete: (data) => { $(window).trigger('tagsLoaded', data) }
|
||||
})
|
||||
})
|
||||
@@ -1,26 +1,32 @@
|
||||
<?php namespace JasonWilliams\Feed\Components;
|
||||
|
||||
use Db;
|
||||
use Cms\Classes\ComponentBase;
|
||||
use JasonWilliams\Feed\Models\Tags;
|
||||
|
||||
class TagList extends ComponentBase
|
||||
{
|
||||
public function componentDetails()
|
||||
{
|
||||
return [
|
||||
'name' => 'Tag List',
|
||||
'description' => 'Displays a list of feed tags.'
|
||||
];
|
||||
}
|
||||
|
||||
public function defineProperties()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function onRun()
|
||||
{
|
||||
$this->page['tags'] = Tags::groupBy('tag')->select(Db::raw('tag, count(*) as count'))->orderBy('count', 'desc')->get();
|
||||
}
|
||||
}
|
||||
<?php namespace JasonWilliams\Feed\Components;
|
||||
|
||||
use Db;
|
||||
use Cms\Classes\ComponentBase;
|
||||
use JasonWilliams\Feed\Models\Tags;
|
||||
|
||||
class TagList extends ComponentBase
|
||||
{
|
||||
public function componentDetails()
|
||||
{
|
||||
return [
|
||||
'name' => 'Tag List',
|
||||
'description' => 'Displays a list of feed tags.'
|
||||
];
|
||||
}
|
||||
|
||||
public function defineProperties()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function onRun()
|
||||
{
|
||||
$this->page['renderPartial'] = $this->property('tagPartial');
|
||||
$this->addJs('/plugins/jasonwilliams/feed/assets/javascript/loadtaglist.js');
|
||||
}
|
||||
|
||||
public function onAjaxDataRequested()
|
||||
{
|
||||
return Tags::groupBy('tag')->select(Db::raw('tag, count(*) as count'))->orderBy('count', 'desc')->get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
<ul>
|
||||
{% for tag in tags %}
|
||||
<li><a href="{{ tag.tag }}">{{ tag.tag }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div id="tagcloud">Loading...</div>
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
title: Channels
|
||||
modelClass: jasonwilliams\feed\Models\Channels
|
||||
list: $/jasonwilliams/feed/models/channels/columns.yaml
|
||||
recordUrl: 'jasonwilliams/feed/channels/update/:id'
|
||||
noRecordsMessage: 'backend::lang.list.no_records'
|
||||
recordsPerPage: 20
|
||||
showSetup: true
|
||||
showCheckboxes: true
|
||||
toolbar:
|
||||
buttons: list_toolbar
|
||||
search:
|
||||
prompt: 'backend::lang.list.search_prompt'
|
||||
title: Channels
|
||||
modelClass: jasonwilliams\feed\Models\Channels
|
||||
list: $/jasonwilliams/feed/models/channels/columns.yaml
|
||||
recordUrl: 'jasonwilliams/feed/channels/update/:id'
|
||||
noRecordsMessage: 'backend::lang.list.no_records'
|
||||
recordsPerPage: 20
|
||||
defaultSort:
|
||||
column: id
|
||||
direction: asc
|
||||
showSetup: false
|
||||
showCheckboxes: true
|
||||
toolbar:
|
||||
buttons: list_toolbar
|
||||
search:
|
||||
prompt: 'backend::lang.list.search_prompt'
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
title: Feed
|
||||
modelClass: jasonwilliams\feed\Models\FeedItem
|
||||
list: $/jasonwilliams/feed/models/feeditem/columns.yaml
|
||||
recordUrl: 'jasonwilliams/feed/feed/update/:id'
|
||||
noRecordsMessage: 'backend::lang.list.no_records'
|
||||
recordsPerPage: 20
|
||||
showSetup: true
|
||||
showCheckboxes: true
|
||||
toolbar:
|
||||
buttons: list_toolbar
|
||||
search:
|
||||
prompt: 'backend::lang.list.search_prompt'
|
||||
title: Feed
|
||||
modelClass: jasonwilliams\feed\Models\FeedItem
|
||||
list: $/jasonwilliams/feed/models/feeditem/columns.yaml
|
||||
recordUrl: 'jasonwilliams/feed/feed/update/:id'
|
||||
noRecordsMessage: 'backend::lang.list.no_records'
|
||||
recordsPerPage: 20
|
||||
defaultSort:
|
||||
column: timestamp
|
||||
direction: desc
|
||||
showSetup: true
|
||||
showCheckboxes: true
|
||||
toolbar:
|
||||
buttons: list_toolbar
|
||||
search:
|
||||
prompt: 'backend::lang.list.search_prompt'
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
columns:
|
||||
id:
|
||||
label: 'Channel ID'
|
||||
type: number
|
||||
sortable: true
|
||||
title:
|
||||
label: Title
|
||||
type: text
|
||||
searchable: true
|
||||
sortable: false
|
||||
columns:
|
||||
id:
|
||||
label: 'Channel ID'
|
||||
type: number
|
||||
sortable: true
|
||||
title:
|
||||
label: Title
|
||||
type: text
|
||||
searchable: true
|
||||
sortable: true
|
||||
|
||||
Reference in New Issue
Block a user