concerto_manykinds 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b08e62b4c867de70d4ea56f4b081c4b26514c25
4
- data.tar.gz: 01a713f1bf602d80e8825f82f0f7239f4c1d0525
3
+ metadata.gz: 5e16d5aaaa5da2429a7cd060f68bb323757e0b93
4
+ data.tar.gz: da4116c271a11e927f9327bde59836aeb46f4acd
5
5
  SHA512:
6
- metadata.gz: 41cc8fd2088c68eb2f3d7f65f9d2c0cb4f424b5808845e7b6d79a89d72960b327106862ed6e66427096c08b7388391242019ba1705679b5ebcb774f635f61ca8
7
- data.tar.gz: 410b212f6948f3fa070cfe2dcf4f9ac20cdcef43ae23ba1465431c3d80fb62ea3d47cf477dad86096a967591fbc08303a9994ec25a6526a915951fe3940beff9
6
+ metadata.gz: 848ddbaca59a72d0bf5af9611c9527f9755a86360a3a486234acd56889941a451dfb1166dee8169d8f44480dfdc9ae86bbc2f6610d36557d0e6689d9e7765957
7
+ data.tar.gz: 95ea846fe59ca8841944e3c735c3e694e4ce828969271dabd23aa901378b7362596da8ec8ef5bb5c34a7e7c22c847f7edc3762a15af2ca69e215bd4d06d00cf6
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Concerto Manykinds
2
2
 
3
- A Rails Engine for displaying multiple types of content in the same template field in Concerto.
3
+ A Rails Engine for displaying multiple types of content in the same template field in Concerto. An example usage scenario is where you have a screen with one field that covers the entire screen-- you can add the other types to that field so that is also shows Text, and Ticker content.
4
4
 
5
5
  To use this engine, add the following to the Concerto Gemfile-plugins, or use the UI to add the plugin:
6
6
  ```
@@ -1,24 +1,41 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
3
- var manykinds_handlers_initialized = false;
1
+ var ConcertoManykinds = {
2
+ _initialized: false,
4
3
 
5
- function attachConcertoManykindsHandlers() {
6
- if (!manykinds_handlers_initialized) {
7
- $('ul.manykinds-list').on('ajax:success', 'a[data-method="delete"]', function (e, data, status, xhr) {
8
- console.debug('firing');
9
- $(this).parent('li').hide();
10
- });
4
+ clearAlert: function() {
5
+ $('#manykind-alert').addClass('hide');
6
+ $('#manykind-alert h4').innerText = '';
7
+ },
11
8
 
12
- $('form[id="new_manykind"]').on('ajax:success', function (e, data, status, xhr) {
13
- // show the new item
14
- $("#manykinds_fld" + data["field_id"]).append(data["item_html"]);
15
- });
9
+ initHandlers: function () {
10
+ if (!ConcertoManykinds._initialized) {
11
+ // clear alerts on button/link
12
+ $(document).on('click', 'ul.manykinds-list .mk-delete', ConcertoManykinds.clearAlert);
13
+ $(document).on('click', 'form[id="new_manykind"] .mk-add', ConcertoManykinds.clearAlert);
16
14
 
17
- console.debug('manykinds handlers initialized');
18
- manykinds_handlers_initialized = true;
15
+ $('ul.manykinds-list').on('ajax:success', 'a[data-method="delete"]', function (e, data, status, xhr) {
16
+ console.debug('firing');
17
+ $(this).parent('li').hide();
18
+ });
19
+
20
+ $('form[id="new_manykind"]').on('ajax:success', function (e, data, status, xhr) {
21
+ // show the new item
22
+ $("#manykinds_fld" + data["field_id"]).append(data["item_html"]);
23
+ });
24
+ $('form[id="new_manykind"]').on('ajax:error', function (e, data, status, xhr) {
25
+ console.debug(data.responseJSON.kind_id.join(', '));
26
+ ConcertoManykinds.showAlert(data.responseJSON.kind_id.join(', '));
27
+ });
28
+
29
+ console.debug('manykinds handlers initialized');
30
+ ConcertoManykinds._initialized = true;
31
+ }
32
+ },
33
+
34
+ showAlert: function (msg) {
35
+ $('#manykind-alert h4').text(msg);
36
+ $('#manykind-alert').removeClass('hide');
19
37
  }
20
38
  }
21
39
 
22
- $(document).ready(attachConcertoManykindsHandlers);
23
- $(document).on('page:change', attachConcertoManykindsHandlers);
24
-
40
+ $(document).ready(ConcertoManykinds.initHandlers);
41
+ $(document).on('page:change', ConcertoManykinds.initHandlers);
@@ -1,104 +1,29 @@
1
- require_dependency "concerto_manykinds/application_controller"
1
+ require_dependency 'concerto_manykinds/application_controller'
2
2
 
3
3
  module ConcertoManykinds
4
4
  class ManykindsController < ApplicationController
5
-
6
- # # GET /schedules
7
- # # GET /schedules.json
8
- # def index
9
- # @schedules = Schedule.all
10
- # # ignore the schedules that belong to screens we cant read
11
- # # or schedules where the template has been deleted
12
- # @schedules.reject! { |s| !can?(:read, s.screen) || s.template.nil? }
13
-
14
- # respond_to do |format|
15
- # format.html # index.html.erb
16
- # format.json { render json: @schedules }
17
- # end
18
- # end
19
-
20
- # # GET /schedules/1
21
- # # GET /schedules/1.json
22
- # def show
23
- # @schedule = Schedule.find(params[:id])
24
- # auth! :action => :read, :object => @schedule.screen
25
-
26
- # respond_to do |format|
27
- # format.html # show.html.erb
28
- # format.json { render json: @schedule }
29
- # end
30
- # end
31
-
32
- # # GET /schedules/new
33
- # # GET /schedules/new.json
34
- # def new
35
- # @schedule = Schedule.new
36
- # if !params[:screen_id].nil?
37
- # # TODO: Error handling
38
- # @schedule.screen = Screen.find(params[:screen_id])
39
- # end
40
- # auth! :action => :update, :object => @schedule.screen
41
-
42
- # respond_to do |format|
43
- # format.html # new.html.erb
44
- # format.json { render json: @schedule }
45
- # end
46
- # end
47
-
48
- # # GET /schedules/1/edit
49
- # def edit
50
- # @schedule = Schedule.find(params[:id])
51
- # auth! :action => :update, :object => @schedule.screen
52
- # end
53
-
54
- # POST /schedules
55
- # POST /schedules.json
56
5
  def create
57
6
  @manykind = Manykind.new(manykind_params)
58
- auth! :action => :update, :object => @manykind.template
7
+ auth! action: :update, object: @manykind.template
59
8
  respond_to do |format|
60
9
  if @manykind.save
61
10
  format.html { redirect_to @manykind, notice: 'Kind was successfully created.' }
62
- #format.json { render json: @manykind, status: :created, location: @manykind }
63
- format.json do
64
- item_html = render_to_string(:partial => 'concerto_manykinds/templates/item', :object => @manykind, :formats => [:html])
65
- render json: { :field_id => @manykind.field.id, :item_html => item_html }, status: :created, location: @manykind
11
+ format.json do
12
+ item_html = render_to_string(partial: 'concerto_manykinds/templates/item', object: @manykind, formats: [:html])
13
+ render json: { field_id: @manykind.field.id, item_html: item_html }, status: :created, location: @manykind
66
14
  end
67
15
  else
68
- format.html { render action: "new" }
16
+ format.html { render action: 'new' }
69
17
  format.json { render json: @manykind.errors, status: :unprocessable_entity }
70
18
  end
71
19
  end
72
20
  end
73
-
74
- # # PUT /schedules/1
75
- # # PUT /schedules/1.json
76
- # def update
77
- # @schedule = Schedule.find(params[:id])
78
- # auth! :action => :update, :object => @schedule.screen
79
21
 
80
- # respond_to do |format|
81
- # if @schedule.update_attributes(schedule_params)
82
- # process_notification(@schedule, {:screen_id => @schedule.screen_id, :screen_name => @schedule.screen.name,
83
- # :template_id => @schedule.template.id, :template_name => @schedule.template.name },
84
- # :key => 'concerto_template_scheduling.schedule.update', :owner => current_user, :action => 'update')
85
-
86
- # format.html { redirect_to @schedule, notice: 'Schedule was successfully updated.' }
87
- # format.json { head :no_content }
88
- # else
89
- # format.html { render action: "edit" }
90
- # format.json { render json: @schedule.errors, status: :unprocessable_entity }
91
- # end
92
- # end
93
- # end
94
-
95
- # DELETE /schedules/1
96
- # DELETE /schedules/1.json
97
22
  def destroy
98
23
  @manykind = Manykind.find(params[:id])
99
- auth! :action => :update, :object => @manykind.template
24
+ auth! action: :update, object: @manykind.template
100
25
  @manykind.destroy
101
-
26
+
102
27
  respond_to do |format|
103
28
  format.html { redirect_to manykindsengine.manykinds_url }
104
29
  format.json { head :no_content }
@@ -5,31 +5,30 @@ module ConcertoManykinds
5
5
  belongs_to :field
6
6
  belongs_to :kind
7
7
  belongs_to :template
8
-
9
- validates :field_id, :presence => true
10
- validates :kind_id, :presence => true
11
- validates :template_id, :presence => true
12
- validates_uniqueness_of :kind_id, :scope => [:template_id, :field_id]
8
+
9
+ validates :field_id, presence: true
10
+ validates :kind_id, presence: true
11
+ validates :template_id, presence: true
12
+ validates_uniqueness_of :kind_id, scope: [:template_id, :field_id], message: I18n.t('concerto_manykinds.already_mapped')
13
13
 
14
14
  # TODO dont allow record if already exists in position field mapping
15
15
  validate :cannot_be_same_as_primary
16
16
 
17
17
  def cannot_be_same_as_primary
18
18
  if template_id.present? && field_id.present? && kind_id.present?
19
- p = Position.where(:template_id => template_id, :field_id => field_id).first
20
- if !p.nil? and p.field.kind_id == kind_id
21
- errors.add(:kind_id, 'already mapped via template definition')
19
+ p = Position.where(template_id: template_id, field_id: field_id).first
20
+ if !p.nil? && p.field.kind_id == kind_id
21
+ errors.add(:kind_id, I18n.t('concerto_manykinds.already_mapped_via_template', kind: kind.name, field: field.name))
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
26
  def self.form_attributes
27
- attributes = [:field_id, :template_id, :kind_id]
27
+ attributes = [:field_id, :template_id, :kind_id]
28
28
  end
29
29
 
30
30
  def self.kinds_for(template_id, field_id)
31
- Manykind.where(:template_id => template_id, :field_id => field_id)
31
+ Manykind.where(template_id: template_id, field_id: field_id)
32
32
  end
33
-
34
33
  end
35
34
  end
@@ -5,7 +5,7 @@
5
5
  </div>
6
6
  </div>
7
7
  <h1 class="default-padding">
8
- <%= t(:all_model, :model => ConcertoManykinds::Manykind.model_name.human.pluralize) %>
8
+ <%= t(:all_model, model: ConcertoManykinds::Manykind.model_name.human.pluralize) %>
9
9
  </h1>
10
10
  </header>
11
11
  <div class="viewblock-cont">
@@ -1,5 +1,6 @@
1
1
  <%= stylesheet_link_tag "concerto_manykinds/application" %>
2
2
  <%= javascript_include_tag "concerto_manykinds/application" %>
3
+
3
4
  <section class="viewblock">
4
5
  <header class="viewblock-header">
5
6
 
@@ -18,6 +19,10 @@
18
19
  <div class="viewblock-cont">
19
20
  <div class="row-fluid">
20
21
  <div class="span12">
22
+ <div id="manykind-alert" class="alert alert-banner alert-error hide">
23
+ <button type="button" class="close" data-dismiss="alert">×</button>
24
+ <h4></h4>
25
+ </div>
21
26
  <div class="default-padding">
22
27
  <div class="subblock">
23
28
  <div class="default-padding clearfix">
@@ -27,7 +32,7 @@
27
32
  <li><%= p.field.kind.name %> <i class='icon-star' title="<%=t('.fundamental_kind')%>"></i></li>
28
33
  <% @manykinds.each do |m| %>
29
34
  <% if m.field.id == p.field.id %>
30
- <%= render :partial => 'concerto_manykinds/templates/item', :object => m %>
35
+ <%= render partial: 'concerto_manykinds/templates/item', object: m %>
31
36
  <% end %>
32
37
  <% end %>
33
38
  </ul>
@@ -35,8 +40,8 @@
35
40
 
36
41
  <% if can? :update, @template %>
37
42
  <div class="row-fluid">
38
- <%= form_for(@manykind_new, :url => manykindsengine.manykinds_path, :html => { 'data-type' => 'json'}, :remote => true, :class => 'form', :format => 'json') do |f| %>
39
- <%= f.hidden_field :template_id, :value => @template.id %>
43
+ <%= form_for(@manykind_new, url: manykindsengine.manykinds_path, html: { 'data-type' => 'json'}, remote: true, class: 'form', format: 'json') do |f| %>
44
+ <%= f.hidden_field :template_id, value: @template.id %>
40
45
  <div class="span4">
41
46
  <%= f.label :field_id %>
42
47
  <%= f.collection_select :field_id, Field.all, :id, :name %>
@@ -47,13 +52,11 @@
47
52
  </div>
48
53
  <div class="span2">
49
54
  <label>&nbsp;</label>
50
- <%= f.button t(:add), :class => 'btn btn-small' %>
55
+ <%= f.button t(:add), class: 'mk-add btn btn-default' %>
51
56
  </div>
52
57
  </div>
53
58
  <% end %>
54
59
  <% end %>
55
-
56
-
57
60
  </div>
58
61
  </div>
59
62
  </div>
@@ -1,6 +1,6 @@
1
1
  <li>
2
2
  <%= item.kind.name %>
3
3
  <% if can? :update, item.template %>
4
- <%= link_to t(:destroy), manykindsengine.manykind_path(item), :data => { :confirm => t(:are_you_sure_delete_model_key, :model => ConcertoManykinds::Manykind.model_name.human, :key => item.kind.name), :type => 'json' }, :method => :delete, :class => "btn btn-small", :remote => true %>
4
+ <%= link_to t(:destroy), manykindsengine.manykind_path(item), data: { confirm: t('concerto_manykinds.are_you_sure_delete', kind: item.kind.name, field: item.field.name), type: 'json' }, method: :delete, class: "mk-delete btn btn-small", remote: true %>
5
5
  <% end %>
6
6
  </li>
@@ -9,6 +9,8 @@ en:
9
9
  kind_id: 'Kind'
10
10
 
11
11
  concerto_manykinds:
12
+ already_mapped: 'That kind is already mapped to that field'
13
+ already_mapped_via_template: 'The %{kind} kind is already mapped to field %{field} via the template definition'
12
14
  are_you_sure_delete: 'Are you sure you want to remove the mapping of the %{kind} from the %{field} field?'
13
15
 
14
16
  templates:
@@ -1,3 +1,3 @@
1
1
  module ConcertoManykinds
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concerto_manykinds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marvin Frederickson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-15 00:00:00.000000000 Z
11
+ date: 2017-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ files:
106
106
  - test/test_helper.rb
107
107
  - test/unit/concerto_template_scheduling/schedule_test.rb
108
108
  - test/unit/helpers/concerto_template_scheduling/schedules_helper_test.rb
109
- homepage: https://github.com/mfrederickson/concerto_manykinds
109
+ homepage: https://github.com/concerto-addons/concerto-manykinds
110
110
  licenses: []
111
111
  metadata: {}
112
112
  post_install_message:
@@ -125,46 +125,46 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.4.5.1
128
+ rubygems_version: 2.6.10
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Allow multiple kinds (content types) per template field
132
132
  test_files:
133
+ - test/fixtures/concerto_template_scheduling/schedules.yml
134
+ - test/test_helper.rb
135
+ - test/integration/navigation_test.rb
136
+ - test/functional/concerto_template_scheduling/schedules_controller_test.rb
133
137
  - test/concerto_template_scheduling_test.rb
138
+ - test/dummy/bin/rake
139
+ - test/dummy/bin/rails
140
+ - test/dummy/bin/bundle
141
+ - test/dummy/public/422.html
142
+ - test/dummy/public/favicon.ico
143
+ - test/dummy/public/404.html
144
+ - test/dummy/public/500.html
145
+ - test/dummy/app/views/layouts/application.html.erb
146
+ - test/dummy/app/controllers/application_controller.rb
134
147
  - test/dummy/app/assets/javascripts/application.js
135
148
  - test/dummy/app/assets/stylesheets/application.css
136
- - test/dummy/app/controllers/application_controller.rb
137
149
  - test/dummy/app/helpers/application_helper.rb
138
- - test/dummy/app/views/layouts/application.html.erb
139
- - test/dummy/bin/bundle
140
- - test/dummy/bin/rails
141
- - test/dummy/bin/rake
142
- - test/dummy/config/application.rb
143
- - test/dummy/config/boot.rb
144
- - test/dummy/config/database.yml
150
+ - test/dummy/README.rdoc
151
+ - test/dummy/Rakefile
145
152
  - test/dummy/config/environment.rb
153
+ - test/dummy/config/environments/test.rb
146
154
  - test/dummy/config/environments/development.rb
147
155
  - test/dummy/config/environments/production.rb
148
- - test/dummy/config/environments/test.rb
149
- - test/dummy/config/initializers/backtrace_silencers.rb
156
+ - test/dummy/config/database.yml
157
+ - test/dummy/config/boot.rb
158
+ - test/dummy/config/application.rb
159
+ - test/dummy/config/routes.rb
160
+ - test/dummy/config/initializers/secret_token.rb
150
161
  - test/dummy/config/initializers/filter_parameter_logging.rb
151
162
  - test/dummy/config/initializers/inflections.rb
163
+ - test/dummy/config/initializers/wrap_parameters.rb
152
164
  - test/dummy/config/initializers/mime_types.rb
153
- - test/dummy/config/initializers/secret_token.rb
165
+ - test/dummy/config/initializers/backtrace_silencers.rb
154
166
  - test/dummy/config/initializers/session_store.rb
155
- - test/dummy/config/initializers/wrap_parameters.rb
156
167
  - test/dummy/config/locales/en.yml
157
- - test/dummy/config/routes.rb
158
168
  - test/dummy/config.ru
159
- - test/dummy/public/404.html
160
- - test/dummy/public/422.html
161
- - test/dummy/public/500.html
162
- - test/dummy/public/favicon.ico
163
- - test/dummy/Rakefile
164
- - test/dummy/README.rdoc
165
- - test/fixtures/concerto_template_scheduling/schedules.yml
166
- - test/functional/concerto_template_scheduling/schedules_controller_test.rb
167
- - test/integration/navigation_test.rb
168
- - test/test_helper.rb
169
169
  - test/unit/concerto_template_scheduling/schedule_test.rb
170
170
  - test/unit/helpers/concerto_template_scheduling/schedules_helper_test.rb