aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorLuc Donnet2017-09-07 16:28:32 +0200
committerLuc Donnet2017-09-07 16:28:32 +0200
commit99aff9c3e63fb15b555806847bc14fbf56eeef2a (patch)
tree339ca9b884504c19cecc0956c629614ace926901 /app
parent8b5a3e68c37a9331f47608faaa6903a01c390861 (diff)
parent01b0d19c329810a083153efbf040911e4079f6ef (diff)
downloadchouette-core-99aff9c3e63fb15b555806847bc14fbf56eeef2a.tar.bz2
Merge branch 'master' of github.com:AF83/stif-boiv
Diffstat (limited to 'app')
-rw-r--r--app/controllers/autocomplete_time_tables_controller.rb5
-rw-r--r--app/models/chouette/active_record.rb13
-rw-r--r--app/models/referential.rb6
-rw-r--r--app/views/calendars/index.html.slim4
-rw-r--r--app/views/time_table_combinations/_form.html.slim2
5 files changed, 22 insertions, 8 deletions
diff --git a/app/controllers/autocomplete_time_tables_controller.rb b/app/controllers/autocomplete_time_tables_controller.rb
index d0cd94e26..f65f5b9f6 100644
--- a/app/controllers/autocomplete_time_tables_controller.rb
+++ b/app/controllers/autocomplete_time_tables_controller.rb
@@ -22,7 +22,12 @@ class AutocompleteTimeTablesController < InheritedResources::Base
scope.distinct
end
+ def split_params! search
+ params[:q][search] = params[:q][search].split(" ") if params[:q][search]
+ end
+
def collection
+ split_params! :comment_or_objectid_cont_any
@time_tables = select_time_tables.search(params[:q]).result.paginate(page: params[:page])
end
end
diff --git a/app/models/chouette/active_record.rb b/app/models/chouette/active_record.rb
index 1862319af..e12f30266 100644
--- a/app/models/chouette/active_record.rb
+++ b/app/models/chouette/active_record.rb
@@ -2,10 +2,8 @@
require 'deep_cloneable'
module Chouette
class ActiveRecord < ::ActiveRecord::Base
-
self.abstract_class = true
-
- before_save :nil_if_blank
+ before_save :nil_if_blank, :set_data_source_ref
# to be overridden to set nullable attrs when empty
def self.nullable_attributes
@@ -16,17 +14,22 @@ module Chouette
self.class.nullable_attributes.each { |attr| self[attr] = nil if self[attr].blank? }
end
-
def human_attribute_name(*args)
self.class.human_attribute_name(*args)
end
+ def set_data_source_ref
+ if self.respond_to?(:data_source_ref)
+ self.data_source_ref ||= 'DATASOURCEREF_EDITION_BOIV'
+ end
+ end
+
# TODO: Can we remove this?
# class << self
# alias_method :create_reflection_without_chouette_naming, :create_reflection
# def create_reflection(macro, name, options, active_record)
- # options =
+ # options =
# Reflection.new(macro, name, options, active_record).options_with_default
# create_reflection_without_chouette_naming(macro, name, options, active_record)
diff --git a/app/models/referential.rb b/app/models/referential.rb
index ecfc69c4a..65e203f9f 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
class Referential < ActiveRecord::Base
include DataFormatEnumerations
@@ -185,7 +186,6 @@ class Referential < ActiveRecord::Base
before_validation :assign_slug, :on => :create
before_validation :assign_prefix, :on => :create
before_create :create_schema
-
after_create :clone_schema, if: :created_from
before_destroy :destroy_schema
@@ -289,7 +289,9 @@ class Referential < ActiveRecord::Base
end
def create_schema
- Apartment::Tenant.create slug
+ unless created_from
+ Apartment::Tenant.create slug
+ end
end
def assign_slug
diff --git a/app/views/calendars/index.html.slim b/app/views/calendars/index.html.slim
index 56232b0af..24ed15484 100644
--- a/app/views/calendars/index.html.slim
+++ b/app/views/calendars/index.html.slim
@@ -31,6 +31,10 @@
attribute: 'short_name' \
), \
TableBuilderHelper::Column.new( \
+ key: :organisation, \
+ attribute: Proc.new { |c| c.organisation.name } \
+ ), \
+ TableBuilderHelper::Column.new( \
key: :shared, \
attribute: Proc.new { |c| t("#{c.try(:shared)}") } \
) \
diff --git a/app/views/time_table_combinations/_form.html.slim b/app/views/time_table_combinations/_form.html.slim
index 8e2d77d46..426624ee3 100644
--- a/app/views/time_table_combinations/_form.html.slim
+++ b/app/views/time_table_combinations/_form.html.slim
@@ -7,7 +7,7 @@
abbr title='Champ requis' *
= f.input :combined_type, as: :boolean, checked_value: 'time_table', unchecked_value: 'calendar', required: false, label: content_tag(:span, t("time_table_combinations.combined_type.#{@combination.combined_type}"), class: 'switch-label', data: { checkedValue: 'Calendriers', uncheckedValue: 'Modèles de calendriers' }), wrapper_html: { class: 'col-sm-8 col-xs-7' }
- = f.input :time_table_id, as: :select, input_html: {class: 'tt_combination_target', style: "width: 100%", data: { 'select2-ajax': 'true', 'select2ed-placeholder': 'Indiquez un calendrier...', term: 'comment_cont_or_objectid_cont', url: referential_autocomplete_time_tables_path(@referential, format: :json, :source_id => @combination.source_id)}}, wrapper_html: {class: @combination.combined_type != 'time_table' ? 'hidden' : ''}
+ = f.input :time_table_id, as: :select, input_html: {class: 'tt_combination_target', style: "width: 100%", data: { 'select2-ajax': 'true', 'select2ed-placeholder': 'Indiquez un calendrier...', term: 'comment_or_objectid_cont_any', url: referential_autocomplete_time_tables_path(@referential, format: :json, :source_id => @combination.source_id)}}, wrapper_html: {class: @combination.combined_type != 'time_table' ? 'hidden' : ''}
= f.input :calendar_id, as: :select, input_html: { class: 'tt_combination_target', style: "width: 100%", data: { 'select2-ajax': 'true', 'select2ed-placeholder': 'Indiquez un modèle de calendrier...', term: 'name_cont', url: autocomplete_calendars_path}}, wrapper_html: {class: @combination.combined_type != 'calendar' ? 'hidden' : ''}