ecm_tags 1.0.0 → 2.0.2

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: 48c7c394a3a5e2df86cc629b57e93534e82ab34d
4
- data.tar.gz: 3bb976c8cc6d988a21caf96e4af0ab1629a40f30
3
+ metadata.gz: 8104551bb3079c872697c2ef2326969d4e92eeec
4
+ data.tar.gz: ec77be070876b144b3584d177d1b3dc5d0219d28
5
5
  SHA512:
6
- metadata.gz: c4b9abfebe2c615b16944a3c5f7d3a4fb5ed364e0fd007feccccf2f8bc71a74833ef0bfdcc0dafacb68c92244d27bbf5c4338807bbe80b1eb32c63f364377f39
7
- data.tar.gz: 72304783882c072c0fc5017621c674d209a65f3e5b8114e69edc377809e04808dec313ec1c1c8443db1169c9efc34bcf56f72f51a729f8672a6004c18ba5fd70
6
+ metadata.gz: b2e7e3771df88f49098225c547a2d73177cffaf9b37f276bcca64f51177c632ffbd57b7cf698650e543e92927fc3c9efdd1fa80e1f9b7844d24c675967665a79
7
+ data.tar.gz: 4b1ca17e0f524fd03172994ec0860452115445789f469a3cf93c0e7e476096f38443afbdde95a2a6295638978eac0448f052a58ad3e89a6222438aa1f8986328
@@ -10,4 +10,4 @@
10
10
  // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
- //= require_tree .
13
+ //= require_tree ./application
@@ -0,0 +1 @@
1
+ //= require ./ecm/tags/application
@@ -9,6 +9,6 @@
9
9
  * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
10
  * files in this directory. It is generally better to create a new file per style scope.
11
11
  *
12
- *= require_tree .
12
+ *= require_tree ./application
13
13
  *= require_self
14
14
  */
@@ -0,0 +1,4 @@
1
+ .tags-for-resource a.label {
2
+ display: inline-block;
3
+ margin-right: 0.25em;
4
+ }
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require ./ecm/tags/application
3
+ */
@@ -0,0 +1,13 @@
1
+ module Model
2
+ module Ecm
3
+ module Tags
4
+ module TaggableConcern
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ acts_as_taggable
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -13,7 +13,11 @@ module Ecm
13
13
  end
14
14
 
15
15
  def create
16
- @tag_search = TagSearch.new(permitted_params)
16
+ if request.get?
17
+ @tag_search = TagSearch.new(tag_list: permitted_params)
18
+ else
19
+ @tag_search = TagSearch.new(permitted_params)
20
+ end
17
21
  @result = @tag_search.result
18
22
  respond_with @tag_search do |format|
19
23
  format.html { render :new }
@@ -28,7 +32,11 @@ module Ecm
28
32
  end
29
33
 
30
34
  def permitted_params
31
- params.require(:tag_search).permit(:tag_list, :exact)
35
+ if request.get?
36
+ params.require(:tag)
37
+ else
38
+ params.require(:tag_search).permit(:tag_list, :exact)
39
+ end
32
40
  end
33
41
  end
34
42
  end
@@ -5,6 +5,10 @@ module Ecm
5
5
  @tag_search ||= Ecm::Tags::TagSearch.new
6
6
  render partial: 'ecm/tags/search_box'
7
7
  end
8
+
9
+ def tag_labels_for(resource)
10
+ render 'ecm/tags/tag_labels_for_resource', resource: resource
11
+ end
8
12
  end
9
13
  end
10
14
  end
@@ -0,0 +1,9 @@
1
+ module Ecm
2
+ module Tags
3
+ class NullTag
4
+ def name
5
+ 'Not tagged'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -39,7 +39,7 @@ module Ecm::Tags
39
39
  end
40
40
 
41
41
  def taggable_classes
42
- @taggable_classes ||= Ecm::Tags::Tagging.uniq.pluck(:taggable_type)
42
+ @taggable_classes ||= Ecm::Tags::Tagging.distinct.pluck(:taggable_type)
43
43
  end
44
44
 
45
45
  def exact
@@ -47,7 +47,11 @@ module Ecm::Tags
47
47
  end
48
48
 
