asf_scaffold_generator 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,8 +43,11 @@ class AsfScaffoldGenerator < ScaffoldGenerator
43
43
  File.join('app/views', controller_class_path, controller_file_name, "#{action}.rhtml"),
44
44
  :assigns => { :action => action }
45
45
  end
46
+
47
+ # ID resolver controller
48
+ m.template 'asf_resolveids_controller.rb', "app/controllers/asf_resolveids_controller.rb"
46
49
 
47
- # Layout and stylesheet.
50
+ # Layout
48
51
  m.template 'asf_layout.rhtml', "app/views/layouts/#{controller_file_name}.rhtml"
49
52
  end
50
53
  end
@@ -5,13 +5,44 @@
5
5
  <%% url = <%= model_name %>.connection.binding.url %>
6
6
  <%%= tag("link", { "rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => "#{url.scheme}://#{url.host}:#{url.port}/dCSS/Theme2/default/common.css" }) %>
7
7
  <script type="text/javascript" src="http://na1.salesforce.com/js/functions.js"></script>
8
+ <%%= javascript_include_tag "prototype", "effects" %>
9
+
10
+ <script>
11
+ function update_ids(id_map) {
12
+ links = document.getElementsByTagName('a')
13
+
14
+ for (var n = 0; n < links.length; n++) {
15
+ link = links[n]
16
+
17
+ // Look for any links that end in /show/<id>
18
+ pos = link.href.lastIndexOf("/show/")
19
+ if (pos >= 0) {
20
+ id = link.href.substring(pos + 6)
21
+ match = id_map[id]
22
+ if (match) {
23
+ link.innerHTML = match
24
+ new Effect.Highlight(link)
25
+ }
26
+ }
27
+ }
28
+ }
8
29
 
30
+ </script>
31
+
9
32
  </head>
10
- <body class="contact overviewPage">
33
+
34
+ <body class="contact overviewPage" onload="request_id_resolve()">
11
35
 
12
36
  <p style="color: green"><%%= flash[:notice] %></p>
13
37
 
14
38
  <%%= @content_for_layout %>
15
39
 
40
+ <script>
41
+ function request_id_resolve() {
42
+ <%%= remote_function(:url => { :controller => 'asf_resolveids', :action => :resolve, :class => '<%= model_name %>', :ids => @id_resolver.serialize }, :complete => "update_ids(eval(request.responseText))") %>
43
+ }
44
+ </script>
45
+
46
+
16
47
  </body>
17
48
  </html>
@@ -0,0 +1,18 @@
1
+ class AsfResolveidsController < ActionController::Base
2
+ def resolve
3
+ klass_name = params[:class]
4
+ ids = params[:ids]
5
+
6
+ klass = klass_name.constantize
7
+ connection = klass.connection
8
+
9
+ name_columns = (klass.columns.reject { |column| not column.is_name? }).map { |column| column.api_name }
10
+
11
+ id_resolver = ActiveSalesforce::IdResolver.new(connection)
12
+ id_resolver.deserialize(ids)
13
+ values = id_resolver.resolve
14
+
15
+ # Send back the JSON encoded mapping from OID => name
16
+ render(:text => "({ " + values.map { |id, names| "\"#{id}\" : \"" + names.map { |name, value| value }.join(' ') + '"'}.join(', ') + " })")
17
+ end
18
+ end
@@ -80,3 +80,9 @@
80
80
  <%%= link_to 'Next page', { :page => @<%= singular_name %>_pages.current.next } if @<%= singular_name %>_pages.current.next %>
81
81
 
82
82
  <br />
83
+
84
+
85
+ <%% @id_resolver = ActiveSalesforce::IdResolver.new(<%= model_name %>.connection)
86
+ @<%= plural_name %>.each { |<%= singular_name %>| @id_resolver.add(<%= singular_name %>, columns) }
87
+ %>
88
+
@@ -47,4 +47,10 @@
47
47
  %>
48
48
  </table>
49
49
  </div></div>
50
- </div></div>
50
+ </div></div>
51
+
52
+
53
+ <%% @id_resolver = ActiveSalesforce::IdResolver.new(<%= model_name %>.connection)
54
+ @id_resolver.add(@<%= singular_name %>)
55
+ %>
56
+
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: asf_scaffold_generator
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.8
7
- date: 2006-02-28 00:00:00 -05:00
6
+ version: 0.0.9
7
+ date: 2006-03-02 00:00:00 -05:00
8
8
  summary: ActiveSalesforce Generator provides additional salesforce aware scaffolding support.
9
9
  require_paths:
10
10
  - lib
@@ -31,18 +31,18 @@ files:
31
31
  - ./USAGE
32
32
  - ./asf_scaffold_generator.rb
33
33
  - ./templates
34
+ - ./templates/asf_resolveids_controller.rb
34
35
  - ./templates/asf_view_list.rhtml
35
36
  - ./templates/asf_view_show.rhtml
36
37
  - ./templates/asf_view_edit.rhtml
37
38
  - ./templates/asf_view_new.rhtml
38
39
  - ./templates/asf_layout.rhtml
39
- - ./templates/asf_application.rb
40
+ - templates/asf_resolveids_controller.rb
40
41
  - templates/asf_view_list.rhtml
41
42
  - templates/asf_view_show.rhtml
42
43
  - templates/asf_view_edit.rhtml
43
44
  - templates/asf_view_new.rhtml
44
45
  - templates/asf_layout.rhtml
45
- - templates/asf_application.rb
46
46
  - USAGE
47
47
  test_files: []
48
48
 
@@ -1,17 +0,0 @@
1
- # Filters added to this controller will be run for all controllers in the application.
2
- # Likewise, all the methods added will be available for all controllers.
3
- class ApplicationController < ActionController::Base
4
- before_filter :asf_sid_authenticate
5
-
6
- def asf_sid_authenticate
7
- # Look to see if a SID was passed in the URL
8
- sid = params[:sid]
9
- if sid
10
- api_server_url = params[:api_server_url]
11
- api_server_url = 'http://na1-api.salesforce.com/services/Soap/u/7.0' unless api_server_url
12
-
13
- puts "asf_sid_authenticate(:sid => '#{sid}', :url => '#{api_server_url}')"
14
- Contact.establish_connection(:adapter => 'activesalesforce', :sid => sid, :url => api_server_url) if sid
15
- end
16
- end
17
- end