motion-prime 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/motion-prime/elements/draw/label.rb +8 -2
- data/motion-prime/models/base.rb +29 -9
- data/motion-prime/sections/form/date_field_section.rb +32 -0
- data/motion-prime/styles/base.rb +5 -0
- data/motion-prime/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjdhZjg1NjJhYTYxNGZlMTA1ZWNkZGQ0ZmUwZTg3YzdiZjBkM2MyNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Mjg3NjUzNDE3ZTA1ZDVkZmZmZWMwNDUwMmMxZjlhNDczN2I5NWVjNg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWVjMjhiMThkMjk3N2M1NWQ5MzU4ZjBjMDc3MWY5MmFiYzEwMWFlN2NlNzE0
|
10
|
+
OTM0NzM5NDMwZDMxNjhlODAzNjdiN2I3MmMyMGFlNDhiYjhjZmQ3MjFlOGI5
|
11
|
+
NjkzZTM5ZTQzZDNhMDMyZjgyYzg4MmUzYjYyZDI5ZGUzMjY1OWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDY1MzIwNjJlOThmN2Q2NWZhZjI0YjJkMDZlMzBhNDI2MTc3MjZhNmYzMmRj
|
14
|
+
MGI2ODFhNWVlY2MyMjBhNTc4M2VjN2E2ZmM2ZWJlZDE1MGM2ODVmOTE1NjNk
|
15
|
+
YjNhZGYwNjZiZDRkMzQwZmIyYzBhMTRlNGFjZjdjODAxMzcyNzM=
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -6,12 +6,18 @@ module MotionPrime
|
|
6
6
|
def draw_in(rect)
|
7
7
|
options = computed_options
|
8
8
|
return if options[:hidden]
|
9
|
+
|
10
|
+
if options[:size_to_fit]
|
11
|
+
@computed_options[:height] = outer_height
|
12
|
+
end
|
13
|
+
|
9
14
|
color = options[:text_color]
|
10
15
|
color.uicolor.set if color
|
16
|
+
font = options[:font] || :system
|
11
17
|
if options[:number_of_lines] != 0
|
12
18
|
options[:text].to_s.drawAtPoint(
|
13
19
|
CGPointMake(computed_left, computed_top),
|
14
|
-
withFont:
|
20
|
+
withFont: font.uifont
|
15
21
|
)
|
16
22
|
else
|
17
23
|
rect = CGRectMake(
|
@@ -20,7 +26,7 @@ module MotionPrime
|
|
20
26
|
line_break = options.has_key?(:line_break_mode) ? options[:line_break_mode] : :wordwrap
|
21
27
|
alignment = options.has_key?(:text_alignment) ? options[:text_alignment] : :left
|
22
28
|
options[:text].to_s.drawInRect(
|
23
|
-
rect, withFont:
|
29
|
+
rect, withFont: font.uifont,
|
24
30
|
lineBreakMode: line_break.uilinebreakmode,
|
25
31
|
alignment: alignment.uitextalignment
|
26
32
|
)
|
data/motion-prime/models/base.rb
CHANGED
@@ -6,7 +6,7 @@ motion_require './store.rb'
|
|
6
6
|
motion_require './store_extension.rb'
|
7
7
|
module MotionPrime
|
8
8
|
class BaseModel < NSFNanoObject
|
9
|
-
class_attribute :
|
9
|
+
class_attribute :_sync_url
|
10
10
|
class_attribute :_updatable_attributes
|
11
11
|
class_attribute :_associations
|
12
12
|
alias_method :attributes, :info
|
@@ -21,7 +21,7 @@ module MotionPrime
|
|
21
21
|
extend MotionPrime::ModelAssociationClassMethods
|
22
22
|
|
23
23
|
def sync_url
|
24
|
-
self.class.sync_url
|
24
|
+
normalize_sync_url(self.class.sync_url)
|
25
25
|
end
|
26
26
|
|
27
27
|
def model_name
|
@@ -53,6 +53,9 @@ module MotionPrime
|
|
53
53
|
should_fetch = sync_options[:fetch]
|
54
54
|
should_update = sync_options[:update]
|
55
55
|
|
56
|
+
should_fetch = false if sync_url.blank?
|
57
|
+
should_update = false if sync_url.blank?
|
58
|
+
|
56
59
|
should_fetch = !new_record? if should_fetch.nil?
|
57
60
|
should_update = new_record? if should_update.nil?
|
58
61
|
|
@@ -62,10 +65,15 @@ module MotionPrime
|
|
62
65
|
end if should_fetch
|
63
66
|
update_with_url self.sync_url do
|
64
67
|
save if sync_options[:save]
|
65
|
-
|
68
|
+
|
69
|
+
# run callback only if it wasn't run on fetch
|
70
|
+
block.call if use_callback && !should_fetch
|
66
71
|
end if should_update
|
67
72
|
|
68
|
-
fetch_associations(sync_options)
|
73
|
+
fetch_associations(sync_options) do
|
74
|
+
# run callback only if it wasn't run on fetch or update
|
75
|
+
block.call if use_callback && !should_fetch && !should_update
|
76
|
+
end
|
69
77
|
end
|
70
78
|
|
71
79
|
# fetch from server using url
|
@@ -99,9 +107,16 @@ module MotionPrime
|
|
99
107
|
block.call(self) if block_given?
|
100
108
|
end
|
101
109
|
|
102
|
-
def fetch_associations(sync_options = {})
|
103
|
-
|
104
|
-
|
110
|
+
def fetch_associations(sync_options = {}, &block)
|
111
|
+
use_callback = block_given?
|
112
|
+
associations = self.class._associations || {}
|
113
|
+
|
114
|
+
associations.keys.each_with_index do |key, index|
|
115
|
+
if use_callback && associations.count - 1 == index
|
116
|
+
fetch_association(key, sync_options, &block)
|
117
|
+
else
|
118
|
+
fetch_association(key, sync_options)
|
119
|
+
end
|
105
120
|
end
|
106
121
|
end
|
107
122
|
|
@@ -117,7 +132,8 @@ module MotionPrime
|
|
117
132
|
old_collection = self.send(key)
|
118
133
|
use_callback = block_given?
|
119
134
|
puts "SYNC: started sync for #{key} in #{self.class.name}"
|
120
|
-
api_client.get(options[:sync_url]) do |data|
|
135
|
+
api_client.get normalize_sync_url(options[:sync_url]) do |data|
|
136
|
+
data = data[options[:sync_key]] if options[:sync_key]
|
121
137
|
if data.present?
|
122
138
|
# Update/Create existing records
|
123
139
|
data.each do |attributes|
|
@@ -167,9 +183,13 @@ module MotionPrime
|
|
167
183
|
end
|
168
184
|
end
|
169
185
|
|
186
|
+
def normalize_sync_url(url)
|
187
|
+
url.to_s.gsub(':id', id.to_s)
|
188
|
+
end
|
189
|
+
|
170
190
|
class << self
|
171
191
|
def sync_url(url = nil)
|
172
|
-
url ? self.
|
192
|
+
url ? self._sync_url = url : self._sync_url
|
173
193
|
end
|
174
194
|
|
175
195
|
def updatable_attributes(*attrs)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module MotionPrime
|
2
|
+
class DateFieldSection < BaseFieldSection
|
3
|
+
container height: 190
|
4
|
+
element :label, type: :label do
|
5
|
+
{
|
6
|
+
styles: [
|
7
|
+
:base_field_label,
|
8
|
+
:base_date_picker_field_label,
|
9
|
+
:"#{form_name}_field_label",
|
10
|
+
:"#{form_name}_#{name}_field_label"
|
11
|
+
]
|
12
|
+
}.merge(options[:label] || {})
|
13
|
+
end
|
14
|
+
element :date_picker, type: :date_picker do
|
15
|
+
{
|
16
|
+
styles: [
|
17
|
+
:base_date_picker,
|
18
|
+
:"#{form_name}_date_picker",
|
19
|
+
:"#{form_name}_#{name}_date_picker"
|
20
|
+
]
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
after_render :bind_date_picker
|
25
|
+
|
26
|
+
def bind_date_picker
|
27
|
+
picker = view(:date_picker)
|
28
|
+
picker.setDelegate form
|
29
|
+
picker.setDate NSDate.date, animated: true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/motion-prime/styles/base.rb
CHANGED
data/motion-prime/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-prime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iskander Haziev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -223,6 +223,7 @@ files:
|
|
223
223
|
- motion-prime/sections/draw.rb
|
224
224
|
- motion-prime/sections/form.rb
|
225
225
|
- motion-prime/sections/form/base_field_section.rb
|
226
|
+
- motion-prime/sections/form/date_field_section.rb
|
226
227
|
- motion-prime/sections/form/password_field_section.rb
|
227
228
|
- motion-prime/sections/form/select_field_section.rb
|
228
229
|
- motion-prime/sections/form/string_field_section.rb
|