ng_on_rails 0.0.3.4 → 0.0.3.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9c135751efa21144f913d5c92dc97b3f8dca41a
4
- data.tar.gz: e16313aefe530ad5ecb2c319cfb1d9e9dd3b24d9
3
+ metadata.gz: d4dbd24da05c3703028c56e9e886bbad00d9bbfb
4
+ data.tar.gz: dae75d2a092dfdb1476aa085b706ebaeb8e93adf
5
5
  SHA512:
6
- metadata.gz: 6fef4fe13a7c3f03c68389c8e18477fa1daa4d49cf5f6d153087e3d20a785908712a11bc3c56f359183363d5d92b3bbfed0065ddcbe1cd4b88347fda8ba0e41d
7
- data.tar.gz: 1df9805234efe3b0b9a3663731e9d349da57ff2952d3c499f9561c43615ed66622bf1b6c9e75344bc16c87cbe80fe93b4300b7c9ae4d2152e0d1dbff991cdc96
6
+ metadata.gz: e45f74e69948b5a4898ce60f597ba32210e24e9d18d2c10d2acb45830b9c2193fe457c8175de7b41657333693cc1c9a53f0ef069a4693d108753066fdfa84de6
7
+ data.tar.gz: 52de3d3c9eee0a6e52be64f4b12e3fe52d89fc81bcdb80b51448ef4c65927edbd26b258ac7ee7dc032eb42e8e30df3bf83b8ecaaf1144cd810a4e2885654cfe8
data/README.md CHANGED
@@ -202,8 +202,8 @@ $ bundle exec rails g ng_on_rails:views Page --properties id:number{skip_form+li
202
202
  ```
203
203
  or even better, in two lines with the scaffolding short hand:
204
204
  ```
205
- $ bundle exec rails g ng_on_rails:views Doc --properties id:number{skip_form+link} name{required} description:textarea{skip_index} --relationships pages --rails-views
206
- $ bundle exec rails g ng_on_rails:views Page --properties id:number{skip_form+link} order_index:number subject{required} body:textarea{skip_index} --belongs_to Doc --rails-views``
205
+ $ bundle exec rails g ng_on_rails:scaffold Doc --properties id:number{skip_form+link} name{required} description:textarea{skip_index} --relationships pages --rails-views
206
+ $ bundle exec rails g ng_on_rails:scaffold Page --properties id:number{skip_form+link} order_index:number subject{required} body:textarea{skip_index} --belongs_to Doc --rails-views
207
207
  ```
208
208
 
209
209
  -----------------------------------------------------------
@@ -1,5 +1,8 @@
1
- NgOnRailsApp.controller 'AppController', ($scope,Rails) ->
2
- # setup
3
- ctrl = this
4
- ctrl.rails = Rails
5
- return
1
+ NgOnRailsApp.controller 'AppController', [
2
+ '$scope','Rails',
3
+ ($scope,Rails) ->
4
+ # setup
5
+ ctrl = this
6
+ ctrl.rails = Rails
7
+ return
8
+ ]
@@ -1,131 +1,134 @@
1
- NgOnRailsApp.controller '<%="#{class_name.pluralize}"%>Controller', ($scope,<%="#{class_name}"%>,Rails) ->
2
- #
3
- # CONTROLLER SETUP
4
- #
5
- ctrl = this
6
- ctrl.rails = Rails
7
- ctrl.data = {}
8
-
9
-
10
- #
11
- # INITIALIZERS
12
- #
13
- ctrl.set<%="#{class_name}"%> = (<%="#{resource_name}"%>)->
14
- ctrl.data.<%="#{resource_name}"%> = <%="#{resource_name}"%>
15
- ctrl.set<%="#{class_name.pluralize}"%> = (<%="#{plural_name}"%>)->
16
- ctrl.data.<%="#{plural_name}"%> = <%="#{plural_name}"%>
17
-
18
-
19
- #
20
- # REST METHODS
21
- #
22
- ctrl.rest =
23
- index: ->
24
- params = {}
25
- <%="#{class_name}"%>.query(params).$promise.then (<%="#{plural_name}"%>) ->
26
- ctrl.data.<%="#{plural_name}"%> = <%="#{plural_name}"%>
27
-
28
- show: (<%="#{resource_name}"%>_id)->
29
- <%="#{class_name}"%>.get({id: <%="#{resource_name}"%>_id}).$promise.then (<%="#{resource_name}"%>) ->
30
- ctrl.data.<%="#{resource_name}"%> = <%="#{resource_name}"%>
31
-
32
- new: (<%=belongs_to_parameters%>)->
33
- ctrl.clear()
34
- ctrl.data.active<%="#{class_name}"%> = {}
35
- ctrl.data.creating_new_<%="#{resource_name}"%> = true
36
- <%
37
- belongs_to_array.each do |relationship|
38
- %>ctrl.data.active<%="#{class_name}"%>.<%= relationship%> = <%= relationship %>
39
- <%
40
- end
41
- %>
42
-
43
- create: ->
44
- if !(ctrl.locked || ctrl.<%="#{resource_name}"%>_form.$error.required)
45
- ctrl.locked = true
46
- working_<%="#{resource_name}"%> = angular.copy(ctrl.data.active<%="#{class_name}"%>)
47
- <%="#{class_name}"%>.save(
48
- working_<%="#{resource_name}"%>,
49
- (<%="#{resource_name}"%>)->
50
- ctrl.data.<%="#{plural_name}"%> ||= []
51
- ctrl.data.<%="#{plural_name}"%>.push(<%="#{resource_name}"%>)
52
- ctrl.clear()
53
- ctrl.locked = false
54
- ,
55
- (error)->
56
- console.log("create_error:",error)
57
- ctrl.clear()
58
- ctrl.locked = false
59
- )
60
-
61
- edit: (<%="#{resource_name}"%><%=belongs_to_comma%><%=belongs_to_parameters%>) ->
62
- ctrl.clear()
63
- ctrl.data.active<%="#{class_name}"%> = <%="#{resource_name}"%>
64
- ctrl.data.editing_<%="#{resource_name}"%> = true
65
- <%="#{resource_name}"%>.is_displayed = false
66
- <%
67
- belongs_to_array.each do |relationship|
68
- %>ctrl.data.active<%="#{class_name}"%>.<%= relationship%> = <%= relationship %>
69
- <%
70
- end
71
- %>
72
-
73
- update: (<%="#{resource_name}"%>)->
74
- if !(ctrl.locked || ctrl.<%="#{resource_name}"%>_form.$error.required)
75
- ctrl.locked = true
76
- <%="#{resource_name}"%> = ctrl.data.active<%="#{class_name}"%> unless !!<%="#{resource_name}"%>
77
- working_<%="#{resource_name}"%> = angular.extend(angular.copy(<%="#{resource_name}"%>),ctrl.data.active<%="#{class_name}"%>)
78
- <%="#{class_name}"%>.update(
79
- working_<%="#{resource_name}"%>,
1
+ NgOnRailsApp.controller '<%="#{class_name.pluralize}"%>Controller', [
2
+ '$scope','<%="#{class_name}"%>','Rails',
3
+ ($scope,<%="#{class_name}"%>,Rails) ->
4
+ #
5
+ # CONTROLLER SETUP
6
+ #
7
+ ctrl = this
8
+ ctrl.rails = Rails
9
+ ctrl.data = {}
10
+
11
+
12
+ #
13
+ # INITIALIZERS
14
+ #
15
+ ctrl.set<%="#{class_name}"%> = (<%="#{resource_name}"%>)->
16
+ ctrl.data.<%="#{resource_name}"%> = <%="#{resource_name}"%>
17
+ ctrl.set<%="#{class_name.pluralize}"%> = (<%="#{plural_name}"%>)->
18
+ ctrl.data.<%="#{plural_name}"%> = <%="#{plural_name}"%>
19
+
20
+
21
+ #
22
+ # REST METHODS
23
+ #
24
+ ctrl.rest =
25
+ index: ->
26
+ params = {}
27
+ <%="#{class_name}"%>.query(params).$promise.then (<%="#{plural_name}"%>) ->
28
+ ctrl.data.<%="#{plural_name}"%> = <%="#{plural_name}"%>
29
+
30
+ show: (<%="#{resource_name}"%>_id)->
31
+ <%="#{class_name}"%>.get({id: <%="#{resource_name}"%>_id}).$promise.then (<%="#{resource_name}"%>) ->
32
+ ctrl.data.<%="#{resource_name}"%> = <%="#{resource_name}"%>
33
+
34
+ new: (<%=belongs_to_parameters%>)->
35
+ ctrl.clear()
36
+ ctrl.data.active<%="#{class_name}"%> = {}
37
+ ctrl.data.creating_new_<%="#{resource_name}"%> = true
38
+ <%
39
+ belongs_to_parameter_array.each do |relationship|
40
+ %>ctrl.data.active<%="#{class_name}"%>.<%= relationship%> = <%= relationship %>
41
+ <%
42
+ end
43
+ %>
44
+
45
+ create: ->
46
+ if !(ctrl.locked || ctrl.<%="#{resource_name}"%>_form.$error.required)
47
+ ctrl.locked = true
48
+ working_<%="#{resource_name}"%> = angular.copy(ctrl.data.active<%="#{class_name}"%>)
49
+ <%="#{class_name}"%>.save(
50
+ working_<%="#{resource_name}"%>,
51
+ (<%="#{resource_name}"%>)->
52
+ ctrl.data.<%="#{plural_name}"%> ||= []
53
+ ctrl.data.<%="#{plural_name}"%>.push(<%="#{resource_name}"%>)
54
+ ctrl.clear()
55
+ ctrl.locked = false
56
+ ,
57
+ (error)->
58
+ console.log("create_error:",error)
59
+ ctrl.clear()
60
+ ctrl.locked = false
61
+ )
62
+
63
+ edit: (<%="#{resource_name}"%><%=belongs_to_comma%><%=belongs_to_parameters%>) ->
64
+ ctrl.clear()
65
+ ctrl.data.active<%="#{class_name}"%> = <%="#{resource_name}"%>
66
+ ctrl.data.editing_<%="#{resource_name}"%> = true
67
+ <%="#{resource_name}"%>.is_displayed = false
68
+ <%
69
+ belongs_to_array.each do |relationship|
70
+ %>ctrl.data.active<%="#{class_name}"%>.<%= relationship%> = <%= relationship %>
71
+ <%
72
+ end
73
+ %>
74
+
75
+ update: (<%="#{resource_name}"%>)->
76
+ if !(ctrl.locked || ctrl.<%="#{resource_name}"%>_form.$error.required)
77
+ ctrl.locked = true
78
+ <%="#{resource_name}"%> = ctrl.data.active<%="#{class_name}"%> unless !!<%="#{resource_name}"%>
79
+ working_<%="#{resource_name}"%> = angular.extend(angular.copy(<%="#{resource_name}"%>),ctrl.data.active<%="#{class_name}"%>)
80
+ <%="#{class_name}"%>.update(
81
+ working_<%="#{resource_name}"%>,
82
+ (<%="#{resource_name}"%>)->
83
+ # success handler
84
+ ctrl.locked = false
85
+ ,
86
+ (error)->
87
+ console.log("update_error:",error)
88
+ ctrl.locked = false
89
+ )
90
+ ctrl.clear()
91
+
92
+ delete: (index,<%="#{resource_name}"%>,<%="#{plural_name}"%>)->
93
+ <%="#{class_name}"%>.delete(
94
+ <%="#{resource_name}"%>,
80
95
  (<%="#{resource_name}"%>)->
81
- # success handler
82
- ctrl.locked = false
96
+ <%="#{plural_name}"%> ||= ctrl.data.<%="#{plural_name}"%>
97
+ if !!<%="#{plural_name}"%>
98
+ <%="#{plural_name}"%>.splice(index,1)
99
+ else
100
+ window.location.href = "<%= path_to_index_page %>"
83
101
  ,
84
102
  (error)->
85
- console.log("update_error:",error)
86
- ctrl.locked = false
103
+ console.log("delete_error:",error)
87
104
  )
88
105
  ctrl.clear()
89
106
 
90
- delete: (index,<%="#{resource_name}"%>,<%="#{plural_name}"%>)->
91
- <%="#{class_name}"%>.delete(
92
- <%="#{resource_name}"%>,
93
- (<%="#{resource_name}"%>)->
94
- <%="#{plural_name}"%> ||= ctrl.data.<%="#{plural_name}"%>
95
- if !!<%="#{plural_name}"%>
96
- <%="#{plural_name}"%>.splice(index,1)
97
- else
98
- window.location.href = "<%= path_to_index_page %>"
99
- ,
100
- (error)->
101
- console.log("delete_error:",error)
102
- )
103
- ctrl.clear()
104
-
105
-
106
- #
107
- # SCOPE METHODS
108
- #
109
- ctrl.clear = (doc)->
110
- ctrl.data.active<%="#{class_name}"%> = null
111
- ctrl.data.creating_new_<%="#{resource_name}"%> = false
112
- ctrl.data.editing_<%="#{resource_name}"%> = false
113
-
114
- ctrl.is_editing = (<%="#{resource_name}"%>)->
115
- (ctrl.data.editing_<%="#{resource_name}"%> && !!<%="#{resource_name}"%> && <%="#{resource_name}"%>.id == ctrl.data.active<%="#{class_name}"%>.id) ||
116
- (ctrl.data.creating_new_<%="#{resource_name}"%> && !<%="#{resource_name}"%>)
117
-
118
- ctrl.toggleDisplay = (<%="#{resource_name}"%>)->
119
- <%="#{resource_name}"%>.is_displayed = !<%="#{resource_name}"%>.is_displayed
120
-
121
- #
122
- # PRIVATE METHODS
123
- #
124
- # => add methods here, not attached to the ctrl object to be used internally
125
- #
126
-
127
-
128
- #
129
- # END
130
- #
131
- return
107
+
108
+ #
109
+ # SCOPE METHODS
110
+ #
111
+ ctrl.clear = (doc)->
112
+ ctrl.data.active<%="#{class_name}"%> = null
113
+ ctrl.data.creating_new_<%="#{resource_name}"%> = false
114
+ ctrl.data.editing_<%="#{resource_name}"%> = false
115
+
116
+ ctrl.is_editing = (<%="#{resource_name}"%>)->
117
+ (ctrl.data.editing_<%="#{resource_name}"%> && !!<%="#{resource_name}"%> && <%="#{resource_name}"%>.id == ctrl.data.active<%="#{class_name}"%>.id) ||
118
+ (ctrl.data.creating_new_<%="#{resource_name}"%> && !<%="#{resource_name}"%>)
119
+
120
+ ctrl.toggleDisplay = (<%="#{resource_name}"%>)->
121
+ <%="#{resource_name}"%>.is_displayed = !<%="#{resource_name}"%>.is_displayed
122
+
123
+ #
124
+ # PRIVATE METHODS
125
+ #
126
+ # => add methods here, not attached to the ctrl object to be used internally
127
+ #
128
+
129
+
130
+ #
131
+ # END
132
+ #
133
+ return
134
+ ]
@@ -152,8 +152,8 @@ module NgOnRails
152
152
  def jbuilder_attributes
153
153
  (
154
154
  options[:properties].map{ |prop| "#{prop.split("{")[0].split(":")[0]}" } |
155
- options[:belongs_to].map{ |model| "#{model}_id" } |
156
- options[:relationships]
155
+ options[:belongs_to].map{ |model| "#{model.underscore}_id" } |
156
+ options[:relationships].map{ |relationship| relationship.underscore }
157
157
  ).join(" ")
158
158
  end
159
159
 
@@ -1,3 +1,3 @@
1
1
  module NgOnRails
2
- VERSION = "0.0.3.4"
2
+ VERSION = "0.0.3.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ng_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.4
4
+ version: 0.0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brookie Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-10 00:00:00.000000000 Z
11
+ date: 2014-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: angularjs-rails