1
0
mirror of https://github.com/flarum/core.git synced 2025-08-18 14:22:02 +02:00
This commit is contained in:
NomisCZ
2019-06-04 20:50:59 +02:00
6 changed files with 72 additions and 68 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2779,9 +2779,9 @@
} }
}, },
"html5sortable": { "html5sortable": {
"version": "0.9.8", "version": "0.9.16",
"resolved": "https://registry.npmjs.org/html5sortable/-/html5sortable-0.9.8.tgz", "resolved": "https://registry.npmjs.org/html5sortable/-/html5sortable-0.9.16.tgz",
"integrity": "sha512-QodBiv8LdTZHot3EMzNHTeKn/nHm66BlvmcFvMFMPVm4mYN5S0uKvDxFnzRltFvrIjvps7OVRrxBJQX8aLnxWg==" "integrity": "sha512-GjCFl7w+Z6bQNs6lU5fhPqLoC5aRbFbQtL9rgqGR3Fs0GCRCrGjoRusZkhWaQpMr4eN25BlkviYA2nH+hFnDoA=="
}, },
"https-browserify": { "https-browserify": {
"version": "1.0.0", "version": "1.0.0",

View File

@@ -3,7 +3,7 @@
"name": "@flarum/tags", "name": "@flarum/tags",
"dependencies": { "dependencies": {
"flarum-webpack-config": "0.1.0-beta.10", "flarum-webpack-config": "0.1.0-beta.10",
"html5sortable": "^0.9.8", "html5sortable": "^0.9.16",
"webpack": "^4.26.0", "webpack": "^4.26.0",
"webpack-cli": "^3.1.2" "webpack-cli": "^3.1.2"
}, },

View File

@@ -1,4 +1,4 @@
import 'html5sortable'; import sortable from 'html5sortable/dist/html5sortable.es.js';
import Page from 'flarum/components/Page'; import Page from 'flarum/components/Page';
import Button from 'flarum/components/Button'; import Button from 'flarum/components/Button';
@@ -80,14 +80,18 @@ export default class TagsPage extends Page {
} }
config() { config() {
this.$('ol, ul') sortable(this.$('ol, ul'), {
.sortable({connectWith: 'primary'}) acceptFrom: 'ol,ul'
.on('sortupdate', (e, ui) => { }).forEach(this.onSortUpdate.bind(this));
}
onSortUpdate(el) {
el.addEventListener('sortupdate', (e) => {
// If we've moved a tag from 'primary' to 'secondary', then we'll update // If we've moved a tag from 'primary' to 'secondary', then we'll update
// its attributes in our local store so that when we redraw the change // its attributes in our local store so that when we redraw the change
// will be made. // will be made.
if (ui.startparent.is('ol') && ui.endparent.is('ul')) { if (e.detail.origin.container instanceof HTMLOListElement && e.detail.destination.container instanceof HTMLUListElement) {
app.store.getById('tags', ui.item.data('id')).pushData({ app.store.getById('tags', e.detail.item.getAttribute('data-id')).pushData({
attributes: { attributes: {
position: null, position: null,
isChild: false isChild: false

View File

@@ -63,11 +63,11 @@ class TagRepository
* @param User|null $user * @param User|null $user
* @return int * @return int
*/ */
public function getIdForSlug($slug, User $user = null) public function getIdForSlug($slug, User $user = null) : ?int
{ {
$query = Tag::where('slug', 'like', $slug); $query = Tag::where('slug', $slug);
return $this->scopeVisibleTo($query, $user)->pluck('id'); return $this->scopeVisibleTo($query, $user)->value('id');
} }
/** /**