contact_manager 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/VERSION +1 -1
- data/app/contact_manager/model/contact.rb +9 -0
- data/app/contact_manager/model/contact_presenter.rb +28 -3
- data/app/contact_manager/view/contact_table.rb +1 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d51e31041c2eabd164ed078a72246650b092c7945dc5c8544e9444a911cdd286
|
4
|
+
data.tar.gz: 879808379c833d41511e69f6b3a470fbc72faad93635dd534259c086a28a75f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c96e23f7a0e9a5f6f9b40c6d0137a79a10e31a863e2be471dce749550b119f8a6c673e3906ad04f7796bf5a36351605888c3fe920e62a4a6b8dcd21833adf8e
|
7
|
+
data.tar.gz: f324b646b102ec353c5a98567a7931e16fb6e537616a4e2d077a8909bafdead7695b2e6ef34e3749a167c913f61f3f5c67f861308fa9e2357696ee82b0a71813
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# <img src="https://raw.githubusercontent.com/AndyObtiva/contact_manager/master/icons/linux/Contact%20Manager.png" height=85 /> Contact Manager 1.0.
|
1
|
+
# <img src="https://raw.githubusercontent.com/AndyObtiva/contact_manager/master/icons/linux/Contact%20Manager.png" height=85 /> Contact Manager 1.0.2
|
2
2
|
## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-dsl-swt/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer Application](https://github.com/AndyObtiva/glimmer-dsl-swt)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/contact_manager.svg)](http://badge.fury.io/rb/contact_manager)
|
4
4
|
|
@@ -46,7 +46,7 @@ Start by setting up [JDK 18](https://www.oracle.com/java/technologies/downloads)
|
|
46
46
|
Install Ruby gem:
|
47
47
|
|
48
48
|
```
|
49
|
-
gem install contact_manager -v1.0.
|
49
|
+
gem install contact_manager -v1.0.2
|
50
50
|
```
|
51
51
|
|
52
52
|
Run:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
@@ -28,6 +28,15 @@ class Contact < ActiveRecord::Base
|
|
28
28
|
(PROVINCES + [''] + STATES)
|
29
29
|
end
|
30
30
|
|
31
|
+
def reset!
|
32
|
+
return unless persisted? && changed?
|
33
|
+
|
34
|
+
attributes.each do |attribute, value|
|
35
|
+
# calling attribute writers explicitly notifies Glimmer GUI observers indirectly
|
36
|
+
send("#{attribute}=", send("#{attribute}_was")) if send("#{attribute}_changed?")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
31
40
|
private
|
32
41
|
|
33
42
|
def email_or_phone_is_present
|
@@ -8,20 +8,45 @@ class ContactPresenter
|
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
renew_current_contact
|
11
|
-
|
11
|
+
refresh_contacts
|
12
12
|
|
13
13
|
# Monitor Contact collection changes
|
14
14
|
# the after_commit hook executes the block under a different object
|
15
15
|
# binding, so we must use `this` to access self
|
16
16
|
this = self
|
17
17
|
Contact.after_commit(on: [:create, :update, :destroy]) do
|
18
|
-
this.
|
18
|
+
this.refresh_contacts
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
def query=(query_value)
|
23
23
|
@query = query_value
|
24
|
-
|
24
|
+
refresh_contacts
|
25
|
+
end
|
26
|
+
|
27
|
+
def current_contact=(new_contact)
|
28
|
+
# first, reset current contact in case it was changed but not saved
|
29
|
+
@current_contact&.reset!
|
30
|
+
# next, update current contact
|
31
|
+
@current_contact = new_contact
|
32
|
+
end
|
33
|
+
|
34
|
+
def refresh_contacts
|
35
|
+
if query
|
36
|
+
new_contacts = ContactRepository.instance.search(query)
|
37
|
+
else
|
38
|
+
new_contacts = ContactRepository.instance.all
|
39
|
+
end
|
40
|
+
|
41
|
+
if new_contacts != contacts
|
42
|
+
self.contacts = new_contacts.to_a
|
43
|
+
refresh_current_contact
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def refresh_current_contact
|
48
|
+
current_contact_index = contacts.index(current_contact)
|
49
|
+
self.current_contact = contacts[current_contact_index] if current_contact_index
|
25
50
|
end
|
26
51
|
|
27
52
|
def renew_current_contact
|
@@ -50,9 +50,7 @@ class ContactManager
|
|
50
50
|
width 320
|
51
51
|
}
|
52
52
|
|
53
|
-
|
54
|
-
# but an Array object is required by Glimmer DSL for SWT table data-binding logic
|
55
|
-
items <=> [contact_presenter, :contacts, on_read: :to_a, column_properties: [:first_name, :last_name, :email, :phone, :address]]
|
53
|
+
items <=> [contact_presenter, :contacts]
|
56
54
|
|
57
55
|
selection <=> [contact_presenter, :current_contact, after_write: reset_validations_action]
|
58
56
|
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contact_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 4.
|
18
|
+
version: 4.24.4.1
|
19
19
|
name: glimmer-dsl-swt
|
20
20
|
prerelease: false
|
21
21
|
type: :runtime
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.
|
26
|
+
version: 4.24.4.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|