Remove data_provide
and data_date_format
attributes
This commit is contained in:
parent
3fbee9fd0d
commit
fdd6cedeb8
11 changed files with 16 additions and 51 deletions
2
Gemfile
2
Gemfile
|
@ -64,8 +64,6 @@ gem 'leaflet-rails'
|
|||
gem 'leaflet-markercluster-rails', '~> 0.7.0'
|
||||
gem 'leaflet-draw-rails'
|
||||
|
||||
gem 'bootstrap-datepicker-rails'
|
||||
|
||||
gem 'chartkick'
|
||||
|
||||
gem 'logstasher'
|
||||
|
|
|
@ -93,8 +93,6 @@ GEM
|
|||
bcrypt (3.1.11)
|
||||
bindata (2.4.1)
|
||||
bindex (0.5.0)
|
||||
bootstrap-datepicker-rails (1.6.4.1)
|
||||
railties (>= 3.0)
|
||||
bootstrap-sass (3.3.7)
|
||||
autoprefixer-rails (>= 5.2.1)
|
||||
sass (>= 3.3.4)
|
||||
|
@ -753,7 +751,6 @@ DEPENDENCIES
|
|||
active_model_serializers
|
||||
administrate
|
||||
apipie-rails
|
||||
bootstrap-datepicker-rails
|
||||
bootstrap-sass (~> 3.3.5)
|
||||
bootstrap-wysihtml5-rails (~> 0.3.3.8)
|
||||
brakeman
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
//= require chartkick
|
||||
//= require_tree ./old_design
|
||||
//= require bootstrap-sprockets
|
||||
//= require bootstrap-datepicker/core
|
||||
//= require bootstrap-datepicker/locales/bootstrap-datepicker.fr.js
|
||||
|
||||
//= require leaflet.js
|
||||
//= require d3.min
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
// = require attestation_recapitulatif
|
||||
|
||||
// = require_self
|
||||
// = require bootstrap-datepicker3
|
||||
// = require leaflet
|
||||
// = require font-awesome
|
||||
// = require franceconnect
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
@import "bootstrap";
|
||||
@import "bootstrap-datepicker3";
|
||||
|
||||
#description-page #liste-champs {
|
||||
|
||||
|
|
|
@ -19,6 +19,16 @@ class ChampDecorator < Draper::Decorator
|
|||
end
|
||||
end
|
||||
|
||||
def date_for_input
|
||||
if object.value.present?
|
||||
if type_champ == "date"
|
||||
object.value
|
||||
elsif type_champ == "datetime" && object.value != ' 00:00'
|
||||
DateTime.parse(object.value, "%d/%m/%Y %H:%M").strftime("%d/%m/%Y")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def description_with_links
|
||||
description.gsub(URI.regexp, '<a target="_blank" href="\0">\0</a>') if description
|
||||
end
|
||||
|
|
|
@ -17,15 +17,6 @@ class Champ < ActiveRecord::Base
|
|||
mandatory
|
||||
end
|
||||
|
||||
def data_provide
|
||||
return 'datepicker' if (type_champ == 'datetime') && !(BROWSER.value.chrome? || BROWSER.value.edge?)
|
||||
return 'typeahead' if type_champ == 'address'
|
||||
end
|
||||
|
||||
def data_date_format
|
||||
('dd/mm/yyyy' if type_champ == 'datetime')
|
||||
end
|
||||
|
||||
def same_hour? num
|
||||
same_date? num, '%H'
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
%input.form-control{ name: "champs['#{champ.id}']",
|
||||
placeholder: "JJ/MM/AAAA",
|
||||
id: "champs_#{champ.id}",
|
||||
value: champ.value ? champ.object.value : champ.value,
|
||||
value: champ.date_for_input,
|
||||
type: "date" }
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
%input.form-control{ name: "champs['#{champ.id}']",
|
||||
placeholder: champ.libelle,
|
||||
id: "champs_#{champ.id}",
|
||||
value: (champ.value.split(/[ ][0-9]*:[0-9]*/).first if champ.value.present?),
|
||||
type: champ.type_champ,
|
||||
'data-provide' => champ.data_provide,
|
||||
'data-date-format' => champ.data_date_format }
|
||||
= render partial: 'users/description/champs/date', locals: { champ: champ }
|
||||
|
||||
%select.form-control{ name: "time_hour['#{champ.id}']", style: 'margin-left: 5px;', id: "time_hour_#{champ.id}" }
|
||||
%br
|
||||
%select.form-control{ name: "time_hour['#{champ.id}']", style: 'width:70px;display:inline;', id: "time_hour_#{champ.id}" }
|
||||
- (0..23).each do |num|
|
||||
- num = "%.2i" %num
|
||||
%option{ value: num, selected: (:selected if champ.same_hour?(num)) }
|
||||
= num
|
||||
h
|
||||
%select.form-control{ name: "time_minute['#{champ.id}']", id: "time_minute_#{champ.id}" }
|
||||
%select.form-control{ name: "time_minute['#{champ.id}']", style: 'width:70px;display:inline;', id: "time_minute_#{champ.id}" }
|
||||
- (0..59).each do |num|
|
||||
- num = "%.2i" %num
|
||||
- if num.to_i%5 == 0
|
||||
|
|
|
@ -26,28 +26,6 @@ shared_examples 'champ_spec' do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'data_provide' do
|
||||
let(:champ) { create :champ }
|
||||
|
||||
subject { champ.data_provide }
|
||||
|
||||
context 'when type_champ is datetime' do
|
||||
before do
|
||||
champ.type_de_champ = create :type_de_champ_public, type_champ: 'datetime'
|
||||
end
|
||||
|
||||
it { is_expected.to eq 'datepicker' }
|
||||
end
|
||||
|
||||
context 'when type_champ is address' do
|
||||
before do
|
||||
champ.type_de_champ = create :type_de_champ_public, type_champ: 'address'
|
||||
end
|
||||
|
||||
it { is_expected.to eq 'typeahead' }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.departement', vcr: { cassette_name: 'call_geo_api_departements' } do
|
||||
subject { Champ.departements }
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ describe 'users/description/show.html.haml', type: :view do
|
|||
end
|
||||
|
||||
describe 'datetime value is correctly setup when is not nil' do
|
||||
it { expect(rendered).to have_css("input[type='datetime'][id='champs_#{champ_datetime.id}'][value='22/06/2016']") }
|
||||
it { expect(rendered).to have_css("input[type='date'][id='champs_#{champ_datetime.id}'][value='22/06/2016']") }
|
||||
it { expect(rendered).to have_css("option[value='12'][selected='selected']") }
|
||||
it { expect(rendered).to have_css("option[value='05'][selected='selected']") }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue