formotion 1.3 → 1.3.1

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.
Files changed (36) hide show
  1. checksums.yaml +15 -0
  2. data/.travis.yml +5 -0
  3. data/CHANGELOG.md +14 -0
  4. data/Formotion.gemspec +1 -0
  5. data/Gemfile +0 -1
  6. data/README.md +2 -0
  7. data/lib/formotion.rb +2 -28
  8. data/lib/formotion/base.rb +2 -0
  9. data/lib/formotion/controller/form_controller.rb +2 -0
  10. data/lib/formotion/form/form.rb +2 -0
  11. data/lib/formotion/form/form_delegate.rb +2 -0
  12. data/lib/formotion/row/row.rb +7 -1
  13. data/lib/formotion/row_type/back_row.rb +2 -0
  14. data/lib/formotion/row_type/button.rb +2 -0
  15. data/lib/formotion/row_type/check_row.rb +2 -0
  16. data/lib/formotion/row_type/currency_row.rb +2 -0
  17. data/lib/formotion/row_type/date_row.rb +2 -0
  18. data/lib/formotion/row_type/edit_row.rb +2 -0
  19. data/lib/formotion/row_type/email_row.rb +2 -0
  20. data/lib/formotion/row_type/image_row.rb +2 -0
  21. data/lib/formotion/row_type/number_row.rb +2 -0
  22. data/lib/formotion/row_type/options_row.rb +3 -0
  23. data/lib/formotion/row_type/phone_row.rb +2 -0
  24. data/lib/formotion/row_type/picker_row.rb +1 -0
  25. data/lib/formotion/row_type/slider_row.rb +2 -0
  26. data/lib/formotion/row_type/static_row.rb +2 -0
  27. data/lib/formotion/row_type/string_row.rb +40 -0
  28. data/lib/formotion/row_type/subform_row.rb +2 -0
  29. data/lib/formotion/row_type/submit_row.rb +2 -0
  30. data/lib/formotion/row_type/switch_row.rb +2 -0
  31. data/lib/formotion/row_type/template_row.rb +3 -0
  32. data/lib/formotion/row_type/text_row.rb +2 -0
  33. data/lib/formotion/section/section.rb +16 -8
  34. data/lib/formotion/version.rb +1 -1
  35. data/spec/functional/template_row_spec.rb +22 -0
  36. metadata +20 -17
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZmNhMGY5ZTMyZWUwYWIzMzhlMTVhYmQ0ODk2NGQ3YTBlYzRmNGI5NQ==
5
+ data.tar.gz: !binary |-
6
+ ODI0MWFkNzkwOTAxNGFmZjM1Yjg5ZjVkYTMwYzkzMTdhMWZhMzZiOA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MDkzMzM3YWE2MTNjZjMwOGI5MWUzN2ZlZWNmYWNkMGMwMTczNDY3YzA4Njli
10
+ NmEzMzQzYjZkYjNkYzI5NTQxNDI2MjM3OWUwZGM3MTkxZTBjNDJlYmJiNjk4
11
+ NjI2NjY2YjJlOTMyNmI5YTZmYTgyYmQ0NzNiMzBhZTc4ODEzYTc=
12
+ data.tar.gz: !binary |-
13
+ MDM3ODUyZWI5MmE5ZTQxOGQyN2YxY2ZhZDI0MzUyNjI5ZDU4M2QyMjI1ODk5
14
+ ZDA5ZTM5Y2ZlY2QyMmI5YWVjMjhjYzE3MjliYmVhMWIzYTY1NTBkNmQ0ZWQ4
15
+ MWIyYTVjMjJmNzM0MWRlMzFmM2VlMjI4MTMwZTlkMDJjYmQ0ZDY=
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: objective-c
2
+ before_install:
3
+ - rvm use 1.9.3
4
+ install: bundle install
5
+ script: bundle exec rake spec:units
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## 1.3.1 - April 15, 2013
2
+
3
+ ### Features
4
+
5
+ - Added `:input_accessory` property, which currently accepts `:done` as the value. This will add a `UIToolbar` above the keyboard with a "Done" button the user can tap to dismiss the keyboard.
6
+
7
+ - Added `Row#on_delete` callback which occurs when a row is swipe-to-delete'd.
8
+
9
+ ### Bug Fixes
10
+
11
+ - `:image` rows which are not editable do not show the "plus" icon.
12
+
13
+ - Fixed bugs in `:template` rows (see [#100](https://github.com/clayallsopp/formotion/issues/100) and [#101](https://github.com/clayallsopp/formotion/pull/101)).
14
+
1
15
  ## 1.3 - March 25, 2013
2
16
 
3
17
  ### Features
data/Formotion.gemspec CHANGED
@@ -15,5 +15,6 @@ Gem::Specification.new do |s|
15
15
  s.require_paths = ["lib"]
16
16
 
17
17
  s.add_dependency "bubble-wrap", ">= 1.1.4"
18
+ s.add_dependency "motion-require", "~> 0.0.3"
18
19
  s.add_development_dependency 'rake'
19
20
  end
data/Gemfile CHANGED
@@ -1,6 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'bubble-wrap', ">=1.1.4"
4
3
  gem 'guard-motion'
5
4
  gem 'rb-fsevent'
6
5
 
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Formotion
2
2
 
3
+ [![Build Status](https://travis-ci.org/clayallsopp/formotion.png)](https://travis-ci.org/clayallsopp/formotion)
4
+
3
5
  Make this:
4
6
 
5
7
  ![Complex data form](http://i.imgur.com/TMwXI.png)
data/lib/formotion.rb CHANGED
@@ -2,32 +2,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), "formotion/version"))
2
2
  require 'bubble-wrap/core'
3
3
  require 'bubble-wrap/camera'
4
4
 
5
- BW.require File.expand_path('../formotion/**/*.rb', __FILE__) do
6
- base_row_type = 'lib/formotion/row_type/base.rb'
5
+ require 'motion-require'
7
6
 
8
- # hack to make sure base row type is compiled early
9
- file('lib/formotion/base.rb').depends_on base_row_type
10
-
11
- row_types = Dir.glob('lib/formotion/row_type/**/*.rb')
12
- row_types.each {|file|
13
- next if file == base_row_type
14
- file(file).depends_on base_row_type
15
- }
16
-
17
- ['date_row', 'email_row', 'number_row', 'phone_row'].each {|file|
18
- file("lib/formotion/row_type/#{file}.rb").depends_on 'lib/formotion/row_type/string_row.rb'
19
- }
20
-
21
- ['currency_row'].each {|file|
22
- file("lib/formotion/row_type/#{file}.rb").depends_on 'lib/formotion/row_type/number_row.rb'
23
- }
24
-
25
- ['submit_row', 'back_row'].each {|file|
26
- file("lib/formotion/row_type/#{file}.rb").depends_on 'lib/formotion/row_type/button.rb'
27
- }
28
-
29
- ['form/form.rb', 'row/row.rb', 'section/section.rb'].each {|file|
30
- file("lib/formotion/#{file}").depends_on 'lib/formotion/base.rb'
31
- }
32
- file("lib/formotion/controller/form_controller.rb").depends_on 'lib/formotion/patch/ui_text_field.rb'
33
- end
7
+ Motion::Require.all(Dir.glob(File.expand_path('../formotion/**/*.rb', __FILE__)))
@@ -1,3 +1,5 @@
1
+ motion_require 'row_type/base'
2
+
1
3
  module Formotion
2
4
  class Base
3
5
  def initialize(params = {})
@@ -1,3 +1,5 @@
1
+ motion_require '../patch/ui_text_field'
2
+
1
3
  #################
2
4
  #
3
5
  # Formotion::FormController
@@ -1,3 +1,5 @@
1
+ motion_require "../base"
2
+
1
3
  module Formotion
2
4
  class Form < Formotion::Base
3
5
  extend BubbleWrap::KVO
@@ -1,3 +1,5 @@
1
+ motion_require "../base"
2
+
1
3
  module Formotion
2
4
  class Form < Formotion::Base
3
5
  attr_reader :table
@@ -1,3 +1,5 @@
1
+ motion_require "../base"
2
+
1
3
  module Formotion
2
4
  class Row < Formotion::Base
3
5
  PROPERTIES = [
@@ -85,7 +87,11 @@ module Formotion
85
87
  :remove_on_delete,
86
88
  # In a date/time or time picker, the minute interval can
87
89
  # be set. That allows picking by every 15 minutes, etc.
88
- :minute_interval
90
+ :minute_interval,
91
+ # Display an inputAccessoryView when editing a StringRow.
92
+ # OPTIONS: :done (a black translucent toolbar with a right-aligned "Done" button)
93
+ # DEFAULT is nil
94
+ :input_accessory
89
95
  ]
90
96
  PROPERTIES.each {|prop|
91
97
  attr_accessor prop
@@ -1,3 +1,5 @@
1
+ motion_require 'button'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class BackRow < ButtonRow
@@ -1,3 +1,5 @@
1
+ motion_require 'base'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class ButtonRow < Base
@@ -1,3 +1,5 @@
1
+ motion_require 'base'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class CheckRow < Base
@@ -1,3 +1,5 @@
1
+ motion_require 'number_row'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class CurrencyRow < NumberRow
@@ -1,3 +1,5 @@
1
+ motion_require 'string_row'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class DateRow < StringRow
@@ -1,3 +1,5 @@
1
+ motion_require 'button'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class EditRow < ButtonRow
@@ -1,3 +1,5 @@
1
+ motion_require 'string_row'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class EmailRow < StringRow
@@ -1,3 +1,5 @@
1
+ motion_require 'base'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class ImageRow < Base
@@ -1,3 +1,5 @@
1
+ motion_require 'string_row'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class NumberRow < StringRow
@@ -1,3 +1,6 @@
1
+ motion_require 'base'
2
+ motion_require 'items_mapper'
3
+
1
4
  module Formotion
2
5
  module RowType
3
6
  class OptionsRow < Base
@@ -1,3 +1,5 @@
1
+ motion_require 'string_row'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class PhoneRow < StringRow
@@ -1,4 +1,5 @@
1
1
  # currently supports only one component
2
+ motion_require 'string_row'
2
3
 
3
4
  module Formotion
4
5
  module RowType
@@ -1,3 +1,5 @@
1
+ motion_require 'base'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class SliderRow < Base
@@ -1,3 +1,5 @@
1
+ motion_require 'string_row'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class StaticRow < StringRow
@@ -1,3 +1,5 @@
1
+ motion_require 'base'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class StringRow < Base
@@ -40,6 +42,7 @@ module Formotion
40
42
  field.autocorrectionType = row.auto_correction if row.auto_correction
41
43
  field.clearButtonMode = row.clear_button || UITextFieldViewModeWhileEditing
42
44
  field.enabled = row.editable?
45
+ field.inputAccessoryView = input_accessory_view(row.input_accessory) if row.input_accessory
43
46
 
44
47
  add_callbacks(field)
45
48
 
@@ -143,6 +146,43 @@ module Formotion
143
146
  def update_text_field(new_value)
144
147
  self.row.text_field.text = row_value
145
148
  end
149
+
150
+ # Creates the inputAccessoryView to show
151
+ # if input_accessory property is set on row.
152
+ # :done is currently the only supported option.
153
+ def input_accessory_view(input_accessory)
154
+ case input_accessory
155
+ when :done
156
+ @input_accessory ||= begin
157
+ tool_bar = UIToolbar.alloc.initWithFrame([[0, 0], [0, 44]])
158
+ tool_bar.autoresizingMask = UIViewAutoresizingFlexibleWidth
159
+ tool_bar.barStyle = UIBarStyleBlack
160
+ tool_bar.translucent = true
161
+
162
+ left_space = UIBarButtonItem.alloc.initWithBarButtonSystemItem(
163
+ UIBarButtonSystemItemFlexibleSpace,
164
+ target: nil,
165
+ action: nil)
166
+
167
+ done_button = UIBarButtonItem.alloc.initWithBarButtonSystemItem(
168
+ UIBarButtonSystemItemDone,
169
+ target: self,
170
+ action: :done_editing)
171
+
172
+ tool_bar.items = [left_space, done_button]
173
+
174
+ tool_bar
175
+ end
176
+ else
177
+ nil
178
+ end
179
+ end
180
+
181
+ # Callback for "Done" button in input_accessory_view
182
+ def done_editing
183
+ self.row.text_field.endEditing(true)
184
+ end
185
+
146
186
  end
147
187
  end
148
188
  end
@@ -1,3 +1,5 @@
1
+ motion_require 'base'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class SubformRow < Base
@@ -1,3 +1,5 @@
1
+ motion_require 'button'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class SubmitRow < ButtonRow
@@ -1,3 +1,5 @@
1
+ motion_require 'base'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class SwitchRow < Base
@@ -1,3 +1,5 @@
1
+ motion_require 'base'
2
+
1
3
  # Define template row:
2
4
  # {
3
5
  # title: "Add nickname",
@@ -55,6 +57,7 @@ module Formotion
55
57
  template_value = row.template_parent.value
56
58
  template_value.delete_at(row.index)
57
59
  row.template_parent.value = template_value
60
+ row.template_parent.template_children.delete_at(row.index)
58
61
  end
59
62
  end
60
63
  new_row.remove_on_delete = true
@@ -1,3 +1,5 @@
1
+ motion_require 'base'
2
+
1
3
  module Formotion
2
4
  module RowType
3
5
  class TextRow < Base
@@ -1,3 +1,5 @@
1
+ motion_require "../base"
2
+
1
3
  module Formotion
2
4
  class Section < Formotion::Base
3
5
  PROPERTIES = [
@@ -38,20 +40,26 @@ module Formotion
38
40
  }
39
41
  end
40
42
 
41
- def build_row(&block)
42
- row = create_row
43
- block.call(row)
44
- row
45
- end
46
-
47
- def create_row(hash = {})
43
+ def generate_row(hash = {})
48
44
  row = hash
49
45
  if hash.class == Hash
50
46
  row = Formotion::Row.new(hash)
51
47
  end
52
48
  row.section = self
53
49
  row.index = self.rows.count
54
- # dont move to after the appending.
50
+ row
51
+ end
52
+
53
+ def build_row(&block)
54
+ row = generate_row
55
+ block.call(row)
56
+ row.after_create
57
+ self.rows << row
58
+ row
59
+ end
60
+
61
+ def create_row(hash = {})
62
+ row = generate_row(hash)
55
63
  row.after_create
56
64
  self.rows << row
57
65
  row
@@ -1,3 +1,3 @@
1
1
  module Formotion
2
- VERSION = "1.3"
2
+ VERSION = "1.3.1"
3
3
  end
@@ -33,6 +33,28 @@ describe "FormController/TemplateRow" do
33
33
  @controller = nil
34
34
  end
35
35
 
36
+ it "should work with DSL" do
37
+ @form = Formotion::Form.new
38
+
39
+ @form.build_section do |section|
40
+ section.build_row do |row|
41
+ row.title = "Add element"
42
+ row.type = :template
43
+ row.key = :template
44
+ row.value = ["Value 1", "Value 2"]
45
+ row.template = {
46
+ title: 'Element',
47
+ type: :string,
48
+ indented: true,
49
+ deletable: true
50
+ }
51
+ end
52
+ end
53
+
54
+ @controller ||= Formotion::FormController.alloc.initWithForm(@form)
55
+ @form.render[:template].should == ['Value 1', 'Value 2']
56
+ end
57
+
36
58
  it "should insert row" do
37
59
  tap("Add element")
38
60
  @form.sections.first.rows.size.should == 3
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formotion
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
5
- prerelease:
4
+ version: 1.3.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Clay Allsopp
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-25 00:00:00.000000000 Z
11
+ date: 2013-04-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bubble-wrap
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,15 +20,27 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.1.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: motion-require
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.3
30
41
  - !ruby/object:Gem::Dependency
31
42
  name: rake
32
43
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
44
  requirements:
35
45
  - - ! '>='
36
46
  - !ruby/object:Gem::Version
@@ -38,7 +48,6 @@ dependencies:
38
48
  type: :development
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
52
  - - ! '>='
44
53
  - !ruby/object:Gem::Version
@@ -51,6 +60,7 @@ extensions: []
51
60
  extra_rdoc_files: []
52
61
  files:
53
62
  - .gitignore
63
+ - .travis.yml
54
64
  - CHANGELOG.md
55
65
  - Formotion.gemspec
56
66
  - Gemfile
@@ -190,33 +200,26 @@ files:
190
200
  - spec/support/ui_control_wrap_extension.rb
191
201
  homepage: https://github.com/clayallsopp/Formotion
192
202
  licenses: []
203
+ metadata: {}
193
204
  post_install_message:
194
205
  rdoc_options: []
195
206
  require_paths:
196
207
  - lib
197
208
  required_ruby_version: !ruby/object:Gem::Requirement
198
- none: false
199
209
  requirements:
200
210
  - - ! '>='
201
211
  - !ruby/object:Gem::Version
202
212
  version: '0'
203
- segments:
204
- - 0
205
- hash: -3419813869520045411
206
213
  required_rubygems_version: !ruby/object:Gem::Requirement
207
- none: false
208
214
  requirements:
209
215
  - - ! '>='
210
216
  - !ruby/object:Gem::Version
211
217
  version: '0'
212
- segments:
213
- - 0
214
- hash: -3419813869520045411
215
218
  requirements: []
216
219
  rubyforge_project:
217
- rubygems_version: 1.8.23
220
+ rubygems_version: 2.0.3
218
221
  signing_key:
219
- specification_version: 3
222
+ specification_version: 4
220
223
  summary: Making iOS Forms insanely great with RubyMotion
221
224
  test_files:
222
225
  - spec/form/persist_spec.rb