Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vue-draggable-grid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Libraries
vue-draggable-grid
Commits
02a5a240
Commit
02a5a240
authored
2 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Create example for raw items
parent
e4902e0c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Resolve "Implement basic functionality"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
example/src/App.vue
+198
-0
198 additions, 0 deletions
example/src/App.vue
with
198 additions
and
0 deletions
example/src/App.vue
+
198
−
0
View file @
02a5a240
...
@@ -132,6 +132,68 @@ import NumberCounter from "./components/NumberCounter.vue";
...
@@ -132,6 +132,68 @@ import NumberCounter from "./components/NumberCounter.vue";
</
template
>
</
template
>
</drag-grid>
</drag-grid>
</div>
</div>
<div
class=
"ttt-container"
>
<drag-grid
:value=
"colorGrid"
:cols=
"4"
:rows=
"4"
grid-id=
"gridA"
context=
"colors"
class=
"bordered color-grid"
@
itemChanged=
"handleColorItemChange"
>
<
template
#item=
"item"
>
<div
:style=
"
{
background: item.rawItem.getColor('red'),
color: 'white',
}"
>
{{
item
.
data
.
name
}}
</div>
</
template
>
</drag-grid>
<drag-grid
:value=
"colorGrid"
:cols=
"4"
:rows=
"4"
grid-id=
"gridB"
context=
"colors"
class=
"bordered color-grid"
@
itemChanged=
"handleColorItemChange"
>
<
template
#item=
"item"
>
<div
:style=
"
{
background: item.rawItem.getColor('green'),
color: 'black',
}"
>
{{
item
.
data
.
name
}}
</div>
</
template
>
</drag-grid>
<drag-grid
:value=
"colorGrid"
:cols=
"4"
:rows=
"4"
grid-id=
"gridC"
context=
"colors"
class=
"bordered color-grid"
@
itemChanged=
"handleColorItemChange"
>
<
template
#item=
"item"
>
<div
:style=
"
{
background: item.rawItem.getColor('red'),
color: 'white',
}"
>
{{
item
.
data
.
name
}}
</div>
</
template
>
</drag-grid>
</div>
</div>
</div>
</template>
</template>
...
@@ -178,6 +240,48 @@ export default {
...
@@ -178,6 +240,48 @@ export default {
handleLessonDropInContainer
(
lesson
)
{
handleLessonDropInContainer
(
lesson
)
{
if
(
lesson
.
key
===
"
lesson3
"
)
this
.
lesson3inPlan
=
false
;
if
(
lesson
.
key
===
"
lesson3
"
)
this
.
lesson3inPlan
=
false
;
},
},
contains
(
array
,
search
)
{
return
array
.
filter
((
obj
)
=>
obj
===
search
).
length
>
0
;
},
findAndRemove
(
array
,
element
)
{
let
index
=
array
.
findIndex
((
i
)
=>
{
return
i
===
element
;
});
if
(
index
>=
0
)
array
.
splice
(
index
,
1
);
},
handleColorItemChange
(
item
)
{
this
[
item
.
key
].
x
=
item
.
x
;
this
[
item
.
key
].
y
=
item
.
y
;
if
(
item
.
gridId
===
item
.
originGridId
)
return
;
switch
(
item
.
gridId
)
{
case
"
gridA
"
:
// Moved to gridA
this
.
findAndRemove
(
item
.
originGridId
===
"
gridB
"
?
this
.
placedB
:
this
.
placedC
,
item
.
key
);
this
.
placedA
.
push
(
item
.
key
);
break
;
case
"
gridB
"
:
// Moved to gridB
this
.
findAndRemove
(
item
.
originGridId
===
"
gridA
"
?
this
.
placedA
:
this
.
placedC
,
item
.
key
);
this
.
placedB
.
push
(
item
.
key
);
break
;
case
"
gridC
"
:
// Moved to gridC
this
.
findAndRemove
(
item
.
originGridId
===
"
gridB
"
?
this
.
placedB
:
this
.
placedA
,
item
.
key
);
this
.
placedC
.
push
(
item
.
key
);
break
;
}
},
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -234,6 +338,33 @@ export default {
...
@@ -234,6 +338,33 @@ export default {
outside
:
"
This is lesson3 outside of the plan
"
,
outside
:
"
This is lesson3 outside of the plan
"
,
},
},
},
},
placedA
:
[
"
item1
"
,
"
item2
"
],
placedB
:
[
"
item3
"
,
"
item4
"
],
placedC
:
[
"
item5
"
,
"
item6
"
],
item1
:
{
x
:
1
,
y
:
1
,
},
item2
:
{
x
:
2
,
y
:
2
,
},
item3
:
{
x
:
1
,
y
:
1
,
},
item4
:
{
x
:
3
,
y
:
3
,
},
item5
:
{
x
:
2
,
y
:
4
,
},
item6
:
{
x
:
4
,
y
:
2
,
},
};
};
},
},
computed
:
{
computed
:
{
...
@@ -294,6 +425,67 @@ export default {
...
@@ -294,6 +425,67 @@ export default {
},
},
];
];
},
},
colorGrid
()
{
let
items
=
[
"
item1
"
,
"
item2
"
,
"
item3
"
,
"
item4
"
,
"
item5
"
,
"
item6
"
];
let
greens
=
[
"
green
"
,
"
seagreen
"
,
"
greenyellow
"
,
"
darkolivegreen
"
,
"
limegreen
"
,
"
palegreen
"
,
];
let
reds
=
[
"
darkred
"
,
"
indianred
"
,
"
orangered
"
,
"
red
"
,
"
maroon
"
,
"
firebrick
"
,
];
return
items
.
map
((
itemName
)
=>
{
return
{
key
:
itemName
,
x
:
(
grid
)
=>
{
if
(
grid
.
gridId
===
"
gridA
"
)
{
return
this
.
contains
(
this
.
placedA
,
itemName
)
?
this
[
itemName
].
x
:
-
1
;
}
else
if
(
grid
.
gridId
===
"
gridB
"
)
{
return
this
.
contains
(
this
.
placedB
,
itemName
)
?
this
[
itemName
].
x
:
-
1
;
}
else
{
// gridC
return
this
.
contains
(
this
.
placedC
,
itemName
)
?
0
:
-
1
;
}
},
y
:
(
grid
)
=>
{
if
(
grid
.
gridId
===
"
gridA
"
)
{
return
this
.
contains
(
this
.
placedA
,
itemName
)
?
this
[
itemName
].
y
:
-
1
;
}
else
if
(
grid
.
gridId
===
"
gridB
"
)
{
return
this
.
contains
(
this
.
placedB
,
itemName
)
?
this
[
itemName
].
y
:
-
1
;
}
else
{
// gridC
return
this
.
contains
(
this
.
placedC
,
itemName
)
?
0
:
-
1
;
}
},
w
:
1
,
h
:
1
,
data
:
{
name
:
itemName
,
},
getColor
:
(
a
)
=>
a
===
"
red
"
?
reds
[
parseInt
(
itemName
[
4
])
-
1
]
:
greens
[
parseInt
(
itemName
[
4
])
-
1
],
};
});
},
},
},
};
};
</
script
>
</
script
>
...
@@ -346,4 +538,10 @@ export default {
...
@@ -346,4 +538,10 @@ export default {
.bordered
{
.bordered
{
border
:
2px
solid
grey
;
border
:
2px
solid
grey
;
}
}
.color-grid
{
min-height
:
11em
;
line-height
:
2em
;
box-sizing
:
content-box
;
}
</
style
>
</
style
>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment