wip(Dashboard): grid widgets
This commit is contained in:
40
assets/controllers/dashboard_widgets_controller.js
Normal file
40
assets/controllers/dashboard_widgets_controller.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
import {GridStack} from "../vendor/gridstack/gridstack.index.js";
|
||||
|
||||
/*
|
||||
* The following line makes this controller "lazy": it won't be downloaded until needed
|
||||
* See https://symfony.com/bundles/StimulusBundle/current/index.html#lazy-stimulus-controllers
|
||||
*/
|
||||
|
||||
/* stimulusFetch: 'lazy' */
|
||||
export default class extends Controller {
|
||||
grid;
|
||||
|
||||
initialize() {
|
||||
|
||||
}
|
||||
|
||||
connect() {
|
||||
this.grid = GridStack.init({
|
||||
column: 2,
|
||||
alwaysShowResizeHandle: true,
|
||||
margin: "2rem",
|
||||
resizable: {
|
||||
handles: 'e,se,s,sw,w'
|
||||
}
|
||||
});
|
||||
|
||||
this.grid.load();
|
||||
}
|
||||
|
||||
// Add custom controller actions here
|
||||
// fooBar() { this.fooTarget.classList.toggle(this.bazClass) }
|
||||
|
||||
disconnect() {
|
||||
// Called anytime its element is disconnected from the DOM
|
||||
// (on page change, when it's removed from or moved in the DOM, etc.)
|
||||
|
||||
// Here you should remove all event listeners added in "connect()"
|
||||
// this.fooTarget.removeEventListener('click', this._fooBar)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user