Merge branch 'staging'
This commit is contained in:
commit
a6708ce1f0
411 changed files with 2720 additions and 2129 deletions
70
.circleci/config.yml
Normal file
70
.circleci/config.yml
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
version: 2
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
docker:
|
||||||
|
- image: ruby:2.3.1
|
||||||
|
- image: postgres:9.4.1
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: tps_test
|
||||||
|
POSTGRES_PASSWORD: tps_test
|
||||||
|
POSTGRES_DB: tps_test
|
||||||
|
|
||||||
|
working_directory: /tps
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: Install System Dependencies
|
||||||
|
command: apt-get update -qq && apt-get install -y build-essential nodejs
|
||||||
|
- restore_cache:
|
||||||
|
key: bundle-install-v3-{{ checksum "Gemfile.lock" }}
|
||||||
|
- run:
|
||||||
|
name: Install Ruby Dependencies
|
||||||
|
command: bundle install
|
||||||
|
- save_cache:
|
||||||
|
key: bundle-install-v3-{{ checksum "Gemfile.lock" }}
|
||||||
|
paths:
|
||||||
|
- /usr/local/bundle
|
||||||
|
- restore_cache:
|
||||||
|
key: phantomjs-2-1-1
|
||||||
|
- run:
|
||||||
|
name: Install PhantomJS Dependencies
|
||||||
|
command: |
|
||||||
|
[ -f /usr/local/bin/phantomjs ] || apt-get update
|
||||||
|
[ -f /usr/local/bin/phantomjs ] || apt-get install -y fontconfig wget
|
||||||
|
- run:
|
||||||
|
name: Install PhantomJS
|
||||||
|
command: |
|
||||||
|
[ -f /usr/local/bin/phantomjs ] || wget -O /tmp/phantomjs.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
|
||||||
|
[ -f /usr/local/bin/phantomjs ] || tar -xjf /tmp/phantomjs.tar.bz2 -C /tmp
|
||||||
|
[ -f /usr/local/bin/phantomjs ] || mv /tmp/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
|
||||||
|
- save_cache:
|
||||||
|
key: phantomjs-2-1-1
|
||||||
|
paths:
|
||||||
|
- /usr/local/bin/phantomjs
|
||||||
|
- run:
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: "postgres://tps_test@localhost:5432/tps_test"
|
||||||
|
name: Create DB
|
||||||
|
command: bundle exec rake db:create db:schema:load db:migrate RAILS_ENV=test
|
||||||
|
- run:
|
||||||
|
environment:
|
||||||
|
DATABASE_URL: "postgres://tps_test@localhost:5432/tps_test"
|
||||||
|
name: Run Tests, Splitted by Timings
|
||||||
|
command: |
|
||||||
|
TESTFILES=$(circleci tests glob "spec/**/*.rb"| xargs -n 1 echo | grep -v "spec/factories/" | tr " " "\n" | circleci tests split --split-by=timings)
|
||||||
|
bundle exec rspec --color --require spec_helper -- ${TESTFILES}
|
||||||
|
- run:
|
||||||
|
name: Run haml-lint
|
||||||
|
command: bundle exec haml-lint app/views/
|
||||||
|
- add_ssh_keys:
|
||||||
|
fingerprints:
|
||||||
|
- "0a:67:42:7d:7e:b7:e1:3c:48:8f:bf:68:10:51:a8:44"
|
||||||
|
- deploy:
|
||||||
|
command: |
|
||||||
|
if [ "${CIRCLE_BRANCH}" == "staging" ]; then
|
||||||
|
bundle exec rake deploy_ha
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${CIRCLE_BRANCH}" == "master" ]; then
|
||||||
|
bundle exec rake deploy_ha to=production
|
||||||
|
fi
|
11
.editorconfig
Normal file
11
.editorconfig
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.{haml,html,js,scss,rake,rb,yml}]
|
||||||
|
charset = utf-8
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
trim_trailing_whitespace = true
|
119
.haml-lint.yml
Normal file
119
.haml-lint.yml
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
linters:
|
||||||
|
AlignmentTabs:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
AltText:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
ClassAttributeWithStaticValue:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
ClassesBeforeIds:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
ConsecutiveComments:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
ConsecutiveSilentScripts:
|
||||||
|
enabled: false
|
||||||
|
max_consecutive: 2
|
||||||
|
|
||||||
|
EmptyObjectReference:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
EmptyScript:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
FinalNewline:
|
||||||
|
enabled: true
|
||||||
|
present: true
|
||||||
|
|
||||||
|
HtmlAttributes:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
IdNames:
|
||||||
|
enabled: false
|
||||||
|
style: lisp_case
|
||||||
|
|
||||||
|
ImplicitDiv:
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
Indentation:
|
||||||
|
enabled: true
|
||||||
|
character: space # or tab
|
||||||
|
width: 2 # ignored if character == tab
|
||||||
|
|
||||||
|
InstanceVariables:
|
||||||
|
enabled: false
|
||||||
|
file_types: partials
|
||||||
|
matchers:
|
||||||
|
all: .*
|
||||||
|
partials: \A_.*\.haml\z
|
||||||
|
|
||||||
|
LeadingCommentSpace:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
LineLength:
|
||||||
|
enabled: false
|
||||||
|
max: 80
|
||||||
|
|
||||||
|
MultilinePipe:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
MultilineScript:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
ObjectReferenceAttributes:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
RepeatedId:
|
||||||
|
enabled: false
|
||||||
|
severity: error
|
||||||
|
|
||||||
|
RuboCop:
|
||||||
|
enabled: false
|
||||||
|
# These cops are incredibly noisy when it comes to HAML templates, so we
|
||||||
|
# ignore them.
|
||||||
|
ignored_cops:
|
||||||
|
- Lint/BlockAlignment
|
||||||
|
- Lint/EndAlignment
|
||||||
|
- Lint/Void
|
||||||
|
- Metrics/BlockLength
|
||||||
|
- Metrics/LineLength
|
||||||
|
- Style/AlignParameters
|
||||||
|
- Style/BlockNesting
|
||||||
|
- Style/ElseAlignment
|
||||||
|
- Style/EndOfLine
|
||||||
|
- Style/FileName
|
||||||
|
- Style/FinalNewline
|
||||||
|
- Style/FrozenStringLiteralComment
|
||||||
|
- Style/IfUnlessModifier
|
||||||
|
- Style/IndentationWidth
|
||||||
|
- Style/Next
|
||||||
|
- Style/TrailingBlankLines
|
||||||
|
- Style/TrailingWhitespace
|
||||||
|
- Style/WhileUntilModifier
|
||||||
|
|
||||||
|
RubyComments:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
SpaceBeforeScript:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
SpaceInsideHashAttributes:
|
||||||
|
enabled: true
|
||||||
|
style: space
|
||||||
|
|
||||||
|
TagName:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
TrailingWhitespace:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
UnnecessaryInterpolation:
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Disabled because too agressive, but to enable
|
||||||
|
# locally from time to time
|
||||||
|
UnnecessaryStringOutput:
|
||||||
|
enabled: false
|
9
Gemfile
9
Gemfile
|
@ -16,7 +16,7 @@ gem 'therubyracer', platforms: :ruby
|
||||||
# Use jquery as the JavaScript library
|
# Use jquery as the JavaScript library
|
||||||
gem 'jquery-rails'
|
gem 'jquery-rails'
|
||||||
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
||||||
gem 'turbolinks', '~> 2.5'
|
gem 'turbolinks', '~> 5.0'
|
||||||
# bundle exec rake doc:rails generates the API under doc/api.
|
# bundle exec rake doc:rails generates the API under doc/api.
|
||||||
gem 'sdoc', '~> 0.4.0', group: :doc
|
gem 'sdoc', '~> 0.4.0', group: :doc
|
||||||
|
|
||||||
|
@ -93,6 +93,8 @@ gem 'simple_form'
|
||||||
|
|
||||||
gem 'newrelic_rpm'
|
gem 'newrelic_rpm'
|
||||||
|
|
||||||
|
gem 'scenic'
|
||||||
|
|
||||||
# Sidekiq
|
# Sidekiq
|
||||||
gem 'sidekiq'
|
gem 'sidekiq'
|
||||||
gem 'sidekiq-cron', '~> 0.4.4'
|
gem 'sidekiq-cron', '~> 0.4.4'
|
||||||
|
@ -114,7 +116,6 @@ group :test do
|
||||||
gem 'guard-livereload', '~> 2.4', require: false
|
gem 'guard-livereload', '~> 2.4', require: false
|
||||||
gem 'vcr'
|
gem 'vcr'
|
||||||
gem 'rails-controller-testing'
|
gem 'rails-controller-testing'
|
||||||
gem 'sqlite3'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
|
@ -122,6 +123,7 @@ group :development do
|
||||||
gem 'web-console'
|
gem 'web-console'
|
||||||
gem 'rack-handlers'
|
gem 'rack-handlers'
|
||||||
gem 'xray-rails'
|
gem 'xray-rails'
|
||||||
|
gem 'haml-lint'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
|
@ -145,6 +147,3 @@ group :production, :staging do
|
||||||
gem 'sentry-raven'
|
gem 'sentry-raven'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :production, :staging, :development do
|
|
||||||
gem 'scenic'
|
|
||||||
end
|
|
||||||
|
|
58
Gemfile.lock
58
Gemfile.lock
|
@ -69,7 +69,7 @@ GEM
|
||||||
i18n (~> 0.7)
|
i18n (~> 0.7)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
addressable (2.5.0)
|
addressable (2.5.1)
|
||||||
public_suffix (~> 2.0, >= 2.0.2)
|
public_suffix (~> 2.0, >= 2.0.2)
|
||||||
apipie-rails (0.3.7)
|
apipie-rails (0.3.7)
|
||||||
json
|
json
|
||||||
|
@ -78,6 +78,7 @@ GEM
|
||||||
actionpack (>= 3.0)
|
actionpack (>= 3.0)
|
||||||
activemodel (>= 3.0)
|
activemodel (>= 3.0)
|
||||||
responders
|
responders
|
||||||
|
ast (2.3.0)
|
||||||
attr_required (1.0.1)
|
attr_required (1.0.1)
|
||||||
autoprefixer-rails (6.5.4)
|
autoprefixer-rails (6.5.4)
|
||||||
execjs
|
execjs
|
||||||
|
@ -95,9 +96,9 @@ GEM
|
||||||
bootstrap-wysihtml5-rails (0.3.3.8)
|
bootstrap-wysihtml5-rails (0.3.3.8)
|
||||||
railties (>= 3.0)
|
railties (>= 3.0)
|
||||||
browser (2.3.0)
|
browser (2.3.0)
|
||||||
builder (3.2.2)
|
builder (3.2.3)
|
||||||
byebug (9.0.6)
|
byebug (9.0.6)
|
||||||
capybara (2.11.0)
|
capybara (2.13.0)
|
||||||
addressable
|
addressable
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
nokogiri (>= 1.3.3)
|
nokogiri (>= 1.3.3)
|
||||||
|
@ -120,8 +121,8 @@ GEM
|
||||||
coffee-script (2.4.1)
|
coffee-script (2.4.1)
|
||||||
coffee-script-source
|
coffee-script-source
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.11.1)
|
coffee-script-source (1.12.2)
|
||||||
concurrent-ruby (1.0.2)
|
concurrent-ruby (1.0.5)
|
||||||
connection_pool (2.2.1)
|
connection_pool (2.2.1)
|
||||||
crack (0.4.3)
|
crack (0.4.3)
|
||||||
safe_yaml (~> 1.0.0)
|
safe_yaml (~> 1.0.0)
|
||||||
|
@ -313,12 +314,20 @@ GEM
|
||||||
rspec (>= 2.99.0, < 4.0)
|
rspec (>= 2.99.0, < 4.0)
|
||||||
haml (4.0.7)
|
haml (4.0.7)
|
||||||
tilt
|
tilt
|
||||||
|
haml-lint (0.999.999)
|
||||||
|
haml_lint
|
||||||
haml-rails (0.9.0)
|
haml-rails (0.9.0)
|
||||||
actionpack (>= 4.0.1)
|
actionpack (>= 4.0.1)
|
||||||
activesupport (>= 4.0.1)
|
activesupport (>= 4.0.1)
|
||||||
haml (>= 4.0.6, < 5.0)
|
haml (>= 4.0.6, < 5.0)
|
||||||
html2haml (>= 1.0.1)
|
html2haml (>= 1.0.1)
|
||||||
railties (>= 4.0.1)
|
railties (>= 4.0.1)
|
||||||
|
haml_lint (0.24.0)
|
||||||
|
haml (>= 4.0, < 5.1)
|
||||||
|
rainbow
|
||||||
|
rake (>= 10, < 13)
|
||||||
|
rubocop (>= 0.47.0)
|
||||||
|
sysexits (~> 1.1)
|
||||||
hashdiff (0.3.1)
|
hashdiff (0.3.1)
|
||||||
hashie (3.4.6)
|
hashie (3.4.6)
|
||||||
html2haml (2.0.0)
|
html2haml (2.0.0)
|
||||||
|
@ -331,7 +340,7 @@ GEM
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
http_parser.rb (0.6.0)
|
http_parser.rb (0.6.0)
|
||||||
httpclient (2.8.3)
|
httpclient (2.8.3)
|
||||||
i18n (0.7.0)
|
i18n (0.8.1)
|
||||||
inflecto (0.0.2)
|
inflecto (0.0.2)
|
||||||
ipaddress (0.8.3)
|
ipaddress (0.8.3)
|
||||||
jquery-rails (4.2.1)
|
jquery-rails (4.2.1)
|
||||||
|
@ -412,11 +421,14 @@ GEM
|
||||||
openstack (3.3.7)
|
openstack (3.3.7)
|
||||||
json
|
json
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
|
parser (2.4.0.0)
|
||||||
|
ast (~> 2.2)
|
||||||
pg (0.19.0)
|
pg (0.19.0)
|
||||||
poltergeist (1.12.0)
|
poltergeist (1.14.0)
|
||||||
capybara (~> 2.1)
|
capybara (~> 2.1)
|
||||||
cliver (~> 0.3.1)
|
cliver (~> 0.3.1)
|
||||||
websocket-driver (>= 0.2.0)
|
websocket-driver (>= 0.2.0)
|
||||||
|
powerpack (0.1.1)
|
||||||
pry (0.10.4)
|
pry (0.10.4)
|
||||||
coderay (~> 1.1.0)
|
coderay (~> 1.1.0)
|
||||||
method_source (~> 0.8.1)
|
method_source (~> 0.8.1)
|
||||||
|
@ -424,7 +436,7 @@ GEM
|
||||||
pry-byebug (3.4.2)
|
pry-byebug (3.4.2)
|
||||||
byebug (~> 9.0)
|
byebug (~> 9.0)
|
||||||
pry (~> 0.10)
|
pry (~> 0.10)
|
||||||
public_suffix (2.0.4)
|
public_suffix (2.0.5)
|
||||||
rack (2.0.1)
|
rack (2.0.1)
|
||||||
rack-handlers (0.7.3)
|
rack-handlers (0.7.3)
|
||||||
rack
|
rack
|
||||||
|
@ -452,9 +464,9 @@ GEM
|
||||||
actionpack (~> 5.x)
|
actionpack (~> 5.x)
|
||||||
actionview (~> 5.x)
|
actionview (~> 5.x)
|
||||||
activesupport (~> 5.x)
|
activesupport (~> 5.x)
|
||||||
rails-dom-testing (2.0.1)
|
rails-dom-testing (2.0.2)
|
||||||
activesupport (>= 4.2.0, < 6.0)
|
activesupport (>= 4.2.0, < 6.0)
|
||||||
nokogiri (~> 1.6.0)
|
nokogiri (~> 1.6)
|
||||||
rails-html-sanitizer (1.0.3)
|
rails-html-sanitizer (1.0.3)
|
||||||
loofah (~> 2.0)
|
loofah (~> 2.0)
|
||||||
railties (5.0.0.1)
|
railties (5.0.0.1)
|
||||||
|
@ -463,6 +475,7 @@ GEM
|
||||||
method_source
|
method_source
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.18.1, < 2.0)
|
thor (>= 0.18.1, < 2.0)
|
||||||
|
rainbow (2.2.1)
|
||||||
raindrops (0.17.0)
|
raindrops (0.17.0)
|
||||||
rake (12.0.0)
|
rake (12.0.0)
|
||||||
rb-fsevent (0.9.8)
|
rb-fsevent (0.9.8)
|
||||||
|
@ -513,6 +526,13 @@ GEM
|
||||||
rspec-mocks (~> 3.5.0)
|
rspec-mocks (~> 3.5.0)
|
||||||
rspec-support (~> 3.5.0)
|
rspec-support (~> 3.5.0)
|
||||||
rspec-support (3.5.0)
|
rspec-support (3.5.0)
|
||||||
|
rubocop (0.48.1)
|
||||||
|
parser (>= 2.3.3.1, < 3.0)
|
||||||
|
powerpack (~> 0.1)
|
||||||
|
rainbow (>= 1.99.1, < 3.0)
|
||||||
|
ruby-progressbar (~> 1.7)
|
||||||
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||||
|
ruby-progressbar (1.8.1)
|
||||||
ruby_dep (1.5.0)
|
ruby_dep (1.5.0)
|
||||||
ruby_parser (3.8.3)
|
ruby_parser (3.8.3)
|
||||||
sexp_processor (~> 4.1)
|
sexp_processor (~> 4.1)
|
||||||
|
@ -574,30 +594,32 @@ GEM
|
||||||
actionpack (>= 4.0)
|
actionpack (>= 4.0)
|
||||||
activesupport (>= 4.0)
|
activesupport (>= 4.0)
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
sqlite3 (1.3.13)
|
|
||||||
swd (1.0.1)
|
swd (1.0.1)
|
||||||
activesupport (>= 3)
|
activesupport (>= 3)
|
||||||
attr_required (>= 0.0.5)
|
attr_required (>= 0.0.5)
|
||||||
httpclient (>= 2.4)
|
httpclient (>= 2.4)
|
||||||
i18n
|
i18n
|
||||||
json (>= 1.4.3)
|
json (>= 1.4.3)
|
||||||
|
sysexits (1.2.0)
|
||||||
therubyracer (0.12.2)
|
therubyracer (0.12.2)
|
||||||
libv8 (~> 3.16.14.0)
|
libv8 (~> 3.16.14.0)
|
||||||
ref
|
ref
|
||||||
thor (0.19.4)
|
thor (0.19.4)
|
||||||
thread_safe (0.3.5)
|
thread_safe (0.3.6)
|
||||||
tilt (2.0.5)
|
tilt (2.0.5)
|
||||||
timecop (0.8.1)
|
timecop (0.8.1)
|
||||||
trollop (2.1.2)
|
trollop (2.1.2)
|
||||||
turbolinks (2.5.3)
|
turbolinks (5.0.1)
|
||||||
coffee-rails
|
turbolinks-source (~> 5)
|
||||||
tzinfo (1.2.2)
|
turbolinks-source (5.0.0)
|
||||||
|
tzinfo (1.2.3)
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
uglifier (3.0.4)
|
uglifier (3.0.4)
|
||||||
execjs (>= 0.3.0, < 3)
|
execjs (>= 0.3.0, < 3)
|
||||||
unf (0.1.4)
|
unf (0.1.4)
|
||||||
unf_ext
|
unf_ext
|
||||||
unf_ext (0.0.7.2)
|
unf_ext (0.0.7.2)
|
||||||
|
unicode-display_width (1.1.3)
|
||||||
unicode_utils (1.4.0)
|
unicode_utils (1.4.0)
|
||||||
unicorn (5.2.0)
|
unicorn (5.2.0)
|
||||||
kgio (~> 2.6)
|
kgio (~> 2.6)
|
||||||
|
@ -625,7 +647,7 @@ GEM
|
||||||
addressable (>= 2.3.6)
|
addressable (>= 2.3.6)
|
||||||
crack (>= 0.3.2)
|
crack (>= 0.3.2)
|
||||||
hashdiff
|
hashdiff
|
||||||
websocket-driver (0.6.4)
|
websocket-driver (0.6.5)
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-extensions (0.1.2)
|
websocket-extensions (0.1.2)
|
||||||
will_paginate (3.1.5)
|
will_paginate (3.1.5)
|
||||||
|
@ -666,6 +688,7 @@ DEPENDENCIES
|
||||||
guard
|
guard
|
||||||
guard-livereload (~> 2.4)
|
guard-livereload (~> 2.4)
|
||||||
guard-rspec
|
guard-rspec
|
||||||
|
haml-lint
|
||||||
haml-rails
|
haml-rails
|
||||||
hashie
|
hashie
|
||||||
jquery-rails
|
jquery-rails
|
||||||
|
@ -704,10 +727,9 @@ DEPENDENCIES
|
||||||
spreadsheet_architect
|
spreadsheet_architect
|
||||||
spring
|
spring
|
||||||
spring-commands-rspec
|
spring-commands-rspec
|
||||||
sqlite3
|
|
||||||
therubyracer
|
therubyracer
|
||||||
timecop
|
timecop
|
||||||
turbolinks (~> 2.5)
|
turbolinks (~> 5.0)
|
||||||
uglifier (>= 1.3.0)
|
uglifier (>= 1.3.0)
|
||||||
unicode_utils
|
unicode_utils
|
||||||
unicorn
|
unicorn
|
||||||
|
|
|
@ -73,6 +73,7 @@ guard :rspec, cmd: 'spring rspec' do
|
||||||
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
||||||
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
||||||
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
||||||
|
watch(%r{^app/services/(.+)_(service)\.rb$}) { |m| "spec/services/#{m[1]}_service_spec.rb" }
|
||||||
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
||||||
watch('config/routes.rb') { "spec/routing" }
|
watch('config/routes.rb') { "spec/routing" }
|
||||||
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
||||||
|
|
35
README.md
35
README.md
|
@ -2,13 +2,18 @@
|
||||||
|
|
||||||
## Context
|
## Context
|
||||||
|
|
||||||
TéléProcédure Simplifiée, ou TPS pour les intimes, est une plateforme 100% web et 0% email, conçue afin de répondre au besoin urgent de l'État d'appliquer la directive sur le 100% démat' à l'horizon 2018 pour les démarches administratives.
|
TéléProcédure Simplifiée, ou TPS pour les intimes, est une plateforme 100 % web et 0 % email, conçue afin de répondre au besoin urgent de l'État d'appliquer la directive sur le 100 % démat' à l'horizon 2018 pour les démarches administratives.
|
||||||
|
|
||||||
|
|
||||||
## Technologies utilisées
|
## Dépendances
|
||||||
|
|
||||||
Ruby : 2.3.1
|
### Tous environnements
|
||||||
Rails : 5.0.0.1
|
|
||||||
|
- postgresql
|
||||||
|
|
||||||
|
### Tests
|
||||||
|
|
||||||
|
- PhantomJS
|
||||||
|
|
||||||
|
|
||||||
## Initialisation de l'environnement de développement
|
## Initialisation de l'environnement de développement
|
||||||
|
@ -20,32 +25,23 @@ Afin d'initialiser l'environnement de développement, éxécutez la commande sui
|
||||||
|
|
||||||
## Création de la base de données
|
## Création de la base de données
|
||||||
|
|
||||||
L'application utilise une base de donnée Postgresql. Pour en installer une, utilisez la commande suivante :
|
|
||||||
|
|
||||||
sudo apt-get install postgresql
|
|
||||||
|
|
||||||
Les informations nécessaire à l'initialisation de la base doivent être pré-configurées à la main grâce à la procédure suivante :
|
Les informations nécessaire à l'initialisation de la base doivent être pré-configurées à la main grâce à la procédure suivante :
|
||||||
|
|
||||||
su - postgres
|
su - postgres
|
||||||
psql
|
psql
|
||||||
> create user tps with password 'lol' superuser;
|
> create user tps_development with password 'tps_development' superuser;
|
||||||
|
> create user tps_test with password 'tps_test' superuser;
|
||||||
> \q
|
> \q
|
||||||
|
|
||||||
|
|
||||||
Afin de générer la BDD de l'application, il est nécessaire d'éxécuter les commandes suivantes :
|
Afin de générer la BDD de l'application, il est nécessaire d'éxécuter les commandes suivantes :
|
||||||
|
|
||||||
rake db:create db:schema:load db:migrate
|
rake db:create db:schema:load db:migrate
|
||||||
rake db:create db:schema:load db:migrate RAILS_ENV=test
|
rake db:create db:schema:load db:migrate RAILS_ENV=test
|
||||||
|
|
||||||
|
|
||||||
## Installation de Phantom JS
|
## Exécution des tests (RSpec)
|
||||||
|
|
||||||
Installer PhantomJS qui est utilisé par les tests automatisés de l'application.
|
Pour exécuter les tests de l'application, plusieurs possibilités :
|
||||||
|
|
||||||
|
|
||||||
## Exécution des tests (Rspec)
|
|
||||||
|
|
||||||
Pour éxécuter les tests de l'application, plusieurs possibilités :
|
|
||||||
|
|
||||||
- Lancer tous les tests
|
- Lancer tous les tests
|
||||||
|
|
||||||
|
@ -62,8 +58,11 @@ Pour éxécuter les tests de l'application, plusieurs possibilités :
|
||||||
rake spec SPEC=file_path/file_name_spec.rb
|
rake spec SPEC=file_path/file_name_spec.rb
|
||||||
rspec file_path/file_name_spec.rb
|
rspec file_path/file_name_spec.rb
|
||||||
|
|
||||||
|
## Linting
|
||||||
|
|
||||||
## Regénérer les binstubs
|
- Linter les fichiers HAML : `bundle exec haml-lint app/views/`
|
||||||
|
|
||||||
|
## Régénérer les binstubs
|
||||||
|
|
||||||
bundle binstub railties --force
|
bundle binstub railties --force
|
||||||
rake rails:update:bin
|
rake rails:update:bin
|
||||||
|
|
BIN
app/assets/images/landing/users/Pilat.sketch
Normal file
BIN
app/assets/images/landing/users/Pilat.sketch
Normal file
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 176 KiB |
Binary file not shown.
Before Width: | Height: | Size: 35 KiB |
Binary file not shown.
Before Width: | Height: | Size: 24 KiB |
Binary file not shown.
Before Width: | Height: | Size: 10 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
|
@ -1,5 +1,4 @@
|
||||||
$(document).on('page:load', init_action_btn_rules);
|
$(document).on('turbolinks:load', init_action_btn_rules);
|
||||||
$(document).ready(init_action_btn_rules);
|
|
||||||
|
|
||||||
function init_action_btn_rules() {
|
function init_action_btn_rules() {
|
||||||
$('.btn-send').click(function () {
|
$('.btn-send').click(function () {
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
function address_type_init() {
|
function address_type_init() {
|
||||||
display = 'label';
|
display = 'label';
|
||||||
|
|
||||||
var bloodhound = new Bloodhound({
|
var bloodhound = new Bloodhound({
|
||||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(display),
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(display),
|
||||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
|
|
||||||
remote: {
|
remote: {
|
||||||
url: '/ban/search?request=%QUERY',
|
url: '/ban/search?request=%QUERY',
|
||||||
wildcard: '%QUERY'
|
wildcard: '%QUERY'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bloodhound.initialize();
|
bloodhound.initialize();
|
||||||
|
|
||||||
$("input[type='address']").typeahead({
|
$("input[type='address']").typeahead({
|
||||||
minLength: 1
|
minLength: 1
|
||||||
}, {
|
}, {
|
||||||
display: display,
|
display: display,
|
||||||
source: bloodhound,
|
source: bloodhound,
|
||||||
limit: 5
|
limit: 5
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +1,46 @@
|
||||||
$(document).on('page:load', init_admin);
|
$(document).on('turbolinks:load', init_admin);
|
||||||
$(document).ready(init_admin);
|
|
||||||
|
|
||||||
function init_admin(){
|
function init_admin(){
|
||||||
destroy_action();
|
destroy_action();
|
||||||
on_change_type_de_champ_select();
|
on_change_type_de_champ_select();
|
||||||
}
|
}
|
||||||
|
|
||||||
function destroy_action(){
|
function destroy_action(){
|
||||||
$(".delete").on('click', function(){
|
$(".delete").on('click', function(){
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$(this).closest('td').find(".confirm").show();
|
$(this).closest('td').find(".confirm").show();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".cancel").on('click', function(){
|
$(".cancel").on('click', function(){
|
||||||
$(this).closest('td').find(".delete").show();
|
$(this).closest('td').find(".delete").show();
|
||||||
$(this).closest('td').find(".confirm").hide();
|
$(this).closest('td').find(".confirm").hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#liste_gestionnaire #libelle").on('click', function(){
|
$("#liste_gestionnaire #libelle").on('click', function(){
|
||||||
setTimeout(destroy_action, 500);
|
setTimeout(destroy_action, 500);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function on_change_type_de_champ_select (){
|
function on_change_type_de_champ_select (){
|
||||||
$("select.form-control.type_champ").on('change', function(e){
|
$("select.form-control.type_champ").on('change', function(e){
|
||||||
|
|
||||||
parent = $(this).parent().parent();
|
parent = $(this).parent().parent();
|
||||||
|
|
||||||
parent.removeClass('header_section');
|
parent.removeClass('header_section');
|
||||||
parent.children(".drop_down_list").removeClass('show_inline');
|
parent.children(".drop_down_list").removeClass('show_inline');
|
||||||
$('.mandatory', parent).show();
|
$('.mandatory', parent).show();
|
||||||
|
|
||||||
switch(this.value){
|
switch(this.value){
|
||||||
case 'header_section':
|
case 'header_section':
|
||||||
parent.addClass('header_section');
|
parent.addClass('header_section');
|
||||||
break;
|
break;
|
||||||
case 'drop_down_list':
|
case 'drop_down_list':
|
||||||
case 'multiple_drop_down_list':
|
case 'multiple_drop_down_list':
|
||||||
parent.children(".drop_down_list").addClass('show_inline');
|
parent.children(".drop_down_list").addClass('show_inline');
|
||||||
break;
|
break;
|
||||||
case 'explication':
|
case 'explication':
|
||||||
$('.mandatory', parent).hide();
|
$('.mandatory', parent).hide();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,98 +1,97 @@
|
||||||
$(document).on('page:load', init_path_modal);
|
$(document).on('turbolinks:load', init_path_modal);
|
||||||
$(document).ready(init_path_modal);
|
|
||||||
|
|
||||||
function init_path_modal() {
|
function init_path_modal() {
|
||||||
path_modal_action();
|
path_modal_action();
|
||||||
path_validation_action();
|
path_validation_action();
|
||||||
path_type_init();
|
path_type_init();
|
||||||
path_validation($("input[id='procedure_path']"));
|
path_validation($("input[id='procedure_path']"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function path_modal_action() {
|
function path_modal_action() {
|
||||||
$('#publishModal').on('show.bs.modal', function (event) {
|
$('#publishModal').on('show.bs.modal', function (event) {
|
||||||
$("#publishModal .modal-body .table .tr_content").hide();
|
$("#publishModal .modal-body .table .tr_content").hide();
|
||||||
|
|
||||||
var button = $(event.relatedTarget) // Button that triggered the modal
|
var button = $(event.relatedTarget) // Button that triggered the modal
|
||||||
var modal_title = button.data('modal_title'); // Extract info from data-* attributes
|
var modal_title = button.data('modal_title'); // Extract info from data-* attributes
|
||||||
var modal_index = button.data('modal_index'); // Extract info from data-* attributes
|
var modal_index = button.data('modal_index'); // Extract info from data-* attributes
|
||||||
|
|
||||||
var modal = $(this)
|
var modal = $(this)
|
||||||
modal.find('#publishModal_title').html(modal_title);
|
modal.find('#publishModal_title').html(modal_title);
|
||||||
$("#publishModal .modal-body .table #"+modal_index).show();
|
$("#publishModal .modal-body .table #"+modal_index).show();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function path_validation_action() {
|
function path_validation_action() {
|
||||||
$("input[id='procedure_path']").keyup(function (key) {
|
$("input[id='procedure_path']").keyup(function (key) {
|
||||||
if (key.keyCode != 13)
|
if (key.keyCode != 13)
|
||||||
path_validation(this);
|
path_validation(this);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function togglePathMessage(valid, mine) {
|
function togglePathMessage(valid, mine) {
|
||||||
$('#path_messages .message').hide();
|
$('#path_messages .message').hide();
|
||||||
|
|
||||||
if (valid === true && mine === true) {
|
if (valid === true && mine === true) {
|
||||||
$('#path_is_mine').show();
|
$('#path_is_mine').show();
|
||||||
} else if (valid === true && mine === false) {
|
} else if (valid === true && mine === false) {
|
||||||
$('#path_is_not_mine').show();
|
$('#path_is_not_mine').show();
|
||||||
} else if (valid === false && mine === null) {
|
} else if (valid === false && mine === null) {
|
||||||
$('#path_is_invalid').show();
|
$('#path_is_invalid').show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((valid && mine === null) || mine === true)
|
if ((valid && mine === null) || mine === true)
|
||||||
$('#publishModal #publish').removeAttr('disabled')
|
$('#publishModal #publish').removeAttr('disabled')
|
||||||
else
|
else
|
||||||
$('#publishModal #publish').attr('disabled', 'disabled')
|
$('#publishModal #publish').attr('disabled', 'disabled')
|
||||||
}
|
}
|
||||||
|
|
||||||
function path_validation(el) {
|
function path_validation(el) {
|
||||||
var valid = validatePath($(el).val());
|
var valid = validatePath($(el).val());
|
||||||
toggleErrorClass(el, valid);
|
toggleErrorClass(el, valid);
|
||||||
togglePathMessage(valid, null);
|
togglePathMessage(valid, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function validatePath(path) {
|
function validatePath(path) {
|
||||||
var re = /^[a-z0-9_]{3,30}$/;
|
var re = /^[a-z0-9_]{3,30}$/;
|
||||||
return re.test(path);
|
return re.test(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
function path_type_init() {
|
function path_type_init() {
|
||||||
display = 'label';
|
display = 'label';
|
||||||
|
|
||||||
var bloodhound = new Bloodhound({
|
var bloodhound = new Bloodhound({
|
||||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(display),
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(display),
|
||||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
|
|
||||||
remote: {
|
remote: {
|
||||||
url: '/admin/procedures/path_list?request=%QUERY',
|
url: '/admin/procedures/path_list?request=%QUERY',
|
||||||
wildcard: '%QUERY'
|
wildcard: '%QUERY'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bloodhound.initialize();
|
bloodhound.initialize();
|
||||||
|
|
||||||
$("#procedure_path").typeahead({
|
$("#procedure_path").typeahead({
|
||||||
minLength: 1
|
minLength: 1
|
||||||
}, {
|
}, {
|
||||||
display: display,
|
display: display,
|
||||||
source: bloodhound,
|
source: bloodhound,
|
||||||
templates: {
|
templates: {
|
||||||
empty: 'Ce lien est disponible !',
|
empty: 'Ce lien est disponible !',
|
||||||
suggestion: Handlebars.compile("<div class='path_mine_{{mine}}'>{{label}}</div>")
|
suggestion: Handlebars.compile("<div class='path_mine_{{mine}}'>{{label}}</div>")
|
||||||
},
|
},
|
||||||
limit: 5
|
limit: 5
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#procedure_path').bind('typeahead:select', function(ev, suggestion) {
|
$('#procedure_path').bind('typeahead:select', function(ev, suggestion) {
|
||||||
togglePathMessage(true, suggestion['mine']);
|
togglePathMessage(true, suggestion['mine']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function transfer_errors_message(show) {
|
function transfer_errors_message(show) {
|
||||||
if(show){
|
if(show){
|
||||||
$("#not_found_admin").slideDown(100)
|
$("#not_found_admin").slideDown(100)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$("#not_found_admin").slideUp(100)
|
$("#not_found_admin").slideUp(100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,26 +33,24 @@
|
||||||
//= require typeahead.bundle
|
//= require typeahead.bundle
|
||||||
//= require select2
|
//= require select2
|
||||||
|
|
||||||
$(document).on('page:load', application_init);
|
$(document).on('turbolinks:load', application_init);
|
||||||
$(document).ready(application_init);
|
|
||||||
|
|
||||||
|
|
||||||
function application_init(){
|
function application_init(){
|
||||||
tooltip_init();
|
tooltip_init();
|
||||||
scroll_to();
|
scroll_to();
|
||||||
}
|
}
|
||||||
|
|
||||||
function tooltip_init() {
|
function tooltip_init() {
|
||||||
$('.action_button[data-toggle="tooltip"]').tooltip({delay: { "show": 100, "hide": 100 }});
|
$('.action_button[data-toggle="tooltip"]').tooltip({delay: { "show": 100, "hide": 100 }});
|
||||||
$('[data-toggle="tooltip"]').tooltip({delay: { "show": 800, "hide": 100 }});
|
$('[data-toggle="tooltip"]').tooltip({delay: { "show": 800, "hide": 100 }});
|
||||||
}
|
}
|
||||||
|
|
||||||
function scroll_to() {
|
function scroll_to() {
|
||||||
$('.js-scrollTo').on('click', function () { // Au clic sur un élément
|
$('.js-scrollTo').on('click', function () { // Au clic sur un élément
|
||||||
var page = $(this).attr('cible'); // Page cible
|
var page = $(this).attr('cible'); // Page cible
|
||||||
var speed = 600; // Durée de l'animation (en ms)
|
var speed = 600; // Durée de l'animation (en ms)
|
||||||
$('html, body').animate({scrollTop: $(page).offset().top - 200}, speed); // Go
|
$('html, body').animate({scrollTop: $(page).offset().top - 200}, speed); // Go
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
$(document).on('page:load', buttons_archived);
|
$(document).on('turbolinks:load', buttons_archived);
|
||||||
$(document).ready(buttons_archived);
|
|
||||||
|
|
||||||
function buttons_archived(){
|
function buttons_archived(){
|
||||||
$("button#archive").on('click', function(){
|
$("button#archive").on('click', function(){
|
||||||
$("button#archive").hide();
|
$("button#archive").hide();
|
||||||
$("#confirm").show();
|
$("#confirm").show();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#confirm #cancel").on('click', function(){
|
$("#confirm #cancel").on('click', function(){
|
||||||
$("button#archive").show();
|
$("button#archive").show();
|
||||||
$("#confirm").hide();
|
$("#confirm").hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
$(document).ready(wysihtml5_active);
|
$(document).on('turbolinks:load', wysihtml5_active);
|
||||||
$(document).on('page:load', wysihtml5_active);
|
|
||||||
|
|
||||||
function wysihtml5_active (){
|
function wysihtml5_active (){
|
||||||
$('.wysihtml5').each(function(i, elem) {
|
$('.wysihtml5').each(function(i, elem) {
|
||||||
$(elem).wysihtml5({ toolbar:{ "fa": true, "link": false, "color": false }, "locale": "fr-FR" });
|
$(elem).wysihtml5({ toolbar:{ "fa": true, "link": false, "color": false }, "locale": "fr-FR" });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
//= require_tree ./channels
|
//= require_tree ./channels
|
||||||
|
|
||||||
//(function() {
|
//(function() {
|
||||||
// this.App || (this.App = {});
|
// this.App || (this.App = {});
|
||||||
//
|
//
|
||||||
// App.cable = ActionCable.createConsumer();
|
// App.cable = ActionCable.createConsumer();
|
||||||
//
|
//
|
||||||
//}).call(this);
|
//}).call(this);
|
||||||
|
|
|
@ -1,60 +1,60 @@
|
||||||
function cadastre_active() {
|
function cadastre_active() {
|
||||||
return $("#map.cadastre").length > 0
|
return $("#map.cadastre").length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_cadastre(coordinates) {
|
function get_cadastre(coordinates) {
|
||||||
if (!cadastre_active())
|
if (!cadastre_active())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var cadastre;
|
var cadastre;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: '/users/dossiers/' + dossier_id + '/carte/cadastre',
|
url: '/users/dossiers/' + dossier_id + '/carte/cadastre',
|
||||||
data: {coordinates: JSON.stringify(coordinates)},
|
data: {coordinates: JSON.stringify(coordinates)},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
async: false
|
async: false
|
||||||
}).done(function (data) {
|
}).done(function (data) {
|
||||||
cadastre = data
|
cadastre = data
|
||||||
});
|
});
|
||||||
|
|
||||||
return cadastre['cadastres'];
|
return cadastre['cadastres'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function display_cadastre(cadastre_array) {
|
function display_cadastre(cadastre_array) {
|
||||||
if (!cadastre_active())
|
if (!cadastre_active())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$("#cadastre.list ul").html('');
|
$("#cadastre.list ul").html('');
|
||||||
new_cadastreLayer();
|
new_cadastreLayer();
|
||||||
|
|
||||||
if (cadastre_array.length == 1 && cadastre_array[0]['zoom_error'])
|
if (cadastre_array.length == 1 && cadastre_array[0]['zoom_error'])
|
||||||
$("#cadastre.list ul").html('<li><b>Merci de dessiner une surface plus petite afin de récupérer les parcelles cadastrales.</b></li>');
|
$("#cadastre.list ul").html('<li><b>Merci de dessiner une surface plus petite afin de récupérer les parcelles cadastrales.</b></li>');
|
||||||
|
|
||||||
else if (cadastre_array.length > 0) {
|
else if (cadastre_array.length > 0) {
|
||||||
cadastre_array.forEach(function (cadastre) {
|
cadastre_array.forEach(function (cadastre) {
|
||||||
$("#cadastre.list ul").append('<li> Parcelle n°' + cadastre.numero + ' - Feuille ' + cadastre.code_arr + ' ' + cadastre.section + ' ' + cadastre.feuille+ '</li>');
|
$("#cadastre.list ul").append('<li> Parcelle n°' + cadastre.numero + ' - Feuille ' + cadastre.code_arr + ' ' + cadastre.section + ' ' + cadastre.feuille+ '</li>');
|
||||||
|
|
||||||
cadastreItems.addData(cadastre.geometry);
|
cadastreItems.addData(cadastre.geometry);
|
||||||
});
|
});
|
||||||
|
|
||||||
cadastreItems.setStyle({
|
cadastreItems.setStyle({
|
||||||
fillColor: '#8a6d3b',
|
fillColor: '#8a6d3b',
|
||||||
weight: 2,
|
weight: 2,
|
||||||
opacity: 0.3,
|
opacity: 0.3,
|
||||||
color: 'white',
|
color: 'white',
|
||||||
dashArray: '3',
|
dashArray: '3',
|
||||||
fillOpacity: 0.7
|
fillOpacity: 0.7
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$("#cadastre.list ul").html('<li>AUCUN</li>');
|
$("#cadastre.list ul").html('<li>AUCUN</li>');
|
||||||
}
|
}
|
||||||
|
|
||||||
function new_cadastreLayer() {
|
function new_cadastreLayer() {
|
||||||
if (typeof cadastreItems != 'undefined')
|
if (typeof cadastreItems != 'undefined')
|
||||||
map.removeLayer(cadastreItems);
|
map.removeLayer(cadastreItems);
|
||||||
|
|
||||||
cadastreItems = new L.GeoJSON();
|
cadastreItems = new L.GeoJSON();
|
||||||
cadastreItems.addTo(map);
|
cadastreItems.addTo(map);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,162 +2,162 @@ var LON = '2.428462';
|
||||||
var LAT = '46.538192';
|
var LAT = '46.538192';
|
||||||
|
|
||||||
function initCarto() {
|
function initCarto() {
|
||||||
OSM = L.tileLayer("http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png", {
|
OSM = L.tileLayer("http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png", {
|
||||||
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||||
|
});
|
||||||
|
|
||||||
|
position = get_position() || default_gestionnaire_position();
|
||||||
|
|
||||||
|
map = L.map("map", {
|
||||||
|
center: new L.LatLng(position.lat, position.lon),
|
||||||
|
zoom: position.zoom,
|
||||||
|
layers: [OSM],
|
||||||
|
scrollWheelZoom: false
|
||||||
|
});
|
||||||
|
|
||||||
|
icon = L.icon({
|
||||||
|
iconUrl: '/assets/marker-icon.png',
|
||||||
|
//shadowUrl: 'leaf-shadow.png',
|
||||||
|
|
||||||
|
iconSize: [34.48, 40], // size of the icon
|
||||||
|
//shadowSize: [50, 64], // size of the shadow
|
||||||
|
iconAnchor: [20, 20] // point of the icon which will correspond to marker's location
|
||||||
|
//shadowAnchor: [4, 62], // the same for the shadow
|
||||||
|
//popupAnchor: [-3, -76] // point from which the popup should open relative to the iconAnchor
|
||||||
|
});
|
||||||
|
|
||||||
|
if (qp_active())
|
||||||
|
display_qp(JSON.parse($("#quartier_prioritaires").val()));
|
||||||
|
|
||||||
|
if (cadastre_active())
|
||||||
|
display_cadastre(JSON.parse($("#cadastres").val()));
|
||||||
|
|
||||||
|
freeDraw = new L.FreeDraw();
|
||||||
|
freeDraw.options.setSmoothFactor(4);
|
||||||
|
freeDraw.options.simplifyPolygon = false;
|
||||||
|
|
||||||
|
map.addLayer(freeDraw);
|
||||||
|
|
||||||
|
if ($("#json_latlngs").val() != '' && $("#json_latlngs").val() != '[]') {
|
||||||
|
map.setZoom(18);
|
||||||
|
|
||||||
|
$.each($.parseJSON($("#json_latlngs").val()), function (i, val) {
|
||||||
|
freeDraw.createPolygon(val);
|
||||||
});
|
});
|
||||||
|
|
||||||
position = get_position() || default_gestionnaire_position();
|
map.fitBounds(freeDraw.polygons[0].getBounds());
|
||||||
|
}
|
||||||
|
else if (position.lat == LAT && position.lon == LON)
|
||||||
|
map.setView(new L.LatLng(position.lat, position.lon), position.zoom);
|
||||||
|
|
||||||
map = L.map("map", {
|
add_event_freeDraw();
|
||||||
center: new L.LatLng(position.lat, position.lon),
|
add_event_search_address();
|
||||||
zoom: position.zoom,
|
|
||||||
layers: [OSM],
|
|
||||||
scrollWheelZoom: false
|
|
||||||
});
|
|
||||||
|
|
||||||
icon = L.icon({
|
|
||||||
iconUrl: '/assets/marker-icon.png',
|
|
||||||
//shadowUrl: 'leaf-shadow.png',
|
|
||||||
|
|
||||||
iconSize: [34.48, 40], // size of the icon
|
|
||||||
//shadowSize: [50, 64], // size of the shadow
|
|
||||||
iconAnchor: [20, 20] // point of the icon which will correspond to marker's location
|
|
||||||
//shadowAnchor: [4, 62], // the same for the shadow
|
|
||||||
//popupAnchor: [-3, -76] // point from which the popup should open relative to the iconAnchor
|
|
||||||
});
|
|
||||||
|
|
||||||
if (qp_active())
|
|
||||||
display_qp(JSON.parse($("#quartier_prioritaires").val()));
|
|
||||||
|
|
||||||
if (cadastre_active())
|
|
||||||
display_cadastre(JSON.parse($("#cadastres").val()));
|
|
||||||
|
|
||||||
freeDraw = new L.FreeDraw();
|
|
||||||
freeDraw.options.setSmoothFactor(4);
|
|
||||||
freeDraw.options.simplifyPolygon = false;
|
|
||||||
|
|
||||||
map.addLayer(freeDraw);
|
|
||||||
|
|
||||||
if ($("#json_latlngs").val() != '' && $("#json_latlngs").val() != '[]') {
|
|
||||||
map.setZoom(18);
|
|
||||||
|
|
||||||
$.each($.parseJSON($("#json_latlngs").val()), function (i, val) {
|
|
||||||
freeDraw.createPolygon(val);
|
|
||||||
});
|
|
||||||
|
|
||||||
map.fitBounds(freeDraw.polygons[0].getBounds());
|
|
||||||
}
|
|
||||||
else if (position.lat == LAT && position.lon == LON)
|
|
||||||
map.setView(new L.LatLng(position.lat, position.lon), position.zoom);
|
|
||||||
|
|
||||||
add_event_freeDraw();
|
|
||||||
add_event_search_address();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_gestionnaire_position() {
|
function default_gestionnaire_position() {
|
||||||
return {lon: LON, lat: LAT, zoom: 5}
|
return {lon: LON, lat: LAT, zoom: 5}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_external_data(latLngs) {
|
function get_external_data(latLngs) {
|
||||||
if (qp_active())
|
if (qp_active())
|
||||||
display_qp(get_qp(latLngs));
|
display_qp(get_qp(latLngs));
|
||||||
|
|
||||||
if (cadastre_active()) {
|
if (cadastre_active()) {
|
||||||
polygons = {"type": "FeatureCollection", "features": []};
|
polygons = {"type": "FeatureCollection", "features": []};
|
||||||
|
|
||||||
for (i = 0; i < latLngs.length; i++)
|
for (i = 0; i < latLngs.length; i++)
|
||||||
polygons.features.push(feature_polygon_latLngs(latLngs[i]))
|
polygons.features.push(feature_polygon_latLngs(latLngs[i]))
|
||||||
|
|
||||||
cadastre_list = [{zoom_error: true}];
|
cadastre_list = [{zoom_error: true}];
|
||||||
|
|
||||||
if (turf_area(polygons) < 300000)
|
if (turf_area(polygons) < 300000)
|
||||||
cadastre_list = get_cadastre(latLngs);
|
cadastre_list = get_cadastre(latLngs);
|
||||||
|
|
||||||
display_cadastre(cadastre_list);
|
display_cadastre(cadastre_list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function feature_polygon_latLngs(coordinates) {
|
function feature_polygon_latLngs(coordinates) {
|
||||||
return ({
|
return ({
|
||||||
"type": "Feature",
|
"type": "Feature",
|
||||||
"properties": {},
|
"properties": {},
|
||||||
"geometry": {
|
"geometry": {
|
||||||
"type": "Polygon",
|
"type": "Polygon",
|
||||||
"coordinates": [
|
"coordinates": [
|
||||||
JSON.parse(L.FreeDraw.Utilities.getJsonPolygons([coordinates]))['latLngs']
|
JSON.parse(L.FreeDraw.Utilities.getJsonPolygons([coordinates]))['latLngs']
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_event_freeDraw() {
|
function add_event_freeDraw() {
|
||||||
freeDraw.on('markers', function (e) {
|
freeDraw.on('markers', function (e) {
|
||||||
$("#json_latlngs").val(JSON.stringify(e.latLngs));
|
$("#json_latlngs").val(JSON.stringify(e.latLngs));
|
||||||
|
|
||||||
add_event_edit();
|
add_event_edit();
|
||||||
|
|
||||||
get_external_data(e.latLngs);
|
get_external_data(e.latLngs);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#map").on('click', function(){
|
$("#map").on('click', function(){
|
||||||
freeDraw.setMode(L.FreeDraw.MODES.VIEW);
|
freeDraw.setMode(L.FreeDraw.MODES.VIEW);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#new").on('click', function (e) {
|
$("#new").on('click', function (e) {
|
||||||
freeDraw.setMode(L.FreeDraw.MODES.CREATE);
|
freeDraw.setMode(L.FreeDraw.MODES.CREATE);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#delete").on('click', function (e) {
|
$("#delete").on('click', function (e) {
|
||||||
freeDraw.setMode(L.FreeDraw.MODES.DELETE);
|
freeDraw.setMode(L.FreeDraw.MODES.DELETE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_event_edit (){
|
function add_event_edit (){
|
||||||
$(".leaflet-container g path").on('click', function (e) {
|
$(".leaflet-container g path").on('click', function (e) {
|
||||||
setTimeout(function(){freeDraw.setMode(L.FreeDraw.MODES.EDIT | L.FreeDraw.MODES.DELETE)}, 50);
|
setTimeout(function(){freeDraw.setMode(L.FreeDraw.MODES.EDIT | L.FreeDraw.MODES.DELETE)}, 50);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_position() {
|
function get_position() {
|
||||||
var position;
|
var position;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/users/dossiers/' + dossier_id + '/carte/position',
|
url: '/users/dossiers/' + dossier_id + '/carte/position',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
async: false
|
async: false
|
||||||
}).done(function (data) {
|
}).done(function (data) {
|
||||||
position = data
|
position = data
|
||||||
});
|
});
|
||||||
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_address_point(request) {
|
function get_address_point(request) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/ban/address_point?request=' + request,
|
url: '/ban/address_point?request=' + request,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
async: true
|
async: true
|
||||||
}).done(function (data) {
|
}).done(function (data) {
|
||||||
if (data.lat != null) {
|
if (data.lat != null) {
|
||||||
map.setView(new L.LatLng(data.lat, data.lon), data.zoom);
|
map.setView(new L.LatLng(data.lat, data.lon), data.zoom);
|
||||||
//L.marker([data.lat, data.lon], {icon: icon}).addTo(map);
|
//L.marker([data.lat, data.lon], {icon: icon}).addTo(map);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function jsObject_to_array(qp_list) {
|
function jsObject_to_array(qp_list) {
|
||||||
return Object.keys(qp_list).map(function (v) {
|
return Object.keys(qp_list).map(function (v) {
|
||||||
return qp_list[v];
|
return qp_list[v];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_event_search_address() {
|
function add_event_search_address() {
|
||||||
$("#search_by_address input[type='address']").bind('typeahead:select', function (ev, seggestion) {
|
$("#search_by_address input[type='address']").bind('typeahead:select', function (ev, seggestion) {
|
||||||
get_address_point(seggestion['label']);
|
get_address_point(seggestion['label']);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#search_by_address input[type='address']").keypress(function (e) {
|
$("#search_by_address input[type='address']").keypress(function (e) {
|
||||||
if (e.keyCode == 13)
|
if (e.keyCode == 13)
|
||||||
get_address_point($(this).val());
|
get_address_point($(this).val());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,60 +1,60 @@
|
||||||
function qp_active() {
|
function qp_active() {
|
||||||
return $("#map.qp").length > 0
|
return $("#map.qp").length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_qp(coordinates) {
|
function get_qp(coordinates) {
|
||||||
if (!qp_active())
|
if (!qp_active())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var qp;
|
var qp;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: '/users/dossiers/' + dossier_id + '/carte/qp',
|
url: '/users/dossiers/' + dossier_id + '/carte/qp',
|
||||||
data: {coordinates: JSON.stringify(coordinates)},
|
data: {coordinates: JSON.stringify(coordinates)},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
async: false
|
async: false
|
||||||
}).done(function (data) {
|
}).done(function (data) {
|
||||||
qp = data
|
qp = data
|
||||||
});
|
});
|
||||||
|
|
||||||
return qp['quartier_prioritaires'];
|
return qp['quartier_prioritaires'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function display_qp(qp_list) {
|
function display_qp(qp_list) {
|
||||||
if (!qp_active())
|
if (!qp_active())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qp_array = jsObject_to_array(qp_list);
|
qp_array = jsObject_to_array(qp_list);
|
||||||
|
|
||||||
$("#qp.list ul").html('');
|
$("#qp.list ul").html('');
|
||||||
|
|
||||||
new_qpLayer();
|
new_qpLayer();
|
||||||
|
|
||||||
if (qp_array.length > 0) {
|
if (qp_array.length > 0) {
|
||||||
qp_array.forEach(function (qp) {
|
qp_array.forEach(function (qp) {
|
||||||
$("#qp.list ul").append('<li>' + qp.commune + ' : ' + qp.nom + '</li>');
|
$("#qp.list ul").append('<li>' + qp.commune + ' : ' + qp.nom + '</li>');
|
||||||
|
|
||||||
qpItems.addData(qp.geometry);
|
qpItems.addData(qp.geometry);
|
||||||
});
|
});
|
||||||
|
|
||||||
qpItems.setStyle({
|
qpItems.setStyle({
|
||||||
fillColor: '#31708f',
|
fillColor: '#31708f',
|
||||||
weight: 2,
|
weight: 2,
|
||||||
opacity: 0.3,
|
opacity: 0.3,
|
||||||
color: 'white',
|
color: 'white',
|
||||||
dashArray: '3',
|
dashArray: '3',
|
||||||
fillOpacity: 0.7
|
fillOpacity: 0.7
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$("#qp.list ul").html('<li>AUCUN</li>');
|
$("#qp.list ul").html('<li>AUCUN</li>');
|
||||||
}
|
}
|
||||||
|
|
||||||
function new_qpLayer() {
|
function new_qpLayer() {
|
||||||
if (typeof qpItems != 'undefined')
|
if (typeof qpItems != 'undefined')
|
||||||
map.removeLayer(qpItems);
|
map.removeLayer(qpItems);
|
||||||
|
|
||||||
qpItems = new L.GeoJSON();
|
qpItems = new L.GeoJSON();
|
||||||
qpItems.addTo(map);
|
qpItems.addTo(map);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
$(document).on('page:load', buttons_anchor);
|
$(document).on('turbolinks:load', buttons_anchor);
|
||||||
$(document).ready(buttons_anchor);
|
|
||||||
|
|
||||||
function buttons_anchor(){
|
function buttons_anchor(){
|
||||||
$("#cgu_menu_block").on('click', 'a', function(){
|
$("#cgu_menu_block").on('click', 'a', function(){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$('html,body').animate({scrollTop:$(this.hash).offset().top-80}, 500);
|
$('html,body').animate({scrollTop:$(this.hash).offset().top-80}, 500);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
//App.messages = App.cable.subscriptions.create('NotificationsChannel', {
|
//App.messages = App.cable.subscriptions.create('NotificationsChannel', {
|
||||||
// received: function (data) {
|
// received: function (data) {
|
||||||
// if (window.location.href.indexOf('backoffice') !== -1) {
|
// if (window.location.href.indexOf('backoffice') !== -1) {
|
||||||
// $("#notification_alert").html(data['message']);
|
// $("#notification_alert").html(data['message']);
|
||||||
//
|
//
|
||||||
// slideIn_notification_alert();
|
// slideIn_notification_alert();
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
|
// }
|
||||||
//});
|
//});
|
||||||
|
|
||||||
function slideIn_notification_alert (){
|
function slideIn_notification_alert (){
|
||||||
$("#notification_alert").animate({
|
$("#notification_alert").animate({
|
||||||
right: '20px'
|
right: '20px'
|
||||||
}, 250);
|
}, 250);
|
||||||
|
|
||||||
setTimeout(slideOut_notification_alert, 3500);
|
setTimeout(slideOut_notification_alert, 3500);
|
||||||
}
|
}
|
||||||
|
|
||||||
function slideOut_notification_alert (){
|
function slideOut_notification_alert (){
|
||||||
$("#notification_alert").animate({
|
$("#notification_alert").animate({
|
||||||
right: '-250px'
|
right: '-250px'
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,33 @@
|
||||||
$(document).on('page:load', init_default_data_block);
|
$(document).on('turbolinks:load', init_default_data_block);
|
||||||
$(document).ready(init_default_data_block);
|
|
||||||
|
|
||||||
function init_default_data_block() {
|
function init_default_data_block() {
|
||||||
$('.default_data_block #dossier .body').toggle();
|
$('.default_data_block #dossier .body').toggle();
|
||||||
$('.default_data_block #dossier .carret-right').toggle();
|
$('.default_data_block #dossier .carret-right').toggle();
|
||||||
$('.default_data_block #dossier .carret-down').toggle();
|
$('.default_data_block #dossier .carret-down').toggle();
|
||||||
|
|
||||||
$('.default_data_block .title').click(function () {
|
$('.default_data_block .title').click(function () {
|
||||||
toggle_default_data_bloc(this, 400);
|
toggle_default_data_bloc(this, 400);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.new-action').click(function () {
|
$('.new-action').click(function () {
|
||||||
var messages_block = $(this).parents().closest('.default_data_block').find('.title')
|
var messages_block = $(this).parents().closest('.default_data_block').find('.title')
|
||||||
toggle_default_data_bloc(messages_block, 400);
|
toggle_default_data_bloc(messages_block, 400);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.default_data_block.default_visible').each(function() {
|
$('.default_data_block.default_visible').each(function() {
|
||||||
toggle_default_data_bloc($(this).find('.title'), 0);
|
toggle_default_data_bloc($(this).find('.title'), 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
function toggle_default_data_bloc(element, duration) {
|
function toggle_default_data_bloc(element, duration) {
|
||||||
var block = $(element).parents('.show-block');
|
var block = $(element).parents('.show-block');
|
||||||
if (block.attr('id') == 'messages') {
|
if (block.attr('id') == 'messages') {
|
||||||
block.children('.last-commentaire').toggle();
|
block.children('.last-commentaire').toggle();
|
||||||
$(".commentaires").animate({ scrollTop: $(this).height() }, "slow");
|
$(".commentaires").animate({ scrollTop: $(this).height() }, "slow");
|
||||||
}
|
|
||||||
|
|
||||||
block.children('.body').slideToggle(duration);
|
|
||||||
|
|
||||||
block.find('.carret-right').toggle();
|
|
||||||
block.find('.carret-down').toggle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
block.children('.body').slideToggle(duration);
|
||||||
|
|
||||||
|
block.find('.carret-right').toggle();
|
||||||
|
block.find('.carret-down').toggle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +1,47 @@
|
||||||
$(document).on('page:load', action_type_de_champs);
|
$(document).on('turbolinks:load', action_type_de_champs);
|
||||||
$(document).ready(action_type_de_champs);
|
|
||||||
|
|
||||||
|
|
||||||
function action_type_de_champs() {
|
function action_type_de_champs() {
|
||||||
$("input[type='email']").on('change', function () {
|
$("input[type='email']").on('change', function () {
|
||||||
toggleErrorClass(this, validateEmail($(this).val()));
|
toggleErrorClass(this, validateEmail($(this).val()));
|
||||||
});
|
});
|
||||||
|
|
||||||
$("input[type='number']").on('change', function () {
|
$("input[type='number']").on('change', function () {
|
||||||
toggleErrorClass(this, validateNumber($(this).val()));
|
toggleErrorClass(this, validateNumber($(this).val()));
|
||||||
});
|
});
|
||||||
|
|
||||||
$("input[type='phone']").on('change', function () {
|
$("input[type='phone']").on('change', function () {
|
||||||
val = $(this).val();
|
val = $(this).val();
|
||||||
val = val.replace(/[ ]/g, '');
|
val = val.replace(/[ ]/g, '');
|
||||||
|
|
||||||
toggleErrorClass(this, validatePhone(val));
|
toggleErrorClass(this, validatePhone(val));
|
||||||
});
|
});
|
||||||
|
|
||||||
address_type_init();
|
address_type_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleErrorClass(node, boolean) {
|
function toggleErrorClass(node, boolean) {
|
||||||
if (boolean)
|
if (boolean)
|
||||||
$(node).removeClass('input-error');
|
$(node).removeClass('input-error');
|
||||||
else
|
else
|
||||||
$(node).addClass('input-error');
|
$(node).addClass('input-error');
|
||||||
}
|
}
|
||||||
|
|
||||||
function validatePhone(phone) {
|
function validatePhone(phone) {
|
||||||
var re = /^(0|(\+[1-9]{2})|(00[1-9]{2}))[1-9][0-9]{8}$/;
|
var re = /^(0|(\+[1-9]{2})|(00[1-9]{2}))[1-9][0-9]{8}$/;
|
||||||
return validateInput(phone, re)
|
return validateInput(phone, re)
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateEmail(email) {
|
function validateEmail(email) {
|
||||||
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||||
return validateInput(email, re)
|
return validateInput(email, re)
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateNumber(number) {
|
function validateNumber(number) {
|
||||||
var re = /^[0-9]+$/;
|
var re = /^[0-9]+$/;
|
||||||
return validateInput(number, re)
|
return validateInput(number, re)
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateInput(input, regex) {
|
function validateInput(input, regex) {
|
||||||
return regex.test(input);
|
return regex.test(input);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
$(document).on('page:load', init_modal_commentaire);
|
$(document).on('turbolinks:load', init_modal_commentaire);
|
||||||
$(document).ready(init_modal_commentaire);
|
|
||||||
|
|
||||||
function init_modal_commentaire() {
|
function init_modal_commentaire() {
|
||||||
var modal = $("#modalCommentairesDossierParChamp");
|
var modal = $("#modalCommentairesDossierParChamp");
|
||||||
var body = modal.find(".modal-body");
|
var body = modal.find(".modal-body");
|
||||||
var originalBody = body.html();
|
var originalBody = body.html();
|
||||||
|
|
||||||
modal.on("show.bs.modal", function (e) {
|
modal.on("show.bs.modal", function (e) {
|
||||||
body.load(e.relatedTarget.getAttribute("data-href"));
|
body.load(e.relatedTarget.getAttribute("data-href"));
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#modalCommentairesDossierParChamp").on("hidden.bs.modal", function (e) {
|
$("#modalCommentairesDossierParChamp").on("hidden.bs.modal", function (e) {
|
||||||
body.html(originalBody);
|
body.html(originalBody);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
$(document).on('page:load', the_terms);
|
$(document).on('turbolinks:load', the_terms);
|
||||||
$(document).ready(the_terms);
|
$(document).on('turbolinks:load', pannel_switch);
|
||||||
$(document).on('page:load', pannel_switch);
|
|
||||||
$(document).ready(pannel_switch);
|
|
||||||
|
|
||||||
function pannel_switch() {
|
function pannel_switch() {
|
||||||
$('#switch-notifications').click(function () {
|
$('#switch-notifications').click(function () {
|
||||||
|
@ -19,43 +17,43 @@ function pannel_switch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function the_terms() {
|
function the_terms() {
|
||||||
var the_terms = $("#dossier_autorisation_donnees");
|
var the_terms = $("#dossier_autorisation_donnees");
|
||||||
|
|
||||||
if (the_terms.size() == 0)
|
if (the_terms.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
check_value(the_terms);
|
||||||
|
|
||||||
|
the_terms.click(function () {
|
||||||
check_value(the_terms);
|
check_value(the_terms);
|
||||||
|
});
|
||||||
|
|
||||||
the_terms.click(function () {
|
function check_value(the_terms) {
|
||||||
check_value(the_terms);
|
if (the_terms.is(":checked")) {
|
||||||
});
|
$("#etape_suivante").removeAttr("disabled");
|
||||||
|
} else {
|
||||||
function check_value(the_terms) {
|
$("#etape_suivante").attr("disabled", "disabled");
|
||||||
if (the_terms.is(":checked")) {
|
|
||||||
$("#etape_suivante").removeAttr("disabled");
|
|
||||||
} else {
|
|
||||||
$("#etape_suivante").attr("disabled", "disabled");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function error_form_siret(invalid_siret) {
|
function error_form_siret(invalid_siret) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$("input[type='submit']").val('Erreur SIRET');
|
$("input[type='submit']").val('Erreur SIRET');
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
$("input[type='submit']").removeClass('btn-success').addClass('btn-danger');
|
$("input[type='submit']").removeClass('btn-success').addClass('btn-danger');
|
||||||
|
|
||||||
$("#dossier_siret").addClass('input-error').val(invalid_siret).on('input', reset_form_siret);
|
$("#dossier_siret").addClass('input-error').val(invalid_siret).on('input', reset_form_siret);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset_form_siret() {
|
function reset_form_siret() {
|
||||||
$("input[type='submit']").removeClass('btn-danger').addClass('btn-success').val('Valider');
|
$("input[type='submit']").removeClass('btn-danger').addClass('btn-success').val('Valider');
|
||||||
$("#dossier_siret").removeClass('input-error');
|
$("#dossier_siret").removeClass('input-error');
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggle_etape_1() {
|
function toggle_etape_1() {
|
||||||
$('.row.etape.etape_1 .etapes_menu #logos').toggle(100);
|
$('.row.etape.etape_1 .etapes_menu #logos').toggle(100);
|
||||||
$('.row.etape.etape_1 .etapes_informations #description_procedure').toggle(100);
|
$('.row.etape.etape_1 .etapes_informations #description_procedure').toggle(100);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +1,44 @@
|
||||||
$(document).on('page:load', filters_init);
|
$(document).on('turbolinks:load', filters_init);
|
||||||
$(document).ready(filters_init);
|
|
||||||
|
|
||||||
function filters_init() {
|
function filters_init() {
|
||||||
$('html').click(function(event) {
|
$('html').click(function(event) {
|
||||||
var visible_filter = $('.filter_framed:visible')
|
var visible_filter = $('.filter_framed:visible')
|
||||||
if(visible_filter.length) {
|
if(visible_filter.length) {
|
||||||
if (!$(event.target).closest('.filter_framed').is(":visible")) {
|
if (!$(event.target).closest('.filter_framed').is(":visible")) {
|
||||||
visible_filter.hide();
|
visible_filter.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".filter").on('click', function (event) {
|
$(".filter").on('click', function (event) {
|
||||||
filter_framed_show(event);
|
filter_framed_show(event);
|
||||||
filter_framed_close_all_excepted(framed_id(event));
|
filter_framed_close_all_excepted(framed_id(event));
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".erase-filter").on('click', function (event) {
|
$(".erase-filter").on('click', function (event) {
|
||||||
$(this).parent().find(".filter_input").val("");
|
$(this).parent().find(".filter_input").val("");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter_framed_close_all_excepted(id) {
|
function filter_framed_close_all_excepted(id) {
|
||||||
$(".filter_framed:not("+id+")").hide();
|
$(".filter_framed:not("+id+")").hide();
|
||||||
|
|
||||||
$(id).toggle();
|
$(id).toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
function framed_id(event) {
|
function framed_id(event) {
|
||||||
return "#framed_" + event.target.id
|
return "#framed_" + event.target.id
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter_framed_show(event) {
|
function filter_framed_show(event) {
|
||||||
dom_object = $(framed_id(event));
|
dom_object = $(framed_id(event));
|
||||||
|
|
||||||
var offset = $('#main-container').offset();
|
var offset = $('#main-container').offset();
|
||||||
|
|
||||||
var y = event.pageY - offset.top;
|
var y = event.pageY - offset.top;
|
||||||
var x = event.pageX - offset.left;
|
var x = event.pageX - offset.left;
|
||||||
|
|
||||||
dom_object.css('top', (y + 7) + 'px');
|
dom_object.css('top', (y + 7) + 'px');
|
||||||
dom_object.css('left', (x + 7) + 'px');
|
dom_object.css('left', (x + 7) + 'px');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
$(document).on('page:load', link_init);
|
$(document).on('turbolinks:load', link_init);
|
||||||
$(document).ready(link_init);
|
|
||||||
|
|
||||||
function link_init() {
|
function link_init() {
|
||||||
$('#dossiers_list tr').on('click', function () {
|
$('#dossiers_list tr').on('click', function () {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
$(document).on('page:load', franceconnect_kit);
|
$(document).on('turbolinks:load', franceconnect_kit);
|
||||||
$(document).ready(franceconnect_kit);
|
|
||||||
|
|
||||||
function franceconnect_kit() {
|
function franceconnect_kit() {
|
||||||
franceConnectKit.init()
|
franceConnectKit.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
$(document).on('page:load', modal_action);
|
$(document).on('turbolinks:load', modal_action);
|
||||||
$(document).ready(modal_action);
|
|
||||||
|
|
||||||
function modal_action() {
|
function modal_action() {
|
||||||
$('#PJmodal').on('show.bs.modal', function (event) {
|
$('#PJmodal').on('show.bs.modal', function (event) {
|
||||||
$("#PJmodal .modal-body .table .tr_content").hide();
|
$("#PJmodal .modal-body .table .tr_content").hide();
|
||||||
|
|
||||||
var button = $(event.relatedTarget) // Button that triggered the modal
|
var button = $(event.relatedTarget) // Button that triggered the modal
|
||||||
var modal_title = button.data('modal_title'); // Extract info from data-* attributes
|
var modal_title = button.data('modal_title'); // Extract info from data-* attributes
|
||||||
var modal_index = button.data('modal_index'); // Extract info from data-* attributes
|
var modal_index = button.data('modal_index'); // Extract info from data-* attributes
|
||||||
|
|
||||||
var modal = $(this)
|
var modal = $(this)
|
||||||
modal.find('#PJmodal_title').html(modal_title);
|
modal.find('#PJmodal_title').html(modal_title);
|
||||||
$("#PJmodal .modal-body .table #"+modal_index).show();
|
$("#PJmodal .modal-body .table #"+modal_index).show();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
36
app/assets/javascripts/new-description.js
Normal file
36
app/assets/javascripts/new-description.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
(function() {
|
||||||
|
var showNotFound = function() {
|
||||||
|
$('.dossier-link .text-info').hide();
|
||||||
|
$('.dossier-link .text-warning').show();
|
||||||
|
};
|
||||||
|
|
||||||
|
var showData = function(data) {
|
||||||
|
$('.dossier-link .procedureLibelle').text(data.procedureLibelle);
|
||||||
|
$('.dossier-link .text-info').show();
|
||||||
|
$('.dossier-link .text-warning').hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
var hideEverything = function() {
|
||||||
|
$('.dossier-link .text-info').hide();
|
||||||
|
$('.dossier-link .text-warning').hide();
|
||||||
|
};
|
||||||
|
|
||||||
|
var fetchProcedureLibelle = function(e) {
|
||||||
|
var dossierId = $(e.target).val();
|
||||||
|
if(dossierId) {
|
||||||
|
$.get('/users/dossiers/' + dossierId + '/procedure_libelle')
|
||||||
|
.done(showData)
|
||||||
|
.fail(showNotFound);
|
||||||
|
} else {
|
||||||
|
hideEverything();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var timeOut = null;
|
||||||
|
var debounceFetchProcedureLibelle = function(e) {
|
||||||
|
if(timeOut){ clearTimeout(timeOut); }
|
||||||
|
timeOut = setTimeout(function() { fetchProcedureLibelle(e); }, 300);
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).on('input', '[data-type=dossier-link]', debounceFetchProcedureLibelle);
|
||||||
|
})();
|
|
@ -1,33 +1,32 @@
|
||||||
$(document).on('page:load', pref_list_dossier_actions);
|
$(document).on('turbolinks:load', pref_list_dossier_actions);
|
||||||
$(document).ready(pref_list_dossier_actions);
|
|
||||||
|
|
||||||
function pref_list_dossier_actions() {
|
function pref_list_dossier_actions() {
|
||||||
pref_list_dossier_open_action();
|
pref_list_dossier_open_action();
|
||||||
pref_list_dossier_close_action();
|
pref_list_dossier_close_action();
|
||||||
}
|
}
|
||||||
|
|
||||||
function pref_list_dossier_open_action() {
|
function pref_list_dossier_open_action() {
|
||||||
$("#pref_list_dossier_open_action").on('click', function () {
|
$("#pref_list_dossier_open_action").on('click', function () {
|
||||||
$("#pref_list_menu").css('display', 'block');
|
$("#pref_list_menu").css('display', 'block');
|
||||||
$("#pref_list_menu").css('visibility', 'visible');
|
$("#pref_list_menu").css('visibility', 'visible');
|
||||||
|
|
||||||
$("#pref_list_menu").animate({
|
$("#pref_list_menu").animate({
|
||||||
right: 0
|
right: 0
|
||||||
}, 250);
|
}, 250);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function pref_list_dossier_close_action() {
|
function pref_list_dossier_close_action() {
|
||||||
$("#pref_list_dossier_close_action").on('click', function () {
|
$("#pref_list_dossier_close_action").on('click', function () {
|
||||||
$("#pref_list_menu").animate({
|
$("#pref_list_menu").animate({
|
||||||
right: parseInt($("#pref_list_menu").css('width'), 10)*(-1)+'px'
|
right: parseInt($("#pref_list_menu").css('width'), 10)*(-1)+'px'
|
||||||
},{
|
},{
|
||||||
duration: 250,
|
duration: 250,
|
||||||
complete: function () {
|
complete: function () {
|
||||||
$("#pref_list_menu").css('display', 'none');
|
$("#pref_list_menu").css('display', 'none');
|
||||||
$("#pref_list_menu").css('visibility', 'hidden');
|
$("#pref_list_menu").css('visibility', 'hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,37 @@
|
||||||
$(document).on('page:load', button_edit_procedure_init);
|
$(document).on('turbolinks:load', button_edit_procedure_init);
|
||||||
$(document).ready(button_edit_procedure_init);
|
|
||||||
|
|
||||||
function button_edit_procedure_init(){
|
function button_edit_procedure_init(){
|
||||||
buttons_api_carto();
|
buttons_api_carto();
|
||||||
button_cerfa();
|
button_cerfa();
|
||||||
button_individual();
|
button_individual();
|
||||||
}
|
}
|
||||||
|
|
||||||
function buttons_api_carto () {
|
function buttons_api_carto () {
|
||||||
|
|
||||||
$("#procedure_module_api_carto_use_api_carto").on('change', function() {
|
$("#procedure_module_api_carto_use_api_carto").on('change', function() {
|
||||||
$("#modules_api_carto").toggle()
|
$("#modules_api_carto").toggle()
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($('#procedure_module_api_carto_use_api_carto').is(':checked'))
|
if ($('#procedure_module_api_carto_use_api_carto').is(':checked'))
|
||||||
$("#modules_api_carto").show();
|
$("#modules_api_carto").show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function button_cerfa () {
|
function button_cerfa () {
|
||||||
|
|
||||||
$("#procedure_cerfa_flag").on('change', function() {
|
$("#procedure_cerfa_flag").on('change', function() {
|
||||||
$("#procedure_lien_demarche").toggle()
|
$("#procedure_lien_demarche").toggle()
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($('#procedure_cerfa_flag').is(':checked'))
|
if ($('#procedure_cerfa_flag').is(':checked'))
|
||||||
$("#procedure_lien_demarche").show();
|
$("#procedure_lien_demarche").show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function button_individual () {
|
function button_individual () {
|
||||||
|
|
||||||
$("#procedure_for_individual").on('change', function() {
|
$("#procedure_for_individual").on('change', function() {
|
||||||
$("#individual_with_siret").toggle()
|
$("#individual_with_siret").toggle()
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($('#procedure_for_individual').is(':checked'))
|
if ($('#procedure_for_individual').is(':checked'))
|
||||||
$("#individual_with_siret").show();
|
$("#individual_with_siret").show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,60 +1,59 @@
|
||||||
$(document).on('page:load', init_search_anim);
|
$(document).on('turbolinks:load', init_search_anim);
|
||||||
$(document).ready(init_search_anim);
|
|
||||||
|
|
||||||
function init_search_anim(){
|
function init_search_anim(){
|
||||||
$("#search_area").on('click', search_fadeIn);
|
$("#search_area").on('click', search_fadeIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
function search_fadeIn(){
|
function search_fadeIn(){
|
||||||
var search_area = $("#search_area");
|
var search_area = $("#search_area");
|
||||||
var body_dom = $('body');
|
var body_dom = $('body');
|
||||||
var positions = search_area.position();
|
var positions = search_area.position();
|
||||||
var width = search_area.width();
|
var width = search_area.width();
|
||||||
|
|
||||||
search_area.css('position', 'fixed');
|
search_area.css('position', 'fixed');
|
||||||
search_area.css('top', positions.top + $('.navbar').height());
|
search_area.css('top', positions.top + $('.navbar').height());
|
||||||
search_area.css('left', positions.left);
|
search_area.css('left', positions.left);
|
||||||
search_area.css('z-index', 300);
|
search_area.css('z-index', 300);
|
||||||
search_area.css('width', width);
|
search_area.css('width', width);
|
||||||
search_area.find('#q').animate({ height: '50px' });
|
search_area.find('#q').animate({ height: '50px' });
|
||||||
search_area.find('#search_button').animate({ height: '50px' });
|
search_area.find('#search_button').animate({ height: '50px' });
|
||||||
|
|
||||||
body_dom.append(search_area);
|
body_dom.append(search_area);
|
||||||
$('#mask_search').fadeIn(200);
|
$('#mask_search').fadeIn(200);
|
||||||
|
|
||||||
var body_width = body_dom.width();
|
var body_width = body_dom.width();
|
||||||
|
|
||||||
var search_area_width = body_width/2.5;
|
var search_area_width = body_width/2.5;
|
||||||
|
|
||||||
search_area.animate({
|
search_area.animate({
|
||||||
width: search_area_width,
|
width: search_area_width,
|
||||||
left: (body_width/2 - search_area_width/2 + 40)
|
left: (body_width/2 - search_area_width/2 + 40)
|
||||||
}, 400, function() {
|
}, 400, function() {
|
||||||
search_area.off();
|
search_area.off();
|
||||||
$("#search_area input").focus();
|
$("#search_area input").focus();
|
||||||
|
|
||||||
$('#mask_search').on('click', search_fadeOut)
|
$('#mask_search').on('click', search_fadeOut)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function search_fadeOut(){
|
function search_fadeOut(){
|
||||||
var search_area = $("#search_area");
|
var search_area = $("#search_area");
|
||||||
|
|
||||||
$('#mask_search').fadeOut(200);
|
$('#mask_search').fadeOut(200);
|
||||||
|
|
||||||
search_area.fadeOut(200, function(){
|
search_area.fadeOut(200, function(){
|
||||||
search_area.css('position', 'static');
|
search_area.css('position', 'static');
|
||||||
search_area.css('top', '');
|
search_area.css('top', '');
|
||||||
search_area.css('left', '');
|
search_area.css('left', '');
|
||||||
search_area.css('z-index', '');
|
search_area.css('z-index', '');
|
||||||
search_area.css('width', 'auto');
|
search_area.css('width', 'auto');
|
||||||
search_area.find('#q').css('height', 34);
|
search_area.find('#q').css('height', 34);
|
||||||
search_area.find('#search_button').css('height', 34);
|
search_area.find('#search_button').css('height', 34);
|
||||||
|
|
||||||
$('#search-block').append(search_area);
|
$('#search-block').append(search_area);
|
||||||
search_area.fadeIn(200);
|
search_area.fadeIn(200);
|
||||||
|
|
||||||
init_search_anim();
|
init_search_anim();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
function show_dossier_id_input (){
|
function show_dossier_id_input (){
|
||||||
$("#btn_show_dossier_id_input").hide()
|
$("#btn_show_dossier_id_input").hide()
|
||||||
}
|
}
|
||||||
|
|
20
app/assets/javascripts/toggle_chart.js
Normal file
20
app/assets/javascripts/toggle_chart.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
var TPS = TPS || {};
|
||||||
|
|
||||||
|
TPS.toggleChart = function(event, chartClass) {
|
||||||
|
var nextSelectorItem = $(event.target),
|
||||||
|
nextChart = $(chartClass),
|
||||||
|
nextChartId = nextChart.children().first().attr("id"),
|
||||||
|
currentSelectorItem = nextSelectorItem.parent().find(".segmented-control-item-active"),
|
||||||
|
currentChart = nextSelectorItem.parent().parent().find(".chart:not(.hidden)");
|
||||||
|
|
||||||
|
// Change the current selector and the next selector states
|
||||||
|
currentSelectorItem.toggleClass("segmented-control-item-active");
|
||||||
|
nextSelectorItem.toggleClass("segmented-control-item-active");
|
||||||
|
|
||||||
|
// Hide the currently shown chart and show the new one
|
||||||
|
currentChart.toggleClass("hidden");
|
||||||
|
nextChart.toggleClass("hidden");
|
||||||
|
|
||||||
|
// Reflow needed, see https://github.com/highcharts/highcharts/issues/1979
|
||||||
|
Chartkick.charts[nextChartId].getChartObject().reflow();
|
||||||
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
$(document).on('page:load', activeSelect2);
|
$(document).on('turbolinks:load', activeSelect2);
|
||||||
$(document).ready(activeSelect2);
|
|
||||||
|
|
||||||
function activeSelect2() {
|
function activeSelect2() {
|
||||||
$('select.select2').select2({ theme: "bootstrap", width: '100%' });
|
$('select.select2').select2({ theme: "bootstrap", width: '100%' });
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
|
box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,4 @@ $default-spacer: 15px;
|
||||||
|
|
||||||
.ml-1 {
|
.ml-1 {
|
||||||
margin-left: $default-spacer;
|
margin-left: $default-spacer;
|
||||||
}
|
}
|
||||||
|
|
5
app/assets/stylesheets/_turbolinks.scss
Normal file
5
app/assets/stylesheets/_turbolinks.scss
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
@import "variables";
|
||||||
|
|
||||||
|
.turbolinks-progress-bar {
|
||||||
|
background-color: $light-blue;
|
||||||
|
}
|
|
@ -1 +1,5 @@
|
||||||
$font-size-base: 16px;
|
// colors
|
||||||
|
$light-blue: #F2F6FA;
|
||||||
|
|
||||||
|
// Bootstrap variables
|
||||||
|
$font-size-base: 16px;
|
||||||
|
|
|
@ -20,4 +20,3 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,4 +15,4 @@
|
||||||
.tt-menu {
|
.tt-menu {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
@import "card";
|
|
||||||
|
|
||||||
.stats {
|
|
||||||
.stat-card {
|
|
||||||
@extend .card;
|
|
||||||
margin: 15px auto;
|
|
||||||
max-width: 1200px;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -27,7 +27,7 @@
|
||||||
@import "bootstrap";
|
@import "bootstrap";
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background-color: #F2F6FA;
|
background-color: $light-blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
html, body {
|
html, body {
|
||||||
|
@ -63,7 +63,7 @@ form {
|
||||||
}
|
}
|
||||||
|
|
||||||
#footer {
|
#footer {
|
||||||
background-color: #F2F6FA;
|
background-color: $light-blue;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
a, p {
|
a, p {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#cgu {
|
#cgu {
|
||||||
margin-left: 2em;
|
margin-left: 2em;
|
||||||
margin-right: 2em;
|
margin-right: 2em;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
@import "variables";
|
||||||
|
|
||||||
.default_data_block {
|
.default_data_block {
|
||||||
font-family: Arial;
|
font-family: Arial;
|
||||||
|
|
||||||
|
@ -53,7 +55,7 @@
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
}
|
}
|
||||||
.action:hover {
|
.action:hover {
|
||||||
color: #F2F6FA;
|
color: $light-blue;
|
||||||
}
|
}
|
||||||
.count {
|
.count {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
width: 300px;
|
width: 300px;
|
||||||
margin-left:auto;
|
margin-left:auto;
|
||||||
margin-right:auto;
|
margin-right:auto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,4 @@
|
||||||
h4 {
|
h4 {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
@import "variables";
|
||||||
|
|
||||||
#header {
|
#header {
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
@ -185,7 +187,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.button-navbar-action:hover {
|
.button-navbar-action:hover {
|
||||||
color: #F2F6FA;
|
color: $light-blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button_navbar:hover, .button-navbar-action:hover {
|
.button_navbar:hover, .button-navbar-action:hover {
|
||||||
|
|
|
@ -9,4 +9,4 @@
|
||||||
height: 80px;
|
height: 80px;
|
||||||
|
|
||||||
border: solid black 1px;
|
border: solid black 1px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,4 @@
|
||||||
.open_pref_list {
|
.open_pref_list {
|
||||||
right: 0 !important;
|
right: 0 !important;
|
||||||
display: block !important;
|
display: block !important;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,4 +9,4 @@
|
||||||
#titre_procedure {
|
#titre_procedure {
|
||||||
margin-top: 3%;
|
margin-top: 3%;
|
||||||
margin-bottom: 2%;
|
margin-bottom: 2%;
|
||||||
}
|
}
|
||||||
|
|
124
app/assets/stylesheets/stats.scss
Normal file
124
app/assets/stylesheets/stats.scss
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
@import "card";
|
||||||
|
|
||||||
|
$dark-grey: #333333;
|
||||||
|
$light-grey: #999999;
|
||||||
|
$blue: rgba(61, 149, 236, 1);
|
||||||
|
$blue-hover: rgba(61, 149, 236, 0.8);
|
||||||
|
|
||||||
|
$default-space: 15px;
|
||||||
|
|
||||||
|
$new-h1-margin-bottom: 4 * $default-space;
|
||||||
|
.new-h1 {
|
||||||
|
color: $dark-grey;
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: $new-h1-margin-bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
$statistiques-padding-top: $default-space * 2;
|
||||||
|
.statistiques {
|
||||||
|
width: 1040px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding-top: $statistiques-padding-top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-cards {
|
||||||
|
.stat-card:nth-of-type(even) {
|
||||||
|
margin-right: 0px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$stat-card-margin-bottom: 3 * $default-space;
|
||||||
|
.stat-card {
|
||||||
|
@extend .card;
|
||||||
|
margin-bottom: $stat-card-margin-bottom;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: none;
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stat-card-half-horizontal-spacing: 4 * $default-space;
|
||||||
|
.stat-card-half {
|
||||||
|
width: calc((100% - #{$stat-card-half-horizontal-spacing}) / 2);
|
||||||
|
margin-right: 3 * $default-space;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card-title {
|
||||||
|
color: $dark-grey;
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: 500;
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
$segmented-control-margin-top: $default-space;
|
||||||
|
.segmented-control {
|
||||||
|
border-radius: 36px;
|
||||||
|
height: 36px;
|
||||||
|
line-height: 36px;
|
||||||
|
font-size: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: inline-block;
|
||||||
|
margin-top: $segmented-control-margin-top;
|
||||||
|
}
|
||||||
|
|
||||||
|
$segmented-control-item-horizontal-padding: $default-space;
|
||||||
|
$segmented-control-item-border-radius: 2 * $default-space;
|
||||||
|
.segmented-control-item {
|
||||||
|
color: $blue;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 15px;
|
||||||
|
border: 2px solid $blue;
|
||||||
|
margin-right: -2px;
|
||||||
|
padding-left: $segmented-control-item-horizontal-padding;
|
||||||
|
padding-right: $segmented-control-item-horizontal-padding;
|
||||||
|
color: $blue;
|
||||||
|
|
||||||
|
&:first-of-type {
|
||||||
|
border-radius: $segmented-control-item-border-radius 0px 0px $segmented-control-item-border-radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-of-type {
|
||||||
|
border-radius: 0px $segmented-control-item-border-radius $segmented-control-item-border-radius 0px;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: $blue-hover;
|
||||||
|
color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.segmented-control-item-active {
|
||||||
|
background-color: $blue;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-container {
|
||||||
|
margin-top: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
$big-number-card-padding: 2 * $segmented-control-item-border-radius;
|
||||||
|
.big-number-card {
|
||||||
|
padding: $big-number-card-padding;
|
||||||
|
}
|
||||||
|
|
||||||
|
.big-number-card-title {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
margin: 0 auto;
|
||||||
|
color: $light-grey;
|
||||||
|
}
|
||||||
|
|
||||||
|
.big-number-card-number {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 90px;
|
||||||
|
line-height: 90px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: $blue;
|
||||||
|
}
|
|
@ -12,4 +12,4 @@
|
||||||
a{
|
a{
|
||||||
color: #c3d9ff;
|
color: #c3d9ff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
left: 10px;
|
left: 10px;
|
||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
z-index: 300;
|
z-index: 300;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,4 +31,4 @@
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: #0097cf;
|
background-color: #0097cf;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,4 @@
|
||||||
li:last-child {
|
li:last-child {
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
@import "variables";
|
||||||
|
|
||||||
#users_index, #admins_index{
|
#users_index, #admins_index{
|
||||||
margin-left: 2rem;
|
margin-left: 2rem;
|
||||||
margin-right: 2rem;
|
margin-right: 2rem;
|
||||||
|
@ -48,7 +50,7 @@
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
.action:hover {
|
.action:hover {
|
||||||
color: #F2F6FA;
|
color: $light-blue;
|
||||||
}
|
}
|
||||||
.padding-left-30 {
|
.padding-left-30 {
|
||||||
padding-left: 30px;
|
padding-left: 30px;
|
||||||
|
|
|
@ -2,4 +2,4 @@ class NotificationsChannel < ApplicationCable::Channel
|
||||||
def subscribed
|
def subscribed
|
||||||
stream_from 'notifications'
|
stream_from 'notifications'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,4 +35,4 @@ class Admin::AccompagnateursController < AdminController
|
||||||
flash.notice = "Assignement effectué"
|
flash.notice = "Assignement effectué"
|
||||||
redirect_to admin_procedure_accompagnateurs_path, procedure_id: params[:procedure_id]
|
redirect_to admin_procedure_accompagnateurs_path, procedure_id: params[:procedure_id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,4 +16,4 @@ class Admin::ChangeDossierStateController < AdminController
|
||||||
return redirect_to admin_change_dossier_state_path
|
return redirect_to admin_change_dossier_state_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,4 +15,4 @@ class Admin::PrevisualisationsController < AdminController
|
||||||
acc
|
acc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,4 +46,4 @@ class Admin::TypesDeChampPrivateController < AdminController
|
||||||
def create_facade
|
def create_facade
|
||||||
@types_de_champ_facade = AdminTypesDeChampFacades.new true, @procedure
|
@types_de_champ_facade = AdminTypesDeChampFacades.new true, @procedure
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
module Administrations
|
|
||||||
class StatsController < ApplicationController
|
|
||||||
before_action :authenticate_administration!
|
|
||||||
|
|
||||||
def index
|
|
||||||
procedures = Procedure.where(created_at: Time.current.all_quarter).group("date_trunc('day', created_at)").count
|
|
||||||
dossiers = Dossier.where(created_at: Time.current.all_quarter).group("date_trunc('day', created_at)").count
|
|
||||||
@procedures = clean_hash(procedures)
|
|
||||||
@dossiers = clean_hash(dossiers)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def clean_hash h
|
|
||||||
h.keys.each{ |key| h[key.to_date] = h[key]; h.delete(key) }
|
|
||||||
min_date = h.keys.min
|
|
||||||
max_date = h.keys.max
|
|
||||||
(min_date..max_date).each do |date|
|
|
||||||
h[date] = 0 if h[date].nil?
|
|
||||||
end
|
|
||||||
h
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -56,4 +56,4 @@ class API::V1::DossiersController < APIController
|
||||||
nombre_de_page: dossiers.total_pages
|
nombre_de_page: dossiers.total_pages
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,4 +19,4 @@ class APIController < ApplicationController
|
||||||
def default_format_json
|
def default_format_json
|
||||||
request.format = "json" unless request.params[:format]
|
request.format = "json" unless request.params[:format]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,4 +4,4 @@ class Backoffice::CommentairesController < CommentairesController
|
||||||
def is_gestionnaire?
|
def is_gestionnaire?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,16 +39,13 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_dossiers_tps
|
def download_dossiers_tps
|
||||||
if procedure = Procedure.find_by(id: params[:procedure_id])
|
procedure = Procedure.find_by(id: params[:procedure_id])
|
||||||
dossiers = dossiers_list_facade(param_liste).dossiers_to_display
|
export = procedure.generate_export
|
||||||
respond_with Dossier.export_full_generation(dossiers, request.format) unless dossiers.empty?
|
|
||||||
else
|
respond_to do |format|
|
||||||
dossiers = dossiers_list_facade(param_liste).dossiers_to_display
|
format.csv { send_data(SpreadsheetArchitect.to_csv(data: export[:data], headers: export[:headers]), filename: 'dossiers.csv') }
|
||||||
respond_to do |format|
|
format.xlsx { send_data(SpreadsheetArchitect.to_xlsx(data: export[:data], headers: export[:headers]), filename: 'dossiers.xlsx') }
|
||||||
format.xlsx { render xlsx: dossiers }
|
format.ods { send_data(SpreadsheetArchitect.to_ods(data: export[:data], headers: export[:headers]), filename: 'dossiers.ods') }
|
||||||
format.ods { render ods: dossiers }
|
|
||||||
format.csv { render csv: dossiers }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Backoffice::PrivateFormulairesController < ApplicationController
|
||||||
dossier = current_gestionnaire.dossiers.find(params[:dossier_id])
|
dossier = current_gestionnaire.dossiers.find(params[:dossier_id])
|
||||||
|
|
||||||
unless params[:champs].nil?
|
unless params[:champs].nil?
|
||||||
champs_service_errors = ChampsService.save_formulaire dossier.champs_private, params
|
champs_service_errors = ChampsService.save_champs dossier.champs_private, params
|
||||||
|
|
||||||
if champs_service_errors.empty?
|
if champs_service_errors.empty?
|
||||||
flash[:notice] = "Formulaire enregistré"
|
flash[:notice] = "Formulaire enregistré"
|
||||||
|
@ -16,4 +16,4 @@ class Backoffice::PrivateFormulairesController < ApplicationController
|
||||||
|
|
||||||
render 'backoffice/dossiers/formulaire_private', formats: :js
|
render 'backoffice/dossiers/formulaire_private', formats: :js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,4 +7,4 @@ class BackofficeController < ApplicationController
|
||||||
redirect_to(:backoffice_dossiers)
|
redirect_to(:backoffice_dossiers)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,4 +17,4 @@ class Ban::SearchController < ApplicationController
|
||||||
|
|
||||||
render json: {lon: lon, lat: lat, zoom: '14', dossier_id: params[:dossier_id]}
|
render json: {lon: lon, lat: lat, zoom: '14', dossier_id: params[:dossier_id]}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,4 +2,4 @@ class CguController < ApplicationController
|
||||||
def index
|
def index
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -117,4 +117,4 @@ class FranceConnect::ParticulierController < ApplicationController
|
||||||
france_connect_information = FranceConnectInformation.find(params[:fci_id])
|
france_connect_information = FranceConnectInformation.find(params[:fci_id])
|
||||||
FranceConnectSaltService.new(france_connect_information).valid? params[:salt]
|
FranceConnectSaltService.new(france_connect_information).valid? params[:salt]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
56
app/controllers/stats_controller.rb
Normal file
56
app/controllers/stats_controller.rb
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
class StatsController < ApplicationController
|
||||||
|
|
||||||
|
def index
|
||||||
|
procedures = Procedure.where(:published => true)
|
||||||
|
dossiers = Dossier.where.not(:state => :draft)
|
||||||
|
|
||||||
|
@procedures_30_days_flow = thirty_days_flow_hash(procedures)
|
||||||
|
@dossiers_30_days_flow = thirty_days_flow_hash(dossiers)
|
||||||
|
|
||||||
|
@procedures_cumulative = cumulative_hash(procedures)
|
||||||
|
@dossiers_cumulative = cumulative_hash(dossiers)
|
||||||
|
|
||||||
|
@procedures_count = procedures.count
|
||||||
|
@dossiers_count = dossiers.count
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def thirty_days_flow_hash(association)
|
||||||
|
min_date = 30.days.ago.to_date
|
||||||
|
max_date = Time.now.to_date
|
||||||
|
|
||||||
|
thirty_days_flow_hash = association
|
||||||
|
.where(:created_at => min_date..max_date)
|
||||||
|
.group("date_trunc('day', created_at)")
|
||||||
|
.count
|
||||||
|
|
||||||
|
clean_hash(thirty_days_flow_hash, min_date, max_date)
|
||||||
|
end
|
||||||
|
|
||||||
|
def clean_hash(h, min_date, max_date)
|
||||||
|
# Convert keys to date
|
||||||
|
h = Hash[h.map { |(k, v)| [k.to_date, v] }]
|
||||||
|
|
||||||
|
# Add missing vales where count is 0
|
||||||
|
(min_date..max_date).each do |date|
|
||||||
|
if h[date].nil?
|
||||||
|
h[date] = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
h
|
||||||
|
end
|
||||||
|
|
||||||
|
def cumulative_hash(association)
|
||||||
|
sum = 0
|
||||||
|
association
|
||||||
|
.group("DATE_TRUNC('month', created_at)")
|
||||||
|
.count
|
||||||
|
.to_a
|
||||||
|
.sort{ |x, y| x[0] <=> y[0] }
|
||||||
|
.map { |x, y| { x => (sum += y)} }
|
||||||
|
.reduce({}, :merge)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,3 +1,3 @@
|
||||||
class Users::CommentairesController < CommentairesController
|
class Users::CommentairesController < CommentairesController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,10 +12,7 @@ class Users::DescriptionController < UsersController
|
||||||
@procedure = @dossier.procedure
|
@procedure = @dossier.procedure
|
||||||
@champs = @dossier.ordered_champs
|
@champs = @dossier.ordered_champs
|
||||||
|
|
||||||
@headers = @champs.inject([]) do |acc, champ|
|
@headers = @champs.select { |c| c.type_champ == 'header_section' }
|
||||||
acc.push(champ) if champ.type_champ == 'header_section'
|
|
||||||
acc
|
|
||||||
end
|
|
||||||
|
|
||||||
unless @dossier.can_be_initiated?
|
unless @dossier.can_be_initiated?
|
||||||
flash[:alert] = t('errors.messages.procedure_archived')
|
flash[:alert] = t('errors.messages.procedure_archived')
|
||||||
|
@ -34,18 +31,12 @@ class Users::DescriptionController < UsersController
|
||||||
|
|
||||||
@champs = @dossier.ordered_champs
|
@champs = @dossier.ordered_champs
|
||||||
|
|
||||||
mandatory = true
|
check_mandatory_fields = !draft_submission?
|
||||||
mandatory = !(params[:submit].keys.first == 'brouillon') unless params[:submit].nil?
|
|
||||||
|
|
||||||
unless @dossier.update_attributes(create_params)
|
if params[:champs]
|
||||||
@dossier = @dossier.decorate
|
champs_service_errors = ChampsService.save_champs @dossier.champs,
|
||||||
|
params,
|
||||||
flash.alert = @dossier.errors.full_messages.join('<br />').html_safe
|
check_mandatory_fields
|
||||||
return redirect_to users_dossier_description_path(dossier_id: @dossier.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
unless params[:champs].nil?
|
|
||||||
champs_service_errors = ChampsService.save_formulaire @dossier.champs, params, mandatory
|
|
||||||
|
|
||||||
unless champs_service_errors.empty?
|
unless champs_service_errors.empty?
|
||||||
flash.alert = (champs_service_errors.inject('') { |acc, error| acc+= error[:message]+'<br>' }).html_safe
|
flash.alert = (champs_service_errors.inject('') { |acc, error| acc+= error[:message]+'<br>' }).html_safe
|
||||||
|
@ -53,33 +44,30 @@ class Users::DescriptionController < UsersController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if @procedure.cerfa_flag?
|
if @procedure.cerfa_flag? && params[:cerfa_pdf]
|
||||||
unless params[:cerfa_pdf].nil?
|
cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: @dossier, user: current_user)
|
||||||
cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: @dossier, user: current_user)
|
unless cerfa.save
|
||||||
unless cerfa.save
|
flash.alert = cerfa.errors.full_messages.join('<br />').html_safe
|
||||||
flash.alert = cerfa.errors.full_messages.join('<br />').html_safe
|
return redirect_to users_dossier_description_path(dossier_id: @dossier.id)
|
||||||
return redirect_to users_dossier_description_path(dossier_id: @dossier.id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless (errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params)).empty?
|
errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params)
|
||||||
|
unless errors_upload.empty?
|
||||||
flash.alert = errors_upload.html_safe
|
flash.alert = errors_upload.html_safe
|
||||||
return redirect_to users_dossier_description_path(dossier_id: @dossier.id)
|
return redirect_to users_dossier_description_path(dossier_id: @dossier.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if draft_submission?
|
||||||
if mandatory
|
flash.notice = 'Votre brouillon a bien été sauvegardé.'
|
||||||
|
redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon)
|
||||||
|
else
|
||||||
if @dossier.draft?
|
if @dossier.draft?
|
||||||
@dossier.initiated!
|
@dossier.initiated!
|
||||||
NotificationMailer.send_notification(@dossier, @dossier.procedure.initiated_mail).deliver_now!
|
NotificationMailer.send_notification(@dossier, @dossier.procedure.initiated_mail).deliver_now!
|
||||||
end
|
end
|
||||||
|
|
||||||
flash.notice = 'Félicitations, votre demande a bien été enregistrée.'
|
flash.notice = 'Félicitations, votre demande a bien été enregistrée.'
|
||||||
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: @dossier.id)
|
redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: @dossier.id)
|
||||||
else
|
|
||||||
flash.notice = 'Votre brouillon a bien été sauvegardé.'
|
|
||||||
redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -123,6 +111,10 @@ class Users::DescriptionController < UsersController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def draft_submission?
|
||||||
|
params[:submit] && params[:submit].keys.first == 'brouillon'
|
||||||
|
end
|
||||||
|
|
||||||
def check_autorisation_donnees
|
def check_autorisation_donnees
|
||||||
@dossier = current_user_dossier
|
@dossier = current_user_dossier
|
||||||
|
|
||||||
|
@ -137,9 +129,4 @@ class Users::DescriptionController < UsersController
|
||||||
redirect_to url_for(users_dossier_path(@dossier.id))
|
redirect_to url_for(users_dossier_path(@dossier.id))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_params
|
|
||||||
params.permit()
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,4 +10,4 @@ class Users::Dossiers::AddSiretController < ApplicationController
|
||||||
flash.alert = t('errors.messages.dossier_not_found')
|
flash.alert = t('errors.messages.dossier_not_found')
|
||||||
redirect_to url_for users_dossiers_path
|
redirect_to url_for users_dossiers_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
class Users::Dossiers::CommentairesController < CommentairesController
|
class Users::Dossiers::CommentairesController < CommentairesController
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,4 +15,4 @@ class Users::Dossiers::InvitesController < UsersController
|
||||||
flash.alert = t('errors.messages.dossier_not_found')
|
flash.alert = t('errors.messages.dossier_not_found')
|
||||||
redirect_to url_for users_dossiers_path
|
redirect_to url_for users_dossiers_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -122,7 +122,7 @@ class Users::DossiersController < UsersController
|
||||||
@facade = facade params[:dossier][:id]
|
@facade = facade params[:dossier][:id]
|
||||||
|
|
||||||
if checked_autorisation_donnees?
|
if checked_autorisation_donnees?
|
||||||
unless Dossier.find(@facade.dossier.id).update_attributes update_params
|
unless Dossier.find(@facade.dossier.id).update_attributes update_params_with_formatted_birthdate
|
||||||
flash.alert = @facade.dossier.errors.full_messages.join('<br />').html_safe
|
flash.alert = @facade.dossier.errors.full_messages.join('<br />').html_safe
|
||||||
|
|
||||||
return redirect_to users_dossier_path(id: @facade.dossier.id)
|
return redirect_to users_dossier_path(id: @facade.dossier.id)
|
||||||
|
@ -154,6 +154,13 @@ class Users::DossiersController < UsersController
|
||||||
redirect_to url_for users_dossiers_path
|
redirect_to url_for users_dossiers_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def procedure_libelle
|
||||||
|
dossier = Dossier.find(params[:dossier_id])
|
||||||
|
render json: { procedureLibelle: dossier.procedure.libelle }
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render json: {}, status: 404
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def check_siret
|
def check_siret
|
||||||
|
@ -171,6 +178,25 @@ class Users::DossiersController < UsersController
|
||||||
params.require(:dossier).permit(:id, :autorisation_donnees, individual_attributes: [:gender, :nom, :prenom, :birthdate])
|
params.require(:dossier).permit(:id, :autorisation_donnees, individual_attributes: [:gender, :nom, :prenom, :birthdate])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_params_with_formatted_birthdate
|
||||||
|
editable_params = update_params
|
||||||
|
|
||||||
|
# If the user was shown a date input field (if its browser supports it),
|
||||||
|
# the returned param will follow the YYYY-MM-DD pattern, which we need
|
||||||
|
# do convert to the DD/MM/YYYY pattern we use
|
||||||
|
if editable_params &&
|
||||||
|
editable_params[:individual_attributes] &&
|
||||||
|
editable_params[:individual_attributes][:birthdate] &&
|
||||||
|
editable_params[:individual_attributes][:birthdate] =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/
|
||||||
|
|
||||||
|
original_birthdate = editable_params[:individual_attributes][:birthdate]
|
||||||
|
formatted_birthdate = I18n.l(original_birthdate.to_date, format: '%d/%m/%Y')
|
||||||
|
editable_params[:individual_attributes][:birthdate] = formatted_birthdate
|
||||||
|
end
|
||||||
|
|
||||||
|
editable_params
|
||||||
|
end
|
||||||
|
|
||||||
def checked_autorisation_donnees?
|
def checked_autorisation_donnees?
|
||||||
update_params[:autorisation_donnees] == '1'
|
update_params[:autorisation_donnees] == '1'
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,4 +29,4 @@ class UsersController < ApplicationController
|
||||||
flash.alert = message
|
flash.alert = message
|
||||||
redirect_to url_for root_path
|
redirect_to url_for root_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class DossiersDecorator < Draper::CollectionDecorator
|
class DossiersDecorator < Draper::CollectionDecorator
|
||||||
delegate :current_page, :per_page, :offset, :total_entries, :total_pages
|
delegate :current_page, :per_page, :offset, :total_entries, :total_pages
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
class TypeDeChampPrivateDecorator < TypeDeChampDecorator
|
class TypeDeChampPrivateDecorator < TypeDeChampDecorator
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
class TypeDePieceJustificativeDecorator < Draper::Decorator
|
class TypeDePieceJustificativeDecorator < Draper::Decorator
|
||||||
delegate_all
|
delegate_all
|
||||||
def button_up params
|
def button_up params
|
||||||
|
@ -34,4 +33,4 @@ class TypeDePieceJustificativeDecorator < Draper::Decorator
|
||||||
def count_type_de_piece_justificative
|
def count_type_de_piece_justificative
|
||||||
@count_type_de_piece_justificative ||= procedure.types_de_piece_justificative.count
|
@count_type_de_piece_justificative ||= procedure.types_de_piece_justificative.count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,4 +43,4 @@ class AdminProceduresShowFacades
|
||||||
def dossiers_termine_total
|
def dossiers_termine_total
|
||||||
dossiers.where(state: :termine).size
|
dossiers.where(state: :termine).size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,4 +45,4 @@ class AdminTypesDeChampFacades
|
||||||
def add_button_id
|
def add_button_id
|
||||||
@private ? :add_type_de_champ_private : :add_type_de_champ
|
@private ? :add_type_de_champ_private : :add_type_de_champ
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,4 +4,4 @@ class InviteDossierFacades < DossierFacades
|
||||||
def initialize id, email
|
def initialize id, email
|
||||||
@dossier = Invite.where(email: email, id: id).first!.dossier
|
@dossier = Invite.where(email: email, id: id).first!.dossier
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,4 +71,4 @@ class FileSizeValidator < ActiveModel::EachValidator
|
||||||
include Singleton
|
include Singleton
|
||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,4 +20,4 @@ class SIADE::ExercicesAdapter
|
||||||
:dateFinExercice,
|
:dateFinExercice,
|
||||||
:date_fin_exercice_timestamp]
|
:date_fin_exercice_timestamp]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class AssignTo < ActiveRecord::Base
|
class AssignTo < ActiveRecord::Base
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
belongs_to :gestionnaire
|
belongs_to :gestionnaire
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,4 +28,4 @@ class Cerfa < ActiveRecord::Base
|
||||||
NotificationService.new('cerfa', self.dossier.id).notify
|
NotificationService.new('cerfa', self.dossier.id).notify
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,6 +28,10 @@ class Champ < ActiveRecord::Base
|
||||||
same_date? num, '%M'
|
same_date? num, '%M'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mandatory_and_blank?
|
||||||
|
mandatory? && value.blank?
|
||||||
|
end
|
||||||
|
|
||||||
def same_date? num, compare
|
def same_date? num, compare
|
||||||
if type_champ == 'datetime' && !value.nil?
|
if type_champ == 'datetime' && !value.nil?
|
||||||
if value.to_datetime.strftime(compare) == num
|
if value.to_datetime.strftime(compare) == num
|
||||||
|
|
|
@ -201,6 +201,8 @@ class Dossier < ActiveRecord::Base
|
||||||
|
|
||||||
scope :archived, -> { where(archived: true) }
|
scope :archived, -> { where(archived: true) }
|
||||||
|
|
||||||
|
scope :downloadable, -> { all_state }
|
||||||
|
|
||||||
def cerfa_available?
|
def cerfa_available?
|
||||||
procedure.cerfa_flag? && cerfa.size != 0
|
procedure.cerfa_flag? && cerfa.size != 0
|
||||||
end
|
end
|
||||||
|
@ -208,19 +210,16 @@ class Dossier < ActiveRecord::Base
|
||||||
def convert_specific_hash_values_to_string(hash_to_convert)
|
def convert_specific_hash_values_to_string(hash_to_convert)
|
||||||
hash = {}
|
hash = {}
|
||||||
hash_to_convert.each do |key, value|
|
hash_to_convert.each do |key, value|
|
||||||
value = value.to_s if !value.kind_of?(Time) && !value.nil?
|
value = serialize_value_for_export(value)
|
||||||
hash.store(key, value)
|
hash.store(key, value)
|
||||||
end
|
end
|
||||||
return hash
|
return hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def convert_specific_array_values_to_string(array_to_convert)
|
def full_data_strings_array
|
||||||
array = []
|
data_with_champs.map do |value|
|
||||||
array_to_convert.each do |value|
|
serialize_value_for_export(value)
|
||||||
value = value.to_s if !value.kind_of?(Time) && !value.nil?
|
|
||||||
array << value
|
|
||||||
end
|
end
|
||||||
return array
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def export_entreprise_data
|
def export_entreprise_data
|
||||||
|
@ -261,23 +260,6 @@ class Dossier < ActiveRecord::Base
|
||||||
return headers
|
return headers
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.export_full_generation(dossiers, format)
|
|
||||||
if dossiers && !dossiers.empty?
|
|
||||||
data = []
|
|
||||||
headers = dossiers.first.export_headers
|
|
||||||
dossiers.each do |dossier|
|
|
||||||
data << dossier.convert_specific_array_values_to_string(dossier.data_with_champs)
|
|
||||||
end
|
|
||||||
if ["csv"].include?(format)
|
|
||||||
return SpreadsheetArchitect.to_csv(data: data, headers: headers)
|
|
||||||
elsif ["xlsx"].include?(format)
|
|
||||||
return SpreadsheetArchitect.to_xlsx(data: data, headers: headers)
|
|
||||||
elsif ["ods"].include?(format)
|
|
||||||
return SpreadsheetArchitect.to_ods(data: data, headers: headers)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def followers_gestionnaires_emails
|
def followers_gestionnaires_emails
|
||||||
follows.includes(:gestionnaire).map { |f| f.gestionnaire }.pluck(:email).join(' ')
|
follows.includes(:gestionnaire).map { |f| f.gestionnaire }.pluck(:email).join(' ')
|
||||||
end
|
end
|
||||||
|
@ -321,4 +303,8 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def serialize_value_for_export(value)
|
||||||
|
value.nil? || value.kind_of?(Time) ? value : value.to_s
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,4 +3,4 @@ class Follow < ActiveRecord::Base
|
||||||
belongs_to :dossier
|
belongs_to :dossier
|
||||||
|
|
||||||
validates_uniqueness_of :gestionnaire_id, :scope => :dossier_id
|
validates_uniqueness_of :gestionnaire_id, :scope => :dossier_id
|
||||||
end
|
end
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue