nali 0.3.7 → 0.3.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/model.js.coffee +7 -11
- data/lib/nali/model.rb +2 -2
- data/lib/nali/version.rb +1 -1
- metadata +2 -2
@@ -125,7 +125,7 @@ Nali.extend Model:
|
|
125
125
|
new: ( attributes ) ->
|
126
126
|
# создает модель, не сохраняя её на сервере
|
127
127
|
model = @clone( attributes: @defaultAttributes() ).accessing()
|
128
|
-
model[ name ] = @
|
128
|
+
model[ name ] = @normalizeAttributeValue name, value for name, value of attributes
|
129
129
|
model
|
130
130
|
|
131
131
|
create: ( attributes, success, failure ) ->
|
@@ -144,7 +144,7 @@ Nali.extend Model:
|
|
144
144
|
|
145
145
|
updateProperty: ( name, value, checkValidation = true ) ->
|
146
146
|
# обновляет один атрибут модели, проверяя его валидность, генерирует событие update.propertyName
|
147
|
-
value = @
|
147
|
+
value = @normalizeAttributeValue name, value
|
148
148
|
if @[ name ] isnt value and ( not checkValidation or @isValidAttributeValue( name, value ) )
|
149
149
|
@[ name ] = value
|
150
150
|
@[ 'onUpdate' + name.capitalize() ]?()
|
@@ -196,17 +196,13 @@ Nali.extend Model:
|
|
196
196
|
attributes = id: @guid()
|
197
197
|
for name, value of @attributes
|
198
198
|
if value instanceof Object
|
199
|
-
attributes[ name ] = if value.default? then @
|
200
|
-
else attributes[ name ] = @
|
199
|
+
attributes[ name ] = if value.default? then @normalizeAttributeValue name, value.default else null
|
200
|
+
else attributes[ name ] = @normalizeAttributeValue name, value
|
201
201
|
attributes
|
202
202
|
|
203
|
-
|
204
|
-
#
|
205
|
-
|
206
|
-
if typeof value is 'string'
|
207
|
-
value = "#{ value }".trim()
|
208
|
-
if value is ( ( correct = + value ) + '' ) then correct else value
|
209
|
-
else value
|
203
|
+
normalizeAttributeValue: ( name, value ) ->
|
204
|
+
# если формат свойства number пробует привести значение к числу
|
205
|
+
if @::attributes[ name ]?.format is 'number' and value is ( ( correct = + value ) + '' ) then correct else value
|
210
206
|
|
211
207
|
isCorrect: ( filters = {} ) ->
|
212
208
|
# проверяет соответствие аттрибутов модели определенному набору фильтров, возвращает true либо false
|
data/lib/nali/model.rb
CHANGED
@@ -38,8 +38,8 @@ module Nali
|
|
38
38
|
relations << value
|
39
39
|
elsif value.is_a?( ActiveRecord::Base )
|
40
40
|
relations << value
|
41
|
-
if
|
42
|
-
params[ :attributes ][
|
41
|
+
if self.respond_to?( key = option.to_s + '_id' ) and self[ key ] == value.id
|
42
|
+
params[ :attributes ][ key ] = value.id
|
43
43
|
end
|
44
44
|
else
|
45
45
|
params[ :attributes ][ option ] = value
|
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.3.
|
4
|
+
version: 0.3.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-12-
|
12
|
+
date: 2014-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thin
|