~mihirsoni/ubuntu-calendar-app/dateSelectNewEventTest

« back to all changes in this revision

Viewing changes to NewEvent.qml

  • Committer: Tarmac
  • Author(s): Frank Mertens
  • Date: 2013-04-01 23:47:20 UTC
  • mfrom: (12.1.3 eventview-merged)
  • Revision ID: tarmac-20130401234720-rlokamymmmfw61t6
Added the NewEvent component from the EventAPI_EventView branch.

Approved by Ubuntu Phone Apps Jenkins Bot, Kunal Parmar.

Show diffs side-by-side

added added

removed removed

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