nali 0.2.7 → 0.2.8
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/lib/client/javascripts/nali/extensions.js.coffee +2 -0
- data/lib/client/javascripts/nali/model.js.coffee +6 -1
- data/lib/client/javascripts/nali/nali.js.coffee +0 -2
- data/lib/client/javascripts/nali/view.js.coffee +22 -13
- data/lib/generator/config/application.rb +1 -3
- data/lib/nali/version.rb +1 -1
- metadata +2 -2
@@ -34,7 +34,7 @@ Nali.extend Model:
|
|
34
34
|
@views[ short = view._shortName ] = view
|
35
35
|
shortCap = short.capitalize()
|
36
36
|
unless @[ viewMethod = 'view' + shortCap ]? then @[ viewMethod ] = -> @view short
|
37
|
-
unless @[ showMethod = 'show' + shortCap ]? then @[ showMethod ] = -> @show short
|
37
|
+
unless @[ showMethod = 'show' + shortCap ]? then @[ showMethod ] = ( insertTo ) -> @show short, insertTo
|
38
38
|
unless @[ hideMethod = 'hide' + shortCap ]? then @[ hideMethod ] = -> @hide short
|
39
39
|
@
|
40
40
|
|
@@ -156,6 +156,11 @@ Nali.extend Model:
|
|
156
156
|
true
|
157
157
|
else false
|
158
158
|
|
159
|
+
upgrade: ( attributes, success, failure ) ->
|
160
|
+
# обновляет атрибуты модели и сохраняет её на сервер
|
161
|
+
@update( attributes ).save success, failure
|
162
|
+
@
|
163
|
+
|
159
164
|
destroy: ( success, failure ) ->
|
160
165
|
# отправляет на сервер запрос на удаление модели, вызывает success в случае успеха и failure при неудаче
|
161
166
|
@query @_name.lower() + 's.destroy', @attributes, success, failure
|
@@ -98,19 +98,29 @@ Nali.extend View:
|
|
98
98
|
@runUrl event.currentTarget.getAttribute( 'action' ), @formToHash event.currentTarget
|
99
99
|
@
|
100
100
|
|
101
|
-
runUrl: ( url, params
|
101
|
+
runUrl: ( url, params ) ->
|
102
102
|
if match = url.match /^(@@?)(.+)/
|
103
|
-
[
|
104
|
-
if
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
else console.warn "Method %s not exists", method
|
103
|
+
[ chain, segments... ] = match[2].split '/'
|
104
|
+
if result = @analizeChain chain, ( if match[1].length is 1 then @ else @model )
|
105
|
+
[ source, method ] = result
|
106
|
+
args = @parseUrlSegments segments
|
107
|
+
args.unshift params if params
|
108
|
+
source[ method ] args...
|
109
|
+
else console.warn "Method %s not exists", chain
|
111
110
|
else @redirect url, params
|
112
111
|
@
|
113
112
|
|
113
|
+
parseUrlSegments: ( segments ) ->
|
114
|
+
params = []
|
115
|
+
for segment in segments
|
116
|
+
[ name, value ] = segment.split ':'
|
117
|
+
if value
|
118
|
+
last = params[ params.length - 1 ]
|
119
|
+
params.push last = {} if typeof last isnt 'object'
|
120
|
+
last[ name ] = value
|
121
|
+
else params.push name
|
122
|
+
params
|
123
|
+
|
114
124
|
formToHash: ( form ) ->
|
115
125
|
params = {}
|
116
126
|
for element in form.elements
|
@@ -286,20 +296,19 @@ Nali.extend View:
|
|
286
296
|
source.subscribe? @, "update.#{ property }", @onSourceUpdated if source isnt @model
|
287
297
|
if match[2] is '?'
|
288
298
|
if source[ property ] then property else ''
|
289
|
-
else source[ property ]
|
299
|
+
else if source[ property ]? then source[ property ] else ''
|
290
300
|
else ''
|
291
301
|
else if match = sub.match /^[=|\+](\w+)$/
|
292
302
|
@helpers?[ match[1] ]?.call @
|
293
303
|
else undefined
|
294
304
|
|
295
|
-
analizeChain: ( chain ) ->
|
305
|
+
analizeChain: ( chain, source = @model ) ->
|
296
306
|
segments = chain.split '.'
|
297
307
|
property = segments.pop()
|
298
|
-
source = @model
|
299
308
|
for segment in segments
|
300
309
|
if segment of source then source = source[ segment ]
|
301
310
|
else break
|
302
311
|
unless property of source
|
303
|
-
console.warn "%s: chain \"%s\" is invalid
|
312
|
+
console.warn "%s: chain \"%s\" is invalid", @_name, chain
|
304
313
|
return null
|
305
314
|
[ source, property ]
|
data/lib/nali/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nali
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-11-
|
12
|
+
date: 2014-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thin
|