glimmer-dsl-opal 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +475 -25
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal.rb +2 -0
- data/lib/glimmer/data_binding/ext/observable_model.rb +1 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +67 -0
- data/lib/glimmer/dsl/opal/column_properties_expression.rb +22 -0
- data/lib/glimmer/dsl/opal/dsl.rb +5 -0
- data/lib/glimmer/dsl/opal/table_column_expression.rb +17 -0
- data/lib/glimmer/dsl/opal/table_expression.rb +17 -0
- data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +29 -0
- data/lib/glimmer/opal/div_proxy.rb +7 -0
- data/lib/glimmer/opal/document_proxy.rb +15 -6
- data/lib/glimmer/opal/element_proxy.rb +2 -3
- data/lib/glimmer/opal/layout_data_proxy.rb +22 -1
- data/lib/glimmer/opal/list_proxy.rb +1 -1
- data/lib/glimmer/opal/tab_folder.rb +9 -2
- data/lib/glimmer/opal/tab_item.rb +1 -1
- data/lib/glimmer/opal/table_column.rb +50 -0
- data/lib/glimmer/opal/table_item.rb +136 -0
- data/lib/glimmer/opal/table_proxy.rb +149 -0
- data/lib/samples/elaborate/contact_manager.rb +1 -2
- metadata +13 -14
- data/lib/glimmer/config.rb +0 -22
- data/lib/glimmer/dsl/engine.rb +0 -193
- data/lib/glimmer/dsl/expression.rb +0 -42
- data/lib/glimmer/dsl/expression_handler.rb +0 -48
- data/lib/glimmer/dsl/parent_expression.rb +0 -12
- data/lib/glimmer/dsl/static_expression.rb +0 -36
- data/lib/glimmer/dsl/top_level_expression.rb +0 -7
- data/lib/glimmer/error.rb +0 -6
- data/lib/glimmer/invalid_keyword_error.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a67315f8276add7f19a24f488c635567a39fe798e7e21e49ce23de2aeb6c0d2
|
4
|
+
data.tar.gz: e667498792a2522e9271a04ccd2051396c778e528dd77fbb593c6369eee971e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02db0846e7e3b430387e693aa4981c2f01636a01b5ed5ba32646cbdac15991604ccbd5efa4d8e8b837027c69861c28b8d1917f5bef792121de9be8b86584e064
|
7
|
+
data.tar.gz: 5d07f4b44c97c81bcf554b18d423e0007efe14bf8cdaa8529f0c295581518654a94989dcc1a0e921e8626a7ca3ca243f572a4d163f3e4bd450fe81684303dae2
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.8
|
4
|
+
|
5
|
+
- Contact Manager sample support
|
6
|
+
|
7
|
+
## 0.0.7
|
8
|
+
|
9
|
+
- Tic Tac Toe sample support
|
10
|
+
- Login sample support
|
11
|
+
|
12
|
+
## 0.0.6
|
13
|
+
|
14
|
+
- Hello, Tab! sample support
|
15
|
+
|
16
|
+
## 0.0.5
|
17
|
+
|
18
|
+
- Hello, Browser! sample support
|
19
|
+
|
20
|
+
## 0.0.4
|
21
|
+
|
22
|
+
- Hello, List Single Selection! sample support
|
23
|
+
- Hello, List Multi Selection! sample support
|
24
|
+
|
25
|
+
## 0.0.3
|
26
|
+
|
27
|
+
- Hello, Computed! sample support
|
28
|
+
|
29
|
+
## 0.0.2
|
30
|
+
|
31
|
+
- Hello, Combo! sample support
|
32
|
+
|
3
33
|
## 0.0.1
|
4
34
|
|
5
35
|
- Initial support for webifying Glimmer SWT apps
|
data/README.md
CHANGED
@@ -1,14 +1,12 @@
|
|
1
|
-
# <img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=65 /> Glimmer DSL for Opal 0.0.
|
1
|
+
# <img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=65 /> Glimmer DSL for Opal 0.0.8 (Webify Desktop Apps)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-opal.svg)](http://badge.fury.io/rb/glimmer-dsl-opal)
|
3
3
|
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
4
|
|
5
|
-
|
5
|
+
Glimmer DSL for Opal is a web GUI adaptor for webifying [Glimmer](https://github.com/AndyObtiva/glimmer) desktop apps (i.e. apps built with [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt)).
|
6
6
|
|
7
|
-
It enables running [Glimmer](https://github.com/AndyObtiva/glimmer) desktop apps on the web via [Rails](https://rubyonrails.org/)
|
7
|
+
It enables running [Glimmer](https://github.com/AndyObtiva/glimmer) desktop apps on the web via [Rails](https://rubyonrails.org/) and [Opal](https://opalrb.com/) without changing a line of code. Apps may then be custom-styled for the web via standard CSS.
|
8
8
|
|
9
|
-
NOTE: Alpha Version 0.0.
|
10
|
-
|
11
|
-
Hello Samples:
|
9
|
+
NOTE: Alpha Version 0.0.8 only supports bare-minimum capabilities for the following [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt) [samples](https://github.com/AndyObtiva/glimmer#samples):
|
12
10
|
- [Hello, World!](#hello-world)
|
13
11
|
- [Hello, Combo!](#hello-combo)
|
14
12
|
- [Hello, Computed!](#hello-computed)
|
@@ -16,10 +14,9 @@ Hello Samples:
|
|
16
14
|
- [Hello, List Multi Selection!](#hello-list-multi-selection)
|
17
15
|
- [Hello, Browser!](#hello-browser)
|
18
16
|
- [Hello, Tab!](#hello-tab)
|
19
|
-
|
20
|
-
Elaborate Samples:
|
21
17
|
- [Login](#login)
|
22
18
|
- [Tic Tac Toe](#tic-tac-toe)
|
19
|
+
- [Contact Manager](#contact-manager)
|
23
20
|
|
24
21
|
Other Glimmer DSL gems:
|
25
22
|
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (Desktop GUI)
|
@@ -39,8 +36,14 @@ The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glim
|
|
39
36
|
- `list` & `list(:multi)`
|
40
37
|
- `tab_folder`
|
41
38
|
- `tab_item`
|
39
|
+
- `table`
|
40
|
+
- `table_column`
|
41
|
+
- `message_box`
|
42
42
|
- `on_widget_selected`
|
43
43
|
- `on_modify_text`
|
44
|
+
- `observe`
|
45
|
+
- `bind`
|
46
|
+
- `async_exec`
|
44
47
|
- `grid_layout`
|
45
48
|
- `layout_data`
|
46
49
|
|
@@ -51,42 +54,47 @@ The following keywords from [glimmer-dsl-swt](https://github.com/AndyObtiva/glim
|
|
51
54
|
|
52
55
|
## Setup
|
53
56
|
|
54
|
-
|
57
|
+
(NOTE: if you run into issues, they are probably fixed in master or development/wip branch, you may check out instead)
|
58
|
+
|
59
|
+
Please install a Rails 5 gem (e.g. `gem install rails -v5.2.4.3` )
|
55
60
|
|
56
61
|
Start a new Rails 5 app:
|
57
62
|
|
58
63
|
```
|
59
|
-
rails new
|
64
|
+
rails new glimmer_app
|
60
65
|
```
|
61
66
|
|
62
|
-
|
67
|
+
Add the following to `Gemfile`:
|
63
68
|
|
64
|
-
Add the following to `Gemfile` (NOTE: if you run into issues, they are probably fixed in master or development/wip branch, you may check out instead):
|
65
69
|
```
|
66
70
|
gem 'opal-rails', '~> 1.1.2'
|
67
71
|
gem 'opal-async', '~> 1.1.0'
|
68
72
|
gem 'opal-browser', '~> 0.2.0'
|
69
|
-
gem 'glimmer-dsl-opal', '~> 0.0.
|
73
|
+
gem 'glimmer-dsl-opal', '~> 0.0.8', require: false
|
70
74
|
```
|
71
75
|
|
72
|
-
|
76
|
+
Follow (opal-rails)[https://github.com/opal/opal-rails] instructions, basically the configuration of: config/initializers/assets.rb
|
77
|
+
|
78
|
+
Edit `config/initializers/assets.rb` and add the following at the bottom:
|
73
79
|
```
|
74
80
|
Opal.use_gem 'glimmer-dsl-opal'
|
75
81
|
```
|
76
82
|
|
77
|
-
Add the following line to the top of an empty `app/assets/javascripts/application.
|
83
|
+
Add the following line to the top of an empty `app/assets/javascripts/application.rb` (replacing `application.js`)
|
78
84
|
|
79
85
|
```ruby
|
80
86
|
require 'glimmer-dsl-opal' # brings opal and opal browser too
|
81
87
|
```
|
82
88
|
|
89
|
+
Add more code to `app/assets/javascripts/application.rb` from one of the samples below or require a [Glimmer](https://github.com/AndyObtiva/glimmer) app/[custom-shell](https://github.com/AndyObtiva/glimmer#custom-shell-gem) gem.
|
90
|
+
|
83
91
|
## Samples
|
84
92
|
|
85
93
|
### Hello Samples
|
86
94
|
|
87
95
|
#### Hello, World!
|
88
96
|
|
89
|
-
Add the following Glimmer code to `app/assets/javascripts/application.
|
97
|
+
Add the following Glimmer code to `app/assets/javascripts/application.rb`
|
90
98
|
|
91
99
|
```ruby
|
92
100
|
include Glimmer
|
@@ -96,7 +104,7 @@ shell {
|
|
96
104
|
label {
|
97
105
|
text 'Hello, World!'
|
98
106
|
}
|
99
|
-
}
|
107
|
+
}.open
|
100
108
|
```
|
101
109
|
|
102
110
|
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
@@ -118,7 +126,7 @@ You should see "Hello, World!"
|
|
118
126
|
|
119
127
|
#### Hello, Combo!
|
120
128
|
|
121
|
-
Add the following Glimmer code to `app/assets/javascripts/application.
|
129
|
+
Add the following Glimmer code to `app/assets/javascripts/application.rb`
|
122
130
|
|
123
131
|
```ruby
|
124
132
|
class Person
|
@@ -175,7 +183,7 @@ You should see "Hello, Combo!"
|
|
175
183
|
|
176
184
|
#### Hello, Computed!
|
177
185
|
|
178
|
-
Add the following Glimmer code to `app/assets/javascripts/application.
|
186
|
+
Add the following Glimmer code to `app/assets/javascripts/application.rb`
|
179
187
|
|
180
188
|
```ruby
|
181
189
|
class HelloComputed
|
@@ -287,7 +295,7 @@ You should see "Hello, Computed!"
|
|
287
295
|
|
288
296
|
#### Hello, List Single Selection!
|
289
297
|
|
290
|
-
Add the following Glimmer code to `app/assets/javascripts/application.
|
298
|
+
Add the following Glimmer code to `app/assets/javascripts/application.rb`
|
291
299
|
|
292
300
|
```ruby
|
293
301
|
class Person
|
@@ -344,7 +352,7 @@ You should see "Hello, List Single Selection!"
|
|
344
352
|
|
345
353
|
#### Hello, List Multi Selection!
|
346
354
|
|
347
|
-
Add the following Glimmer code to `app/assets/javascripts/application.
|
355
|
+
Add the following Glimmer code to `app/assets/javascripts/application.rb`
|
348
356
|
|
349
357
|
```ruby
|
350
358
|
class Person
|
@@ -411,7 +419,7 @@ You should see "Hello, List Multi Selection!"
|
|
411
419
|
|
412
420
|
#### Hello, Browser!
|
413
421
|
|
414
|
-
Add the following Glimmer code to `app/assets/javascripts/application.
|
422
|
+
Add the following Glimmer code to `app/assets/javascripts/application.rb`
|
415
423
|
|
416
424
|
```ruby
|
417
425
|
include Glimmer
|
@@ -442,7 +450,7 @@ You should see "Hello, Browser!"
|
|
442
450
|
|
443
451
|
#### Hello, Tab!
|
444
452
|
|
445
|
-
Add the following Glimmer code to `app/assets/javascripts/application.
|
453
|
+
Add the following Glimmer code to `app/assets/javascripts/application.rb`
|
446
454
|
|
447
455
|
```ruby
|
448
456
|
class HelloTab
|
@@ -493,7 +501,7 @@ You should see "Hello, Tab!"
|
|
493
501
|
|
494
502
|
#### Login
|
495
503
|
|
496
|
-
Add the following Glimmer code to `app/assets/javascripts/application.
|
504
|
+
Add the following Glimmer code to `app/assets/javascripts/application.rb`
|
497
505
|
|
498
506
|
```ruby
|
499
507
|
require "observer"
|
@@ -607,7 +615,7 @@ You should see "Login" dialog
|
|
607
615
|
|
608
616
|
#### Tic Tac Toe
|
609
617
|
|
610
|
-
Add the following Glimmer code to `app/assets/javascripts/application.
|
618
|
+
Add the following Glimmer code to `app/assets/javascripts/application.rb`
|
611
619
|
|
612
620
|
```ruby
|
613
621
|
class TicTacToe
|
@@ -834,6 +842,448 @@ You should see "Tic Tac Toe"
|
|
834
842
|
![Glimmer DSL for Opal Tic Tac Toe In Progress](images/glimmer-dsl-opal-tic-tac-toe-in-progress.png)
|
835
843
|
![Glimmer DSL for Opal Tic Tac Toe Game Over](images/glimmer-dsl-opal-tic-tac-toe-game-over.png)
|
836
844
|
|
845
|
+
#### Contact Manager
|
846
|
+
|
847
|
+
Add the following Glimmer code to `app/assets/javascripts/application.rb`
|
848
|
+
|
849
|
+
```ruby
|
850
|
+
class ContactManager
|
851
|
+
class Contact
|
852
|
+
attr_accessor :first_name, :last_name, :email
|
853
|
+
|
854
|
+
def initialize(attribute_map)
|
855
|
+
@first_name = attribute_map[:first_name]
|
856
|
+
@last_name = attribute_map[:last_name]
|
857
|
+
@email = attribute_map[:email]
|
858
|
+
end
|
859
|
+
end
|
860
|
+
end
|
861
|
+
|
862
|
+
class ContactManager
|
863
|
+
class ContactRepository
|
864
|
+
NAMES_FIRST = %w[
|
865
|
+
Liam
|
866
|
+
Noah
|
867
|
+
William
|
868
|
+
James
|
869
|
+
Oliver
|
870
|
+
Benjamin
|
871
|
+
Elijah
|
872
|
+
Lucas
|
873
|
+
Mason
|
874
|
+
Logan
|
875
|
+
Alexander
|
876
|
+
Ethan
|
877
|
+
Jacob
|
878
|
+
Michael
|
879
|
+
Daniel
|
880
|
+
Henry
|
881
|
+
Jackson
|
882
|
+
Sebastian
|
883
|
+
Aiden
|
884
|
+
Matthew
|
885
|
+
Samuel
|
886
|
+
David
|
887
|
+
Joseph
|
888
|
+
Carter
|
889
|
+
Owen
|
890
|
+
Wyatt
|
891
|
+
John
|
892
|
+
Jack
|
893
|
+
Luke
|
894
|
+
Jayden
|
895
|
+
Dylan
|
896
|
+
Grayson
|
897
|
+
Levi
|
898
|
+
Isaac
|
899
|
+
Gabriel
|
900
|
+
Julian
|
901
|
+
Mateo
|
902
|
+
Anthony
|
903
|
+
Jaxon
|
904
|
+
Lincoln
|
905
|
+
Joshua
|
906
|
+
Christopher
|
907
|
+
Andrew
|
908
|
+
Theodore
|
909
|
+
Caleb
|
910
|
+
Ryan
|
911
|
+
Asher
|
912
|
+
Nathan
|
913
|
+
Thomas
|
914
|
+
Leo
|
915
|
+
Isaiah
|
916
|
+
Charles
|
917
|
+
Josiah
|
918
|
+
Hudson
|
919
|
+
Christian
|
920
|
+
Hunter
|
921
|
+
Connor
|
922
|
+
Eli
|
923
|
+
Ezra
|
924
|
+
Aaron
|
925
|
+
Landon
|
926
|
+
Adrian
|
927
|
+
Jonathan
|
928
|
+
Nolan
|
929
|
+
Jeremiah
|
930
|
+
Easton
|
931
|
+
Elias
|
932
|
+
Colton
|
933
|
+
Cameron
|
934
|
+
Carson
|
935
|
+
Robert
|
936
|
+
Angel
|
937
|
+
Maverick
|
938
|
+
Nicholas
|
939
|
+
Dominic
|
940
|
+
Jaxson
|
941
|
+
Greyson
|
942
|
+
Adam
|
943
|
+
Ian
|
944
|
+
Austin
|
945
|
+
Santiago
|
946
|
+
Jordan
|
947
|
+
Cooper
|
948
|
+
Brayden
|
949
|
+
Roman
|
950
|
+
Evan
|
951
|
+
Ezekiel
|
952
|
+
Xaviar
|
953
|
+
Jose
|
954
|
+
Jace
|
955
|
+
Jameson
|
956
|
+
Leonardo
|
957
|
+
Axel
|
958
|
+
Everett
|
959
|
+
Kayden
|
960
|
+
Miles
|
961
|
+
Sawyer
|
962
|
+
Jason
|
963
|
+
Emma
|
964
|
+
Olivia
|
965
|
+
Ava
|
966
|
+
Isabella
|
967
|
+
Sophia
|
968
|
+
Charlotte
|
969
|
+
Mia
|
970
|
+
Amelia
|
971
|
+
Harper
|
972
|
+
Evelyn
|
973
|
+
Abigail
|
974
|
+
Emily
|
975
|
+
Elizabeth
|
976
|
+
Mila
|
977
|
+
Ella
|
978
|
+
Avery
|
979
|
+
Sofia
|
980
|
+
Camila
|
981
|
+
Aria
|
982
|
+
Scarlett
|
983
|
+
Victoria
|
984
|
+
Madison
|
985
|
+
Luna
|
986
|
+
Grace
|
987
|
+
Chloe
|
988
|
+
Penelope
|
989
|
+
Layla
|
990
|
+
Riley
|
991
|
+
Zoey
|
992
|
+
Nora
|
993
|
+
Lily
|
994
|
+
Eleanor
|
995
|
+
Hannah
|
996
|
+
Lillian
|
997
|
+
Addison
|
998
|
+
Aubrey
|
999
|
+
Ellie
|
1000
|
+
Stella
|
1001
|
+
Natalie
|
1002
|
+
Zoe
|
1003
|
+
Leah
|
1004
|
+
Hazel
|
1005
|
+
Violet
|
1006
|
+
Aurora
|
1007
|
+
Savannah
|
1008
|
+
Audrey
|
1009
|
+
Brooklyn
|
1010
|
+
Bella
|
1011
|
+
Claire
|
1012
|
+
Skylar
|
1013
|
+
Lucy
|
1014
|
+
Paisley
|
1015
|
+
Everly
|
1016
|
+
Anna
|
1017
|
+
Caroline
|
1018
|
+
Nova
|
1019
|
+
Genesis
|
1020
|
+
Emilia
|
1021
|
+
Kennedy
|
1022
|
+
Samantha
|
1023
|
+
Maya
|
1024
|
+
Willow
|
1025
|
+
Kinsley
|
1026
|
+
Naomi
|
1027
|
+
Aaliyah
|
1028
|
+
Elena
|
1029
|
+
Sarah
|
1030
|
+
Ariana
|
1031
|
+
Allison
|
1032
|
+
Gabriella
|
1033
|
+
Alice
|
1034
|
+
Madelyn
|
1035
|
+
Cora
|
1036
|
+
Ruby
|
1037
|
+
Eva
|
1038
|
+
Serenity
|
1039
|
+
Autumn
|
1040
|
+
Adeline
|
1041
|
+
Hailey
|
1042
|
+
Gianna
|
1043
|
+
Valentina
|
1044
|
+
Isla
|
1045
|
+
Eliana
|
1046
|
+
Quinn
|
1047
|
+
Nevaeh
|
1048
|
+
Ivy
|
1049
|
+
Sadie
|
1050
|
+
Piper
|
1051
|
+
Lydia
|
1052
|
+
Alexa
|
1053
|
+
Josephine
|
1054
|
+
Emery
|
1055
|
+
Julia
|
1056
|
+
Delilah
|
1057
|
+
Arianna
|
1058
|
+
Vivian
|
1059
|
+
Kaylee
|
1060
|
+
Sophie
|
1061
|
+
Brielle
|
1062
|
+
Madeline
|
1063
|
+
]
|
1064
|
+
NAMES_LAST = %w[
|
1065
|
+
Smith
|
1066
|
+
Johnson
|
1067
|
+
Williams
|
1068
|
+
Brown
|
1069
|
+
Jones
|
1070
|
+
Miller
|
1071
|
+
Davis
|
1072
|
+
Wilson
|
1073
|
+
Anderson
|
1074
|
+
Taylor
|
1075
|
+
]
|
1076
|
+
def initialize(contacts = nil)
|
1077
|
+
@contacts = contacts || 1000.times.map do |n|
|
1078
|
+
random_first_name_index = (rand*NAMES_FIRST.size).to_i
|
1079
|
+
random_last_name_index = (rand*NAMES_LAST.size).to_i
|
1080
|
+
first_name = NAMES_FIRST[random_first_name_index]
|
1081
|
+
last_name = NAMES_LAST[random_last_name_index]
|
1082
|
+
email = "#{first_name}@#{last_name}.com".downcase
|
1083
|
+
Contact.new(
|
1084
|
+
first_name: first_name,
|
1085
|
+
last_name: last_name,
|
1086
|
+
email: email
|
1087
|
+
)
|
1088
|
+
end
|
1089
|
+
end
|
1090
|
+
|
1091
|
+
def find(attribute_filter_map)
|
1092
|
+
@contacts.find_all do |contact|
|
1093
|
+
match = true
|
1094
|
+
attribute_filter_map.keys.each do |attribute_name|
|
1095
|
+
contact_value = contact.send(attribute_name).downcase
|
1096
|
+
filter_value = attribute_filter_map[attribute_name].downcase
|
1097
|
+
match = false unless contact_value.match(filter_value)
|
1098
|
+
end
|
1099
|
+
match
|
1100
|
+
end
|
1101
|
+
end
|
1102
|
+
end
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
class ContactManager
|
1106
|
+
class ContactManagerPresenter
|
1107
|
+
attr_accessor :results
|
1108
|
+
@@contact_attributes = [:first_name, :last_name, :email]
|
1109
|
+
@@contact_attributes.each {|attribute_name| attr_accessor attribute_name}
|
1110
|
+
|
1111
|
+
def initialize(contact_repository = nil)
|
1112
|
+
@contact_repository = contact_repository || ContactRepository.new
|
1113
|
+
@results = []
|
1114
|
+
end
|
1115
|
+
|
1116
|
+
def list
|
1117
|
+
self.results = @contact_repository.find({})
|
1118
|
+
end
|
1119
|
+
|
1120
|
+
def find
|
1121
|
+
filter_map = {}
|
1122
|
+
@@contact_attributes.each do |attribute_name|
|
1123
|
+
filter_map[attribute_name] = self.send(attribute_name) if self.send(attribute_name)
|
1124
|
+
end
|
1125
|
+
self.results = @contact_repository.find(filter_map)
|
1126
|
+
@sort_attribute_name = nil
|
1127
|
+
@sort_direction_ascending = nil
|
1128
|
+
end
|
1129
|
+
|
1130
|
+
def toggle_sort(attribute_name)
|
1131
|
+
@sort_attribute_name = attribute_name
|
1132
|
+
@sort_direction_ascending = !@sort_direction_ascending
|
1133
|
+
sorted_results = self.results.sort_by {|contact| contact.send(attribute_name).downcase}
|
1134
|
+
sorted_results = sorted_results.reverse unless @sort_direction_ascending
|
1135
|
+
self.results = sorted_results
|
1136
|
+
end
|
1137
|
+
end
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
class ContactManager
|
1141
|
+
include Glimmer
|
1142
|
+
|
1143
|
+
def initialize
|
1144
|
+
@contact_manager_presenter = ContactManagerPresenter.new
|
1145
|
+
@contact_manager_presenter.list
|
1146
|
+
end
|
1147
|
+
|
1148
|
+
def launch
|
1149
|
+
shell {
|
1150
|
+
text "Contact Manager"
|
1151
|
+
composite {
|
1152
|
+
composite {
|
1153
|
+
grid_layout 2, false
|
1154
|
+
label {text "First &Name: "}
|
1155
|
+
text {
|
1156
|
+
text bind(@contact_manager_presenter, :first_name)
|
1157
|
+
on_key_pressed {|key_event|
|
1158
|
+
@contact_manager_presenter.find if key_event.keyCode == Glimmer::SWT::SWTProxy[:cr]
|
1159
|
+
}
|
1160
|
+
}
|
1161
|
+
label {text "&Last Name: "}
|
1162
|
+
text {
|
1163
|
+
text bind(@contact_manager_presenter, :last_name)
|
1164
|
+
on_key_pressed {|key_event|
|
1165
|
+
@contact_manager_presenter.find if key_event.keyCode == Glimmer::SWT::SWTProxy[:cr]
|
1166
|
+
}
|
1167
|
+
}
|
1168
|
+
label {text "&Email: "}
|
1169
|
+
text {
|
1170
|
+
text bind(@contact_manager_presenter, :email)
|
1171
|
+
on_key_pressed {|key_event|
|
1172
|
+
@contact_manager_presenter.find if key_event.keyCode == Glimmer::SWT::SWTProxy[:cr]
|
1173
|
+
}
|
1174
|
+
}
|
1175
|
+
composite {
|
1176
|
+
grid_layout 2, false
|
1177
|
+
button {
|
1178
|
+
text "&Find"
|
1179
|
+
on_widget_selected {
|
1180
|
+
@contact_manager_presenter.find
|
1181
|
+
}
|
1182
|
+
}
|
1183
|
+
button {
|
1184
|
+
text "&List All"
|
1185
|
+
on_widget_selected {
|
1186
|
+
@contact_manager_presenter.list
|
1187
|
+
}
|
1188
|
+
}
|
1189
|
+
}
|
1190
|
+
}
|
1191
|
+
|
1192
|
+
table(:multi) { |table_proxy|
|
1193
|
+
layout_data {
|
1194
|
+
horizontal_alignment :fill
|
1195
|
+
vertical_alignment :fill
|
1196
|
+
grab_excess_horizontal_space true
|
1197
|
+
grab_excess_vertical_space true
|
1198
|
+
height_hint 200
|
1199
|
+
}
|
1200
|
+
table_column {
|
1201
|
+
text "First Name"
|
1202
|
+
width 80
|
1203
|
+
on_widget_selected {
|
1204
|
+
@contact_manager_presenter.toggle_sort(:first_name)
|
1205
|
+
}
|
1206
|
+
}
|
1207
|
+
table_column {
|
1208
|
+
text "Last Name"
|
1209
|
+
width 80
|
1210
|
+
on_widget_selected {
|
1211
|
+
@contact_manager_presenter.toggle_sort(:last_name)
|
1212
|
+
}
|
1213
|
+
}
|
1214
|
+
table_column {
|
1215
|
+
text "Email"
|
1216
|
+
width 200
|
1217
|
+
on_widget_selected {
|
1218
|
+
@contact_manager_presenter.toggle_sort(:email)
|
1219
|
+
}
|
1220
|
+
}
|
1221
|
+
items bind(@contact_manager_presenter, :results), column_properties(:first_name, :last_name, :email)
|
1222
|
+
on_mouse_down { |event|
|
1223
|
+
table_proxy.edit_table_item(event.table_item, event.column_index)
|
1224
|
+
}
|
1225
|
+
}
|
1226
|
+
}
|
1227
|
+
}.open
|
1228
|
+
end
|
1229
|
+
end
|
1230
|
+
|
1231
|
+
ContactManager.new.launch
|
1232
|
+
|
1233
|
+
```
|
1234
|
+
Glimmer app on the desktop (using [`glimmer-dsl-swt`](https://github.com/AndyObtiva/glimmer-dsl-swt) gem):
|
1235
|
+
|
1236
|
+
Glimmer DSL for SWT Contact Manager
|
1237
|
+
|
1238
|
+
![Glimmer DSL for SWT Contact Manager](https://github.com/AndyObtiva/glimmer/raw/master/images/glimmer-contact-manager.png)
|
1239
|
+
|
1240
|
+
Glimmer DSL for SWT Contact Manager Find
|
1241
|
+
|
1242
|
+
![Glimmer DSL for SWT Contact Manager Find](https://github.com/AndyObtiva/glimmer/raw/master/images/glimmer-contact-manager-find.png)
|
1243
|
+
|
1244
|
+
Glimmer DSL for SWT Contact Manager Edit Started
|
1245
|
+
|
1246
|
+
![Glimmer DSL for SWT Contact Manager Edit Started](https://github.com/AndyObtiva/glimmer/raw/master/images/glimmer-contact-manager-edit-started.png)
|
1247
|
+
|
1248
|
+
Glimmer DSL for SWT Contact Manager Edit In Progress
|
1249
|
+
|
1250
|
+
![Glimmer DSL for SWT Contact Manager Edit In Progress](https://github.com/AndyObtiva/glimmer/raw/master/images/glimmer-contact-manager-edit-in-progress.png)
|
1251
|
+
|
1252
|
+
Glimmer DSL for SWT Contact Manager Edit Done
|
1253
|
+
|
1254
|
+
![Glimmer DSL for SWT Contact Manager Edit Done](https://github.com/AndyObtiva/glimmer/raw/master/images/glimmer-contact-manager-edit-done.png)
|
1255
|
+
|
1256
|
+
Glimmer app on the web (using `glimmer-dsl-opal` gem):
|
1257
|
+
|
1258
|
+
Start the Rails server:
|
1259
|
+
```
|
1260
|
+
rails s
|
1261
|
+
```
|
1262
|
+
|
1263
|
+
Visit `http://localhost:3000`
|
1264
|
+
|
1265
|
+
You should see "Tic Tac Toe"
|
1266
|
+
|
1267
|
+
Glimmer DSL for Opal Contact Manager
|
1268
|
+
|
1269
|
+
![Glimmer DSL for Opal Contact Manager](images/glimmer-dsl-opal-contact-manager.png)
|
1270
|
+
|
1271
|
+
Glimmer DSL for Opal Contact Manager Find
|
1272
|
+
|
1273
|
+
![Glimmer DSL for Opal Contact Manager Find](images/glimmer-dsl-opal-contact-manager-find.png)
|
1274
|
+
|
1275
|
+
Glimmer DSL for Opal Contact Manager Edit Started
|
1276
|
+
|
1277
|
+
![Glimmer DSL for Opal Contact Manager Edit Started](images/glimmer-dsl-opal-contact-manager-edit-started.png)
|
1278
|
+
|
1279
|
+
Glimmer DSL for Opal Contact Manager Edit In Progress
|
1280
|
+
|
1281
|
+
![Glimmer DSL for Opal Contact Manager Edit In Progress](images/glimmer-dsl-opal-contact-manager-edit-in-progress.png)
|
1282
|
+
|
1283
|
+
Glimmer DSL for Opal Contact Manager Edit Done
|
1284
|
+
|
1285
|
+
![Glimmer DSL for Opal Contact Manager Edit Done](images/glimmer-dsl-opal-contact-manager-edit-done.png)
|
1286
|
+
|
837
1287
|
## Help
|
838
1288
|
|
839
1289
|
### Issues
|