resty-generators 0.3.3 → 0.4.0

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.
@@ -16,7 +16,7 @@ module Resty
16
16
  end
17
17
 
18
18
  def create_module_file
19
- template 'module.gwt.xml', File.join(java_root, name.gsub(/\./, "/"), "#{application_name.underscore}.gwt.xml")
19
+ template 'module.gwt.xml', File.join(java_root, name.gsub(/\./, "/"), "#{application_name}.gwt.xml")
20
20
  end
21
21
 
22
22
  def create_maven_file
@@ -87,12 +87,8 @@ module Resty
87
87
  end
88
88
  end
89
89
 
90
- def create_initializers
91
- template 'monkey_patch.rb', File.join('config', 'initializers', 'resty_monkey_patch.rb')
92
- end
93
-
94
90
  def create_html
95
- template 'page.html', File.join('public', "#{application_name.underscore}.html")
91
+ template 'page.html', File.join('public', "#{application_name}.html")
96
92
  template 'gwt.css', File.join('public', 'stylesheets', "#{application_name.underscore}.css")
97
93
  end
98
94
 
@@ -163,7 +159,13 @@ SESSION
163
159
  template 'group.rb', File.join('app', 'models', "group.rb")
164
160
  template 'session.rb', File.join('app', 'models', "session.rb")
165
161
  template 'user.rb', File.join('app', 'models', "user.rb")
166
- route "resource :session"
162
+ route <<ROUTE
163
+ resource :session do
164
+ member do
165
+ post :reset_password
166
+ end
167
+ end
168
+ ROUTE
167
169
  gem 'ixtlan-session-timeout'
168
170
  gem 'ixtlan-guard'
169
171
  # TODO until rmvn uses the right openssl gem
@@ -9,16 +9,16 @@ import <%= gwt_rails_package %>.RestfulPlace;
9
9
 
10
10
  public abstract class ActivityPlace extends RestfulPlace {
11
11
 
12
- protected ActivityPlace(RestfulAction restfulAction) {
13
- super(restfulAction);
12
+ protected ActivityPlace(RestfulAction restfulAction, String name) {
13
+ super(restfulAction, name);
14
14
  }
15
15
 
16
- protected ActivityPlace(int id, RestfulAction restfulAction) {
17
- super(id, restfulAction);
16
+ protected ActivityPlace(int id, RestfulAction restfulAction, String name) {
17
+ super(id, restfulAction, name);
18
18
  }
19
19
 
20
- protected ActivityPlace(String id, RestfulAction restfulAction) {
21
- super(id, restfulAction);
20
+ protected ActivityPlace(String id, RestfulAction restfulAction, String name) {
21
+ super(id, restfulAction, name);
22
22
  }
23
23
 
24
24
  public abstract Activity create(ActivityFactory factory);
@@ -70,7 +70,7 @@ public class <%= application_name %>EntryPoint implements EntryPoint {
70
70
  * This is the entry point method.
71
71
  */
72
72
  public void onModuleLoad() {
73
- Defaults.setServiceRoot(GWT.getModuleBaseURL().replaceFirst("[a-z]+/$", ""));
73
+ Defaults.setServiceRoot(GWT.getModuleBaseURL().replaceFirst("[a-zA-Z0-9_]+/$", ""));
74
74
  Defaults.setDispatcher(DefaultDispatcherSingleton.INSTANCE);
75
75
  GWT.log("base url for restservices: " + Defaults.getServiceRoot());
76
76
 
@@ -15,6 +15,7 @@ import com.google.gwt.event.shared.EventBus;
15
15
  import com.google.gwt.user.client.ui.AcceptsOneWidget;
16
16
  import com.google.inject.assistedinject.Assisted;
17
17
 
18
+ import <%= gwt_rails_package %>.Notice;
18
19
  import <%= gwt_rails_session_package %>.Authentication;
19
20
  import <%= gwt_rails_session_package %>.LoginView;
20
21
  import <%= gwt_rails_session_package %>.Session;
@@ -25,15 +26,18 @@ public class LoginActivity extends AbstractActivity implements LoginView.Present
25
26
  private final SessionRestService service;
26
27
  private final LoginView view;
27
28
  private final SessionManager<User> sessionManager;
29
+ private final Notice notice;
28
30
 
29
31
  @Inject
30
32
  public LoginActivity(@Assisted LoginPlace place,
31
33
  LoginView view,
32
34
  SessionRestService service,
33
- SessionManager<User> sessionManager) {
35
+ SessionManager<User> sessionManager,
36
+ Notice notice) {
34
37
  this.view = view;
35
38
  this.service = service;
36
39
  this.sessionManager = sessionManager;
40
+ this.notice = notice;
37
41
  }
38
42
 
39
43
  public void start(AcceptsOneWidget display, EventBus eventBus) {
@@ -56,4 +60,18 @@ public class LoginActivity extends AbstractActivity implements LoginView.Present
56
60
  }
57
61
  });
58
62
  }
63
+
64
+ public void resetPassword(final String login) {
65
+ Authentication authentication = new Authentication(login);
66
+ service.resetPassword(authentication, new MethodCallback<Void>() {
67
+
68
+ public void onSuccess(Method method, Void result) {
69
+ notice.setText("new password was sent to your email address");
70
+ }
71
+
72
+ public void onFailure(Method method, Throwable exception) {
73
+ notice.setText("could not reset password - username/email unknown");
74
+ }
75
+ });
76
+ }
59
77
  }
@@ -6,13 +6,16 @@
6
6
  <ui:style>
7
7
  </ui:style>
8
8
 
9
- <g:SimplePanel>
10
- <g:VerticalPanel>
11
- <g:InlineHTML>username</g:InlineHTML>
12
- <g:TextBox ui:field="username"/>
13
- <g:InlineHTML>password</g:InlineHTML>
14
- <g:PasswordTextBox ui:field="password"/>
15
- <g:Button ui:field="loginButton">login</g:Button>
16
- </g:VerticalPanel>
17
- </g:SimplePanel>
9
+ <g:FlowPanel>
10
+ <g:HTML><label name="login">Username or Email</label></g:HTML>
11
+ <g:TextBox ui:field="login" name="login"/>
12
+ <g:HTML><label name="password">Password</label></g:HTML>
13
+ <g:PasswordTextBox ui:field="password" name="password"/>
14
+ <g:HTML></g:HTML>
15
+ <g:Button ui:field="loginButton">login</g:Button>
16
+ <g:HTML><label name="username">Username or Email</label></g:HTML>
17
+ <g:TextBox ui:field="username" name="username"/>
18
+ <g:HTML></g:HTML>
19
+ <g:Button ui:field="resetPasswordButton">password reset</g:Button>
20
+ </g:FlowPanel>
18
21
  </ui:UiBinder>
@@ -4,7 +4,7 @@ jar('org.fusesource.restygwt:restygwt', '1.2-SNAPSHOT').scope :provided
4
4
  jar('javax.ws.rs:jsr311-api', '1.1').scope :provided
5
5
  jar('com.google.gwt:gwt-user', GWT_VERSION).scope :provided
6
6
  jar('com.google.gwt.inject:gin', '1.5.0').scope :provided
7
- jar('de.mkristian.rails-gwt:rails-gwt', '0.1.0-SNAPSHOT').scope :provided
7
+ jar('de.mkristian.rails-gwt:rails-gwt', '0.2.0-SNAPSHOT').scope :provided
8
8
 
9
9
  plugin('org.codehaus.mojo:gwt-maven-plugin', GWT_VERSION) do |gwt|
10
10
  gwt.with({ :warSourceDirectory => "${basedir}/public",
@@ -16,7 +16,7 @@ plugin('org.codehaus.mojo:gwt-maven-plugin', GWT_VERSION) do |gwt|
16
16
  :style => "DETAILED",
17
17
  :treeLogger => true,
18
18
  :extraJvmArgs => "-Xmx512m",
19
- :runTarget => "<%= application_name.underscore %>.html",
19
+ :runTarget => "<%= application_name %>.html",
20
20
  :includes => "**/<%= application_name %>GWTTestSuite.java"
21
21
  })
22
22
  gwt.executions.goals << ["clean", "compile", "test"]
@@ -20,4 +20,7 @@ public interface SessionRestService extends RestService {
20
20
 
21
21
  @DELETE
22
22
  void destroy(MethodCallback<Void> callback);
23
+
24
+ @POST @Path("/reset_password")
25
+ void resetPassword(Authentication authentication, MethodCallback<Void> methodCallback);
23
26
  }
@@ -1,5 +1,9 @@
1
1
  package <%= models_package %>;
2
2
 
3
+ import org.fusesource.restygwt.client.Json;
4
+ import org.fusesource.restygwt.client.Json.Style;
5
+
6
+ @Json(style = Style.RAILS)
3
7
  public class User {
4
8
 
5
9
  public String login;
@@ -1,4 +1,4 @@
1
- <module rename-to='<%= application_name.underscore %>'>
1
+ <module rename-to='<%= application_name %>'>
2
2
 
3
3
  <inherits name='com.google.gwt.user.User' />
4
4
  <inherits name="com.google.gwt.activity.Activity"/>
@@ -12,7 +12,7 @@
12
12
  <!-- If you add any GWT meta tags, they must -->
13
13
  <!-- be added before this line. -->
14
14
  <!-- -->
15
- <script type="text/javascript" language="javascript" src="<%= application_name.underscore %>/<%= application_name.underscore %>.nocache.js"></script>
15
+ <script type="text/javascript" language="javascript" src="<%= application_name %>/<%= application_name %>.nocache.js"></script>
16
16
  </head>
17
17
 
18
18
  <!-- -->
@@ -41,5 +41,3 @@ class Session
41
41
  ""
42
42
  end
43
43
  end
44
- Session.include_root_in_json = false
45
- Session
@@ -7,20 +7,28 @@ class SessionsController < ApplicationController
7
7
  public
8
8
 
9
9
  def create
10
- @session = Session.create(params[:session])
10
+ @session = Session.create(params[:authentication] || params)
11
11
 
12
12
  if @session
13
13
  current_user @session.user
14
14
  @session.permissions = guard.permissions(self)
15
15
 
16
- # TODO make all formats available
17
16
  # TODO make html login
18
- render :json => @session.to_json(:excludes => :groups)
17
+ respond_to do |format|
18
+ format.html { render :text => "authorized - but nothing further is implemented" }
19
+ format.xml { render :xml => @session.to_xml }
20
+ format.json { render :json => @session.to_json }
21
+ end
19
22
  else
20
23
  head :not_found
21
24
  end
22
25
  end
23
26
 
27
+ def reset_password
28
+ warn "not implemented"
29
+ head :ok
30
+ end
31
+
24
32
  def destroy
25
33
  # reset session happens in the after filter which allows for
26
34
  # audit log with username which happens in another after filter
@@ -24,5 +24,3 @@ class User
24
24
  end
25
25
  end
26
26
  end
27
- User.include_root_in_json = false
28
- User
@@ -70,8 +70,9 @@ public class <%= class_name %>Activity extends AbstractActivity implements <%= c
70
70
  service.show(<% unless options[:singleton] -%>id, <% end -%>new MethodCallback<<%= class_name %>>() {
71
71
 
72
72
  public void onFailure(Method method, Throwable exception) {
73
- notice.setText("error loading <%= class_name.humanize %>: "
73
+ notice.setText("error loading <%= class_name.underscore.humanize %>: "
74
74
  + exception.getMessage());
75
+ view.reset(place.action);
75
76
  }
76
77
 
77
78
  public void onSuccess(Method method, <%= class_name %> response) {
@@ -81,7 +82,7 @@ public class <%= class_name %>Activity extends AbstractActivity implements <%= c
81
82
  }
82
83
  });
83
84
  if(!notice.isVisible()){
84
- notice.setText("loading <%= class_name.humanize %> . . .");
85
+ notice.setText("loading <%= class_name.underscore.humanize %> . . .");
85
86
  }
86
87
  }
87
88
  <% unless options[:singleton] -%>
@@ -91,7 +92,7 @@ public class <%= class_name %>Activity extends AbstractActivity implements <%= c
91
92
  service.create(model, new MethodCallback<<%= class_name %>>() {
92
93
 
93
94
  public void onFailure(Method method, Throwable exception) {
94
- notice.setText("error creating <%= class_name.humanize %>: "
95
+ notice.setText("error creating <%= class_name.underscore.humanize %>: "
95
96
  + exception.getMessage());
96
97
  }
97
98
 
@@ -100,7 +101,7 @@ public class <%= class_name %>Activity extends AbstractActivity implements <%= c
100
101
  RestfulActionEnum.EDIT));
101
102
  }
102
103
  });
103
- notice.setText("creating <%= class_name.humanize %> . . .");
104
+ notice.setText("creating <%= class_name.underscore.humanize %> . . .");
104
105
  }
105
106
 
106
107
  public void delete() {
@@ -109,7 +110,7 @@ public class <%= class_name %>Activity extends AbstractActivity implements <%= c
109
110
  service.destroy(model, new MethodCallback<Void>() {
110
111
 
111
112
  public void onFailure(Method method, Throwable exception) {
112
- notice.setText("error deleting <%= class_name.humanize %>: "
113
+ notice.setText("error deleting <%= class_name.underscore.humanize %>: "
113
114
  + exception.getMessage());
114
115
  }
115
116
 
@@ -117,7 +118,7 @@ public class <%= class_name %>Activity extends AbstractActivity implements <%= c
117
118
  goTo(new <%= class_name %>Place(RestfulActionEnum.INDEX));
118
119
  }
119
120
  });
120
- notice.setText("deleting <%= class_name.humanize %> . . .");
121
+ notice.setText("deleting <%= class_name.underscore.humanize %> . . .");
121
122
  }
122
123
  <% end -%>
123
124
  public void save() {
@@ -126,7 +127,7 @@ public class <%= class_name %>Activity extends AbstractActivity implements <%= c
126
127
  service.update(model, new MethodCallback<<%= class_name %>>() {
127
128
 
128
129
  public void onFailure(Method method, Throwable exception) {
129
- notice.setText("error loading <%= class_name.humanize %>: "
130
+ notice.setText("error loading <%= class_name.underscore.humanize %>: "
130
131
  + exception.getMessage());
131
132
  }
132
133
 
@@ -135,6 +136,6 @@ public class <%= class_name %>Activity extends AbstractActivity implements <%= c
135
136
  <% end -%>RestfulActionEnum.EDIT));
136
137
  }
137
138
  });
138
- notice.setText("saving <%= class_name.humanize %> . . .");
139
+ notice.setText("saving <%= class_name.underscore.humanize %> . . .");
139
140
  }
140
141
  }
@@ -4,26 +4,39 @@ package <%= models_package %>;
4
4
  import java.util.Date;
5
5
  <% end -%>
6
6
 
7
+ import org.fusesource.restygwt.client.Json;
8
+ import org.fusesource.restygwt.client.Json.Style;
9
+
10
+ @Json(style = Style.RAILS<% if class_name.downcase == class_name.underscore -%>)<% else -%>, name = "<%= class_name.underscore %>")<% end %>
7
11
  public class <%= class_name %> {
8
12
 
9
13
  <% unless options[:singleton] -%>
10
14
  public int id;
11
-
12
15
  <% end -%>
13
16
  <% for attribute in attributes -%>
17
+ <% name = attribute.name.classify.sub(/^(.)/) {$1.downcase} -%>
18
+
19
+ <% if name != name.underscore -%> @Json(name = "<%= name.underscore %>")
20
+ <% end -%>
14
21
  <% if attribute.type == :has_one -%>
15
- <%= attribute.name.classify %> <%= attribute.name %>;
22
+ public <%= attribute.name.classify %> <%= name %>;
16
23
  <% elsif attribute.type == :has_many -%>
17
- public java.util.List<<%= attribute.name.classify %>> <%= attribute.name %>;
24
+ public java.util.List<<%= attribute.name.classify %>> <%= name %>;
18
25
  <% else -%>
19
- public <%= type_map[attribute.type] || attribute.type.to_s.classify %> <%= attribute.name.classify.underscore.sub(/^(.)/){ $1 } %>;
26
+ public <%= type_map[attribute.type] || attribute.type.to_s.classify %> <%= name %>;
20
27
  <% end -%>
21
28
  <% end -%>
22
29
  <% if options[:timestamps] %>
23
- public Date created_at;
24
- public Date updated_at;
30
+
31
+ @Json(name = "created_at")
32
+ public Date createdAt;
33
+
34
+ @Json(name = "updated_at")
35
+ public Date updatedAt;
25
36
  <% end -%>
26
37
  <% if options[:modified_by] %>
27
- public options[:modified_by].classify.underscore modified_by
38
+
39
+ @Json(name = "modified_by")
40
+ public options[:modified_by].classify.underscore modifiedBy
28
41
  <% end -%>
29
42
  }
@@ -14,14 +14,14 @@ public class <%= class_name %>Place extends ActivityPlace {
14
14
  }
15
15
 
16
16
  public <%= class_name %>Place(RestfulAction restfulAction) {
17
- super(restfulAction);
17
+ super(restfulAction, "<%= table_name %>");
18
18
  }
19
19
 
20
20
  public <%= class_name %>Place(int id, RestfulAction restfulAction) {
21
- super(id, restfulAction);
21
+ super(id, restfulAction, "<%= table_name %>");
22
22
  }
23
23
 
24
24
  public <%= class_name %>Place(String id, RestfulAction restfulAction) {
25
- super(id, restfulAction);
25
+ super(id, restfulAction, "<%= table_name %>");
26
26
  }
27
27
  }
@@ -2,13 +2,13 @@ package <%= restservices_package %>;
2
2
 
3
3
  import <%= gwt_rails_package %>.RestfulDispatcherSingleton;
4
4
  <% if action_map.values.member? :get_all -%>
5
+ import <%= gwt_rails_package %>.DefaultDispatcherSingleton;
5
6
  import java.util.List;
6
7
  <% end -%>
7
8
 
8
9
  import javax.ws.rs.*;
9
10
 
10
11
  import org.fusesource.restygwt.client.*;
11
- import org.fusesource.restygwt.client.dispatcher.DefaultDispatcher;
12
12
 
13
13
  <% if name -%>
14
14
  import <%= models_package %>.*;
