Merge lp:~aacid/unity8/edit_reviews into lp:unity8

Proposed by Albert Astals Cid
Status: Merged
Approved by: Andrea Cimitan
Approved revision: 1760
Merged at revision: 1785
Proposed branch: lp:~aacid/unity8/edit_reviews
Merge into: lp:unity8
Diff against target: 352 lines (+246/-46)
7 files modified
qml/Dash/Previews/PreviewRatingDisplay.qml (+11/-46)
qml/Dash/Previews/PreviewRatingEdit.qml (+80/-0)
qml/Dash/Previews/PreviewRatingInput.qml (+3/-0)
qml/Dash/Previews/PreviewRatingSingleDisplay.qml (+70/-0)
qml/Dash/Previews/PreviewWidgetFactory.qml (+1/-0)
tests/qmltests/CMakeLists.txt (+1/-0)
tests/qmltests/Dash/Previews/tst_PreviewRatingEdit.qml (+80/-0)
To merge this branch: bzr merge lp:~aacid/unity8/edit_reviews
Reviewer Review Type Date Requested Status
Andrea Cimitan (community) Approve
Paweł Stołowski Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+258623@code.launchpad.net

Commit message

Implement "rating-edit" preview widget

Description of the change

 * Are there any related MPs required for this MP to build/function as expected?
Not required but should probably land with https://code.launchpad.net/~stolowski/unity-scope-click/edit-review and the rest of unlanded stuff in the bug

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * Did you make sure that your branch does not contain spurious tags?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

 * If you changed the UI, has there been a design review?
Not yet, Will pass it around once we have a silo so it's easier to show live in a phone

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~aacid/unity8/edit_reviews updated
1760. By Albert Astals Cid

whitespaaaaaaaaaaaace

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Works as expected with corresponding unity-scope-click branch. Thanks!

review: Approve
Revision history for this message
Andrea Cimitan (cimi) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes
 * Did CI run pass? If not, please explain why.
Ap
 * Did you make sure that the branch does not contain spurious tags?
Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Dash/Previews/PreviewRatingDisplay.qml'
2--- qml/Dash/Previews/PreviewRatingDisplay.qml 2014-08-13 10:29:21 +0000
3+++ qml/Dash/Previews/PreviewRatingDisplay.qml 2015-05-11 07:33:57 +0000
4@@ -49,53 +49,18 @@
5 objectName: "reviewsRepeater"
6 model: root.widgetData["reviews"]
7
8- delegate: Column {
9- id: reviewItem
10+ delegate: PreviewRatingSingleDisplay {
11 objectName: "reviewItem" + index
12- anchors { left: parent.left; right: parent.right;}
13- spacing: units.gu(1)
14-
15- Rating {
16- id: rating
17- objectName: "rating"
18- size: 5
19- value: modelData["rating"] || -1
20- visible: value >= 0
21- interactive: false
22-
23- property var urlIconEmpty: widgetData["rating-icon-empty"]
24- property var urlIconFull: widgetData["rating-icon-full"]
25- property var urlIconHalf: widgetData["rating-icon-half"]
26- }
27-
28- Label {
29- id: authorLabel
30- objectName: "authorLabel"
31- anchors { left: parent.left; right: parent.right }
32- color: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
33- opacity: .8
34- text: modelData["author"] || ""
35- visible: text !== ""
36- wrapMode: Text.Wrap
37- }
38-
39- Label {
40- id: reviewLabel
41- objectName: "reviewLabel"
42- anchors { left: parent.left; right: parent.right }
43- color: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
44- opacity: .8
45- text: modelData["review"] || ""
46- visible: text !== ""
47- wrapMode: Text.Wrap
48- }
49-
50- Item {
51- id: spacing
52- anchors { left: parent.left; right: parent.right }
53- height: units.gu(2)
54- visible: rating.visible || authorLabel.visible || reviewLabel.visible
55- }
56+
57+ anchors { left: parent.left; right: parent.right; }
58+
59+ rating: modelData["rating"] || -1
60+ author: modelData["author"] || ""
61+ review: modelData["review"] || ""
62+ urlIconEmpty: widgetData["rating-icon-empty"]
63+ urlIconFull: widgetData["rating-icon-full"]
64+ urlIconHalf: widgetData["rating-icon-half"]
65+ labelColor: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
66 }
67 }
68 }
69
70=== added file 'qml/Dash/Previews/PreviewRatingEdit.qml'
71--- qml/Dash/Previews/PreviewRatingEdit.qml 1970-01-01 00:00:00 +0000
72+++ qml/Dash/Previews/PreviewRatingEdit.qml 2015-05-11 07:33:57 +0000
73@@ -0,0 +1,80 @@
74+/*
75+ * Copyright (C) 2015 Canonical, Ltd.
76+ *
77+ * This program is free software; you can redistribute it and/or modify
78+ * it under the terms of the GNU General Public License as published by
79+ * the Free Software Foundation; version 3.
80+ *
81+ * This program is distributed in the hope that it will be useful,
82+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
83+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84+ * GNU General Public License for more details.
85+ *
86+ * You should have received a copy of the GNU General Public License
87+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
88+ */
89+
90+import QtQuick 2.4
91+import Ubuntu.Components 0.1
92+import "../../Components"
93+
94+/*! \brief Preview widget for editable rating.
95+
96+ Shows a single display rating that can be switched by the user to edit mode
97+ and then behaves as a rating display widget
98+
99+ The display part uses widgetData["author"], widgetData["review"] and widgetData["rating"].
100+
101+ The edit part uses the same fields as the "rating-input" widget
102+*/
103+
104+PreviewWidget {
105+ id: root
106+ implicitHeight: display.visible ? display.implicitHeight : input.implicitHeight
107+
108+ Button {
109+ id: editIcon
110+ objectName: "editButton"
111+
112+ iconName: "edit"
113+ width: height
114+ anchors.right: parent.right
115+ visible: display.visible
116+ onClicked: display.visible = false
117+ }
118+
119+ PreviewRatingSingleDisplay {
120+ id: display
121+ objectName: "display"
122+
123+ anchors.left: parent.left
124+ anchors.right: editIcon.left
125+
126+ rating: widgetData["rating"] || -1
127+ author: widgetData["author"] || ""
128+ review: widgetData["review"] || ""
129+ urlIconEmpty: widgetData["rating-icon-empty"]
130+ urlIconFull: widgetData["rating-icon-full"]
131+ urlIconHalf: widgetData["rating-icon-half"]
132+ labelColor: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
133+ }
134+
135+ PreviewRatingInput {
136+ id: input
137+ objectName: "input"
138+
139+ visible: !display.visible
140+ width: parent.width
141+
142+ widgetId: root.widgetId
143+ widgetData: root.widgetData
144+ isCurrentPreview: root.isCurrentPreview
145+ scopeStyle: root.scopeStyle
146+
147+ ratingValue: widgetData["rating"]
148+ reviewText: widgetData["review"]
149+
150+ onTriggered: root.triggered(widgetId, actionId, data);
151+ }
152+
153+}
154
155=== modified file 'qml/Dash/Previews/PreviewRatingInput.qml'
156--- qml/Dash/Previews/PreviewRatingInput.qml 2014-08-13 10:29:21 +0000
157+++ qml/Dash/Previews/PreviewRatingInput.qml 2015-05-11 07:33:57 +0000
158@@ -48,6 +48,9 @@
159 }
160 }
161
162+ property alias ratingValue: rating.value
163+ property alias reviewText: reviewTextArea.text
164+
165 function submit() {
166 // checks rating-input requirements
167 if (((widgetData["required"] === "both" ||
168
169=== added file 'qml/Dash/Previews/PreviewRatingSingleDisplay.qml'
170--- qml/Dash/Previews/PreviewRatingSingleDisplay.qml 1970-01-01 00:00:00 +0000
171+++ qml/Dash/Previews/PreviewRatingSingleDisplay.qml 2015-05-11 07:33:57 +0000
172@@ -0,0 +1,70 @@
173+/*
174+ * Copyright (C) 2015 Canonical, Ltd.
175+ *
176+ * This program is free software; you can redistribute it and/or modify
177+ * it under the terms of the GNU General Public License as published by
178+ * the Free Software Foundation; version 3.
179+ *
180+ * This program is distributed in the hope that it will be useful,
181+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
182+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
183+ * GNU General Public License for more details.
184+ *
185+ * You should have received a copy of the GNU General Public License
186+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
187+ */
188+
189+import QtQuick 2.4
190+import Ubuntu.Components 0.1
191+import "../../Components"
192+
193+Column {
194+ id: reviewItem
195+ spacing: units.gu(1)
196+
197+ property alias rating: ratingItem.value
198+ property alias author: authorLabel.text
199+ property alias review: reviewLabel.text
200+ property alias urlIconEmpty: ratingItem.urlIconEmpty
201+ property alias urlIconFull: ratingItem.urlIconFull
202+ property alias urlIconHalf: ratingItem.urlIconHalf
203+ property alias labelColor: authorLabel.color
204+
205+ Rating {
206+ id: ratingItem
207+ objectName: "rating"
208+ size: 5
209+ visible: value >= 0
210+ interactive: false
211+
212+ property var urlIconEmpty
213+ property var urlIconFull
214+ property var urlIconHalf
215+ }
216+
217+ Label {
218+ id: authorLabel
219+ objectName: "authorLabel"
220+ anchors { left: parent.left; right: parent.right }
221+ opacity: .8
222+ visible: text !== ""
223+ wrapMode: Text.Wrap
224+ }
225+
226+ Label {
227+ id: reviewLabel
228+ objectName: "reviewLabel"
229+ anchors { left: parent.left; right: parent.right }
230+ color: authorLabel.color
231+ opacity: .8
232+ visible: text !== ""
233+ wrapMode: Text.Wrap
234+ }
235+
236+ Item {
237+ id: spacing
238+ anchors { left: parent.left; right: parent.right }
239+ height: units.gu(2)
240+ visible: rating.visible || authorLabel.visible || reviewLabel.visible
241+ }
242+}
243\ No newline at end of file
244
245=== modified file 'qml/Dash/Previews/PreviewWidgetFactory.qml'
246--- qml/Dash/Previews/PreviewWidgetFactory.qml 2014-08-26 10:54:49 +0000
247+++ qml/Dash/Previews/PreviewWidgetFactory.qml 2015-05-11 07:33:57 +0000
248@@ -57,6 +57,7 @@
249 case "progress": return "PreviewProgress.qml";
250 case "payments": return "PreviewPayments.qml";
251 case "rating-input": return "PreviewRatingInput.qml";
252+ case "rating-edit": return "PreviewRatingEdit.qml";
253 case "reviews": return "PreviewRatingDisplay.qml";
254 case "table": return "PreviewTable.qml";
255 case "text": return "PreviewTextSummary.qml";
256
257=== modified file 'tests/qmltests/CMakeLists.txt'
258--- tests/qmltests/CMakeLists.txt 2015-03-18 10:18:52 +0000
259+++ tests/qmltests/CMakeLists.txt 2015-05-11 07:33:57 +0000
260@@ -49,6 +49,7 @@
261 add_qml_test(Dash/Previews PreviewPayments)
262 add_qml_test(Dash/Previews PreviewProgress)
263 add_qml_test(Dash/Previews PreviewRatingDisplay)
264+add_qml_test(Dash/Previews PreviewRatingEdit)
265 add_qml_test(Dash/Previews PreviewRatingInput)
266 add_qml_test(Dash/Previews PreviewTable)
267 add_qml_test(Dash/Previews PreviewTextSummary)
268
269=== added file 'tests/qmltests/Dash/Previews/tst_PreviewRatingEdit.qml'
270--- tests/qmltests/Dash/Previews/tst_PreviewRatingEdit.qml 1970-01-01 00:00:00 +0000
271+++ tests/qmltests/Dash/Previews/tst_PreviewRatingEdit.qml 2015-05-11 07:33:57 +0000
272@@ -0,0 +1,80 @@
273+/*
274+ * Copyright 2014 Canonical Ltd.
275+ *
276+ * This program is free software; you can redistribute it and/or modify
277+ * it under the terms of the GNU General Public License as published by
278+ * the Free Software Foundation; version 3.
279+ *
280+ * This program is distributed in the hope that it will be useful,
281+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
282+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
283+ * GNU General Public License for more details.
284+ *
285+ * You should have received a copy of the GNU General Public License
286+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
287+ */
288+
289+import QtQuick 2.0
290+import QtTest 1.0
291+import Ubuntu.Components 0.1
292+import "../../../../qml/Dash/Previews"
293+import Unity.Test 0.1 as UT
294+
295+Rectangle {
296+ id: root
297+ width: units.gu(40)
298+ height: units.gu(80)
299+ color: Theme.palette.selected.background
300+
301+ property var widgetData0: { "visible": "both", "required": "both", author: "Some dude", rating: 4.5, review: "Very cool app" }
302+
303+ PreviewRatingEdit {
304+ id: previewRatingEdit
305+ anchors.left: parent.left
306+ anchors.right: parent.right
307+ widgetData: widgetData0
308+ widgetId: "previewRatingInput"
309+ }
310+
311+ SignalSpy {
312+ id: spy
313+ signalName: "triggered"
314+ }
315+
316+ UT.UnityTestCase {
317+ name: "PreviewRatingEditTest"
318+ when: windowShown
319+
320+ function test_switch_and_trigger(data) {
321+ spy.target = previewRatingEdit;
322+
323+ var authorLabel = findChild(previewRatingEdit, "authorLabel");
324+ var reviewTextArea = findChild(previewRatingEdit, "reviewTextArea");
325+ var inputRating = findChild(findChild(previewRatingEdit, "input"), "rating");
326+ verify(authorLabel.visible)
327+ verify(!reviewTextArea.visible)
328+
329+ var editButton = findChild(previewRatingEdit, "editButton");
330+ mouseClick(editButton);
331+ verify(!authorLabel.visible)
332+ verify(reviewTextArea.visible)
333+
334+ compare(reviewTextArea.text, "Very cool app");
335+ compare(inputRating.value, 4.5);
336+
337+ reviewTextArea.text = "Ho Ho";
338+ inputRating.value = 3;
339+
340+ var submitButton = findChild(previewRatingEdit, "submitButton")
341+ mouseClick(submitButton);
342+
343+ compare(spy.count, 1);
344+ var args = spy.signalArguments[0];
345+ compare(args[0], previewRatingEdit.widgetId);
346+ compare(args[1], "rated");
347+ compare(args[2]["rating"], 3);
348+ compare(args[2]["review"], "Ho Ho");
349+ verify(args[2]["author"] !== undefined); // Just verifying it exists now
350+ }
351+ }
352+}

Subscribers

People subscribed via source and target branches