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,25 @@
|
|
1
|
+
class ExtRadio < ExtNode
|
2
|
+
include FormField
|
3
|
+
include Magic::InputValue
|
4
|
+
|
5
|
+
@@ALIAS_CONFIG = {
|
6
|
+
:text => :boxLabel
|
7
|
+
}
|
8
|
+
|
9
|
+
def initialize(config, parent)
|
10
|
+
@default_config = {
|
11
|
+
:labelWidth => 100,
|
12
|
+
:hideLabel => true
|
13
|
+
}
|
14
|
+
|
15
|
+
super "radiofield", config, parent
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_extjs(at_deep = 0)
|
19
|
+
if parent.xtype == "radiogroup"
|
20
|
+
name = parent.config[:name]
|
21
|
+
config[:name] = name
|
22
|
+
end
|
23
|
+
super at_deep
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class ExtTabpanel < ExtNode
|
2
|
+
@@ALIAS_CONFIG = {
|
3
|
+
:text => :title
|
4
|
+
}
|
5
|
+
|
6
|
+
def initialize(config, parent)
|
7
|
+
@default_config = {
|
8
|
+
height: 200,
|
9
|
+
activeTab: 0,
|
10
|
+
autoHeight: true,
|
11
|
+
layoutOnTabChange: true,
|
12
|
+
deferredRender: true,
|
13
|
+
animScroll: true
|
14
|
+
}
|
15
|
+
super "tabpanel", config, parent
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class ExtTextfield < ExtNode
|
2
|
+
include FormField
|
3
|
+
|
4
|
+
@@ALIAS_CONFIG = {
|
5
|
+
:text => :fieldLabel
|
6
|
+
}
|
7
|
+
|
8
|
+
def initialize(config, parent)
|
9
|
+
@default_config = {
|
10
|
+
:labelAlign => "right",
|
11
|
+
:autoCreate => {
|
12
|
+
:tag => "input",
|
13
|
+
:type => "text",
|
14
|
+
:autocomplete => "off"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
if config[:autoCreate]
|
18
|
+
@default_config.merge! config[:autoCreate]
|
19
|
+
config.delete :autoCreate
|
20
|
+
end
|
21
|
+
if config[:emptyText]
|
22
|
+
@default_config[:autoCreate][:placeholder] = config[:emptyText]
|
23
|
+
config.delete :emptyText
|
24
|
+
end
|
25
|
+
super('textfield',config, parent)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class ExtTimefield < ExtNode
|
2
|
+
include FormField
|
3
|
+
|
4
|
+
@@ALIAS_CONFIG = {
|
5
|
+
:text => :fieldLabel
|
6
|
+
}
|
7
|
+
|
8
|
+
def initialize(config, parent)
|
9
|
+
@default_config = {
|
10
|
+
labelAlign: "right",
|
11
|
+
cls: 'time'
|
12
|
+
}
|
13
|
+
super('timefield',config, parent)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class ExtWindow < ExtNode
|
2
|
+
include Magic::Title
|
3
|
+
|
4
|
+
def initialize(config, parent)
|
5
|
+
@default_config = {
|
6
|
+
y: 10,
|
7
|
+
width: 500,
|
8
|
+
layout: "anchor",
|
9
|
+
title: "My Window",
|
10
|
+
maximizable: true,
|
11
|
+
modal: true,
|
12
|
+
padding: "0.5em"
|
13
|
+
}
|
14
|
+
super "window", config, parent
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_extjs(at_deep = 0)
|
18
|
+
if @childs.last.xtype == "toolbar"
|
19
|
+
@config.merge! :fbar => @childs.last.to_extjs(at_deep + 1)
|
20
|
+
@childs.pop
|
21
|
+
end
|
22
|
+
|
23
|
+
if @childs.first.xtype == "toolbar"
|
24
|
+
@config.merge! :tbar => @childs.first.to_extjs(at_deep + 1)
|
25
|
+
@childs.slice!(0)
|
26
|
+
end
|
27
|
+
# if find("paging",{:recursive => 1})
|
28
|
+
# @config.merge! :bbar => find("paging").to_extjs(at_deep + 1)
|
29
|
+
# self.remove_childs "paging"
|
30
|
+
# end
|
31
|
+
|
32
|
+
super at_deep
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,347 @@
|
|
1
|
+
# require "active_support/all"
|
2
|
+
class ExtNode
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_accessor :xtype, :config, :parent, :childs, :default_config, :deep_lvl
|
6
|
+
|
7
|
+
# def self.inherited(klass)
|
8
|
+
# klass.class_attribute :before_filters
|
9
|
+
# klass.before_filters = []
|
10
|
+
# end
|
11
|
+
|
12
|
+
def initialize(xtype, config = {}, parent = nil)
|
13
|
+
@xtype = xtype
|
14
|
+
@config ||= {} # init config first for future use
|
15
|
+
@config.merge! :autoDestroy => true
|
16
|
+
# TODO able to alias config key
|
17
|
+
override_config config
|
18
|
+
# Hook
|
19
|
+
do_alias_config
|
20
|
+
prepare_config rescue "next"
|
21
|
+
apply_config @default_config unless @default_config.nil?
|
22
|
+
@parent = parent
|
23
|
+
@childs = []
|
24
|
+
end
|
25
|
+
|
26
|
+
def do_alias_config
|
27
|
+
if self.class.class_variable_defined? :@@ALIAS_CONFIG
|
28
|
+
# replace alias with actual config attributes
|
29
|
+
ac = self.class.class_variable_get :@@ALIAS_CONFIG
|
30
|
+
nc = {}
|
31
|
+
@config.each do |k, v|
|
32
|
+
if ac.keys.include? k
|
33
|
+
nc[ac[k]] = @config[k]
|
34
|
+
@config.delete k
|
35
|
+
end
|
36
|
+
end
|
37
|
+
@config.merge! nc
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def conv_id_to_ref
|
42
|
+
return nil unless @config[:id]
|
43
|
+
sid = @config[:id].split("-")
|
44
|
+
temp = sid[1..-1]
|
45
|
+
fword = sid[0];
|
46
|
+
temp.each do |el|
|
47
|
+
fword += (el[0].upcase + el[1..-1])
|
48
|
+
end
|
49
|
+
|
50
|
+
fword
|
51
|
+
end
|
52
|
+
|
53
|
+
def conv_id_to_label
|
54
|
+
@config[:id].split("-").map(&:capitalize) * " "
|
55
|
+
end
|
56
|
+
|
57
|
+
def conv_id_to_name
|
58
|
+
@config[:id].nil? ? "" : @config[:id].split("-") * "_"
|
59
|
+
end
|
60
|
+
|
61
|
+
def add_child(node)
|
62
|
+
return if node.nil?
|
63
|
+
if node.is_a? Array
|
64
|
+
@childs += node
|
65
|
+
node.each do |n|
|
66
|
+
n.set_parent self
|
67
|
+
end
|
68
|
+
else
|
69
|
+
@childs << node
|
70
|
+
node.set_parent self
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def set_parent(node)
|
75
|
+
@parent = node
|
76
|
+
end
|
77
|
+
|
78
|
+
def root?
|
79
|
+
@parent.nil?
|
80
|
+
end
|
81
|
+
|
82
|
+
def do_layout
|
83
|
+
raise "Not Implemented"
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_all_siblings
|
87
|
+
parent.childs rescue []
|
88
|
+
end
|
89
|
+
|
90
|
+
def prepare_config(h)
|
91
|
+
@default_config.merge! @@magic_config
|
92
|
+
end
|
93
|
+
|
94
|
+
def find_parent(*xtype)
|
95
|
+
return nil if parent.nil?
|
96
|
+
if xtype.include? parent.xtype
|
97
|
+
parent
|
98
|
+
else
|
99
|
+
parent.find_parent(*xtype)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def is_field_element?
|
104
|
+
ExtUtil.field_xtype.include? self.xtype
|
105
|
+
end
|
106
|
+
|
107
|
+
def find_field_elements
|
108
|
+
element = []
|
109
|
+
if self.childs.count > 0
|
110
|
+
childs.each do |c|
|
111
|
+
if c.is_field_element?
|
112
|
+
element << c
|
113
|
+
else
|
114
|
+
element += c.find_field_elements
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
element
|
120
|
+
end
|
121
|
+
|
122
|
+
def find(xtype, option = nil)
|
123
|
+
return false unless has_child?
|
124
|
+
if(!option.nil? and option[:recursive])
|
125
|
+
return false if option[:recursive] == 0
|
126
|
+
option[:recursive] -= 1
|
127
|
+
end
|
128
|
+
found = false
|
129
|
+
childs.each do |c|
|
130
|
+
if c.xtype == xtype
|
131
|
+
unless option.nil?
|
132
|
+
match_option = true
|
133
|
+
option.each do |k, v|
|
134
|
+
next if k == :recursive
|
135
|
+
match_option = false if option[k] != c.config[k]
|
136
|
+
end
|
137
|
+
if match_option
|
138
|
+
found = c
|
139
|
+
break
|
140
|
+
end
|
141
|
+
else
|
142
|
+
found = c
|
143
|
+
break
|
144
|
+
end
|
145
|
+
end
|
146
|
+
found = c.find xtype, option
|
147
|
+
break if found
|
148
|
+
end
|
149
|
+
found
|
150
|
+
end
|
151
|
+
|
152
|
+
def remove_childs(xtype, options = {:recursive => 1})
|
153
|
+
return false unless has_child?
|
154
|
+
opt = options
|
155
|
+
if opt[:recursive]
|
156
|
+
opt[:recursive] -= 1
|
157
|
+
end
|
158
|
+
new_childs = []
|
159
|
+
childs.each do |c|
|
160
|
+
c.remove_childs xtype if opt[:recursive] > 0
|
161
|
+
unless c.xtype == xtype
|
162
|
+
new_childs << c
|
163
|
+
end
|
164
|
+
end
|
165
|
+
self.childs = new_childs
|
166
|
+
end
|
167
|
+
|
168
|
+
def child_of?(*xxtype)
|
169
|
+
if parent.nil?
|
170
|
+
false
|
171
|
+
elsif xxtype.include?(parent.xtype)
|
172
|
+
true
|
173
|
+
else
|
174
|
+
parent.child_of?(*xxtype)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def child_of_form?
|
179
|
+
if parent.nil?
|
180
|
+
false
|
181
|
+
elsif parent.xtype == "form"
|
182
|
+
true
|
183
|
+
else
|
184
|
+
parent.child_of_form?
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def apply_config(h)
|
189
|
+
if not @config[:cls].nil? and not h[:cls].nil?
|
190
|
+
@config[:cls] += " #{h[:cls]}"
|
191
|
+
end
|
192
|
+
@config = h.merge @config
|
193
|
+
end
|
194
|
+
|
195
|
+
def remove_config(key)
|
196
|
+
@config.delete key
|
197
|
+
end
|
198
|
+
|
199
|
+
def override_config(h)
|
200
|
+
if not @config[:cls].nil? and not h[:cls].nil?
|
201
|
+
@config[:cls] += " #{h[:cls]}"
|
202
|
+
delete h[:cls]
|
203
|
+
end
|
204
|
+
@config.merge! h
|
205
|
+
end
|
206
|
+
|
207
|
+
def has_child?
|
208
|
+
childs.count > 0
|
209
|
+
end
|
210
|
+
|
211
|
+
def to_extjs(at_deep = 0)
|
212
|
+
# if self.before_filters.count > 0
|
213
|
+
# self.before_filters.each do |method|
|
214
|
+
# self.send method, at_deep
|
215
|
+
# end
|
216
|
+
# end
|
217
|
+
|
218
|
+
ref = conv_id_to_ref
|
219
|
+
# if not root? and ref
|
220
|
+
# TODO skip if id is the same of instance method
|
221
|
+
# puts "../"*(at_deep == 0 ? 0 : at_deep-1 ) + conv_id_to_ref unless @config[:id].nil?
|
222
|
+
# @config = @config.merge({ :ref => "../"*(at_deep-1) + conv_id_to_ref }) unless @config[:id].nil?
|
223
|
+
# end
|
224
|
+
|
225
|
+
# not gen id
|
226
|
+
@config[:cmp_id] = conv_id_to_ref
|
227
|
+
unless @@generator[:noid].nil?
|
228
|
+
# skip if force gen id
|
229
|
+
unless @config[:forceId]
|
230
|
+
# remove id
|
231
|
+
@config.delete :id
|
232
|
+
# @config[:id] = ExtUtil.random_id
|
233
|
+
end
|
234
|
+
# gen random id for ref
|
235
|
+
end
|
236
|
+
|
237
|
+
collect_events
|
238
|
+
# TODO remove ref for *column xtype ?
|
239
|
+
collect_ref(ref)
|
240
|
+
|
241
|
+
if has_child?
|
242
|
+
child_h = { :items => [] }
|
243
|
+
childs.each do |c|
|
244
|
+
child_h[:items] << c.to_extjs(at_deep + 1)
|
245
|
+
end
|
246
|
+
h = {:xtype => @xtype}.merge(@config).merge(child_h)
|
247
|
+
else
|
248
|
+
{:xtype => @xtype}.merge(@config)
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
@@refs = {}
|
253
|
+
def collect_ref(ref)
|
254
|
+
return false if not ref or @config[:id].nil?
|
255
|
+
@@refs[@config[:id].dup] = ref.dup
|
256
|
+
end
|
257
|
+
|
258
|
+
@@events_store = {}
|
259
|
+
def collect_events
|
260
|
+
del_keys = []
|
261
|
+
@config.each do |k, v|
|
262
|
+
if k =~ /^on-/i
|
263
|
+
del_keys << k
|
264
|
+
# v is fn_name
|
265
|
+
ev = /^on-(.*)/.match(k)[1]
|
266
|
+
@@events_store[conv_id_to_ref.to_sym] = [ev, v]
|
267
|
+
# p conv_id_to_ref, ev, v
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
del_keys.each do |k|
|
272
|
+
@config.delete k
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
def self.get_events
|
277
|
+
@@events_store
|
278
|
+
end
|
279
|
+
|
280
|
+
def self.get_refs
|
281
|
+
@@refs
|
282
|
+
end
|
283
|
+
|
284
|
+
def build_abstract_function
|
285
|
+
# unless root?
|
286
|
+
# @config = @config.merge({ :ref => "../"*(at_deep-1) + conv_id_to_ref }) unless @config[:id].nil?
|
287
|
+
# end
|
288
|
+
|
289
|
+
code = []
|
290
|
+
p @xtype, @config
|
291
|
+
if has_child?
|
292
|
+
childs.each do |c|
|
293
|
+
code += c.build_abstract_function
|
294
|
+
end
|
295
|
+
else
|
296
|
+
return code if @config[:call].nil?
|
297
|
+
code << "this.#{conv_id_to_ref}.on('#{@config[:call_on]}', this.#{@config[:call_fn]}, this)"
|
298
|
+
end
|
299
|
+
|
300
|
+
code
|
301
|
+
end
|
302
|
+
|
303
|
+
def get_deep()
|
304
|
+
deep = 0
|
305
|
+
node = self
|
306
|
+
while true
|
307
|
+
unless node.root?
|
308
|
+
node = node.parent
|
309
|
+
deep += 1
|
310
|
+
else
|
311
|
+
break
|
312
|
+
end
|
313
|
+
end
|
314
|
+
deep
|
315
|
+
end
|
316
|
+
|
317
|
+
#def to_s
|
318
|
+
# o = self.dup
|
319
|
+
# n = get_deep
|
320
|
+
# o.parent = nil
|
321
|
+
# o.config[:items] = nil
|
322
|
+
# %Q{
|
323
|
+
# #{" "*n}#{o.xtype}(#{o.config})
|
324
|
+
# #{" "*n}>#{o.childs}"}
|
325
|
+
#end
|
326
|
+
|
327
|
+
@@generator = {}
|
328
|
+
def self.set_generator_config(option)
|
329
|
+
@@generator.merge! option
|
330
|
+
end
|
331
|
+
|
332
|
+
def self.reset_generator_config
|
333
|
+
@@generator = {}
|
334
|
+
end
|
335
|
+
|
336
|
+
def self.before_to_extjs(method)
|
337
|
+
# @before_filters ||= []
|
338
|
+
before_filters << method
|
339
|
+
# p method, name, @@before_filters, self
|
340
|
+
end
|
341
|
+
|
342
|
+
def self.get_before_filters
|
343
|
+
before_filters
|
344
|
+
# @@before_filters
|
345
|
+
end
|
346
|
+
|
347
|
+
end
|