aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichel Etienne2014-07-23 10:38:39 +0200
committerMichel Etienne2014-07-23 10:38:39 +0200
commit98c377c231abd19343a6163c396b4489fca14ef2 (patch)
treecf00ac71cfb92a89c8acde8d306956a80846824e
parent08c0bce019481d54f07d67de79061b791dc51a9d (diff)
downloadchouette-core-98c377c231abd19343a6163c396b4489fca14ef2.tar.bz2
manage tags on time_table , Mantis 26833
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock12
-rw-r--r--app/assets/javascripts/application.js2
-rw-r--r--app/assets/stylesheets/application.css.scss.erb1
-rw-r--r--app/controllers/time_tables_controller.rb10
-rw-r--r--app/views/time_tables/_form.erb19
-rw-r--r--app/views/time_tables/edit.html.erb1
-rw-r--r--app/views/time_tables/show.html.erb4
-rw-r--r--config/deploy.rb2
-rw-r--r--db/migrate/20140721080943_acts_as_taggable_on_migration.ninoxe_engine.rb32
-rw-r--r--db/migrate/20140721080944_add_missing_unique_indices.ninoxe_engine.rb21
-rw-r--r--db/migrate/20140721080945_add_taggings_counter_cache_to_tags.ninoxe_engine.rb16
-rw-r--r--db/migrate/20140721080946_add_missing_taggable_index.ninoxe_engine.rb11
-rw-r--r--db/schema.rb22
14 files changed, 151 insertions, 4 deletions
diff --git a/Gemfile b/Gemfile
index e801e72a2..15701852f 100644
--- a/Gemfile
+++ b/Gemfile
@@ -47,6 +47,8 @@ gem 'bootswatch-rails'
gem 'font-awesome-sass'
gem 'will_paginate-bootstrap'
gem 'simple_form'
+gem 'tagmanager-rails', '~> 3.0.1.0'
+gem 'typeahead-rails', '~> 0.10.1'
# Format Output
gem 'json'
diff --git a/Gemfile.lock b/Gemfile.lock
index d259795eb..5b7653da4 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,10 +1,11 @@
GIT
remote: https://github.com/afimb/ninoxe.git
- revision: 4678304bb9a6d550ce45feb6557fbe33d3d11312
+ revision: ea581b1a6e49ccdc98019a6c382f9ce35a63dcb7
branch: sismo
specs:
ninoxe (1.1.0)
- activerecord (~> 3.2)
+ activerecord (~> 3.2.13)
+ acts-as-taggable-on (>= 3)
acts_as_list (>= 0.1.6)
acts_as_tree (>= 1.1.0)
deep_cloneable (~> 2.0.0)
@@ -51,6 +52,8 @@ GEM
activesupport (3.2.18)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
+ acts-as-taggable-on (3.3.0)
+ activerecord (>= 3, < 5)
acts_as_list (0.1.6)
acts_as_tree-1.8 (1.1.0)
activerecord (>= 3.0.0)
@@ -323,6 +326,8 @@ GEM
activerecord (~> 3.0)
activesupport (~> 3.0)
polyamorous (~> 0.5.0)
+ tagmanager-rails (3.0.1.0)
+ railties (>= 3.0, < 5.0)
therubyracer (0.10.2)
libv8 (~> 3.3.10)
therubyrhino (2.0.1)
@@ -333,6 +338,7 @@ GEM
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
+ typeahead-rails (0.10.1)
tzinfo (0.3.40)
uglifier (1.2.7)
execjs (>= 0.3.0)
@@ -416,8 +422,10 @@ DEPENDENCIES
simple_form
sqlite3
squeel
+ tagmanager-rails (~> 3.0.1.0)
therubyracer (~> 0.10.2)
therubyrhino
+ typeahead-rails (~> 0.10.1)
uglifier (>= 1.0.3)
warbler
will_paginate (~> 3.0)
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 748de2483..7a7d16d08 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -12,4 +12,6 @@
//= require raphael
//= require morris
//= require bootstrap
+//= require typeahead
+//= require tagmanager
//= require_directory .
diff --git a/app/assets/stylesheets/application.css.scss.erb b/app/assets/stylesheets/application.css.scss.erb
index bcea7ca92..32cbba6e8 100644
--- a/app/assets/stylesheets/application.css.scss.erb
+++ b/app/assets/stylesheets/application.css.scss.erb
@@ -19,6 +19,7 @@ $body-bg: #eee;
// @import "partials/reset";
// Third-party
+@import "tagmanager";
@import "font-awesome";
@import "jquery.ui.all";
@import "morris";
diff --git a/app/controllers/time_tables_controller.rb b/app/controllers/time_tables_controller.rb
index 20100ddd6..b7598301b 100644
--- a/app/controllers/time_tables_controller.rb
+++ b/app/controllers/time_tables_controller.rb
@@ -11,6 +11,16 @@ class TimeTablesController < ChouetteController
@year = params[:year] ? params[:year].to_i : Date.today.cwyear
show!
end
+
+ def new
+ @autocomplete_items = ActsAsTaggableOn::Tag.all
+ new!
+ end
+
+ def edit
+ @autocomplete_items = ActsAsTaggableOn::Tag.all
+ edit!
+ end
def comment_filter
respond_to do |format|
diff --git a/app/views/time_tables/_form.erb b/app/views/time_tables/_form.erb
index 7933b2f7c..ddae4a793 100644
--- a/app/views/time_tables/_form.erb
+++ b/app/views/time_tables/_form.erb
@@ -8,6 +8,16 @@
<%= form.input :school_holliday, :as => :boolean, :class => "others" %>
<%= form.input :public_holliday, :as => :boolean %>
<% end %>
+
+ <%= form.inputs do %>
+ <%= form.label :tag_list %>
+ <%= text_field_tag 'tag_input', nil, class: "tm-input", autocomplete: "off", data:{provide: "typeahead"} %>
+ <%= hidden_field_tag 'time_table[tag_list]', nil , autocomplete: "off" %>
+ <%= javascript_tag "var items = #{ @time_table.tag_list.to_json };" %>
+ <%= javascript_tag "var autocomplete_items = #{ @autocomplete_items.to_json };" %>
+ <% end %>
+
+
<%= form.inputs do %>
<%= form.input :objectid, :required => !@time_table.new_record? %>
<% end %>
@@ -85,5 +95,14 @@
<% end %>
<% end %>
+<script>
+$(".tm-input").tagsManager(
+ {
+ prefilled: items,
+ output: '#time_table_tag_list'
+
+ });
+
+</script>
diff --git a/app/views/time_tables/edit.html.erb b/app/views/time_tables/edit.html.erb
index d80974841..ac3beaeaa 100644
--- a/app/views/time_tables/edit.html.erb
+++ b/app/views/time_tables/edit.html.erb
@@ -1,3 +1,4 @@
<%= title_tag t('time_tables.edit.title', :time_table => @time_table.comment) %>
<%= render "form" %>
+
diff --git a/app/views/time_tables/show.html.erb b/app/views/time_tables/show.html.erb
index 6e61d722b..4f06c3677 100644
--- a/app/views/time_tables/show.html.erb
+++ b/app/views/time_tables/show.html.erb
@@ -42,6 +42,10 @@
</p>
<% end %>
<p>
+ <label><%= @time_table.human_attribute_name("tag_list") %>: </label>
+ <%= @time_table.tag_list %>
+ </p>
+ <p>
<label><%= @time_table.human_attribute_name("day_types") %>:&nbsp;&nbsp;</label>
<% if @time_table.int_day_types & 508 == 0 %>
<label><%= @time_table.human_attribute_name("none") %></label>
diff --git a/config/deploy.rb b/config/deploy.rb
index c3dbb5db5..5d3324c74 100644
--- a/config/deploy.rb
+++ b/config/deploy.rb
@@ -12,7 +12,7 @@ set :group_writable, true
set :rake, "bundle exec rake"
set :keep_releases, 4
set :rails_env, "production" #added for delayed job
-set :user, "mflorisson"
+set :user, "metienne"
set :deploy_via, :copy
set :copy_via, :scp
set :copy_exclude, ".git/*"
diff --git a/db/migrate/20140721080943_acts_as_taggable_on_migration.ninoxe_engine.rb b/db/migrate/20140721080943_acts_as_taggable_on_migration.ninoxe_engine.rb
new file mode 100644
index 000000000..cf116560a
--- /dev/null
+++ b/db/migrate/20140721080943_acts_as_taggable_on_migration.ninoxe_engine.rb
@@ -0,0 +1,32 @@
+# This migration comes from ninoxe_engine (originally 20140718141703)
+# This migration comes from acts_as_taggable_on_engine (originally 1)
+class ActsAsTaggableOnMigration < ActiveRecord::Migration
+ def self.up
+ create_table :tags do |t|
+ t.string :name
+ end
+
+ 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.down
+ drop_table :taggings
+ drop_table :tags
+ end
+end
diff --git a/db/migrate/20140721080944_add_missing_unique_indices.ninoxe_engine.rb b/db/migrate/20140721080944_add_missing_unique_indices.ninoxe_engine.rb
new file mode 100644
index 000000000..f85bb4c75
--- /dev/null
+++ b/db/migrate/20140721080944_add_missing_unique_indices.ninoxe_engine.rb
@@ -0,0 +1,21 @@
+# This migration comes from ninoxe_engine (originally 20140718141704)
+# 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
+ 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
+ add_index :taggings, [:taggable_id, :taggable_type, :context]
+ end
+end
diff --git a/db/migrate/20140721080945_add_taggings_counter_cache_to_tags.ninoxe_engine.rb b/db/migrate/20140721080945_add_taggings_counter_cache_to_tags.ninoxe_engine.rb
new file mode 100644
index 000000000..27d7e4d1e
--- /dev/null
+++ b/db/migrate/20140721080945_add_taggings_counter_cache_to_tags.ninoxe_engine.rb
@@ -0,0 +1,16 @@
+# This migration comes from ninoxe_engine (originally 20140718141705)
+# 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
diff --git a/db/migrate/20140721080946_add_missing_taggable_index.ninoxe_engine.rb b/db/migrate/20140721080946_add_missing_taggable_index.ninoxe_engine.rb
new file mode 100644
index 000000000..6aba71e6f
--- /dev/null
+++ b/db/migrate/20140721080946_add_missing_taggable_index.ninoxe_engine.rb
@@ -0,0 +1,11 @@
+# This migration comes from ninoxe_engine (originally 20140718141706)
+# 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
diff --git a/db/schema.rb b/db/schema.rb
index 343ccdceb..be5e89c97 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20140626081658) do
+ActiveRecord::Schema.define(:version => 20140721080946) do
create_table "access_links", :force => true do |t|
t.integer "access_point_id", :limit => 8
@@ -412,6 +412,26 @@ ActiveRecord::Schema.define(:version => 20140626081658) do
add_index "stop_points", ["objectid"], :name => "stop_points_objectid_key", :unique => true
+ create_table "taggings", :force => true do |t|
+ t.integer "tag_id"
+ t.integer "taggable_id"
+ t.string "taggable_type"
+ t.integer "tagger_id"
+ t.string "tagger_type"
+ t.string "context", :limit => 128
+ t.datetime "created_at"
+ end
+
+ add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], :name => "taggings_idx", :unique => true
+ add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
+
+ create_table "tags", :force => true do |t|
+ t.string "name"
+ t.integer "taggings_count", :default => 0
+ end
+
+ add_index "tags", ["name"], :name => "index_tags_on_name", :unique => true
+
create_table "time_slots", :force => true do |t|
t.string "objectid", :null => false
t.integer "object_version"