Skip to content
Snippets Groups Projects
Commit 78005ceb authored by Julian's avatar Julian
Browse files

Enable grid disablement

parent b0c9c76f
No related branches found
No related tags found
1 merge request!2Resolve "Implement basic functionality"
...@@ -248,6 +248,41 @@ import NumberCounter from "./components/NumberCounter.vue"; ...@@ -248,6 +248,41 @@ import NumberCounter from "./components/NumberCounter.vue";
</template> </template>
</drag-grid> </drag-grid>
</div> </div>
<div class="ttt-container">
<div>
<h2>Example 6: Disabled grid</h2>
<p>
This uses the same data as the tic tac toe but is completely disabled.
Notice how the items still move if the tic tac toe grid above is
changed. Uncheck the checkbox to enable:
</p>
<label>
<input type="checkbox" v-model="gridDisabled" />
Grid disabled?
</label>
<drag-grid
v-model="ticTacToe1"
:cols="3"
:rows="3"
:disabled="gridDisabled"
class="tic-tac-toe"
context="ticTacToe"
:validate-element="randomKey"
>
<template #item="item">
<CircularCard>
{{ item.key.startsWith("a") ? "X" : "O" }}
</CircularCard>
</template>
</drag-grid>
</div>
<div>
<h2>Example 7: Disabled fields and items with props</h2>
</div>
</div>
</div> </div>
</template> </template>
...@@ -419,6 +454,7 @@ export default { ...@@ -419,6 +454,7 @@ export default {
x: 4, x: 4,
y: 2, y: 2,
}, },
gridDisabled: true,
}; };
}, },
computed: { computed: {
......
<template> <template>
<div <div
@dragover.prevent="handleDragOver" @dragover.prevent="disabled ? undefined : handleDragOver($event)"
@drop.prevent="handleDrop" @drop.prevent="disabled ? undefined : handleDrop($event)"
class="grid" class="grid"
> >
<div class="highlight-container" ref="highlightContainer"> <div class="highlight-container" ref="highlightContainer">
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
:data="getObject('data', item)" :data="getObject('data', item)"
:context="context" :context="context"
:grid-id="gridId" :grid-id="gridId"
:disabled="disabled"
> >
<slot v-bind="transformItem(item)" :raw-item="item" name="item"> <slot v-bind="transformItem(item)" :raw-item="item" name="item">
<dl> <dl>
...@@ -86,6 +87,11 @@ export default { ...@@ -86,6 +87,11 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
disabled: {
type: Boolean,
required: false,
default: false,
},
}, },
methods: { methods: {
positionAllowed(x, y, key) { positionAllowed(x, y, key) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment