scrivito_jr_form_widget 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68ee1a72684b73e424602646e50c8f183ae492e9
4
- data.tar.gz: 95caeeab2477e3d6073f87e192b91ad97af27338
3
+ metadata.gz: 676dbda876781edca0055d27c8c41d8a242b6bed
4
+ data.tar.gz: d5ff7437b7e00abc0cbe4303b17c604fb690da67
5
5
  SHA512:
6
- metadata.gz: fce92c28efc8c6fdc7b4f010e6ddf081a11e74bb3dffed16cf679a1191a0705d760bdb7adc72fbdc733972f2cd9c5a0108863ccca7ba285c152e6fc3a7005704
7
- data.tar.gz: 520e9a656460de6c73ae5605706eadc7011b9eb2d329de6480daa90080e10601067bb300138205125da5002e1bfb8b3de9cf5927628cdd673e5825efc0056dbb
6
+ metadata.gz: 586ec51684c0935eecd0a5656a42dea0f4dc0ca1b37ba163d48b60318e445334b31ccde23f63336bfd4a1ed32f889c1da18e4b6ebcf39189230d58c48ce50858
7
+ data.tar.gz: e805c699337fbdbd693de4e55090add43872a98abdb02bc6928eb618300b4a8f0bd0ba42de07e6370ee365d829f0649671b1161879f5b82144e88e450f4e7b65
@@ -1,8 +1,15 @@
1
1
  class JrFormWidget < Widget
2
2
  include JustRelate
3
3
 
4
+ attribute :activity_id, :string
5
+ attribute :event_id, :string
6
+ attribute :subject, :string
7
+ attribute :tags, :string
8
+ attribute :redirect_to, :reference
9
+ attribute :submit_button_text, :string
10
+
4
11
  def self.activities
5
- Obj.try(:jr_activity_filter) || JustRelate::Type.all.to_a
12
+ Obj.try(:jr_activity_filter) || JustRelate::Type.all.select {|i| i.item_base_type == "Activity"}
6
13
  end
7
14
 
8
15
  def attributes
@@ -20,4 +27,8 @@ class JrFormWidget < Widget
20
27
  def submit_button
21
28
  submit_button_text.present? ? submit_button_text : "send"
22
29
  end
30
+
31
+ def self.events
32
+ Obj.try(:jr_activity_filter) || JustRelate::Event.all.to_a
33
+ end
23
34
  end
@@ -24,11 +24,12 @@ class JrFormPresenter < JrFormAttributes
24
24
 
25
25
  if contact
26
26
  set_params_for_activty(contact)
27
+ add_contact_to_event(contact) if @widget.event_id.present?
27
28
  end
28
29
 
29
30
  @params["title"] = @params[:title].empty? ? @activity.id : @params[:title]
30
31
  @params["type_id"] = @activity.id
31
- @params["state"] = 'created'
32
+ @params["state"] = @activity.attributes['states'].first
32
33
 
33
34
  activity = JustRelate::Activity.create(@params)
34
35
 
@@ -54,9 +55,19 @@ class JrFormPresenter < JrFormAttributes
54
55
  return contact
55
56
  end
56
57
 
58
+ def add_contact_to_event(contact)
59
+ JustRelate::EventContact.create({
60
+ contact_id: contact.id,
61
+ event_id: @widget.event_id,
62
+ state: 'registered'
63
+ })
64
+ end
65
+
57
66
  def add_tags_to(contact)
58
- tags = contact.tags + @widget.tags.split("|")
59
- contact.update({tags: tags})
67
+ if @widget.tags
68
+ tags = contact.tags + @widget.tags.split("|")
69
+ contact.update({tags: tags})
70
+ end
60
71
  end
61
72
 
62
73
  def set_params_for_activty(contact)
@@ -1,6 +1,13 @@
1
1
  <div class="form-group">
2
2
  <%= form.label name.to_sym, class: "control-label col-sm-3 #{options[:mandatory] ? 'mandatory' : ''}" %>
3
3
  <div class="col-sm-9">
4
- <%= form.select name.to_sym, options['valid_values'], {}, {multiple: true, class: 'form-control'} %>
4
+ <% options['valid_values'].each do |value| %>
5
+ <div class="^checkbox">
6
+ <%= form.label "#{name}_#{value.downcase}" do %>
7
+ <%= form.check_box name.to_sym, value %>
8
+ <%= t("helpers.label.jr_form_presenter.#{name}_option.#{value.downcase}") %>
9
+ <% end %>
10
+ </div>
11
+ <% end %>
5
12
  </div>
6
13
  </div>
@@ -1,6 +1,6 @@
1
1
  <div class="form-group">
2
2
  <%= form.label name.to_sym, class: "control-label col-sm-3 #{options[:mandatory] ? 'mandatory' : ''}" %>
3
3
  <div class="col-sm-9">
4
- <%= form.text_field name.to_sym, class: "form-control" %>
4
+ <%= form.text_field name.to_sym, class: "form-control", maxlength: options[:maxlength] %>
5
5
  </div>
6
6
  </div>
@@ -1,6 +1,6 @@
1
1
  <div class="form-group">
2
2
  <%= form.label name.to_sym, class: "control-label col-sm-3 #{options[:mandatory] ? 'mandatory' : ''}" %>
3
3
  <div class="col-sm-9">
4
- <%= form.text_area name.to_sym, class: "form-control" %>
4
+ <%= form.text_area name.to_sym, class: "form-control", maxlength: options[:maxlength] %>
5
5
  </div>
6
6
  </div>
@@ -3,6 +3,7 @@
3
3
  <li class="active" data-panel-target="#edit-general">General</li>
4
4
  <li data-panel-target="#edit-tags">Tags</li>
5
5
  <li data-panel-target="#edit-activity">Activity</li>
6
+ <li data-panel-target="#edit-event">Event</li>
6
7
  </ul>
7
8
 
8
9
  <div class="tab-panels">
@@ -25,5 +26,14 @@
25
26
  <h4>Activity</h4>
26
27
  <%= scrivito_toggle_button_editor widget, :activity_id, JrFormWidget.activities.map { |a| a.id } %>
27
28
  </div>
29
+
30
+ <div class="tab-panel" id="edit-event">
31
+ <h4>Activity</h4>
32
+ <%= scrivito_toggle_button_editor widget, :event_id, JrFormWidget.events do |event|
33
+ scrivito_tag(:button, widget, :event_id, data: {editor: 'scrivito-toggle-button', content: event.id}) do
34
+ event.name
35
+ end
36
+ end %>
37
+ </div>
28
38
  </div>
29
39
  </div>
@@ -1,3 +1,3 @@
1
1
  module ScrivitoJrFormWidget
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -6,10 +6,11 @@ class CreateJrFormWidget < ::Scrivito::Migration
6
6
  title: 'Just Relate Fromular Widget',
7
7
  attributes: [
8
8
  {name: "activity_id", type: "string"},
9
+ {name: "event_id", type: "string"},
9
10
  {name: "subject", type: "string"},
10
11
  {name: "tags", type: "string"},
11
12
  {name: "redirect_to", type: "reference"},
12
- {name: "submit_button_text", type: "string"}
13
+ {name: "submit_button_text", type: "string"},
13
14
  ]
14
15
  )
15
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivito_jr_form_widget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scrivito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-25 00:00:00.000000000 Z
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler