extjsml 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/extjsmlc +70 -0
- data/lib/extclasses/actioncolumn.rb +11 -0
- data/lib/extclasses/booleancolumn.rb +34 -0
- data/lib/extclasses/button.rb +11 -0
- data/lib/extclasses/checkbox.rb +30 -0
- data/lib/extclasses/checkboxgroup.rb +14 -0
- data/lib/extclasses/checkcolumn.rb +16 -0
- data/lib/extclasses/combo.rb +56 -0
- data/lib/extclasses/compositefield.rb +11 -0
- data/lib/extclasses/container.rb +12 -0
- data/lib/extclasses/datecolumn.rb +21 -0
- data/lib/extclasses/datefield.rb +16 -0
- data/lib/extclasses/editorgrid.rb +97 -0
- data/lib/extclasses/fieldcontainer.rb +23 -0
- data/lib/extclasses/fieldset.rb +61 -0
- data/lib/extclasses/filefield.rb +18 -0
- data/lib/extclasses/form.rb +33 -0
- data/lib/extclasses/grid.rb +141 -0
- data/lib/extclasses/gridcolumn.rb +19 -0
- data/lib/extclasses/hidden.rb +7 -0
- data/lib/extclasses/htmleditor.rb +15 -0
- data/lib/extclasses/label.rb +10 -0
- data/lib/extclasses/numbercolumn.rb +30 -0
- data/lib/extclasses/numberfield.rb +19 -0
- data/lib/extclasses/paging.rb +12 -0
- data/lib/extclasses/panel.rb +29 -0
- data/lib/extclasses/passwordfield.rb +27 -0
- data/lib/extclasses/pivotgrid.rb +91 -0
- data/lib/extclasses/radio.rb +25 -0
- data/lib/extclasses/radiogroup.rb +14 -0
- data/lib/extclasses/runningcolumn.rb +9 -0
- data/lib/extclasses/tabpanel.rb +17 -0
- data/lib/extclasses/tbfill.rb +5 -0
- data/lib/extclasses/tbseparator.rb +5 -0
- data/lib/extclasses/templatecolumn.rb +11 -0
- data/lib/extclasses/textarea.rb +12 -0
- data/lib/extclasses/textfield.rb +27 -0
- data/lib/extclasses/timefield.rb +16 -0
- data/lib/extclasses/toolbar.rb +7 -0
- data/lib/extclasses/viewport.rb +8 -0
- data/lib/extclasses/window.rb +34 -0
- data/lib/extjsml/basenode.rb +347 -0
- data/lib/extjsml/ext_util.rb +232 -0
- data/lib/extjsml/generator.rb +578 -0
- data/lib/extjsml/parser.rb +35 -0
- data/lib/extmodules/form_field.rb +32 -0
- data/lib/extmodules/magic.rb +196 -0
- data/lib/extplugins/currency.rb +25 -0
- data/lib/extplugins/currencycolumn.rb +18 -0
- data/lib/extplugins/numeric.rb +32 -0
- data/lib/extplugins/pricefield.rb +36 -0
- data/lib/extuxs/uxaccount.rb +8 -0
- data/lib/extuxs/uxbroker.rb +7 -0
- data/lib/extuxs/uxchq.rb +8 -0
- data/lib/extuxs/uxreceiverinfo.rb +8 -0
- data/lib/extuxs/uxsettlement.rb +8 -0
- data/lib/test/test_parser.rb +97 -0
- metadata +115 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
require "yaml"
|
2
|
+
YAML::ENGINE.yamler = 'psych'
|
3
|
+
class ExtParser
|
4
|
+
|
5
|
+
def self.parse(text)
|
6
|
+
begin
|
7
|
+
matcher = /^(\w+)(?:(?:#([\w\-]+))?(?:\.([\w\-]+))?)?(?:(?:@\{(.*)\}))*$/
|
8
|
+
res = matcher.match text
|
9
|
+
xtype = res[1]
|
10
|
+
id = res[2]
|
11
|
+
classes = res[3].sub("_"," ") unless res[3].nil?
|
12
|
+
options = {}
|
13
|
+
options.merge! :id => id unless id.nil?
|
14
|
+
options.merge! :cls => classes unless classes.nil?
|
15
|
+
|
16
|
+
config = res[4]
|
17
|
+
|
18
|
+
if not config.nil? and config.strip != ""
|
19
|
+
config = config.strip!.gsub(/\)\s+:/, ")$$:").split("$$")
|
20
|
+
config.map! do |c|
|
21
|
+
c.gsub!(/\(/,": ")
|
22
|
+
c.gsub!(/\)/," ")
|
23
|
+
end
|
24
|
+
config = YAML.load(config * "\n")
|
25
|
+
options.merge! config
|
26
|
+
end
|
27
|
+
rescue Exception => e
|
28
|
+
puts "error near #{text}: #{e.message}"
|
29
|
+
abort()
|
30
|
+
end
|
31
|
+
# TODO validate xtype
|
32
|
+
[ xtype, options ]
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module FormField
|
2
|
+
def self.included(base)
|
3
|
+
base.class_eval do
|
4
|
+
alias_method :mod_field, :prepare_config
|
5
|
+
|
6
|
+
define_method :prepare_config do
|
7
|
+
mod_field rescue "skip"
|
8
|
+
unless @config[:id].nil?
|
9
|
+
@default_config.merge! :submitValue => true
|
10
|
+
@default_config.merge! :name => conv_id_to_name
|
11
|
+
|
12
|
+
if @xtype == 'textfield'
|
13
|
+
@default_config.merge! :emptyText => conv_id_to_label.capitalize
|
14
|
+
end
|
15
|
+
|
16
|
+
if base.to_s.match /Checkbox$|Radio$|Radiogroup$/
|
17
|
+
@default_config.merge! :boxLabel => conv_id_to_label.capitalize
|
18
|
+
end
|
19
|
+
# if base.to_s.match /Combo$/
|
20
|
+
# user hidden name for combobox
|
21
|
+
#@default_config.merge! :name => nil #, :hiddenName => conv_id_to_name
|
22
|
+
# end
|
23
|
+
unless base.to_s.match /Checkbox$|Radio$/
|
24
|
+
@default_config.merge! :fieldLabel => conv_id_to_label.capitalize
|
25
|
+
# label_width = @default_config[:fieldLabel].size * ExtUtil.FontWidthRatio + 15
|
26
|
+
# @default_config.merge! :labelWidth => label_width
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
module Magic
|
2
|
+
module Column
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
define_method :id_to_title do
|
6
|
+
return if @config[:id].nil?
|
7
|
+
@config[:id].split("-").map(&:capitalize) * " "
|
8
|
+
end
|
9
|
+
|
10
|
+
alias_method :mod_column, :prepare_config
|
11
|
+
|
12
|
+
define_method :prepare_config do
|
13
|
+
mod_column rescue "skip"
|
14
|
+
@default_config.merge! :header => id_to_title, :dataIndex => conv_id_to_name unless @config[:id].nil?
|
15
|
+
@default_config.merge! :sortable => true
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module Title
|
23
|
+
def self.included(base)
|
24
|
+
base.class_eval do
|
25
|
+
define_method :id_to_title do
|
26
|
+
return if @config[:id].nil?
|
27
|
+
@config[:id].split("-").map(&:capitalize) * " "
|
28
|
+
end
|
29
|
+
|
30
|
+
alias_method :mod_title, :prepare_config
|
31
|
+
|
32
|
+
define_method :prepare_config do
|
33
|
+
mod_title rescue "skip"
|
34
|
+
@default_config.merge! :title => id_to_title unless @config[:id].nil?
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
module Store
|
42
|
+
def self.included(base)
|
43
|
+
base.class_eval do
|
44
|
+
|
45
|
+
define_method :cls_to_store do
|
46
|
+
return if @config[:cls].nil?
|
47
|
+
first_cls = @config[:cls].split(" ").first.to_storeid
|
48
|
+
end
|
49
|
+
|
50
|
+
alias_method :mod_store, :prepare_config
|
51
|
+
|
52
|
+
define_method :prepare_config do
|
53
|
+
mod_store rescue "skip"
|
54
|
+
@default_config.merge! :store => cls_to_store unless @config[:cls].nil?
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
module Text
|
62
|
+
def self.included(base)
|
63
|
+
base.class_eval do
|
64
|
+
|
65
|
+
alias_method :mod_text, :prepare_config
|
66
|
+
|
67
|
+
define_method :prepare_config do
|
68
|
+
mod_text rescue "skip"
|
69
|
+
@default_config.merge! :text => conv_id_to_label.capitalize unless @config[:id].nil?
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
module InputValue
|
77
|
+
def self.included(base)
|
78
|
+
base.class_eval do
|
79
|
+
|
80
|
+
alias_method :mod_input_value, :prepare_config
|
81
|
+
|
82
|
+
define_method :prepare_config do
|
83
|
+
mod_input_value rescue "skip"
|
84
|
+
@default_config.merge! :inputValue => conv_id_to_name unless @config[:id].nil?
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
module EmptyText
|
92
|
+
def self.included(base)
|
93
|
+
base.class_eval do
|
94
|
+
|
95
|
+
alias_method :mod_empty_text, :prepare_config
|
96
|
+
|
97
|
+
define_method :prepare_config do
|
98
|
+
mod_empty_text rescue "skip"
|
99
|
+
text = @config[:fieldLabel] || @default_config[:fieldLabel]
|
100
|
+
@default_config.merge! :emptyText => "Select #{text}" unless text.nil?
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
module Listener
|
108
|
+
def self.included(base)
|
109
|
+
base.class_eval do
|
110
|
+
|
111
|
+
alias_method :mod_listener, :prepare_config
|
112
|
+
|
113
|
+
define_method :prepare_config do
|
114
|
+
mod_listener rescue "skip"
|
115
|
+
call = @config[:call]
|
116
|
+
if call.is_a? Array
|
117
|
+
if call.first.is_a? Array
|
118
|
+
call.each do |c|
|
119
|
+
call_on = call[0]
|
120
|
+
call_fn = call[1]
|
121
|
+
end
|
122
|
+
else
|
123
|
+
call_on = call[0]
|
124
|
+
call_fn = call[1]
|
125
|
+
end
|
126
|
+
else
|
127
|
+
call = []
|
128
|
+
{
|
129
|
+
:call_on => @default_config[:call_on],
|
130
|
+
:call_fn => @config[:call]
|
131
|
+
}
|
132
|
+
call << [@default_config[:call_on], @config[:call]]
|
133
|
+
end
|
134
|
+
|
135
|
+
@default_config.merge! :emptyText => "Select #{text}" unless text.nil?
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
module IconClass
|
143
|
+
# depend icon framework
|
144
|
+
def self.included(base)
|
145
|
+
base.class_eval do
|
146
|
+
|
147
|
+
alias_method :mod_icon_class, :prepare_config
|
148
|
+
|
149
|
+
define_method :prepare_config do
|
150
|
+
mod_icon_class rescue "skip"
|
151
|
+
unless @default_config[:text].nil?
|
152
|
+
t = @default_config[:text]
|
153
|
+
if t =~ /add|create|new/i
|
154
|
+
icon_cls = "icon-add"
|
155
|
+
elsif t =~ /update|edit/i
|
156
|
+
icon_cls = "icon-application_form_edit"
|
157
|
+
elsif t =~ /delete/i
|
158
|
+
icon_cls = "icon-bullet_cross"
|
159
|
+
elsif t =~ /search/i
|
160
|
+
icon_cls = "icon-magnifier"
|
161
|
+
elsif t =~ /save/i
|
162
|
+
icon_cls = "icon-table_save"
|
163
|
+
elsif t =~ /select/i
|
164
|
+
icon_cls = "icon-bullet_tick"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
@default_config.merge! :iconCls => icon_cls unless icon_cls.nil?
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
module Toolbar
|
175
|
+
def self.included(base)
|
176
|
+
base.class_eval do
|
177
|
+
|
178
|
+
before_to_extjs :arrage_toolbar
|
179
|
+
|
180
|
+
define_method :arrage_toolbar do |at_deep|
|
181
|
+
if @childs.last.xtype == "toolbar"
|
182
|
+
@config.merge! :fbar => @childs.last.to_extjs(at_deep + 1)
|
183
|
+
@childs.pop
|
184
|
+
end
|
185
|
+
|
186
|
+
if @childs.first.xtype == "toolbar"
|
187
|
+
@config.merge! :tbar => @childs.first.to_extjs(at_deep + 1)
|
188
|
+
@childs.slice!(0)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# depend on extjs currenct plugin
|
2
|
+
|
3
|
+
class ExtCurrency < ExtNode
|
4
|
+
include FormField
|
5
|
+
|
6
|
+
@@ALIAS_CONFIG = {
|
7
|
+
:text => :fieldLabel
|
8
|
+
}
|
9
|
+
|
10
|
+
def initialize(config, parent)
|
11
|
+
@default_config = {
|
12
|
+
:width => 150,
|
13
|
+
:cls => "number",
|
14
|
+
:plugins => [{ ptype: "currency" }, { ptype: "multiple_validations"}],
|
15
|
+
:currencyConfig => {}
|
16
|
+
}
|
17
|
+
|
18
|
+
if config[:decimalPrecision]
|
19
|
+
@default_config[:currencyConfig].merge!({ :decimalPrecision => config[:decimalPrecision] })
|
20
|
+
config.delete :decimalPrecision
|
21
|
+
end
|
22
|
+
|
23
|
+
super "textfield", config, parent
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class ExtCurrencycolumn < ExtNode
|
2
|
+
include Magic::Column
|
3
|
+
@@ALIAS_CONFIG = {
|
4
|
+
:text => :header,
|
5
|
+
:name => :dataIndex
|
6
|
+
}
|
7
|
+
def initialize(config, parent)
|
8
|
+
@default_config = {
|
9
|
+
:format => "0,000.00",
|
10
|
+
:align => "right",
|
11
|
+
:editor => {
|
12
|
+
:xtype => "textfield",
|
13
|
+
:plugins => [{:ptype => "currency"}]
|
14
|
+
}
|
15
|
+
}
|
16
|
+
super "numbercolumn", config, parent
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# depend on extjs currency plugin
|
2
|
+
|
3
|
+
class ExtNumeric < ExtNode
|
4
|
+
include FormField
|
5
|
+
|
6
|
+
@@ALIAS_CONFIG = {
|
7
|
+
:text => :fieldLabel
|
8
|
+
}
|
9
|
+
|
10
|
+
def initialize(config, parent)
|
11
|
+
@default_config = {
|
12
|
+
:width => 150,
|
13
|
+
:cls => "number",
|
14
|
+
:plugins => [{ ptype: "currency" }], # depend the plugins
|
15
|
+
:currencyConfig => {
|
16
|
+
:currencySymbol => ""
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
# maually merge nested config
|
21
|
+
unless config[:currencyConfig].nil?
|
22
|
+
@default_config[:currencyConfig].merge! config[:currencyConfig]
|
23
|
+
config.delete :currencyConfig
|
24
|
+
end
|
25
|
+
|
26
|
+
unless config[:decimalPrecision].nil?
|
27
|
+
@default_config[:currencyConfig].merge!({ :decimalPrecision => config[:decimalPrecision]})
|
28
|
+
end
|
29
|
+
|
30
|
+
super "textfield", config, parent
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# depend on extjs currenct pluginclass Ext < ExtNode
|
2
|
+
|
3
|
+
class ExtPricefield < ExtNode
|
4
|
+
include FormField
|
5
|
+
|
6
|
+
@@ALIAS_CONFIG = {
|
7
|
+
:text => :fieldLabel
|
8
|
+
}
|
9
|
+
|
10
|
+
def initialize(config, parent)
|
11
|
+
@default_config = {
|
12
|
+
:labelAlign => "right",
|
13
|
+
:cls => "number",
|
14
|
+
# :plugins => [{ xclass: "Ext.plugin.Price" }, { ptype: "multiple_validations"}],
|
15
|
+
:plugins => [{ xclass: "Ext.plugin.Price" } ],
|
16
|
+
:priceConfig => {}
|
17
|
+
}
|
18
|
+
|
19
|
+
if config[:decimalPrecision]
|
20
|
+
@default_config[:priceConfig].merge!({ :decimalPrecision => config[:decimalPrecision] })
|
21
|
+
config.delete :decimalPrecision
|
22
|
+
end
|
23
|
+
|
24
|
+
if config[:currencySymbol]
|
25
|
+
@default_config[:priceConfig].merge!({ :currencySymbol => config[:currencySymbol] })
|
26
|
+
config.delete :currencySymbol
|
27
|
+
end
|
28
|
+
|
29
|
+
if config[:allowNegative]
|
30
|
+
@default_config[:priceConfig].merge!({ :allowNegative => config[:allowNegative] })
|
31
|
+
config.delete :allowNegative
|
32
|
+
end
|
33
|
+
|
34
|
+
super "textfield", config, parent
|
35
|
+
end
|
36
|
+
end
|
data/lib/extuxs/uxchq.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# encoding utf-8
|
2
|
+
|
3
|
+
require_relative "../parser"
|
4
|
+
require "test/unit"
|
5
|
+
|
6
|
+
class ExtParserTest < Test::Unit::TestCase
|
7
|
+
def test_parse_xtype
|
8
|
+
text = "panel"
|
9
|
+
res = ExtParser.parse(text)
|
10
|
+
assert_equal [ "panel", {} ], res
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_parse_key_consist_id
|
14
|
+
idtext = "panel#id"
|
15
|
+
res_idtext = ExtParser.parse(idtext)
|
16
|
+
assert_equal ["panel", { :id => "id"} ], res_idtext
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_parse_key_consist_classname
|
20
|
+
classtext = "panel.class"
|
21
|
+
res_classtext = ExtParser.parse(classtext)
|
22
|
+
assert_equal ["panel", { :cls => "class"} ], res_classtext
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_parse_key_consist_multiclass
|
26
|
+
muticlass = "panel.class1-x_class2"
|
27
|
+
res = ExtParser.parse(muticlass)
|
28
|
+
assert_equal ["panel", { :cls => "class1-x class2"} ], res
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_parse_key_consist_mix_class_and_id
|
32
|
+
mixtext = "panel#id.class"
|
33
|
+
res = ExtParser.parse(mixtext)
|
34
|
+
assert_equal ["panel", { :id => "id", :cls => "class"} ], res
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_parse_key_consist_dash
|
38
|
+
text = "panel#form-wrapper"
|
39
|
+
res = ExtParser.parse text
|
40
|
+
assert_equal ["panel", { :id => "form-wrapper" }], res
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_parse_only_one_inline_config
|
44
|
+
text = "panel@{ :title(test) }"
|
45
|
+
res = ExtParser.parse text
|
46
|
+
assert_equal [ "panel", {title: "test"} ], res
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_parse_only_multiword_value_inline_config
|
50
|
+
text = "panel@{ :title(test test) }"
|
51
|
+
res = ExtParser.parse text
|
52
|
+
assert_equal [ "panel", {title: "test test"} ], res
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_parse_only_underscored_word_value_inline_config
|
56
|
+
text = "panel@{ :title(test_test) }"
|
57
|
+
res = ExtParser.parse text
|
58
|
+
assert_equal [ "panel", {title: "test_test"} ], res
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_parse_only_multiple_underscored_word_value_inline_config
|
62
|
+
text = "panel@{ :title(test_test) :value(id) :number(123) }"
|
63
|
+
res = ExtParser.parse text
|
64
|
+
assert_equal [ "panel", {title: "test_test", value: "id", number: 123} ], res
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_parse_inline_config_with_integer_value
|
68
|
+
text = "panel@{ :title(test) :number(123) }"
|
69
|
+
res = ExtParser.parse text
|
70
|
+
assert_equal [ "panel", {title: "test", :number => 123} ], res
|
71
|
+
end
|
72
|
+
|
73
|
+
# def test_parse_inline_with_thai_language
|
74
|
+
# text = "panel@{ :title(test) :thai(กขค) }"
|
75
|
+
# res = ExtParser.parse text
|
76
|
+
# assert_equal [ "panel", {title: "test", :thai => "กขค" } ], res
|
77
|
+
# end
|
78
|
+
|
79
|
+
def test_parse_more_inline_config_attributes
|
80
|
+
text = "panel@{ :title(test) :text(aaa) }"
|
81
|
+
res = ExtParser.parse text
|
82
|
+
assert_equal [ "panel", {title: "test", text: "aaa"} ], res
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_parse_id_and_inline_config
|
86
|
+
text = "panel#some-id@{ :config(config) }"
|
87
|
+
res = ExtParser.parse text
|
88
|
+
assert_equal [ "panel", {:id => "some-id", :config => "config"}], res
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_parse_id_class_and_inline_config
|
92
|
+
text = "panel#some-id.some-class@{ :config(config) }"
|
93
|
+
res = ExtParser.parse text
|
94
|
+
assert_equal [ "panel", {:id => "some-id", :cls => "some-class", :config => "config"}], res
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|