49
49
  def exact=(value)
50
- @exact = ActiveRecord::Type::Boolean.new.type_cast_from_database(value)
50
+ if Rails.version < '5.1'
51
+ @exact = ActiveRecord::Type::Boolean.new.type_cast_from_database(value)
52
+ else
53
+ @exact = ActiveRecord::Type::Boolean.new.cast(value)
54
+ end
51
55
  end
52
56
 
53
57
  private
@@ -0,0 +1,4 @@
1
+ %span.tags-for-resource
2
+ - resource.tags.each do |tag|
3
+ = link_to(ecm_tags.tag_path(tag: CGI::escape(tag.name)), class: 'label label-default', style: "background-color: #{tag.color}") do
4
+ = tag.name
@@ -1,7 +1,8 @@
1
- = simple_form_for(@tag_search, url: ecm_tags.tag_searchs_path) do |f|
2
- = f.input :tag_list
3
- = f.input :exact, as: :boolean
4
- = f.button :submit, class: 'btn btn-primary'
1
+ - unless params[:tag].present?
2
+ = simple_form_for(@tag_search, url: ecm_tags.tag_searchs_path) do |f|
3
+ = f.input :tag_list
4
+ = f.input :exact, as: :boolean
5
+ = f.button :submit, class: 'btn btn-primary'
5
6
 
6
7
  #tag_search_result
7
8
  - @result.each do |class_name, resources|
File without changes
@@ -1,4 +1,6 @@
1
1
  de:
2
+ classes:
3
+ ecm/tags/engine: Tags
2
4
  attributes:
3
5
  tag_list: Tags
4
6
  activerecord:
@@ -15,11 +17,11 @@ de:
15
17
  ecm/tags/tag_search:
16
18
  exact: Wortgenau
17
19
  tag_list: Tags
18
- model:
20
+ models:
19
21
  ecm/tags/tag:
20
22
  one: Tag
21
23
  other: Tags
22
- ecm/tags/tag:
24
+ ecm/tags/tagging:
23
25
  one: Tagging
24
26
  other: Taggings
25
27
  ecm:
@@ -31,5 +33,4 @@ de:
31
33
  tag_search:
32
34
  create: 'Suchen'
33
35
  routes:
34
- mount:
35
- ecm_tags: '/backend/tags'
36
+ ecm_tags_engine: tags
@@ -1,4 +1,6 @@
1
1
  en:
2
+ classes:
3
+ ecm/tags/engine: Tags
2
4
  attributes:
3
5
  tag_list: Tags
4
6
  activerecord:
@@ -28,5 +30,4 @@ en:
28
30
  tag_search:
29
31
  create: 'Search'
30
32
  routes:
31
- mount:
32
- ecm_tags: '/backend/tags'
33
+ ecm_tags_engine: tags
@@ -1,7 +1,13 @@
1
1
  Ecm::Tags::Engine.routes.draw do
2
- resources :tag_searchs, only: [:new, :create] do
3
- get '/', on: :collection, to: "tag_searchs#create"
4
- end
2
+ localized do
3
+ scope :ecm_tags_engine do
4
+ resources :tag_searchs, only: [:new, :create] do
5
+ get '/', on: :collection, to: "tag_searchs#create"
6
+ end
7
+
8
+ get '/:tag', to: "tag_searchs#create", as: 'tag'
5
9
 
6
- root to: 'tag_searchs#new'
10
+ root to: 'tag_searchs#new'
11
+ end
12
+ end
7
13
  end
@@ -1,4 +1,4 @@
1
- class CreateEcmTagsTags < ActiveRecord::Migration
1
+ class CreateEcmTagsTags < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :ecm_tags_tags do |t|
4
4
  t.string 'name'
@@ -1,5 +1,5 @@
1
1
  # This migration comes from ecm_tags (originally 20160208121300)
2
- class CreateEcmTagsTaggings < ActiveRecord::Migration
2
+ class CreateEcmTagsTaggings < ActiveRecord::Migration[4.2]
3
3
  def change
4
4
  create_table :ecm_tags_taggings do |t|
5
5
  t.integer 'tag_id'
