Skip to content

Commit fc123d5

Browse files
committed
feat(docs): new Resource Label example
1 parent 8fe5356 commit fc123d5

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed

docs/src/assets/menu.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ const menu = [
559559
{
560560
name: 'Resource - Width/Height',
561561
path: 'resource-width-height'
562+
},
563+
{
564+
name: 'Resource - (Slot) Resource Label',
565+
path: 'resource-slot-resource-label'
562566
}
563567
]
564568
},
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<template>
2+
<div class="subcontent">
3+
<navigation-bar
4+
@today="onToday"
5+
@prev="onPrev"
6+
@next="onNext"
7+
/>
8+
9+
<div class="row justify-center">
10+
<div style="display: flex; max-width: 800px; width: 100%;">
11+
<q-calendar-resource
12+
ref="calendar"
13+
v-model="selectedDate"
14+
v-model:modelResources="resources"
15+
resource-key="id"
16+
resource-label="name"
17+
bordered
18+
sticky
19+
@change="onChange"
20+
@moved="onMoved"
21+
@resource-expanded="onResourceExpanded"
22+
@click-date="onClickDate"
23+
@click-time="onClickTime"
24+
@click-resource="onClickResource"
25+
@click-head-resources="onClickHeadResources"
26+
@click-interval="onClickInterval"
27+
:style="styles"
28+
>
29+
<template #resource-label="{ scope: { resource } }">
30+
<div class="col-12">
31+
<q-chip>
32+
<q-avatar>
33+
<img v-if="resource.avatar" :src="resource.avatar">
34+
<q-icon v-if="resource.icon" :name="resource.icon"></q-icon>
35+
</q-avatar>
36+
{{ resource.name }}
37+
</q-chip>
38+
</div>
39+
</template>
40+
41+
</q-calendar-resource>
42+
</div>
43+
</div>
44+
</div>
45+
</template>
46+
47+
<script>
48+
import { QCalendarResource } from '@quasar/quasar-ui-qcalendar/src/QCalendarResource.js'
49+
import { today } from '@quasar/quasar-ui-qcalendar/src/Timestamp.js'
50+
import '@quasar/quasar-ui-qcalendar/src/QCalendarVariables.sass'
51+
import '@quasar/quasar-ui-qcalendar/src/QCalendarTransitions.sass'
52+
import '@quasar/quasar-ui-qcalendar/src/QCalendarResource.sass'
53+
54+
import { defineComponent } from 'vue'
55+
import NavigationBar from '../components/NavigationBar.vue'
56+
57+
export default defineComponent({
58+
name: 'ResourceSlotResourceLabel',
59+
components: {
60+
NavigationBar,
61+
QCalendarResource
62+
},
63+
data () {
64+
return {
65+
selectedDate: today(),
66+
resourceWidth: 100,
67+
resourceHeight: 70,
68+
resourceMinHeight: 20,
69+
resources: [
70+
{ id: '1', name: 'John', avatar: 'https://cdn.quasar.dev/img/avatar4.jpg' },
71+
{
72+
id: '2',
73+
name: 'Board Room',
74+
icon: 'meeting_room',
75+
expanded: false,
76+
children: [
77+
{ id: '2.1', name: 'Room-1', icon: 'meeting_room' },
78+
{
79+
id: '2.2',
80+
name: 'Room-2',
81+
icon: 'meeting_room',
82+
expanded: false,
83+
children: [
84+
{ id: '2.2.1', name: 'Partition-A', icon: 'meeting_room' },
85+
{ id: '2.2.2', name: 'Partition-B', icon: 'meeting_room' },
86+
{ id: '2.2.2', name: 'Partition-C', icon: 'meeting_room' }
87+
]
88+
}
89+
]
90+
},
91+
{ id: '3', name: 'Mary', avatar: 'https://cdn.quasar.dev/img/avatar2.jpg' },
92+
{ id: '4', name: 'Susan', avatar: 'https://cdn.quasar.dev/img/avatar1.jpg' },
93+
{ id: '5', name: 'Olivia', avatar: 'https://cdn.quasar.dev/img/avatar6.jpg' }
94+
]
95+
}
96+
},
97+
computed: {
98+
styles () {
99+
return {
100+
'--calendar-resources-width': 150 + 'px'
101+
}
102+
}
103+
},
104+
methods: {
105+
getResourceImage (resource) {
106+
return (resource.icon !== undefined ? resource.icon : resource.avatar !== undefined ? 'img:' + resource.avatar : '')
107+
},
108+
onToday () {
109+
this.$refs.calendar.moveToToday()
110+
},
111+
onPrev () {
112+
this.$refs.calendar.prev()
113+
},
114+
onNext () {
115+
this.$refs.calendar.next()
116+
},
117+
onMoved (data) {
118+
console.log('onMoved', data)
119+
},
120+
onChange (data) {
121+
console.log('onChange', data)
122+
},
123+
onResourceExpanded (data) {
124+
console.log('onResourceExpanded', data)
125+
},
126+
onClickDate (data) {
127+
console.log('onClickDate', data)
128+
},
129+
onClickTime (data) {
130+
console.log('onClickTime', data)
131+
},
132+
onClickResource (data) {
133+
console.log('onClickResource', data)
134+
},
135+
onClickHeadResources (data) {
136+
console.log('onClickHeadResources', data)
137+
},
138+
onClickInterval (data) {
139+
console.log('onClickInterval', data)
140+
}
141+
}
142+
})
143+
</script>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Resource - (Slot) Resource Label
3+
desc: QCalendarResource - (Slot) Resource Label
4+
keys: developing
5+
---
6+
7+
<example-viewer
8+
title="(Slot) Resource Label"
9+
file="ResourceSlotResourceLabel"
10+
codepen-title="QCalendarResource"
11+
/>

0 commit comments

Comments
 (0)