Changing tag list to load content by ajax (fix #40) and updating the default sort order of backend lists (fix #49)
This commit is contained in:
parent
a50c117a98
commit
675c377d91
@ -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) }
|
||||
})
|
||||
})
|
@ -21,6 +21,12 @@ class TagList extends ComponentBase
|
||||
|
||||
public function onRun()
|
||||
{
|
||||
$this->page['tags'] = Tags::groupBy('tag')->select(Db::raw('tag, count(*) as count'))->orderBy('count', 'desc')->get();
|
||||
$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>
|
||||
|
@ -4,7 +4,10 @@ list: $/jasonwilliams/feed/models/channels/columns.yaml
|
||||
recordUrl: 'jasonwilliams/feed/channels/update/:id'
|
||||
noRecordsMessage: 'backend::lang.list.no_records'
|
||||
recordsPerPage: 20
|
||||
showSetup: true
|
||||
defaultSort:
|
||||
column: id
|
||||
direction: asc
|
||||
showSetup: false
|
||||
showCheckboxes: true
|
||||
toolbar:
|
||||
buttons: list_toolbar
|
||||
|
@ -4,6 +4,9 @@ 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:
|
||||
|
@ -7,4 +7,4 @@ columns:
|
||||
label: Title
|
||||
type: text
|
||||
searchable: true
|
||||
sortable: false
|
||||
sortable: true
|
||||
|
@ -26,6 +26,25 @@
|
||||
})
|
||||
})
|
||||
|
||||
// Render the tag cloud if/when tag data is loaded by the component
|
||||
$(window).on('tagsLoaded', function(event, data) {
|
||||
console.log(data.responseJSON)
|
||||
|
||||
var cloudWords = []
|
||||
|
||||
data.responseJSON.forEach((tag) => {
|
||||
cloudWords.push({text: tag.tag, weight: tag.count, link: '/feed/all/' + tag.tag})
|
||||
})
|
||||
|
||||
$('#tagcloud').html('').height($('#tagcloud').width() * 4/3)
|
||||
|
||||
$('#tagcloud').jQCloud(cloudWords, {
|
||||
autoResize: true,
|
||||
removeOverflowing: true,
|
||||
delay: 2
|
||||
})
|
||||
})
|
||||
|
||||
// If there's tag data set once the page is loaded, create a tag cloud
|
||||
$(function() {
|
||||
if(typeof tagData !== 'undefined') {
|
||||
|
@ -34,10 +34,6 @@ function onStart()
|
||||
{% component 'ChannelList' %}
|
||||
|
||||
<h2>Tags</h2>
|
||||
<div id="tagcloud" style="height: 500px;"></div>
|
||||
<div id="tagcloud"><img src="{{ 'assets/images/loading.svg' | theme }}"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% put scripts %}
|
||||
<script type="text/javascript">const tagData = {{ tags | raw }};</script>
|
||||
{% endput %}
|
Loading…
Reference in New Issue
Block a user