@@ -22,7 +22,7 @@ public interface <%= controller_class_name %>RestService extends RestService {
22
22
  case action_map[action]
23
23
  when :get_all -%>
24
24
  @GET @Path("/<%= table_name %>")
25
- @Options(dispatcher = DefaultDispatcher.class)
25
+ @Options(dispatcher = DefaultDispatcherSingleton.class)
26
26
  void <%= action %>(MethodCallback<List<<%= class_name %>>> callback);
27
27
 
28
28
  // @GET @Path("/<%= table_name %>")
@@ -37,7 +37,7 @@
37
37
  <% if attribute.type != :has_one && attribute.type != :has_many -%>
38
38
  <% name = attribute.name.classify.sub(/^(.)/){ $1.downcase } -%>
39
39
  <g:FlowPanel styleName="{style.field}">
40
- <g:HTML><label name="<%= name %>"><%= name.humanize %></label></g:HTML>
40
+ <g:HTML><label name="<%= name %>"><%= name.underscore.humanize %></label></g:HTML>
41
41
  <g:TextBox ui:field="<%= name %>" name="<%= name %>"/>
42
42
  </g:FlowPanel>
43
43
  <% end -%>
@@ -3,6 +3,9 @@ package <%= views_package %>;
3
3
  <% if options[:timestamps] %>
4
4
  import java.util.Date;
5
5
  <% end -%>
6
+ <% if options[:timestamps] -%>
7
+ import <%= gwt_rails_package %>.<% unless options[:singleton] -%>Identifyable<% end -%>TimestampedView;<% else -%><% unless options[:singleton] -%>
8
+ import <%= gwt_rails_package %>.IdentifyableView;<% end -%><% end -%>
6
9
 
7
10
  import <%= gwt_rails_package %>.RestfulAction;
8
11
  import <%= gwt_rails_package %>.RestfulActionEnum;
@@ -12,10 +15,6 @@ import <%= places_package %>.<%= class_name %>Place;
12
15
 
13
16
  import com.google.gwt.core.client.GWT;
14
17
  import com.google.gwt.event.dom.client.ClickEvent;
15
- <% if options[:timestamps] %>
16
- import com.google.gwt.i18n.client.DateTimeFormat;
17
- import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
18
- <% end -%>
19
18
  import com.google.gwt.uibinder.client.UiBinder;
20
19
  import com.google.gwt.uibinder.client.UiField;
21
20
  import com.google.gwt.uibinder.client.UiHandler;
@@ -24,7 +23,7 @@ import com.google.gwt.user.client.ui.*;
24
23
  import com.google.inject.Singleton;
25
24
 
26
25
  @Singleton
27
- public class <%= class_name %>ViewImpl extends Composite
26
+ public class <%= class_name %>ViewImpl extends <% if options[:timestamps] -%><% unless options[:singleton] -%>Identifyable<% end -%>TimestampedView<% else -%><% unless options[:singleton] -%>IdentifyableView<% else -%>Composite<% end -%><% end %>
28
27
  implements <%= class_name %>View {
29
28
 
30
29
  @UiTemplate("<%= class_name %>View.ui.xml")
@@ -32,6 +31,7 @@ public class <%= class_name %>ViewImpl extends Composite
32
31
 
33
32
  private static <%= class_name %>ViewUiBinder uiBinder = GWT.create(<%= class_name %>ViewUiBinder.class);
34
33
 
34
+ <% unless options[:readonly] -%>
35
35
  <% unless options[:singleton] -%>
36
36
  @UiField
37
37
  Button newButton;
@@ -48,17 +48,7 @@ public class <%= class_name %>ViewImpl extends Composite
48
48
  @UiField
49
49
  Button deleteButton;
50
50
 
51
- @UiField
52
- Label id;
53
-
54
51
  <% end -%>
55
- <% if options[:timestamps] %>
56
- @UiField
57
- Label createdAt;
58
-
59
- @UiField
60
- Label updatedAt;
61
-
62
52
  <% end -%>
63
53
  <% for attribute in attributes -%>
64
54
  <% if attribute.type == :has_one -%>
@@ -74,18 +64,10 @@ public class <%= class_name %>ViewImpl extends Composite
74
64
 
75
65
  private Presenter presenter;
76
66
 
77
- <% unless options[:singleton] -%>
78
- private int idCache;
79
-
80
- <% end -%>
81
- <% if options[:timestamps] %>
82
- private Date createdAtCache;
83
- private Date updatedAtCache;
84
-
85
- <% end -%>
86
67
  public <%= class_name %>ViewImpl() {
87
68
  initWidget(uiBinder.createAndBindUi(this));
88
69
  }
70
+ <% unless options[:readonly] %>
89
71
  <% unless options[:singleton] -%>
90
72
  @UiHandler("newButton")
91
73
  void onClickNew(ClickEvent e) {
@@ -111,48 +93,35 @@ public class <%= class_name %>ViewImpl extends Composite
111
93
  void onClickDelete(ClickEvent e) {
112
94
  presenter.delete();
113
95
  }
96
+ <% end -%>
114
97
  <% end -%>
115
98
  public void setPresenter(Presenter presenter) {
116
99
  this.presenter = presenter;
117
100
  }
118
101
 
119
102
  public void reset(<%= class_name %> model) {
120
- <% if options[:singleton] -%>
121
- //TODO singleton support
103
+ <% if options[:singleton] && options[:timestamps] -%>
104
+ resetSignature(model.createdAt, model.updatedAt);
122
105
  <% else -%>
123
- if(model.id > 0){
124
- id.setText("id: " + model.id);
125
- <% if options[:timestamps] %>
126
- createdAt.setText("created at: "
127
- + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM).format(model.created_at));
128
- updatedAt.setText("updated at: "
129
- + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM).format(model.updated_at));
130
- <% end -%>
131
- }
132
- else {
133
- id.setText(null);
134
106
  <% if options[:timestamps] %>
135
- createdAt.setText(null);
136
- updatedAt.setText(null);
137
- <% end -%>
138
- }
139
- this.idCache = model.id;
140
- <% if options[:timestamps] %>
141
- this.createdAtCache = model.created_at;
142
- this.updatedAtCache = model.updated_at;
107
+ resetSignature(model.id, model.createdAt, model.updatedAt);
108
+ <% else -%>
109
+ resetSignature(model.id);
143
110
  <% end -%>
144
111
  <% end -%>
145
112
  <% for attribute in attributes -%>
146
113
  <% if attribute.type != :has_one && attribute.type != :has_many -%>
147
114
  <% name = attribute.name.classify.sub(/^(.)/){ $1.downcase } -%>
148
- <% field_name = attribute.name.classify.underscore.sub(/^(.)/){ $1.downcase } -%>
149
- <%= name %>.setText(model.<%= field_name %><% if type_conversion_map[attribute.type] -%> + ""<% end -%>);
115
+ <%= name %>.setText(model.<%= name %><% if type_conversion_map[attribute.type] -%> + ""<% end -%>);
150
116
  <% end -%>
151
117
  <% end -%>
152
118
  }
153
119
 
154
120
  public void reset(RestfulAction action) {
155
- GWT.log(action.name() + " <%= class_name %>"<% unless options[:singleton] -%> + (idCache > 0 ? "(" + id + ")" : "")<% end -%>);
121
+ GWT.log(action.name() + " <%= class_name %>"<% unless options[:singleton] -%> + (idCache > 0 ? "(" + idCache + ")" : "")<% end -%>);
122
+ <% if options[:readonly] -%>
123
+ setEnabled(false);
124
+ <% else -%>
156
125
  <% unless options[:singleton] -%>
157
126
  newButton.setVisible(!action.name().equals(RestfulActionEnum.NEW.name()));
158
127
  createButton.setVisible(action.name().equals(RestfulActionEnum.NEW.name()));
@@ -163,6 +132,7 @@ public class <%= class_name %>ViewImpl extends Composite
163
132
  deleteButton.setVisible(!action.name().equals(RestfulActionEnum.NEW.name()));
164
133
  <% end -%>
165
134
  setEnabled(!action.viewOnly());
135
+ <% end -%>
166
136
  }
167
137
 
168
138
  public <%= class_name %> retrieve<%= class_name %>() {
@@ -171,14 +141,14 @@ public class <%= class_name %>ViewImpl extends Composite
171
141
  model.id = idCache;
172
142
  <% end -%>
173
143
  <% if options[:timestamps] %>
174
- model.created_at = createdAtCache;
175
- model.updated_at = updatedAtCache;
144
+ model.createdAt = createdAtCache;
145
+ model.updatedAt = updatedAtCache;
176
146
  <% end -%>
177
147
 
178
148
  <% for attribute in attributes -%>
179
149
  <% if attribute.type != :has_one && attribute.type != :has_many -%>
180
150
  <% name = attribute.name.classify.sub(/^(.)/){ $1.downcase } -%>
181
- model.<%= attribute.name.classify.underscore.sub(/^(.)/){ $1.downcase } %> = <% if (conv = type_conversion_map[attribute.type]).nil? -%><%= name %>.getText()<% else -%><%= conv %>(<%= name %>.getText())<% end -%>;
151
+ model.<%= name %> = <% if (conv = type_conversion_map[attribute.type]).nil? -%><%= name %>.getText()<% else -%><%= conv %>(<%= name %>.getText())<% end -%>;
182
152
  <% end -%>
183
153
 
184
154
  <% end -%>
@@ -13,10 +13,6 @@ module Resty
13
13
  end
14
14
 
15
15
  config.after_initialize do
16
- ActiveRecord::Base.include_root_in_json = false
17
- # TODO there migt be a way to tell ALL ActiveModel:
18
- #ActiveModel::Base.include_root_in_json = false
19
-
20
16
  # get the time/date format right ;-) and match it with resty
21
17
  class DateTime
22
18
  def as_json(options = nil)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: resty-generators
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.3
5
+ version: 0.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - mkristian
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-24 00:00:00 +05:30
13
+ date: 2011-08-06 00:00:00 +05:30
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency