Merge lp:~renatofilho/address-book-app/fix-1227870 into lp:address-book-app

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Bill Filler
Approved revision: 74
Merged at revision: 76
Proposed branch: lp:~renatofilho/address-book-app/fix-1227870
Merge into: lp:address-book-app
Diff against target: 57 lines (+24/-0)
2 files modified
src/imports/ContactEdit/ContactDetailNameEditor.qml (+23/-0)
src/imports/ContactEdit/ContactEditor.qml (+1/-0)
To merge this branch: bzr merge lp:~renatofilho/address-book-app/fix-1227870
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+187041@code.launchpad.net

Commit message

Disable save button if the field name is empty.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

tested, works

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/imports/ContactEdit/ContactDetailNameEditor.qml'
2--- src/imports/ContactEdit/ContactDetailNameEditor.qml 2013-09-12 22:52:37 +0000
3+++ src/imports/ContactEdit/ContactDetailNameEditor.qml 2013-09-23 14:50:17 +0000
4@@ -23,6 +23,9 @@
5 ContactDetailItem {
6 id: root
7
8+ property bool isEmpty: (fields == -1) || (emptyFields.length === fields.length)
9+ property variant emptyFields: []
10+
11 function save() {
12 var changed = false;
13
14@@ -49,11 +52,31 @@
15 fields: [ QtContacts.Name.FirstName, QtContacts.Name.LastName ]
16
17 fieldDelegate: TextInputDetail {
18+ id: textInputDetail
19+
20+ function checkIsEmpty() {
21+ if (field == -1) {
22+ return;
23+ }
24+
25+ var newEmtpyFields = root.emptyFields
26+ var indexOf = newEmtpyFields.indexOf(field)
27+
28+ if ((text.length > 0) && (indexOf !== -1)) {
29+ newEmtpyFields.splice(indexOf, 1)
30+ } else if ((text.length === 0) && (indexOf === -1)){
31+ newEmtpyFields.push(field)
32+ }
33+ root.emptyFields = newEmtpyFields
34+ }
35+
36 width: root.width - units.gu(4)
37 x: units.gu(2)
38 detail: root.detail
39 height: units.gu(4)
40 placeholderText: field == QtContacts.Name.FirstName ? i18n.tr("First name") : i18n.tr("Last name")
41+ onTextChanged: checkIsEmpty()
42+ onFieldChanged: checkIsEmpty()
43
44 //style
45 font.pixelSize: FontUtils.sizeToPixels("x-large")
46
47=== modified file 'src/imports/ContactEdit/ContactEditor.qml'
48--- src/imports/ContactEdit/ContactEditor.qml 2013-09-19 03:02:46 +0000
49+++ src/imports/ContactEdit/ContactEditor.qml 2013-09-23 14:50:17 +0000
50@@ -285,6 +285,7 @@
51 height: units.gu(6)
52 acceptAction: Action {
53 text: i18n.tr("Save")
54+ enabled: !nameEditor.isEmpty
55 onTriggered: {
56 // wait for contact to be saved or cause a error
57 contactSaveLock.saving = true

Subscribers

People subscribed via source and target branches