jinda 0.5.2 → 0.5.7

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/lib/generators/jinda/install_generator.rb +10 -2
  4. data/lib/generators/jinda/templates/README.md +1 -1
  5. data/lib/generators/jinda/templates/app/assets/stylesheets/app.scss +11 -5
  6. data/lib/generators/jinda/templates/app/assets/stylesheets/articles.scss +16 -6
  7. data/lib/generators/jinda/templates/app/controllers/concerns/jinda_general_concern.rb +27 -4
  8. data/lib/generators/jinda/templates/app/controllers/concerns/jinda_run_concern.rb +135 -6
  9. data/lib/generators/jinda/templates/app/controllers/jinda_org/application_controller.rb +0 -1
  10. data/lib/generators/jinda/templates/app/controllers/jinda_org/articles_controller.rb +58 -35
  11. data/lib/generators/jinda/templates/app/controllers/jinda_org/comments_controller.rb +12 -10
  12. data/lib/generators/jinda/templates/app/controllers/jinda_org/docs_controller.rb +56 -0
  13. data/lib/generators/jinda/templates/app/controllers/jinda_org/jinda_controller.rb +23 -2
  14. data/lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb +6 -8
  15. data/lib/generators/jinda/templates/app/jinda/index.mm +90 -25
  16. data/lib/generators/jinda/templates/app/jinda/template/view.html.erb +22 -23
  17. data/lib/generators/jinda/templates/app/models/jinda/doc.rb +5 -0
  18. data/lib/generators/jinda/templates/app/views/articles/index.haml +2 -2
  19. data/lib/generators/jinda/templates/app/views/articles/my.haml +3 -3
  20. data/lib/generators/jinda/templates/app/views/articles/new_article/form_article.html.erb +5 -3
  21. data/lib/generators/jinda/templates/app/views/articles/show.html.haml +4 -3
  22. data/lib/generators/jinda/templates/app/views/docs/doc_edit/doc_edit.html.erb +21 -0
  23. data/lib/generators/jinda/templates/app/views/docs/doc_edit/doc_select.html.erb +14 -0
  24. data/lib/generators/jinda/templates/app/views/docs/doc_new/doc_form.html.erb +26 -0
  25. data/lib/generators/jinda/templates/app/views/docs/doc_new/doc_form.md +36 -0
  26. data/lib/generators/jinda/templates/app/views/docs/doc_xedit/doc_edit.html.erb +21 -0
  27. data/lib/generators/jinda/templates/app/views/docs/edit/select_note.html.erb +14 -0
  28. data/lib/generators/jinda/templates/app/views/docs/index.haml +21 -0
  29. data/lib/generators/jinda/templates/app/views/docs/my.haml +27 -0
  30. data/lib/generators/jinda/templates/app/views/jinda/index.html.haml +3 -3
  31. data/lib/generators/jinda/templates/app/views/jinda/run_output.haml +3 -3
  32. data/lib/generators/jinda/templates/app/views/layouts/_head.html.erb +7 -10
  33. data/lib/generators/jinda/templates/app/views/layouts/{_metatag.html.erb → _meta_tag.html.erb} +0 -0
  34. data/lib/generators/jinda/templates/app/views/layouts/jqm/_full.haml +1 -9
  35. data/lib/generators/jinda/templates/app/views/notes/new/new_note.html.erb +1 -1
  36. data/lib/jinda/helpers.rb +11 -16
  37. data/lib/jinda/version.rb +1 -1
  38. data/lib/jquery.validate.js +1293 -0
  39. metadata +13 -8
  40. data/lib/generators/jinda/templates/app/views/layouts/_meta_tags.html.erb +0 -5
  41. data/lib/generators/jinda/templates/app/views/new.html.erb +0 -7
  42. data/lib/jinda/ template/view.html.erb +0 -25
  43. data/lib/jinda/app/jinda/index.mm +0 -309
  44. data/lib/jinda/app/jinda/template/view.html.erb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d32e253610977d016f3a715060ae616171a2c71331474c9f7dc7091682b4d58b
4
- data.tar.gz: 6af32a30a010f037e392fb630713c5b42a8ebc1482da18faae7605aaff8d804d
3
+ metadata.gz: c9ccb1a4e45e53213b02caa625662e84ccd386d446509fef479f183f8a2aa3b9
4
+ data.tar.gz: f0efd2ac4630d6a145510969de1d361a28d3c376179649b906bb3f6f9e5b46b9
5
5
  SHA512:
6
- metadata.gz: b4fa824aa0b3598642f0e2b818883e2b1eea7f5dcfb5eacc04bd3dbc1c279dbc6ec697dca9a6b0759f8ba6f4b5eab9c12d31736b70a520d2d84fa4eff9aab99b
7
- data.tar.gz: '04840e4df4f2d0e02a8f200bf5707d294b7993c53d2fc009c4ef558a9a9bab87cb4a3700f666b19a7b09fe094f655dd9e33c6815138ae8d194ab4d8c746d9d32'
6
+ metadata.gz: a2fbe028c4cd8b129c70b35c908479ca9aec7b0d0389256a1e423eb81315b8c07728ac8dc5a81d469114f2eb9e6380c39420d35202247b878bc690cda832d8d2
7
+ data.tar.gz: 84ef6f473657779def3fdfe49dfbfdb08f386d79028d3cffb5d3896ae06d864185b6ddb949e695a0deb1162fcae7f40ffa353b289f67cc6d2320c532a0f5b88a
data/README.md CHANGED
@@ -14,8 +14,8 @@ Rails Application Generator using Freemind
14
14
 
15
15
  These versions works for sure but others may do.
16
16
 
17
- * Ruby 2.7.0
18
- * Rails 6.0.2
17
+ * Ruby 2.7.1
18
+ * Rails 6.0.3
19
19
  * MongoDB 6
20
20
  * Freemind 1.0.1
21
21
 
@@ -40,7 +40,7 @@ app without ActiveRecord
40
40
 
41
41
  ## Add jinda to your Gemfile:
42
42
 
43
- gem 'jinda', '~> 0.5.2'
43
+ gem 'jinda', '~> 0.5.7'
44
44
 
45
45
  For Development (most updated)
46
46
 
@@ -83,6 +83,7 @@ module Jinda
83
83
  inside("app/controllers") {(File.file? "admins_controller.rb") ? ( say "Please merge existing jinda_org/admins_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/admins_controller.rb', 'admins_controller.rb')}
84
84
  inside("app/controllers") {(File.file? "articles_controller.rb") ? ( say "Please merge existing jinda_org/articles_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/articles_controller.rb', 'articles_controller.rb')}
85
85
  inside("app/controllers") {(File.file? "comments_controller.rb") ? ( say "Please merge existing jinda_org/comments_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/comments_controller.rb', 'comments_controller.rb')}
86
+ inside("app/controllers") {(File.file? "docs_controller.rb") ? ( say "Please merge existing jinda_org/docs_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/docs_controller.rb', 'docs_controller.rb')}
86
87
  inside("app/controllers") {(File.file? "identities_controller.rb") ? ( say "Please merge existing jinda_org/identities_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/identities_controller.rb', 'identities_controller.rb')}
87
88
  inside("app/controllers") {(File.file? "jinda_controller.rb") ? ( say "Please merge existing jinda_org/jinda_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/jinda_controller.rb', 'jinda_controller.rb')}
88
89
  inside("app/controllers") {(File.file? "password_resets_controller.rb") ? ( say "Please merge existing jinda_org/password_resets_controller.rb after this installation", :red) : (FileUtils.mv 'jinda_org/password_resets_controller.rb', 'password_resets_controller.rb')}
@@ -107,13 +108,19 @@ module Jinda
107
108
  route "resources :sessions"
108
109
  route "resources :identities"
109
110
  route "resources :users"
111
+ route "resources :docs"
110
112
  route "resources :notes"
111
- route "resources :articles"
113
+ route "resources :comments"
114
+ route "resources :articles do resources :comments end"
115
+ route "get '/jinda/document/:id' => 'jinda#document'"
112
116
  route "get '/notes/destroy/:id' => 'notes#destroy'"
113
117
  route "get '/notes/my/destroy/:id' => 'notes#destroy'"
118
+ route "get '/docs/my/destroy' => 'docs#destroy'"
114
119
  route "get '/notes/my' => 'notes/my'"
120
+ route "get '/docs/my' => 'docs/my'"
115
121
  route "get '/articles/my/destroy' => 'articles#destroy'"
116
- route "get '/articles/my' => 'articles/my'"
122
+ route "get '/articles/show' => 'articles/show'"
123
+ route "get '/articles/my' => 'articles#my'"
117
124
  route "get '/logout' => 'sessions#destroy', :as => 'logout'"
118
125
  route "get '/auth/failure' => 'sessions#destroy'"
119
126
  route "get '/auth/:provider/callback' => 'sessions#create'"
@@ -125,6 +132,7 @@ module Jinda
125
132
  route "post '/jinda/init' => 'jinda#init'"
126
133
  route "jinda_methods.each do \|aktion\| get \"/jinda/\#\{aktion\}\" => \"jinda#\#\{aktion\}\" end"
127
134
  route "jinda_methods += ['error_logs', 'notice_logs', 'cancel', 'run_output', 'end_output']"
135
+ route "jinda_methods += ['run_redirect', 'run_direct_to','run_if']"
128
136
  route "jinda_methods += ['init', 'run', 'run_mail', 'document', 'run_do', 'run_form', 'end_form']"
129
137
  route "jinda_methods = ['pending', 'status', 'search', 'doc', 'doc_print', 'logs', 'ajax_notice']"
130
138
  route "\# start jiinda method routes"
@@ -36,7 +36,7 @@ app without ActiveRecord
36
36
 
37
37
  ## Add jinda to your Gemfile:
38
38
 
39
- gem 'jinda', '~> 0.5.2'
39
+ gem 'jinda', '~> 0.5.3'
40
40
 
41
41
  For Development (most updated)
42
42
 
@@ -1,14 +1,19 @@
1
1
 
2
+ #article-title {
3
+ text-align: left;
4
+ font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif;
5
+ color:#333;
6
+ }
7
+
2
8
  #title {
3
9
  font-size: 14pt;
4
10
  font-weight: bold;
5
- text-align: center;
6
- background: #d2f0ff;
11
+ text-align: left;
7
12
  font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif;
8
13
  color:#333;
9
14
 
10
15
  }
11
- #text {
16
+ #text{
12
17
  font-size: 14pt;
13
18
  font-weight: bold;
14
19
  text-align:left;
@@ -41,7 +46,6 @@
41
46
  #table th {
42
47
  background-color: #bcecff;
43
48
  color:#333;
44
- ;
45
49
  width:100%;
46
50
  }
47
51
 
@@ -59,12 +63,14 @@
59
63
  font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif;
60
64
  /*font-size: 110%;*/
61
65
  }
62
- .ui-li .ui-btn-inner a.ui-link-inherit, .ui-li-static.ui-li { padding: 7px 75px 7px 15px; display: block; }
66
+ .ui-li .ui-btn-inner a.ui-link-inherit, .ui-li-static.ui-li { padding: 7px 75px 7px 7px; display: block; }
63
67
  .ui-link-inherit { font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif;}
64
68
  label.ui-input-text {
65
69
  font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif;
66
70
  /*font-size: 110%;*/
67
71
  text-shadow: none;
72
+ margin: 2% 2% 0 0;
73
+
68
74
  }
69
75
  label.ui-select {
70
76
  font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif;
@@ -1,16 +1,28 @@
1
1
 
2
- #article-title {
2
+
3
+ #article-table {
3
4
  font-size: 14pt;
4
5
  font-weight: bold;
5
- text-align: center;
6
- background: #d2f0ff;
6
+ text-align: left;
7
+ background:#f7f7f7;
7
8
  font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif;
9
+ padding:2px 5px;
8
10
  color:#333;
9
11
 
10
12
  }
11
- #article-text {
13
+
14
+ #article-title {
12
15
  font-size: 14pt;
13
16
  font-weight: bold;
17
+ text-align: left;
18
+ background:#f7f7f7;
19
+ font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif;
20
+ padding:2px 5px;
21
+ color:#333;
22
+
23
+ }
24
+ #article-text {
25
+ font-size: 8pt;
14
26
  text-align:left;
15
27
  border:1px solid #c1c1c1;
16
28
  background:#f7f7f7;
@@ -28,7 +40,6 @@
28
40
 
29
41
  #comment-body {
30
42
  font-size: 10pt;
31
- font-weight: bold;
32
43
  text-align:left;
33
44
  color:#333;
34
45
  }
@@ -41,7 +52,6 @@
41
52
  #article-table th {
42
53
  background-color: #bcecff;
43
54
  color:#333;
44
- ;
45
55
  width:100%;
46
56
  }
47
57
 
@@ -55,6 +55,7 @@ module JindaGeneralConcern
55
55
  end
56
56
 
57
57
  # process images from second level, e.g,, fields_for
58
+ # save uploaded file info to Doc
58
59
  def get_image1(key, key1, params)
59
60
  doc = Jinda::Doc.create(
60
61
  :name=> "#{key}_#{key1}",
@@ -63,16 +64,24 @@ module JindaGeneralConcern
63
64
  :filename=> params.original_filename,
64
65
  :content_type => params.content_type || 'application/zip',
65
66
  :data_text=> '',
67
+ :dscan=> '',
68
+ :description=>'',
69
+ :keywords=>'',
70
+ :category=>'',
66
71
  :ma_display=>true, :ma_secured => @xmain.service.ma_secured )
67
72
  if defined?(IMAGE_LOCATION)
68
73
  filename = "#{IMAGE_LOCATION}/f#{Param.gen(:asset_id)}"
69
74
  File.open(filename,"wb") { |f| f.write(params.read) }
70
75
  eval "@xvars[@runseq.code][key][key1] = '#{url_for(:action=>'document', :id=>doc.id, :only_path => true)}' "
71
- doc.update_attributes :url => filename, :basename => File.basename(filename), :cloudinary => false
76
+ doc.update_attributes :url => filename,
77
+ :basename => File.basename(filename),
78
+ :cloudinary => false,
79
+ :dscan => @xvars[@runseq.code][key][key1],
80
+ :user_id => @xvars["user_id"]
72
81
  else
73
82
  result = Cloudinary::Uploader.upload(params)
74
83
  eval %Q{ @xvars[@runseq.code][key][key1] = '#{result["url"]}' }
75
- doc.update_attributes :url => result["url"], :basename => File.basename(result["url"]), :cloudinary => true
84
+ doc.update_attributes :url => result["url"], :basename => File.basename(result["url"]), :cloudinary => true, :dscan => @xvars[@runseq.code][key][key1]
76
85
  end
77
86
  end
78
87
 
@@ -81,13 +90,27 @@ module JindaGeneralConcern
81
90
  end
82
91
 
83
92
  # generate documentation for application
93
+ # search data from Doc
94
+ def document
95
+ doc = Jinda::Doc.find params[:id]
96
+ if doc.cloudinary
97
+ require 'net/http'
98
+ require "uri"
99
+ uri = URI.parse(doc.url)
100
+ data = Net::HTTP.get_response(uri)
101
+ send_data(data.body, :filename=>doc.filename, :type=>doc.content_type, :disposition=>"inline")
102
+ else
103
+ data= read_binary(doc.url)
104
+ send_data(data, :filename=>doc.filename, :type=>doc.content_type, :disposition=>"inline")
105
+ end
106
+ end
107
+
84
108
  def doc
85
109
  require 'rdoc'
86
110
  @app= get_app
87
111
  @intro = File.read('README.md')
88
112
  @print= "<div align='right'><img src='/assets/printer.png'/> <a href='/jinda/doc_print' target='_blank'/>Print</a></div>"
89
113
  doc= render_to_string 'doc.md', :layout => false
90
-
91
114
  html= Maruku.new(doc).to_html
92
115
  File.open('public/doc.html','w') {|f| f.puts html }
93
116
  respond_to do |format|
@@ -127,7 +150,7 @@ module JindaGeneralConcern
127
150
 
128
151
  def search
129
152
  @q = params[:q] || params[:ma_search][:q] || ""
130
- @title = "ผลการค้นหา #{@q}"
153
+ @title = "Search Result #{@q}"
131
154
  @backbtn= true
132
155
  @cache= true
133
156
  if @q.blank?
@@ -60,6 +60,20 @@ module JindaRunConcern
60
60
  end_action(next_runseq)
61
61
  end
62
62
 
63
+ # redirect when finish last runseq
64
+ # eg: http://localhost:3000/notes/my
65
+ def run_direct_to
66
+ init_vars(params[:id])
67
+ next_runseq= @xmain.runseqs.where(:id.ne=>@runseq.id, :code=>@runseq.code).first
68
+ if !@runseq.code.blank?
69
+ @xvars['p']['return'] = @runseq.code
70
+ else
71
+ flash[:notice]= "Error: missing required forward path in Freemind"
72
+ ma_log "Error: require forward path in Freemind"
73
+ end
74
+ end_action(next_runseq)
75
+ end
76
+
63
77
  def run_redirect
64
78
  init_vars(params[:id])
65
79
  # next_runseq= @xmain.runseqs.first :conditions=>["id != ? AND code = ?",@runseq.id, @runseq.code]
@@ -68,16 +82,19 @@ module JindaRunConcern
68
82
  end_action(next_runseq)
69
83
  end
70
84
 
85
+ # call controller to do the freemind task using Star symbol eg: Update
86
+ # not for run_form
71
87
  def run_do
72
88
  init_vars(params[:id])
73
89
  @runseq.start ||= Time.now
74
90
  @runseq.status= 'R' # running
75
91
  $runseq_id= @runseq.id
76
92
  $user_id= current_ma_user.try(:id)
93
+ # $xmain, $runseq, $user, $xvars, $ip from local
77
94
  set_global
78
95
  controller = Kernel.const_get(@xvars['custom_controller']).new
79
- # call controller to do the freemind task using Star symbol eg: Update
80
96
  result = controller.send(@runseq.code)
97
+ # save local var to database
81
98
  init_vars_by_runseq($runseq_id)
82
99
  @xvars = $xvars
83
100
  @xvars[@runseq.code.to_sym]= result.to_s
@@ -97,6 +114,100 @@ module JindaRunConcern
97
114
  refresh_to "/", :alert => "Sorry opeation error at #{@xmain.id} #{@xvars['error']}"
98
115
  end
99
116
 
117
+ def run_list
118
+ init_vars(params[:id])
119
+ service= @xmain.service
120
+ # disp= get_option("display")
121
+ # disp = Nil or :"??????"
122
+ # get option from last node: rule, role, display
123
+ disp= get_option("display")
124
+ # change from Nil to false and string to true
125
+ ma_display = (disp && !affirm(disp)) ? false : true
126
+ # Todo check if file is available
127
+ # if service and file exist
128
+ # ma_display from disp of 3rd level node as rule, role, display
129
+ if service && !@runseq.code.blank?
130
+ f= "app/views/#{service.module.code}/#{service.code}/#{@runseq.code}.html.erb"
131
+ @ui= File.read(f)
132
+ if Jinda::Doc.where(:runseq_id=>@runseq.id).exists?
133
+ @doc= Jinda::Doc.where(:runseq_id=>@runseq.id).first
134
+ @doc.update_attributes :data_text=> render_to_string(:inline=>@ui, :layout=>"utf8"),
135
+ :xmain=>@xmain, :runseq=>@runseq, :user=>current_ma_user,
136
+ :ip=> get_ip, :service=>service, :ma_display=>ma_display,
137
+ :ma_secured => @xmain.service.ma_secured,
138
+ :filename => "#{@runseq.code}.html.erb"
139
+ else
140
+ @doc= Jinda::Doc.create :name=> @runseq.name,
141
+ :content_type=>"output", :data_text=> render_to_string(:inline=>@ui, :layout=>"utf8"),
142
+ :xmain=>@xmain, :runseq=>@runseq, :user=>current_ma_user,
143
+ :ip=> get_ip, :service=>service, :ma_display=>ma_display,
144
+ :ma_secured => @xmain.service.ma_secured,
145
+ :filename => "#{@runseq.code}.html.erb"
146
+ end
147
+ # @message = defined?(MSG_NEXT) ? MSG_NEXT : "Next &gt;"
148
+ @message = defined?(MSG_NEXT) ? MSG_NEXT : "Next >>"
149
+ @message = "Finish" if @runseq.end
150
+ ma_log("Todo defined?(NSG_NEXT : Next >>)")
151
+ eval "@xvars[@runseq.code] = url_for(:controller=>'jinda', :action=>'document', :id=>@doc.id)"
152
+ else
153
+ flash[:notice]= "Error: Can not find the view file for this controller"
154
+ ma_log "Error: Can not find the view file for this controller"
155
+ redirect_to_root
156
+ end
157
+ # Check if ma_display available
158
+ # ma_display= get_option("display")
159
+ # if not ma_display then no display both controller-view and content then end back to root
160
+ unless ma_display
161
+ end_action
162
+ end
163
+ # controller display from @ui
164
+ end
165
+
166
+ def run_folder
167
+ init_vars(params[:id])
168
+ service= @xmain.service
169
+ # disp= get_option("display")
170
+ # disp = Nil or :"??????"
171
+ disp= get_option("display")
172
+ ma_display = (disp && !affirm(disp)) ? false : true
173
+ # Todo check if file is available
174
+ # if service and file exist
175
+ if service && !@runseq.code.blank?
176
+ f= "app/views/#{service.module.code}/#{service.code}/#{@runseq.code}.html.erb"
177
+ @ui= File.read(f)
178
+ if Jinda::Doc.where(:runseq_id=>@runseq.id).exists?
179
+ @doc= Jinda::Doc.where(:runseq_id=>@runseq.id).first
180
+ @doc.update_attributes :data_text=> render_to_string(:inline=>@ui, :layout=>"utf8"),
181
+ :xmain=>@xmain, :runseq=>@runseq, :user=>current_ma_user,
182
+ :ip=> get_ip, :service=>service, :ma_display=>ma_display,
183
+ :ma_secured => @xmain.service.ma_secured,
184
+ :filename => "#{@runseq.code}.html.erb"
185
+ else
186
+ @doc= Jinda::Doc.create :name=> @runseq.name,
187
+ :content_type=>"output", :data_text=> render_to_string(:inline=>@ui, :layout=>"utf8"),
188
+ :xmain=>@xmain, :runseq=>@runseq, :user=>current_ma_user,
189
+ :ip=> get_ip, :service=>service, :ma_display=>ma_display,
190
+ :ma_secured => @xmain.service.ma_secured,
191
+ :filename => "#{@runseq.code}.html.erb"
192
+ end
193
+ # @message = defined?(MSG_NEXT) ? MSG_NEXT : "Next &gt;"
194
+ @message = defined?(MSG_NEXT) ? MSG_NEXT : "Next >>"
195
+ @message = "Finish" if @runseq.end
196
+ ma_log("Todo defined?(NSG_NEXT : Next >>)")
197
+ eval "@xvars[@runseq.code] = url_for(:controller=>'jinda', :action=>'document', :id=>@doc.id)"
198
+ else
199
+ flash[:notice]= "Error: Can not find the view file for this controller"
200
+ ma_log "Error: Can not find the view file for this controller"
201
+ redirect_to_root
202
+ end
203
+ # Check if ma_display available
204
+ # ma_display= get_option("display")
205
+ unless ma_display
206
+ end_action
207
+ end
208
+ # controller display from @ui
209
+ end
210
+
100
211
  def run_output
101
212
  init_vars(params[:id])
102
213
  service= @xmain.service
@@ -135,11 +246,11 @@ module JindaRunConcern
135
246
  redirect_to_root
136
247
  end
137
248
  # Check if ma_display available
138
- # ma_display= get_option("ma_display")
249
+ # ma_display= get_option("display")
139
250
  unless ma_display
140
251
  end_action
141
252
  end
142
- # display from @ui
253
+ # controller display from @ui
143
254
  end
144
255
 
145
256
  def run_mail
@@ -168,8 +279,11 @@ module JindaRunConcern
168
279
  end_action
169
280
  end
170
281
 
282
+ # Store params to @xvars[@runseq]
283
+ # Perform task from the form input eg: attach file
284
+ # replace end_action (for form)
285
+ # Store params attach file to @xvars to use in get_image
171
286
  def end_form
172
- # Check error using xmain_id to redirect_to_root and return
173
287
  if params[:xmain_id]
174
288
  init_vars(params[:xmain_id])
175
289
  else
@@ -183,13 +297,17 @@ module JindaRunConcern
183
297
  get_image(k, params[k])
184
298
  # check if params of array in form eg: edit_article
185
299
  elsif params[k].is_a?(ActionController::Parameters)
300
+ eval "@xvars[@runseq.code][k] = {} unless @xvars[@runseq.code][k]"
186
301
  params[k].each { |k1,v1|
187
302
  # eval "@xvars[@runseq.code][k1] = params.require(k1).permit(k1)"
188
- eval "@xvars[@runseq.code][k1] = v1"
303
+ eval "@xvars[@runseq.code][k][k1] = v1"
189
304
  next unless v1.respond_to?(:original_filename)
305
+ doc = {}
190
306
  get_image1(k, k1, params[k][k1])
191
307
  }
192
308
  else
309
+ # No file attached
310
+ #
193
311
  # https://stackoverflow.com/questions/34949505/rails-5-unable-to- retrieve-hash-values-from-parameter # bug in to_unsalfe_h rails 5.1.6 https://github.com/getsentry/raven-ruby/issues/799
194
312
  # Solution:
195
313
  # https://stackoverflow.com/questions/34949505/rails-5-unable-to-retrieve-hash-values-from-parameter
@@ -200,10 +318,21 @@ module JindaRunConcern
200
318
  eval "@xvars[@runseq.code][k] = v"
201
319
  end
202
320
  }
203
- end_action
321
+ end_action
322
+ rescue => e
323
+ @xmain.status='E'
324
+ @xvars['error']= e.to_s+e.backtrace.to_s
325
+ @xmain.xvars= $xvars
326
+ @xmain.save
327
+ @runseq.status= 'F' #finish
328
+ @runseq.stop= Time.now
329
+ @runseq.save
330
+ ma_log "Error:end_form "
331
+ refresh_to "/", :alert => "Sorry opeation error at #{@xmain.id} #{@xvars['error']}"
204
332
  end
205
333
 
206
334
  def end_action(next_runseq = nil)
335
+ # not for form
207
336
  # @runseq.status='F' unless @runseq_not_f
208
337
  @xmain.xvars= @xvars
209
338
  @xmain.status= 'R' # running