JSFiddle - React, Tailwind, and code Playground
by webwakko
HTML
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.4/vue.js"></script>
<script src="https://cdn.jsdelivr.net/sortable/1.4.2/Sortable.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.13.1/lodash.min.js"></script>
<script src="https://cdn.rawgit.com/David-Desmaisons/Vue.Draggable/master/dist/vuedraggable.min.js"></script>
<div id="app">
<schedule></schedule>
</div>
<template id="schedule-template">
<div class="col-lg-12">
<div class="col-lg-12">
<div class="row col-lg-12">
<h2 class="type-header">Schedule</h2>
</div>
<div class="row col-lg-12"><hr></div>
<div class="row col-lg-12">
<div class="col-lg-3 dropzone">
<span style="text-align: center; font-weight: bold;">JD</span>
<itemlist v-bind="JDItems" v-on:item-moved-to-list="moveItemToList"></itemlist>
</div>
<div class="col-lg-3 dropzone">
<span style="text-align: center; font-weight: bold;">KDG</span>
<itemlist v-bind="KDGItems" v-on:item-moved-to-list="moveItemToList"></itemlist>
</div>
<div class="col-lg-3 dropzone">
<span style="text-align: center; font-weight: bold;">EDG</span>
<itemlist v-bind="EDGItems" v-on:item-moved-to-list="moveItemToList"></itemlist>
</div>
<div class="col-lg-3 dropzone">
<span style="text-align: center; font-weight: bold;">PM</span>
<itemlist v-bind="PMItems"...
CSS
.dropzone {
border: 2px solid steelblue;
padding: 2px;
min-height: 60px;
}
.item-list {
display: flex;
min-height: 72px;
padding: 2px;
border: 2px gray solid;
}
.item {
display: flex;
max-width: 115px;
height: 60px;
padding: 5px;
border: 2px solid black;
margin: 2px;
}
.modal-mask {
position: fixed;
z-index: 9998;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .5);
display: table;
transition: opacity .3s ease;
}
.modal-wrapper {
display: table-cell;
vertical-align: middle;
}
.modal-container {
width: 300px;
margin: 0px auto;
padding: 20px 30px;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
transition: all .3s ease;
font-family: Helvetica, Arial, sans-serif;
}
.modal-header h3 {
margin-top: 0;
color: #42b983;
}
.modal-body {
margin: 20px 0;
}
.modal-default-button {
float: right;
}
/*
* The following styles are auto-applied to elements with
* transition="modal" when their visibility is toggled
* by Vue.js.
*
* You can easily play with the modal transition by editing
* these styles.
*/
.modal-enter {
opacity: 0;
}
.modal-leave-active {
opacity: 0;
}
.modal-enter .modal-container,
.modal-leave-active .modal-container {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
JavaScript
Vue.component('itemmodal', {
template: '#item-modal-template',
props: {
id: {
type: Number,
unplanned: true
}
}
});
Vue.component('item', {
template: '#item-template',
props: {
id: {
type: Number,
unplanned: true,
},
title: {
type: String,
unplanned: true,
}
},
data: function () {
return {
modalActive: false,
};
},
methods: {
showModal: function() {
console.log('Showing modal...');
this.modalActive = true;
},
hideModal: function() {
console.log('Hiding modal...');
this.modalActive = false;
}
}
});
Vue.component('itemlist', {
template: '#item-list-template',
props: {
items: {
type: Array,
unplanned: false
},
resource: {
type: String,
unplanned: true
}
},
methods: {
onChangeCallback: function(event) {
if( "added" in event ) {
this.$emit( 'item-moved-to-list', event.added.element.id, this.resource );
}
}
}
});
Vue.component('schedule', {
template: '#schedule-template',
data: function () {
return {
items: [
{
id: 1,
title: "Fix the issue",
resource: "none",
unplanned: true
},
{
id: 2,
title: "Plant a tree",
resource: "none",
unplanned: true
},
{
...