@@ -0,0 +1,5 @@
1
+ class AddColorToEcmTagsTags < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_column :ecm_tags_tags, :color, :string
4
+ end
5
+ end
@@ -11,6 +11,11 @@ module Ecm
11
11
  mattr_accessor(:base_controller) { 'FrontendController' }
12
12
  mattr_accessor(:add_submit_button_to_search_box) { true }
13
13
  mattr_accessor(:tag_search_exact_default_value) { false }
14
+ mattr_accessor(:taggable_models) { [] }
15
+
16
+ def self.taggable_models
17
+ @@taggable_models.map(&:constantize)
18
+ end
14
19
  end
15
20
  end
16
21
  end
@@ -2,6 +2,13 @@ module Ecm
2
2
  module Tags
3
3
  class Engine < ::Rails::Engine
4
4
  isolate_namespace Ecm::Tags
5
+
6
+ config.after_initialize do
7
+ Configuration.taggable_models.each do |model|
8
+ puts "Including Models::Ecm::Tags::TaggableConcern in #{model}"
9
+ model.send(:include, Model::Ecm::Tags::TaggableConcern)
10
+ end
11
+ end
5
12
  end
6
13
  end
7
14
  end
@@ -1,5 +1,5 @@
1
1
  module Ecm
2
2
  module Tags
3
- VERSION = '1.0.0'.freeze
3
+ VERSION = '2.0.2'.freeze
4
4
  end
5
5
  end
@@ -16,4 +16,11 @@ Ecm::Tags.configure do |config|
16
16
  # Default: config.tag_search_exact_default_value = false
17
17
  #
18
18
  config.tag_search_exact_default_value = false
19
+
20
+
21
+ # Specify the models to be tagged.
22
+ #
23
+ # Default: config.taggable_models = %w()
24
+ #
25
+ config.taggable_models = %w()
19
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-20 00:00:00.000000000 Z
11
+ date: 2017-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -231,22 +231,31 @@ files:
231
231
  - README.rdoc
232
232
  - Rakefile
233
233
  - app/assets/javascripts/ecm/tags/application.js
234
+ - app/assets/javascripts/ecm/tags/application/dummy.js
235
+ - app/assets/javascripts/ecm_tags.js
234
236
  - app/assets/stylesheets/ecm/tags/application.css
237
+ - app/assets/stylesheets/ecm/tags/application/tag-labels.css
238
+ - app/assets/stylesheets/ecm_tags.css
235
239
  - app/attribute_renderers/tag_list_renderer.rb
240
+ - app/concerns/model/ecm/tags/taggable_concern.rb
236
241
  - app/controllers/ecm/tags/application_controller.rb
237
242
  - app/controllers/ecm/tags/tag_searchs_controller.rb
238
243
  - app/helpers/ecm/tags/application_helper.rb
244
+ - app/models/ecm/tags/null_tag.rb
239
245
  - app/models/ecm/tags/tag.rb
240
246
  - app/models/ecm/tags/tag_search.rb
241
247
  - app/models/ecm/tags/tagging.rb
242
248
  - app/views/ecm/tags/_search_box.haml
249
+ - app/views/ecm/tags/_tag_labels_for_resource.html.haml
243
250
  - app/views/ecm/tags/tag_searchs/new.haml
244
251
  - app/views/layouts/ecm/tags/application.html.erb
252
+ - config/initializers/assets.rb
245
253
  - config/locales/de.yml
246
254
  - config/locales/en.yml
247
255
  - config/routes.rb
248
256
  - db/migrate/20160208121254_create_ecm_tags_tags.rb
249
257
  - db/migrate/20160208121300_create_ecm_tags_taggings.rb
258
+ - db/migrate/20161101170254_add_color_to_ecm_tags_tags.rb
250
259
  - lib/ecm/tags.rb
251
260
  - lib/ecm/tags/configuration.rb
252
261
  - lib/ecm/tags/engine.rb
@@ -277,9 +286,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
277
286
  version: '0'
278
287
  requirements: []
279
288
  rubyforge_project:
280
- rubygems_version: 2.4.8
289
+ rubygems_version: 2.6.11
281
290
  signing_key:
282
291
  specification_version: 4
283
292
  summary: Easy tagging for itsf backend
284
293
  test_files: []
285
- has_rdoc: