Webshims and select2 removed, replaced with straight rails datetime select and jquery tags input
parent
1849ac942b
commit
5b3228dae8
@ -1,13 +0,0 @@
|
||||
$(document).on 'turbolinks:load', ->
|
||||
# Manage orga tags edition
|
||||
$('#orga_tags').each ->
|
||||
elt = $(this)
|
||||
$.ajax
|
||||
url: '/tags/orgas.json'
|
||||
.done (data) ->
|
||||
tags = jQuery.map data, (n) -> n[0]
|
||||
|
||||
elt.select2 tags: tags, separator: [' '], tokenSeparators: [' ']
|
||||
|
||||
# Manage the tags label so it points the proper select2 input
|
||||
$('label[for=orga_tags]').attr 'for', 's2id_autogen1'
|
@ -0,0 +1,4 @@
|
||||
# Helper for the tags views
|
||||
module TagsHelper
|
||||
include ActsAsTaggableOn::TagsHelper
|
||||
end
|
@ -1,3 +1,3 @@
|
||||
json.extract! @event, :id, :title, :description, :start_time, :end_time,
|
||||
:place_name, :address, :city, :region, :locality, :url, :contact,
|
||||
:tags
|
||||
:tag_list
|
||||
|
@ -1,6 +1,6 @@
|
||||
json.array!(@orgas) do |orga|
|
||||
json.extract! orga, :id, :name, :description,
|
||||
:place_name, :address, :city, :region_id, :url,
|
||||
:contact, :tags
|
||||
:contact, :tag_list
|
||||
json.url orga_url(orga, format: :json)
|
||||
end
|
||||
|
@ -1,2 +1,2 @@
|
||||
json.extract! @orga, :id, :name, :description,
|
||||
:place_name, :address, :city, :region, :url, :contact, :tags
|
||||
:place_name, :address, :city, :region, :url, :contact, :tag_list
|
||||
|
@ -0,0 +1,2 @@
|
||||
ActsAsTaggableOn.delimiter = ' ' # use space as delimiter
|
||||
ActsAsTaggableOn.force_lowercase = true
|
@ -0,0 +1,35 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 1)
|
||||
class ActsAsTaggableOnMigration < ActiveRecord::Migration
|
||||
def taggings
|
||||
create_table :taggings do |t|
|
||||
t.references :tag
|
||||
|
||||
# You should make sure that the column created is
|
||||
# long enough to store the required class names.
|
||||
t.references :taggable, polymorphic: true
|
||||
t.references :tagger, polymorphic: true
|
||||
|
||||
# Limit is created to prevent MySQL error on index
|
||||
# length for MyISAM table type: http://bit.ly/vgW2Ql
|
||||
t.string :context, limit: 128
|
||||
|
||||
t.datetime :created_at
|
||||
end
|
||||
|
||||
add_index :taggings, :tag_id
|
||||
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
||||
end
|
||||
|
||||
def self.up
|
||||
create_table :tags do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
taggings
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :taggings
|
||||
drop_table :tags
|
||||
end
|
||||
end
|
@ -0,0 +1,22 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 2)
|
||||
class AddMissingUniqueIndices < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_index :tags, :name, unique: true
|
||||
|
||||
remove_index :taggings, :tag_id if index_exists?(:taggings, :tag_id)
|
||||
remove_index :taggings, [:taggable_id, :taggable_type, :context]
|
||||
add_index :taggings,
|
||||
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id,
|
||||
:tagger_type],
|
||||
unique: true, name: 'taggings_idx'
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :tags, :name
|
||||
|
||||
remove_index :taggings, name: 'taggings_idx'
|
||||
|
||||
add_index :taggings, :tag_id unless index_exists?(:taggings, :tag_id)
|
||||
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
||||
end
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 3)
|
||||
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :tags, :taggings_count, :integer, default: 0
|
||||
|
||||
ActsAsTaggableOn::Tag.reset_column_information
|
||||
ActsAsTaggableOn::Tag.find_each do |tag|
|
||||
ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :tags, :taggings_count
|
||||
end
|
||||
end
|
@ -0,0 +1,10 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 4)
|
||||
class AddMissingTaggableIndex < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :taggings, [:taggable_id, :taggable_type, :context]
|
||||
end
|
||||
end
|
@ -0,0 +1,10 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 5)
|
||||
# This migration is added to circumvent issue #623 and have special characters
|
||||
# work properly
|
||||
class ChangeCollationForTagNames < ActiveRecord::Migration
|
||||
def up
|
||||
return unless ActsAsTaggableOn::Utils.using_mysql?
|
||||
execute 'ALTER TABLE tags MODIFY name varchar(255)
|
||||
CHARACTER SET utf8 COLLATE utf8_bin;'
|
||||
end
|
||||
end
|
@ -0,0 +1,14 @@
|
||||
# This migration comes from acts_as_taggable_on_engine (originally 6)
|
||||
class AddMissingIndexes < ActiveRecord::Migration
|
||||
def change
|
||||
add_index :taggings, :tag_id
|
||||
add_index :taggings, :taggable_id
|
||||
add_index :taggings, :taggable_type
|
||||
add_index :taggings, :tagger_id
|
||||
add_index :taggings, :context
|
||||
|
||||
add_index :taggings, [:tagger_id, :tagger_type]
|
||||
add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context],
|
||||
name: 'taggings_idy'
|
||||
end
|
||||
end
|
@ -0,0 +1,20 @@
|
||||
# Migrate tags from inline attribute to separate table
|
||||
class PopulateTags < ActiveRecord::Migration
|
||||
def self.up
|
||||
execute('SELECT id, tags FROM events;').each do |result|
|
||||
event = Event.find_by id: result[0]
|
||||
event.tag_list = result[1] + ' helo world'
|
||||
event.save
|
||||
say event.id
|
||||
say event.tag_list
|
||||
end
|
||||
|
||||
change_column :events, :tags, :text, null: true
|
||||
change_column :orgas, :tags, :text, null: true
|
||||
end
|
||||
|
||||
def self.down
|
||||
change_column :events, :tags, :text, null: false
|
||||
change_column :orgas, :tags, :text, null: false
|
||||
end
|
||||
end
|