motion-prime 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTkxOTc5ZjRkMTM3NGZiM2U5ZDkxZjNiMTkxZTlmYjM1M2NjMDZmNg==
4
+ NmQ3ZGM2Yzk1NGVmZDhiMDVkZWMxMTkyNmU0MjJlODE0ODBkMTJmNg==
5
5
  data.tar.gz: !binary |-
6
- ZjMyMTY2ODZhNDY4MzJmZWI4MGZhMjc3NDViN2EyNTFkMmNmZTYzNg==
6
+ YWJhYTVhYmE5OWEzYmQ3M2ExZDA3NjhlMTNjN2RiYzcyYTRjMmNiNg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjdlZDY1ZWExM2EzMDg1ZmIyNDI2YjlhMjQzMjllNDBmZDFjZDQ4NzlhY2Jl
10
- Y2Q1OTk4NDlhM2ZiOTU5MDg2MjEzYzAwZTQwM2I3ZjczMWZlYTUwNWQwMjJk
11
- OWM3MDk5YTQxYjNmMjVkZmE0YWUxZWZhMTZmMjI1YjAzMDdjNjE=
9
+ OGRlNTdiYWIxNTU3MzZkNmE0ODRiZjJmNTY2MGVjZGI0NDUxYzRjNDIwNThk
10
+ ZGE5YjE4NTIzYzJkMDI2OTcxMjJkOWU2MmYwOGU1NDZmZjk3YWZjMGYwZTI3
11
+ YzkyMjM0MGI5YzhiMDZjNDMzMDQ0ODAwOWQwYjdmZmE0OTFmNjg=
12
12
  data.tar.gz: !binary |-
13
- MGI3ZmIxZDFkNzc5YWQ2ZDc1Mjg3YWEwMzY0NDQ1M2I5NTFjMDgyNWNlY2Fk
14
- OTc5Mjg4YjJkNjk1MzJkMjQ4Mjk4NmYwYjRhZDg4MGY4NTNhMDI3MDMwNWZl
15
- MjM4ZGVkNTk4NjhlYWMyY2E2NDE0NDNmZDYwOTRjMzlmN2ZkNTM=
13
+ YzEwMTg1MDk2OTc0MjIyNDVmOWJjZTU2MGE2NWM2OTc2OGFlNzc2YjhmOWEw
14
+ ZDcyMWYxZDhmMTA0NDNhYTBkZGRjNmM5NDQ0ZTUwNDY5Mzk0ZGU1NjRkZGJk
15
+ ODA5NjU1MDhkMzYyMWM4NWU4NGEzY2QxYTNlMWRiNDk5NTk0MWY=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.9.2
2
+ * Updated scaffold and added deleting items.
3
+ * Ability to reload base section.
4
+
1
5
  === 0.9.1
2
6
  * Set correct navigation button title color by default.
3
7
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- motion-prime (0.9.1)
4
+ motion-prime (0.9.2)
5
5
  activesupport
6
6
  afmotion (~> 2.0.0)
7
7
  bubble-wrap (~> 1.5.0)
data/files/Gemfile CHANGED
@@ -1,10 +1,10 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'motion-cocoapods', '~> 1.4.0'
4
- gem 'motion-prime', '0.9.1'
4
+ gem 'motion-prime', '0.9.2'
5
5
 
6
6
  # add reside menu for sidebar support
7
- gem 'prime_reside_menu', '~> 0.1.4'
7
+ # gem 'prime_reside_menu', '~> 0.1.4'
8
8
 
9
9
  # or add sliding menu for sidebar support
10
10
  # gem 'prime_sliding_menu', '~> 0.1.5'
@@ -1,5 +1,5 @@
1
1
  class AppDelegate < Prime::BaseAppDelegate
2
2
  def on_load(app, options)
3
- # open_screen :home, sidebar: true
3
+ # open_screen :home
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- class <%= @p_class_name %>CellSection < Prime::Section
1
+ class <%= @p_class_name %>IndexCellSection < Prime::Section
2
2
  container height: 40
3
3
  element :title, text: proc { model.title }
4
4
  end
@@ -6,13 +6,26 @@ class <%= @p_class_name %>FormSection < Prime::FormSection
6
6
  placeholder: "Enter title here"
7
7
  }
8
8
 
9
+ field :delete, type: :submit,
10
+ button: {
11
+ title: "Delete",
12
+ background_color: :red
13
+ },
14
+ action: :on_delete,
15
+ if: proc { model.persisted? }
16
+
9
17
  field :submit, type: :submit,
10
18
  button: { title: "Save" },
11
19
  action: :on_submit
12
20
 
21
+ def on_delete
22
+ model.delete
23
+ screen.close_screen(to_root: true)
24
+ end
25
+
13
26
  def on_submit
14
27
  model.assign_attributes(field_values)
15
28
  model.save
16
- screen.back
29
+ screen.close_screen
17
30
  end
18
31
  end
@@ -7,7 +7,7 @@ class <%= @p_class_name %>Screen < ApplicationScreen
7
7
  set_navigation_right_button 'New' do
8
8
  open_screen "<%= @p_name %>#new"
9
9
  end
10
- set_section :<%= @p_name %>_table
10
+ set_section :<%= @p_name %>_index_table
11
11
  end
12
12
 
13
13
  # open_screen "<%= @p_name %>#show"
@@ -38,8 +38,8 @@ class <%= @p_class_name %>Screen < ApplicationScreen
38
38
  end
39
39
 
40
40
  def on_return
41
- if action?(:index)
42
- main_section.reload_data
41
+ if action?(:index) || action?(:show)
42
+ refresh
43
43
  end
44
44
  end
45
45
  end
@@ -1,6 +1,6 @@
1
1
  Prime::Styles.define :<%= @p_name %> do
2
- style :cell do
3
- style :title,
2
+ style :index do
3
+ style :cell_title,
4
4
  text_color: :app_base,
5
5
  left: 20,
6
6
  top: 10,
@@ -1,7 +1,7 @@
1
- class <%= @p_class_name %>TableSection < Prime::TableSection
1
+ class <%= @p_class_name %>IndexTableSection < Prime::TableSection
2
2
  def table_data
3
3
  <%= @s_class_name %>.all.map do |model|
4
- <%= @p_class_name %>CellSection.new(model: model)
4
+ <%= @p_class_name %>IndexCellSection.new(model: model)
5
5
  end
6
6
  end
7
7
 
@@ -64,7 +64,7 @@ module MotionPrime
64
64
  end
65
65
 
66
66
  def refresh
67
- main_section.try(:reload_data)
67
+ main_section.try(:reload)
68
68
  end
69
69
 
70
70
  # Class methods
@@ -36,9 +36,9 @@ module MotionPrime
36
36
  close_screen
37
37
  end
38
38
 
39
- def send_on_return
40
- if parent_screen && parent_screen.respond_to?(:on_return)
41
- parent_screen.send(:on_return)
39
+ def send_on_return(screen)
40
+ if screen && screen.respond_to?(:on_return)
41
+ screen.send(:on_return)
42
42
  end
43
43
  end
44
44
 
@@ -91,7 +91,7 @@ module MotionPrime
91
91
  # @return screen [Prime::Screen] screen appearing after close
92
92
  def close_screen_modal(args = {})
93
93
  parent_screen.dismissViewControllerAnimated(args[:animated], completion: lambda {
94
- send_on_return
94
+ send_on_return(parent_screen)
95
95
  })
96
96
  parent_screen
97
97
  end
@@ -113,7 +113,7 @@ module MotionPrime
113
113
  result = self.navigation_controller.childViewControllers.last
114
114
  end
115
115
  end
116
- send_on_return
116
+ send_on_return(result)
117
117
  result
118
118
  end
119
119
 
@@ -139,7 +139,11 @@ module MotionPrime
139
139
 
140
140
  # Force reload section, will also re-render elements.
141
141
  # For table view cells will also reload it's table data.
142
+ #
143
+ # @return [Boolean] true
142
144
  def reload_section
145
+ # reload Base Elements
146
+ # TODO: probably should use update_with_options for Base elements too?
143
147
  self.elements_to_render.values.map(&:view).flatten.each do |view|
144
148
  view.removeFromSuperview if view
145
149
  end
@@ -147,11 +151,23 @@ module MotionPrime
147
151
  run_callbacks :render do
148
152
  render!
149
153
  end
154
+ # reload Draw Elements
155
+ elements_to_draw.each do |key, element|
156
+ element.update_with_options
157
+ end
150
158
 
151
159
  if @table && !self.is_a?(BaseFieldSection)
152
160
  cell.setNeedsDisplay
153
161
  @table.reload_table_data
154
162
  end
163
+ true
164
+ end
165
+
166
+ # Alias for reload_section
167
+ #
168
+ # @return [Boolean] true
169
+ def reload
170
+ reload_section
155
171
  end
156
172
 
157
173
  def add_element(key, options = {})
@@ -53,6 +53,13 @@ module MotionPrime
53
53
  reload_table_data
54
54
  end
55
55
 
56
+ # Alias for reload_data
57
+ #
58
+ # @return [Boolean] true
59
+ def reload
60
+ reload_data
61
+ end
62
+
56
63
  # Reload table view
57
64
  #
58
65
  # @return [Boolean] true
@@ -1,3 +1,3 @@
1
1
  module MotionPrime
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-prime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Haziev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-14 00:00:00.000000000 Z
12
+ date: 2014-03-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake