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 (community) 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
=== modified file 'qml/Dash/Previews/PreviewRatingDisplay.qml'
--- qml/Dash/Previews/PreviewRatingDisplay.qml 2014-08-13 10:29:21 +0000
+++ qml/Dash/Previews/PreviewRatingDisplay.qml 2015-05-11 07:33:57 +0000
@@ -49,53 +49,18 @@
49 objectName: "reviewsRepeater"49 objectName: "reviewsRepeater"
50 model: root.widgetData["reviews"]50 model: root.widgetData["reviews"]
5151
52 delegate: Column {52 delegate: PreviewRatingSingleDisplay {
53 id: reviewItem
54 objectName: "reviewItem" + index53 objectName: "reviewItem" + index
55 anchors { left: parent.left; right: parent.right;}54
56 spacing: units.gu(1)55 anchors { left: parent.left; right: parent.right; }
5756
58 Rating {57 rating: modelData["rating"] || -1
59 id: rating58 author: modelData["author"] || ""
60 objectName: "rating"59 review: modelData["review"] || ""
61 size: 560 urlIconEmpty: widgetData["rating-icon-empty"]
62 value: modelData["rating"] || -161 urlIconFull: widgetData["rating-icon-full"]
63 visible: value >= 062 urlIconHalf: widgetData["rating-icon-half"]
64 interactive: false63 labelColor: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
65
66 property var urlIconEmpty: widgetData["rating-icon-empty"]
67 property var urlIconFull: widgetData["rating-icon-full"]
68 property var urlIconHalf: widgetData["rating-icon-half"]
69 }
70
71 Label {
72 id: authorLabel
73 objectName: "authorLabel"
74 anchors { left: parent.left; right: parent.right }
75 color: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
76 opacity: .8
77 text: modelData["author"] || ""
78 visible: text !== ""
79 wrapMode: Text.Wrap
80 }
81
82 Label {
83 id: reviewLabel
84 objectName: "reviewLabel"
85 anchors { left: parent.left; right: parent.right }
86 color: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
87 opacity: .8
88 text: modelData["review"] || ""
89 visible: text !== ""
90 wrapMode: Text.Wrap
91 }
92
93 Item {
94 id: spacing
95 anchors { left: parent.left; right: parent.right }
96 height: units.gu(2)
97 visible: rating.visible || authorLabel.visible || reviewLabel.visible
98 }
99 }64 }
100 }65 }
101 }66 }
10267
=== added file 'qml/Dash/Previews/PreviewRatingEdit.qml'
--- qml/Dash/Previews/PreviewRatingEdit.qml 1970-01-01 00:00:00 +0000
+++ qml/Dash/Previews/PreviewRatingEdit.qml 2015-05-11 07:33:57 +0000
@@ -0,0 +1,80 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 0.1
19import "../../Components"
20
21/*! \brief Preview widget for editable rating.
22
23 Shows a single display rating that can be switched by the user to edit mode
24 and then behaves as a rating display widget
25
26 The display part uses widgetData["author"], widgetData["review"] and widgetData["rating"].
27
28 The edit part uses the same fields as the "rating-input" widget
29*/
30
31PreviewWidget {
32 id: root
33 implicitHeight: display.visible ? display.implicitHeight : input.implicitHeight
34
35 Button {
36 id: editIcon
37 objectName: "editButton"
38
39 iconName: "edit"
40 width: height
41 anchors.right: parent.right
42 visible: display.visible
43 onClicked: display.visible = false
44 }
45
46 PreviewRatingSingleDisplay {
47 id: display
48 objectName: "display"
49
50 anchors.left: parent.left
51 anchors.right: editIcon.left
52
53 rating: widgetData["rating"] || -1
54 author: widgetData["author"] || ""
55 review: widgetData["review"] || ""
56 urlIconEmpty: widgetData["rating-icon-empty"]
57 urlIconFull: widgetData["rating-icon-full"]
58 urlIconHalf: widgetData["rating-icon-half"]
59 labelColor: scopeStyle ? scopeStyle.foreground : Theme.palette.normal.baseText
60 }
61
62 PreviewRatingInput {
63 id: input
64 objectName: "input"
65
66 visible: !display.visible
67 width: parent.width
68
69 widgetId: root.widgetId
70 widgetData: root.widgetData
71 isCurrentPreview: root.isCurrentPreview
72 scopeStyle: root.scopeStyle
73
74 ratingValue: widgetData["rating"]
75 reviewText: widgetData["review"]
76
77 onTriggered: root.triggered(widgetId, actionId, data);
78 }
79
80}
081
=== modified file 'qml/Dash/Previews/PreviewRatingInput.qml'
--- qml/Dash/Previews/PreviewRatingInput.qml 2014-08-13 10:29:21 +0000
+++ qml/Dash/Previews/PreviewRatingInput.qml 2015-05-11 07:33:57 +0000
@@ -48,6 +48,9 @@
48 }48 }
49 }49 }
5050
51 property alias ratingValue: rating.value
52 property alias reviewText: reviewTextArea.text
53
51 function submit() {54 function submit() {
52 // checks rating-input requirements55 // checks rating-input requirements
53 if (((widgetData["required"] === "both" ||56 if (((widgetData["required"] === "both" ||
5457
=== added file 'qml/Dash/Previews/PreviewRatingSingleDisplay.qml'
--- qml/Dash/Previews/PreviewRatingSingleDisplay.qml 1970-01-01 00:00:00 +0000
+++ qml/Dash/Previews/PreviewRatingSingleDisplay.qml 2015-05-11 07:33:57 +0000
@@ -0,0 +1,70 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 0.1
19import "../../Components"
20
21Column {
22 id: reviewItem
23 spacing: units.gu(1)
24
25 property alias rating: ratingItem.value
26 property alias author: authorLabel.text
27 property alias review: reviewLabel.text
28 property alias urlIconEmpty: ratingItem.urlIconEmpty
29 property alias urlIconFull: ratingItem.urlIconFull
30 property alias urlIconHalf: ratingItem.urlIconHalf
31 property alias labelColor: authorLabel.color
32
33 Rating {
34 id: ratingItem
35 objectName: "rating"
36 size: 5
37 visible: value >= 0
38 interactive: false
39
40 property var urlIconEmpty
41 property var urlIconFull
42 property var urlIconHalf
43 }
44
45 Label {
46 id: authorLabel
47 objectName: "authorLabel"
48 anchors { left: parent.left; right: parent.right }
49 opacity: .8
50 visible: text !== ""
51 wrapMode: Text.Wrap
52 }
53
54 Label {
55 id: reviewLabel
56 objectName: "reviewLabel"
57 anchors { left: parent.left; right: parent.right }
58 color: authorLabel.color
59 opacity: .8
60 visible: text !== ""
61 wrapMode: Text.Wrap
62 }
63
64 Item {
65 id: spacing
66 anchors { left: parent.left; right: parent.right }
67 height: units.gu(2)
68 visible: rating.visible || authorLabel.visible || reviewLabel.visible
69 }
70}
0\ No newline at end of file71\ No newline at end of file
172
=== modified file 'qml/Dash/Previews/PreviewWidgetFactory.qml'
--- qml/Dash/Previews/PreviewWidgetFactory.qml 2014-08-26 10:54:49 +0000
+++ qml/Dash/Previews/PreviewWidgetFactory.qml 2015-05-11 07:33:57 +0000
@@ -57,6 +57,7 @@
57 case "progress": return "PreviewProgress.qml";57 case "progress": return "PreviewProgress.qml";
58 case "payments": return "PreviewPayments.qml";58 case "payments": return "PreviewPayments.qml";
59 case "rating-input": return "PreviewRatingInput.qml";59 case "rating-input": return "PreviewRatingInput.qml";
60 case "rating-edit": return "PreviewRatingEdit.qml";
60 case "reviews": return "PreviewRatingDisplay.qml";61 case "reviews": return "PreviewRatingDisplay.qml";
61 case "table": return "PreviewTable.qml";62 case "table": return "PreviewTable.qml";
62 case "text": return "PreviewTextSummary.qml";63 case "text": return "PreviewTextSummary.qml";
6364
=== modified file 'tests/qmltests/CMakeLists.txt'
--- tests/qmltests/CMakeLists.txt 2015-03-18 10:18:52 +0000
+++ tests/qmltests/CMakeLists.txt 2015-05-11 07:33:57 +0000
@@ -49,6 +49,7 @@
49add_qml_test(Dash/Previews PreviewPayments)49add_qml_test(Dash/Previews PreviewPayments)
50add_qml_test(Dash/Previews PreviewProgress)50add_qml_test(Dash/Previews PreviewProgress)
51add_qml_test(Dash/Previews PreviewRatingDisplay)51add_qml_test(Dash/Previews PreviewRatingDisplay)
52add_qml_test(Dash/Previews PreviewRatingEdit)
52add_qml_test(Dash/Previews PreviewRatingInput)53add_qml_test(Dash/Previews PreviewRatingInput)
53add_qml_test(Dash/Previews PreviewTable)54add_qml_test(Dash/Previews PreviewTable)
54add_qml_test(Dash/Previews PreviewTextSummary)55add_qml_test(Dash/Previews PreviewTextSummary)
5556
=== added file 'tests/qmltests/Dash/Previews/tst_PreviewRatingEdit.qml'
--- tests/qmltests/Dash/Previews/tst_PreviewRatingEdit.qml 1970-01-01 00:00:00 +0000
+++ tests/qmltests/Dash/Previews/tst_PreviewRatingEdit.qml 2015-05-11 07:33:57 +0000
@@ -0,0 +1,80 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import QtTest 1.0
19import Ubuntu.Components 0.1
20import "../../../../qml/Dash/Previews"
21import Unity.Test 0.1 as UT
22
23Rectangle {
24 id: root
25 width: units.gu(40)
26 height: units.gu(80)
27 color: Theme.palette.selected.background
28
29 property var widgetData0: { "visible": "both", "required": "both", author: "Some dude", rating: 4.5, review: "Very cool app" }
30
31 PreviewRatingEdit {
32 id: previewRatingEdit
33 anchors.left: parent.left
34 anchors.right: parent.right
35 widgetData: widgetData0
36 widgetId: "previewRatingInput"
37 }
38
39 SignalSpy {
40 id: spy
41 signalName: "triggered"
42 }
43
44 UT.UnityTestCase {
45 name: "PreviewRatingEditTest"
46 when: windowShown
47
48 function test_switch_and_trigger(data) {
49 spy.target = previewRatingEdit;
50
51 var authorLabel = findChild(previewRatingEdit, "authorLabel");
52 var reviewTextArea = findChild(previewRatingEdit, "reviewTextArea");
53 var inputRating = findChild(findChild(previewRatingEdit, "input"), "rating");
54 verify(authorLabel.visible)
55 verify(!reviewTextArea.visible)
56
57 var editButton = findChild(previewRatingEdit, "editButton");
58 mouseClick(editButton);
59 verify(!authorLabel.visible)
60 verify(reviewTextArea.visible)
61
62 compare(reviewTextArea.text, "Very cool app");
63 compare(inputRating.value, 4.5);
64
65 reviewTextArea.text = "Ho Ho";
66 inputRating.value = 3;
67
68 var submitButton = findChild(previewRatingEdit, "submitButton")
69 mouseClick(submitButton);
70
71 compare(spy.count, 1);
72 var args = spy.signalArguments[0];
73 compare(args[0], previewRatingEdit.widgetId);
74 compare(args[1], "rated");
75 compare(args[2]["rating"], 3);
76 compare(args[2]["review"], "Ho Ho");
77 verify(args[2]["author"] !== undefined); // Just verifying it exists now
78 }
79 }
80}

Subscribers

People subscribed via source and target branches