Set reservation’s rectangle color based on status
This commit is contained in:
parent
e404727c45
commit
c795effd3d
|
@ -83,10 +83,26 @@ Page {
|
||||||
id: booking
|
id: booking
|
||||||
|
|
||||||
required property string holder
|
required property string holder
|
||||||
|
required property string reservationStatus
|
||||||
|
|
||||||
|
function reservationStatusColor(status) {
|
||||||
|
switch (status) {
|
||||||
|
case "created":
|
||||||
|
return "#cbebff";
|
||||||
|
case "cancelled":
|
||||||
|
return "#ffbaa6";
|
||||||
|
case "confirmed":
|
||||||
|
return "#ffe673";
|
||||||
|
case "checked-in":
|
||||||
|
return "#9fefb9";
|
||||||
|
case "invoiced":
|
||||||
|
return "#e1dbd6";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
border.color: "black"
|
border.color: "black"
|
||||||
border.width: 1
|
border.width: 1
|
||||||
color: "lightblue"
|
color: reservationStatusColor(reservationStatus)
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -174,6 +174,7 @@ TimelineView::Item *TimelineView::createItem(qint64 day, const TimelineModel::It
|
||||||
if (m_reusableItems.isEmpty()) {
|
if (m_reusableItems.isEmpty()) {
|
||||||
QVariantMap initialProperties{
|
QVariantMap initialProperties{
|
||||||
{"holder", modelItem.holder},
|
{"holder", modelItem.holder},
|
||||||
|
{"reservationStatus", modelItem.status},
|
||||||
};
|
};
|
||||||
item = qobject_cast<QQuickItem *>(
|
item = qobject_cast<QQuickItem *>(
|
||||||
m_delegate->createWithInitialProperties(initialProperties,
|
m_delegate->createWithInitialProperties(initialProperties,
|
||||||
|
@ -185,6 +186,7 @@ TimelineView::Item *TimelineView::createItem(qint64 day, const TimelineModel::It
|
||||||
} else {
|
} else {
|
||||||
item = m_reusableItems.takeLast();
|
item = m_reusableItems.takeLast();
|
||||||
item->setProperty("holder", modelItem.holder);
|
item->setProperty("holder", modelItem.holder);
|
||||||
|
item->setProperty("reservationStatus", modelItem.status);
|
||||||
}
|
}
|
||||||
auto *viewItem = new TimelineView::Item(day, modelItem.nights, *item, *this);
|
auto *viewItem = new TimelineView::Item(day, modelItem.nights, *item, *this);
|
||||||
return viewItem;
|
return viewItem;
|
||||||
|
|
Loading…
Reference in New Issue