1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.Popups 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import "dataService.js" as DataService
Popover {
id: popover
property var defaultDate;
Column {
id: containerLayout
anchors {
left: parent.left
top: parent.top
right: parent.right
}
ListItem.Header { text: i18n.tr("Create event") }
ListItem.Empty {
highlightWhenPressed: false
TextField {
id: titleEdit
placeholderText: i18n.tr("Add event name")
anchors {
fill: parent
margins: units.gu(1)
}
}
}
ListItem.Empty {
id: dateItem
height: column.height
width: parent.width
Column {
id: column
anchors {
left: parent.left
right: parent.right
}
Item {
width: popover.width
height: dateLabel.height
Label {
id: dateLabel
text: Qt.formatDateTime(defaultDate, "ddd, d MMMM yyyy");
anchors {
left: parent.left
right: parent.right
margins: units.gu(1)
}
}
}
Item {
id: timeContainer
width: parent.width
height: startTime.height
ListItem.Empty {
id: startTime
highlightWhenPressed: false
anchors.left: timeContainer.left
width: units.gu(12)
TextField {
id: startTimeEdit
text: Qt.formatDateTime(defaultDate,"hh")
anchors {
fill: parent
margins: units.gu(1)
}
}
}
ListItem.Empty {
id: endTime
highlightWhenPressed: false
anchors.right: timeContainer.right
width: units.gu(12)
TextField {
id: endTimeEdit
text: Qt.formatDateTime(defaultDate,"hh")
anchors {
fill: parent
margins: units.gu(1)
}
}
}
}
}
}
ListItem.Header { text: i18n.tr("Location") }
ListItem.Empty {
highlightWhenPressed: false
TextField {
id: locationEdit
placeholderText: i18n.tr("Add Location")
anchors {
fill: parent
margins: units.gu(1)
}
}
}
ListItem.Header { text: i18n.tr("People") }
ListItem.Empty {
highlightWhenPressed: false
TextField {
id: personEdit
placeholderText: i18n.tr("Invite People")
anchors {
fill: parent
margins: units.gu(1)
}
}
}
ListItem.SingleControl {
highlightWhenPressed: false
control: Button {
text: i18n.tr("Save")
anchors {
fill: parent
margins: units.gu(1)
}
onClicked: {
var startDate = new Date(defaultDate)
print(startDate)
startDate.setHours(startTimeEdit.text)
print(startTimeEdit.text)
var endDate = new Date(defaultDate)
print(endDate)
endDate.setHours(endTimeEdit.text)
print(endTimeEdit.text)
var event = {
title: titleEdit.text,
message: null,
startTime: startDate.getTime(),
endTime: endDate.getTime()
}
DataService.addEvent(event)
PopupUtils.close(popover);
}
}
}
}
}
|