ruby-extjs 2.0.3 → 2.0.4

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.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruby-extjs.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 macielcr7
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # Ruby::Extjs
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ruby-extjs'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ruby-extjs
18
+
19
+ ## Usage
20
+ Argumentos: [nameApp] [generateTipo] [modulo] [options]
21
+
22
+ Model
23
+ $ ruby-extjs --g MyApp model Contatos id:int contato:string email:string
24
+
25
+ Controller
26
+ $ ruby-extjs --g MyApp controller Contatos ch:id dr:contato cb:true
27
+
28
+ Store
29
+ $ ruby-extjs --g MyApp store Contatos
30
+
31
+ View
32
+ $ ruby-extjs --g MyApp view Contatos id:ch nome:no email:ve telefone:m_fone
33
+
34
+ App
35
+ $ ruby-extjs --g MyApp app
36
+
37
+ Parametros
38
+ 1 - nameApp
39
+ 2 - generateTipo
40
+ * app
41
+ * controller
42
+ * model
43
+ * store
44
+ * view
45
+ 3 - modulo ~> Nome da tabela Ex.: Contato
46
+ 4 - options
47
+
48
+ * generateTipo => App
49
+
50
+ * generateTipo => Controller
51
+ ch:id dr:nome cb: true
52
+ Obs.:
53
+ ch -> Chave Primaria
54
+ dr -> Ex.: Deseja deletar: record.get('nome')?
55
+ cb -> se o modulo tera um storeCombo
56
+
57
+ * generateTipo => Model
58
+ id:int nome:string email:string telefone:string
59
+
60
+ * generateTipo => Store
61
+
62
+ * generateTipo => View
63
+ id:ch nome:no email:ve telefone:m_fone
64
+
65
+ Obs.:
66
+ key => nome do campo
67
+ values =>
68
+ no -> sem condincoes
69
+ ch -> chave primaria
70
+ ve -> valid Email
71
+ tp -> campo de senha
72
+ r_{modulo} -> combobox {modulo} => tabela referencia
73
+ m_{tipo} -> mascara {tipo} => fone,cep,cpf,cnpj,money
74
+
75
+
76
+
77
+
78
+ ## Contributing
79
+
80
+ 1. Fork it
81
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
82
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
83
+ 4. Push to the branch (`git push origin my-new-feature`)
84
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/ruby-extjs ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+
4
+ begin
5
+ require 'ruby-extjs'
6
+ rescue LoadError => e
7
+ abort 'Could not load "ruby-extjs"'
8
+ end
9
+
10
+ Ruby::Extjs.start
11
+
data/lib/USAGE ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ *
3
+ * Modo de Usar
4
+ *
5
+ * Model
6
+ * ruby-extjs --g MacielSousa model Contatos id:int contato:string email:string
7
+ *
8
+ * Controller
9
+ * ruby-extjs --g MacielSousa controller Contatos ch:id dr:contato cb:true
10
+ *
11
+ * Store
12
+ * ruby-extjs --g MacielSousa store Contatos
13
+ *
14
+ * View
15
+ * ruby-extjs --g MacielSousa view Contatos id:ch nome:no email:ve telefone:m_fone
16
+ *
17
+ * App
18
+ * ruby-extjs --g MacielSousa app
19
+ *
20
+ * Parametros
21
+ * 1 - nameApp
22
+ * 2 - generateTipo
23
+ * * app
24
+ * * controller
25
+ * * model
26
+ * * store
27
+ * * view
28
+ * 3 - modulo ~> Nome da tabela Ex.: Contato
29
+ * 4 - options
30
+ *
31
+ * * generateTipo => App
32
+ *
33
+ * * generateTipo => Controller
34
+ * ch:id dr:nome cb: true
35
+ * Obs.:
36
+ * ch -> Chave Primaria
37
+ * dr -> Ex.: Deseja deletar: record.get('nome')?
38
+ * cb -> se o modulo tera um storeCombo
39
+ *
40
+ * * generateTipo => Model
41
+ * id:int nome:string email:string telefone:string
42
+ *
43
+ * * generateTipo => Store
44
+ *
45
+ * * generateTipo => View
46
+ * id:ch nome:no email:ve telefone:m_fone
47
+ *
48
+ * Obs.:
49
+ * key => nome do campo
50
+ * values =>
51
+ * no -> sem condincoes
52
+ * ch -> chave primaria
53
+ * ve -> valid Email
54
+ * tp -> campo de senha
55
+ * r_{modulo} -> combobox {modulo} => tabela referencia
56
+ * m_{tipo} -> mascara {tipo} => fone,cep,cpf,cnpj,money
57
+ *
58
+ **/
59
+
data/lib/prepare.rb ADDED
@@ -0,0 +1,226 @@
1
+ require "erb"
2
+ require "pathname"
3
+ require "fileutils"
4
+
5
+ class Parametros
6
+ def initialize( nameApp = "", generateTipo = "", modulo = "", opcoes = {}, opts = {})
7
+ @nameApp = nameApp
8
+ @generateTipo = generateTipo
9
+ @modulo = modulo
10
+ @opcoes = opcoes
11
+ @opts = opts
12
+ end
13
+
14
+ def controllersApp
15
+ @files = Dir.glob('public/app/controller/*.js')
16
+ @arqs = []
17
+
18
+ for file in @files
19
+ @arqs << file.split('public/app/controller/')[1].split('.js')[0]
20
+ end
21
+
22
+ return @arqs
23
+ end
24
+
25
+ def typeList(tipo="", edit=false)
26
+
27
+ @d = [true]
28
+ @c = tipo.split('_')
29
+ if @c.size == 2
30
+ if @c[0] =='m'
31
+ @d << 'mask'
32
+ if @c[1] == 'cpf'
33
+ @d << "Ext.util.Format.maskRenderer('999.999.999-99')"
34
+ elsif @c[1]=='cep'
35
+ @d << "Ext.util.Format.maskRenderer('99.999-999')"
36
+ elsif @c[1]=='fone'
37
+ @d << "Ext.util.Format.maskRenderer('(99) 9999-9999')"
38
+ elsif @c[1]=='cnpj'
39
+ @d << "Ext.util.Format.maskRenderer('99.999.999/9999-99')"
40
+ elsif @c[1]=='money'
41
+ @d << "Ext.util.Format.maskRenderer('R$ #9.999.990,00', true)"
42
+ else
43
+ @d = [false]
44
+ end
45
+ elsif @c[0] =='r'
46
+ if edit == true
47
+ @d << true
48
+ @d << @c[1]
49
+ else
50
+ @d = [false]
51
+ end
52
+ else
53
+ @d = [false]
54
+ end
55
+ else
56
+ @d = [false]
57
+ end
58
+
59
+ return @d
60
+ end
61
+
62
+ def typeEdit(tipo="")
63
+ @d = self.typeList(tipo, true)
64
+
65
+ if @d[0] != true
66
+ @d = [true]
67
+ if tipo == 'ch'
68
+ @d << 'chave'
69
+ elsif tipo == 've'
70
+ @d << 'valid_email'
71
+ elsif tipo == 'tp'
72
+ @d << 'type_pass'
73
+ else
74
+ @d = [false]
75
+ end
76
+ end
77
+
78
+ return @d
79
+ end
80
+
81
+ def setOpts (opts)
82
+ @opts = opts
83
+ end
84
+
85
+ def get_binding
86
+ binding
87
+ end
88
+
89
+ end
90
+
91
+ class Prepare
92
+ def initialize (nameApp = "", generateTipo = "", modulo = "", opcoes = {})
93
+ @nameApp = nameApp
94
+ @generateTipo = generateTipo
95
+ @modulo = modulo
96
+ @opcoes = opcoes
97
+ @opts = {}
98
+
99
+ @TEMPLATES_DIR = File.expand_path(File.join('ruby-extjs','templates'),File.dirname(__FILE__))
100
+ @PARAMS = Parametros.new(nameApp, generateTipo, modulo, opcoes, {})
101
+
102
+ if Dir.exists?("public") == false
103
+ FileUtils.mkdir 'public', :mode => 0777
104
+ end
105
+ if Dir.exists?("public/app") == false
106
+ FileUtils.mkdir 'public/app', :mode => 0777
107
+ end
108
+ end
109
+
110
+ def verifyArguments
111
+ if @generateTipo === 'controller'
112
+ if self.testController == true
113
+ puts 'generate - Controller'
114
+ self.startGenerate
115
+ end
116
+ elsif @generateTipo === 'model'
117
+ if self.testModel == true
118
+ puts 'generate - Model'
119
+ self.startGenerate
120
+ end
121
+ elsif @generateTipo === 'store'
122
+ if @modulo != nil
123
+ puts 'generate - Store'
124
+ self.startGenerate
125
+ end
126
+ elsif @generateTipo === 'view'
127
+ if self.testView == true
128
+ puts 'generate - View'
129
+ self.startGenerate
130
+ end
131
+ elsif @generateTipo === 'app'
132
+ puts 'generate - App'
133
+ self.startGenerate
134
+ else
135
+ puts "[ERROR] - #{@generateTipo}"
136
+ end
137
+ end
138
+
139
+ def testController
140
+ if @opcoes != nil
141
+ @Chave = false
142
+ @DelRec = false
143
+ @Combo = false
144
+ @opcoes.each do |o,v|
145
+ if o=='ch'
146
+ @Chave = true
147
+ elsif o=='cb'
148
+ @Combo = true
149
+ elsif o=='dr'
150
+ @DelRec = true
151
+ end
152
+ end
153
+
154
+ if @Chave==false
155
+ puts '[ERROR-Controller] chave Nao informada....'
156
+ elsif @Combo==false
157
+ puts '[ERROR-Controller] combobox Nao informada....'
158
+ elsif @Combo==false
159
+ puts '[ERROR-Controller] deleteRecord Nao informada....'
160
+ else
161
+ return true
162
+ end
163
+
164
+ else
165
+ puts '[ERROR] Options Incorreto...'
166
+ end
167
+ end
168
+
169
+ def testModel
170
+ if @opcoes != nil
171
+ return true
172
+ else
173
+ puts '[ERROR-Model] Opcoes Incorreto...'
174
+ end
175
+
176
+ return false
177
+ end
178
+
179
+ def testView
180
+ if @opcoes != nil
181
+ return true
182
+ else
183
+ puts '[ERROR-View] Opcoes Incorreto...'
184
+ end
185
+
186
+ return false
187
+ end
188
+
189
+ def generateNow (tpl, dest)
190
+ template = ERB.new File.new("#{tpl}").read
191
+ File.open("#{dest}", 'w') do |f|
192
+ f.write template.result(@PARAMS.get_binding)
193
+ end
194
+ end
195
+
196
+ def startGenerate
197
+ if @generateTipo == "view"
198
+ if Dir.exists?("public/app/view") == false
199
+ FileUtils.mkdir 'public/app/view', :mode => 0777
200
+ end
201
+ if Dir.exists?("public/app/view/#{@modulo.downcase}") == false
202
+ FileUtils.mkdir "public/app/view/#{@modulo.downcase}", :mode => 0777
203
+ end
204
+ self.generateNow("#{@TEMPLATES_DIR}/#{@generateTipo}/list.erb" , "public/app/#{@generateTipo}/#{@modulo.downcase}/List.js")
205
+ self.generateNow("#{@TEMPLATES_DIR}/#{@generateTipo}/edit.erb" , "public/app/#{@generateTipo}/#{@modulo.downcase}/Edit.js")
206
+ self.generateNow("#{@TEMPLATES_DIR}/#{@generateTipo}/filtro.erb" , "public/app/#{@generateTipo}/#{@modulo.downcase}/Filtro.js")
207
+
208
+ elsif @generateTipo == "app"
209
+ self.generateNow("#{@TEMPLATES_DIR}/app.erb" , "public/app.js")
210
+ else
211
+ if Dir.exists?("public/app/#{@generateTipo}") == false
212
+ FileUtils.mkdir "public/app/#{@generateTipo}", :mode => 0777
213
+ end
214
+
215
+ self.generateNow("#{@TEMPLATES_DIR}/#{@generateTipo}/#{@generateTipo}.erb", "public/app/#{@generateTipo}/#{@modulo.capitalize}.js")
216
+ end
217
+
218
+ if Dir.exists?("public/app/util") == false
219
+ FileUtils.chmod 0777, "#{@TEMPLATES_DIR}/util/"
220
+ FileUtils.mkdir "public/app/util", :mode => 0777
221
+ FileUtils.cp "#{@TEMPLATES_DIR}/util/", "public/app/util"
222
+ end
223
+
224
+ end
225
+
226
+ end
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @Autor: Maciel Sousa
3
+ * @Email: macielcr7@gmail.com
4
+ **/
5
+ <%
6
+ @ab = controllersApp
7
+ @a = @ab.size
8
+ @b = 1
9
+ %>
10
+ Ext.Loader.setConfig({
11
+ enabled: true,
12
+ paths: {
13
+ '<%=@nameApp.capitalize%>': 'app',
14
+ 'Abstract': 'app'
15
+ }
16
+ });
17
+
18
+ Ext.application({
19
+ name: '<%=@nameApp.capitalize%>',
20
+ controllers: [<% @ab.each do |v| %>
21
+ '<%=v%>'<% if @a != @b %>,<% @b = @b + 1 end %><% end %>
22
+ ],
23
+
24
+ autoCreateViewport: false,
25
+
26
+ launch: function(){
27
+ var me = this;
28
+ Ext.widget('containerprincipal').show();
29
+
30
+ Ext.get('loading').hide();
31
+ Ext.get('loading-mask').setOpacity(0, true);
32
+ setTimeout(function(){
33
+ Ext.get('loading-mask').hide();
34
+ },400);
35
+
36
+ }
37
+
38
+ });
39
+
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @Autor: Maciel Sousa
3
+ * @Email: macielcr7@gmail.com
4
+ **/
5
+
6
+ Ext.define('<%=@nameApp%>.controller.<%=@modulo.capitalize%>', {
7
+ extend: 'Abstract.util.Controller',
8
+
9
+ modulo : '<%=@modulo%>',
10
+ listmodulo : '<%=@modulo%>list',
11
+ addmodulo : 'add<%=@modulo%>win',
12
+ filtermodulo : 'filter<%=@modulo%>win',
13
+
14
+ deleteRecord : '<%=@opcoes['dr']%>',
15
+ chave : '<%=@opcoes['ch']%>',
16
+
17
+ models: [
18
+ '<%=@modulo.capitalize%>'<%if @opcoes['cb'] == 'true' %>,
19
+ 'Combo'<%end%>
20
+ ],
21
+
22
+ stores: [
23
+ '<%=@modulo.capitalize%>'<%if @opcoes['cb'] == 'true' %>,
24
+ 'Combo<%=@modulo.capitalize%>'<%end%>
25
+ ],
26
+
27
+ views: [
28
+ '<%=@modulo%>.List',
29
+ '<%=@modulo%>.Filtro',
30
+ '<%=@modulo%>.Edit'
31
+ ]
32
+
33
+ });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @Autor: Maciel Sousa
3
+ * @Email: macielcr7@gmail.com
4
+ **/
5
+ <%
6
+ @a = @opcoes.size
7
+ @b = 1
8
+ %>
9
+ Ext.define('<%=@nameApp%>.model.<%=@modulo.capitalize%>', {
10
+ extend: 'Ext.data.Model',
11
+ alias: 'model.<%=@modulo.downcase %>',
12
+
13
+ fields: [<% @opcoes.each do |key, value| %>
14
+ {
15
+ name: "<%= key %>",
16
+ type: "<%= value %>"
17
+ }<% if @a != @b %>,<% @b = @b + 1 end %><% end %>
18
+ ]
19
+ });
20
+
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @Autor: Maciel Sousa
3
+ * @Email: macielcr7@gmail.com
4
+ **/
5
+
6
+ Ext.define('<%=@nameApp%>.store.<%=@modulo.capitalize%>', {
7
+ extend: 'Abstract.util.Store',
8
+
9
+ modulo : '<%=@modulo.capitalize%>',
10
+ model : '<%=@nameApp%>.model.<%=@modulo.capitalize%>'
11
+
12
+ });
@@ -0,0 +1,165 @@
1
+ /**
2
+ * @Autor: Maciel Sousa
3
+ * @Email: macielcr7@gmail.com
4
+ **/
5
+
6
+ Ext.define('Abstract.util.Controller', {
7
+ extend: 'Ext.app.Controller',
8
+ mixins: {
9
+ controls: 'Abstract.util.Util'
10
+ },
11
+
12
+ modulo : false,
13
+
14
+ addmodulo : false,
15
+ listmodulo : false,
16
+ filtermodulo : false,
17
+
18
+ button_add : true,
19
+ button_edit : true,
20
+ button_del : true,
21
+ button_filter : true,
22
+ button_pdf : true,
23
+
24
+ deleteRecord : false,
25
+
26
+ constructor: function (config) {
27
+ var me = this;
28
+ /* refs */
29
+ var refs = [];
30
+ if(me.addmodulo){
31
+ refs = Ext.Array.merge(refs, [
32
+ {
33
+ ref: 'addWin',
34
+ selector: me.addmodulo
35
+ },
36
+ {
37
+ ref: 'form',
38
+ selector: me.addmodulo +' form'
39
+ }
40
+
41
+ ]);
42
+ }
43
+
44
+ if(me.listmodulo){
45
+ refs = Ext.Array.merge(refs, [
46
+ {
47
+ ref: 'list',
48
+ selector: me.listmodulo
49
+ },
50
+ {
51
+ ref: 'filterBtn',
52
+ selector: me.listmodulo + ' button[action=filtrar]'
53
+ }
54
+
55
+ ]);
56
+ }
57
+
58
+ if(me.filtermodulo){
59
+ refs = Ext.Array.merge(refs, [
60
+ {
61
+ ref: 'filterWin',
62
+ selector: me.filtermodulo
63
+ },
64
+ {
65
+ ref: 'filterForm',
66
+ selector: me.filtermodulo +' form'
67
+ }
68
+
69
+ ]);
70
+ }
71
+
72
+ me.refs = me.refs ? Ext.Array.merge(me.refs, refs) : refs;
73
+
74
+ /* control */
75
+ var control = {};
76
+ if(me.listmodulo){
77
+ control[me.listmodulo] = {
78
+ afterrender: this.getPermissoes,
79
+ render: this.gridLoad
80
+ };
81
+
82
+ if(me.button_filter){
83
+ control[me.listmodulo + ' button[action=filtrar]'] = {
84
+ click: this.btfilter
85
+ };
86
+ }
87
+
88
+ if(me.button_add){
89
+ control[me.listmodulo + ' button[action=adicionar]'] = {
90
+ click: this.add
91
+ };
92
+ }
93
+
94
+ if(me.button_edit){
95
+ control[me.listmodulo + ' button[action=editar]'] = {
96
+ click: this.btedit
97
+ };
98
+ }
99
+
100
+ if(me.button_del){
101
+ control[me.listmodulo + ' button[action=deletar]'] = {
102
+ click: this.btdel
103
+ };
104
+ }
105
+
106
+ if(me.button_pdf){
107
+ control[me.listmodulo + ' button[action=gerar_pdf]'] = {
108
+ click: this.gerarPdf
109
+ };
110
+ }
111
+
112
+ }
113
+
114
+ if(me.addmodulo){
115
+ control[me.addmodulo +' button[action=salvar]'] = {
116
+ click: this.update
117
+ };
118
+
119
+ control[me.addmodulo +' button[action=resetar]'] = {
120
+ click: this.reset
121
+ };
122
+
123
+ control[me.addmodulo +' form fieldcontainer combobox'] = {
124
+ change: this.enableButton,
125
+ render: this.comboLoad
126
+ };
127
+
128
+ control[me.addmodulo +' form fieldcontainer button[action=reset_combo]'] = {
129
+ click: this.resetCombo
130
+ };
131
+
132
+ control[me.addmodulo +' form fieldcontainer button[action=add_win]'] = {
133
+ click: this.getAddWindow
134
+ };
135
+ }
136
+
137
+ if(me.filtermodulo){
138
+ control[me.filtermodulo +' form fieldcontainer combobox'] = {
139
+ change: this.enableButton,
140
+ render: this.comboLoad
141
+ };
142
+
143
+ control[me.filtermodulo +' button[action=resetar_filtro]'] = {
144
+ click: this.resetFielter
145
+ };
146
+
147
+ control[me.filtermodulo +' button[action=filtrar_busca]'] = {
148
+ click: this.setFielter
149
+ };
150
+
151
+ control[me.filtermodulo] = {
152
+ show: this.filterSetFields
153
+ };
154
+ }
155
+ me.controls = me.controls ? Ext.Object.merge(me.controls, control) : control;
156
+
157
+ me.callParent(arguments);
158
+ },
159
+
160
+ init: function(app){
161
+ this.control(this.controls);
162
+ }
163
+
164
+ });
165
+