From 308a037f1987933a79c06251e6bb263e85ea1e1f Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 14 Feb 2017 11:13:48 +0100 Subject: [PATCH 1/6] Add clickable links in champ description and use bootstrap layout for forms --- .byebug_history | 9 +++ Gemfile | 5 +- app/assets/javascripts/bootstrap_wysihtml5.js | 4 +- app/assets/javascripts/description.js | 8 -- app/assets/stylesheets/application.scss | 4 - app/assets/stylesheets/description.scss | 11 +-- app/decorators/champ_decorator.rb | 7 +- app/decorators/type_de_champ_decorator.rb | 2 +- app/views/users/description/_show.html.haml | 2 +- .../champs/_render_list_champs.html.haml | 76 ++++++++++--------- .../description/champs/_textarea.html.haml | 2 +- 11 files changed, 62 insertions(+), 68 deletions(-) diff --git a/.byebug_history b/.byebug_history index f22879884..bfbe59fde 100644 --- a/.byebug_history +++ b/.byebug_history @@ -1,3 +1,12 @@ +continue +next +SIADETOKEN +next +exit +params +next +params +SIADETOKEN exit xit xtei diff --git a/Gemfile b/Gemfile index e38f8d656..4acfb8697 100644 --- a/Gemfile +++ b/Gemfile @@ -119,12 +119,11 @@ end group :development do # Access an IRB console on exception pages or by using <%= console %> in views - gem 'web-console' - gem 'rack-handlers' - gem 'xray-rails' + gem 'guard' + end group :development, :test do diff --git a/app/assets/javascripts/bootstrap_wysihtml5.js b/app/assets/javascripts/bootstrap_wysihtml5.js index 4f1ed7bcf..b0606ce8a 100644 --- a/app/assets/javascripts/bootstrap_wysihtml5.js +++ b/app/assets/javascripts/bootstrap_wysihtml5.js @@ -3,6 +3,6 @@ $(document).on('page:load', wysihtml5_active); function wysihtml5_active (){ $('.wysihtml5').each(function(i, elem) { - $(elem).wysihtml5({ toolbar:{ "fa": true, "link": false, "color": true }, "locale": "fr-FR" }); + $(elem).wysihtml5({ toolbar:{ "fa": true, "link": false, "color": false }, "locale": "fr-FR" }); }); -} \ No newline at end of file +} diff --git a/app/assets/javascripts/description.js b/app/assets/javascripts/description.js index 24a9e7e56..6df9f436d 100644 --- a/app/assets/javascripts/description.js +++ b/app/assets/javascripts/description.js @@ -18,14 +18,6 @@ function action_type_de_champs() { toggleErrorClass(this, validatePhone(val)); }); - $("#liste_champs input").on('focus', function () { - $("#description_" + this.id).slideDown(); - }); - - $("#liste_champs input").on('blur', function () { - $("#description_" + this.id).slideUp(); - }); - address_type_init(); } diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 58f55fa66..be9827586 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -143,10 +143,6 @@ textarea#description { max-width: 27px; } -label { - font-weight: normal; -} - div.pagination { padding-top: 20px; display: block; diff --git a/app/assets/stylesheets/description.scss b/app/assets/stylesheets/description.scss index dc24f6646..c471c10c1 100644 --- a/app/assets/stylesheets/description.scss +++ b/app/assets/stylesheets/description.scss @@ -7,9 +7,7 @@ .show-block { width: 90%; .body{ - padding-left: 35px; - padding-right: 35px; - padding-bottom: 35px; + padding: 15px; } } } @@ -134,10 +132,3 @@ width: 160px; } } - -.description_div { - margin-top: 5px; - margin-left: 5px; - color: dimgrey; - display: none; -} \ No newline at end of file diff --git a/app/decorators/champ_decorator.rb b/app/decorators/champ_decorator.rb index 6713e5049..42c9639e4 100644 --- a/app/decorators/champ_decorator.rb +++ b/app/decorators/champ_decorator.rb @@ -7,4 +7,9 @@ class ChampDecorator < Draper::Decorator end object.value end -end \ No newline at end of file + + def description_with_links + description.gsub(URI.regexp, '\0').html_safe if description + end + +end diff --git a/app/decorators/type_de_champ_decorator.rb b/app/decorators/type_de_champ_decorator.rb index d149996a7..ffe824855 100644 --- a/app/decorators/type_de_champ_decorator.rb +++ b/app/decorators/type_de_champ_decorator.rb @@ -39,4 +39,4 @@ class TypeDeChampDecorator < Draper::Decorator @count_type_de_champ ||= procedure.types_de_champ.count end end -end \ No newline at end of file +end diff --git a/app/views/users/description/_show.html.haml b/app/views/users/description/_show.html.haml index 5aebd3baa..1c28d55d0 100644 --- a/app/views/users/description/_show.html.haml +++ b/app/views/users/description/_show.html.haml @@ -15,7 +15,7 @@ = @dossier.procedure.libelle -#TODO use form_for - = form_tag(url_for({controller: 'users/description', action: :create, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST', multipart: true) do + = form_tag(url_for({controller: 'users/description', action: :create, dossier_id: @dossier.id}), class: 'form', method: 'POST', multipart: true) do -unless @champs.nil? #liste_champs =render partial: 'users/description/champs', locals:{private: false} diff --git a/app/views/users/description/champs/_render_list_champs.html.haml b/app/views/users/description/champs/_render_list_champs.html.haml index e15eceef6..021054b59 100644 --- a/app/views/users/description/champs/_render_list_champs.html.haml +++ b/app/views/users/description/champs/_render_list_champs.html.haml @@ -1,54 +1,56 @@ --champs.each do |champ| +- champs.decorate.each do |champ| - if champ.order_place > order_place - if champ.type_champ == 'header_section' - break - unless champ.type_champ == 'checkbox' || champ.type_champ == 'engagement' - %h4 - = champ.libelle - - if champ.mandatory? - = '*' + .row + %div{ class: if champ.type_champ == 'textarea' then 'col-md-12' else 'col-md-6' end } + .form-group + %label{ for: "champs_#{ champ.id }"} + = champ.libelle + - if champ.mandatory? + * - -if champ.type_champ == 'textarea' - =render partial: 'users/description/champs/textarea', locals: {champ: champ} + - if champ.type_champ == 'textarea' + = render partial: 'users/description/champs/textarea', locals: { champ: champ } - -elsif champ.type_champ == 'checkbox' - = render partial: 'users/description/champs/checkbox', locals: {champ: champ} + - elsif champ.type_champ == 'checkbox' + = render partial: 'users/description/champs/checkbox', locals: { champ: champ } - -elsif champ.type_champ == 'civilite' - =render partial: 'users/description/champs/civilite', locals: {champ: champ} + - elsif champ.type_champ == 'civilite' + = render partial: 'users/description/champs/civilite', locals: { champ: champ } - - elsif champ.type_champ == 'datetime' - =render partial: 'users/description/champs/datetime', locals: {champ: champ} + - elsif champ.type_champ == 'datetime' + = render partial: 'users/description/champs/datetime', locals: { champ: champ } - - elsif champ.type_champ == 'yes_no' - =render partial: 'users/description/champs/yes_no', locals: {champ: champ} + - elsif champ.type_champ == 'yes_no' + = render partial: 'users/description/champs/yes_no', locals: { champ: champ } - - elsif champ.type_champ == 'drop_down_list' - =render partial: 'users/description/champs/drop_down_list', locals: {champ: champ} + - elsif champ.type_champ == 'drop_down_list' + = render partial: 'users/description/champs/drop_down_list', locals: { champ: champ } - - elsif champ.type_champ == 'pays' - =render partial: 'users/description/champs/pays', locals: {champ: champ} + - elsif champ.type_champ == 'pays' + = render partial: 'users/description/champs/pays', locals: { champ: champ } - - elsif champ.type_champ == 'regions' - =render partial: 'users/description/champs/regions', locals: {champ: champ} + - elsif champ.type_champ == 'regions' + = render partial: 'users/description/champs/regions', locals: { champ: champ } - - elsif champ.type_champ == 'engagement' - =render partial: 'users/description/champs/engagement', locals: {champ: champ} + - elsif champ.type_champ == 'engagement' + = render partial: 'users/description/champs/engagement', locals: { champ: champ } - - elsif champ.type_champ == 'departements' - =render partial: 'users/description/champs/departements', locals: {champ: champ} + - elsif champ.type_champ == 'departements' + = render partial: 'users/description/champs/departements', locals: { champ: champ } - -else - %input.form-control{name:"champs['#{champ.id}']", - placeholder: champ.libelle, - id: "champs_#{champ.id}", - value: champ.value, - type: champ.type_champ, - 'data-provide' => champ.data_provide, - 'data-date-format' => champ.data_date_format} + - else + %input.form-control{name:"champs['#{ champ.id }']", + placeholder: champ.libelle, + id: "champs_#{ champ.id }", + value: champ.value, + type: champ.type_champ, + 'data-provide' => champ.data_provide, + 'data-date-format' => champ.data_date_format} - - unless champ.description.empty? || champ.type_champ == 'engagement' - .row - .col-lg-8.col-md-8.col-sm-8.col-xs-8{class: 'description_div', id:"description_champs_#{champ.id}"} - = champ.description + - unless champ.description.empty? || champ.type_champ == 'engagement' + .help-block{ id:"description_champs_#{ champ.id }" } + = champ.description_with_links diff --git a/app/views/users/description/champs/_textarea.html.haml b/app/views/users/description/champs/_textarea.html.haml index 4c062a300..9ea66d68e 100644 --- a/app/views/users/description/champs/_textarea.html.haml +++ b/app/views/users/description/champs/_textarea.html.haml @@ -2,4 +2,4 @@ placeholder: champ.description, id: "champs_#{champ.id}", row: '6'} - =champ.value \ No newline at end of file + = champ.value From 86901f7f2092aca820bbfc219482adf657ea801c Mon Sep 17 00:00:00 2001 From: LeSim Date: Tue, 14 Feb 2017 11:22:28 +0100 Subject: [PATCH 2/6] Update type_de_champ_decorator.rb From 8a3df4979b2777641984dbbf466a4765bbbd94a3 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 14 Feb 2017 12:05:08 +0100 Subject: [PATCH 3/6] remove byebug and guard until it works --- .byebug_history | 13 ------------- Gemfile | 2 -- 2 files changed, 15 deletions(-) delete mode 100644 .byebug_history diff --git a/.byebug_history b/.byebug_history deleted file mode 100644 index bfbe59fde..000000000 --- a/.byebug_history +++ /dev/null @@ -1,13 +0,0 @@ -continue -next -SIADETOKEN -next -exit -params -next -params -SIADETOKEN -exit -xit -xtei -cniuecniu diff --git a/Gemfile b/Gemfile index 4acfb8697..7e1ca50c9 100644 --- a/Gemfile +++ b/Gemfile @@ -122,8 +122,6 @@ group :development do gem 'web-console' gem 'rack-handlers' gem 'xray-rails' - gem 'guard' - end group :development, :test do From b08a4c5091aa740c42d4aaba9f57f590ed0f5b5f Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 14 Feb 2017 14:34:00 +0100 Subject: [PATCH 4/6] Fix style for checkbox and radios --- app/assets/stylesheets/typeahead.scss | 3 +++ .../users/description/champs/_civilite.html.haml | 13 +++++++------ .../users/description/champs/_yes_no.html.haml | 13 +++++++------ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/assets/stylesheets/typeahead.scss b/app/assets/stylesheets/typeahead.scss index 8cda8e19b..8d4c2a37c 100644 --- a/app/assets/stylesheets/typeahead.scss +++ b/app/assets/stylesheets/typeahead.scss @@ -1,3 +1,6 @@ +.twitter-typeahead { + width: 100%; // http://stackoverflow.com/questions/17957513/extending-the-width-of-bootstrap-typeahead-to-match-input-field +} .tt-menu { padding: 8px 0; diff --git a/app/views/users/description/champs/_civilite.html.haml b/app/views/users/description/champs/_civilite.html.haml index 1a9ad45f3..c6fcf6525 100644 --- a/app/views/users/description/champs/_civilite.html.haml +++ b/app/views/users/description/champs/_civilite.html.haml @@ -1,7 +1,8 @@ -%label.radio-inline - = radio_button_tag "champs['#{champ.id}']", "M.", champ.value == 'Mme' ? false : true - Monsieur +%div + %label.radio-inline + = radio_button_tag "champs['#{champ.id}']", "M.", champ.value == 'Mme' ? false : true + Monsieur -%label.radio-inline - = radio_button_tag "champs['#{champ.id}']", "Mme", champ.value == 'Mme' - Madame \ No newline at end of file + %label.radio-inline + = radio_button_tag "champs['#{champ.id}']", "Mme", champ.value == 'Mme' + Madame \ No newline at end of file diff --git a/app/views/users/description/champs/_yes_no.html.haml b/app/views/users/description/champs/_yes_no.html.haml index 9224f98f5..58cfac7e4 100644 --- a/app/views/users/description/champs/_yes_no.html.haml +++ b/app/views/users/description/champs/_yes_no.html.haml @@ -1,7 +1,8 @@ -%label.radio-inline - = radio_button_tag "champs['#{champ.id}']", "true", champ.value == 'true' - Oui +%div + %label.radio-inline + = radio_button_tag "champs['#{champ.id}']", "true", champ.value == 'true' + Oui -%label.radio-inline - = radio_button_tag "champs['#{champ.id}']", "false", champ.value == 'false' - Non \ No newline at end of file + %label.radio-inline + = radio_button_tag "champs['#{champ.id}']", "false", champ.value == 'false' + Non \ No newline at end of file From f60098311ef93130bffd728d15e52f64f30ca7c9 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 14 Feb 2017 14:55:08 +0100 Subject: [PATCH 5/6] Fix hidden checkbox bug, address field : full width --- .../description/champs/_checkbox.html.haml | 8 +- .../description/champs/_engagement.html.haml | 11 +-- .../champs/_render_list_champs.html.haml | 77 +++++++++---------- 3 files changed, 43 insertions(+), 53 deletions(-) diff --git a/app/views/users/description/champs/_checkbox.html.haml b/app/views/users/description/champs/_checkbox.html.haml index 8f2727f9d..bae7b55ad 100644 --- a/app/views/users/description/champs/_checkbox.html.haml +++ b/app/views/users/description/champs/_checkbox.html.haml @@ -1,6 +1,2 @@ -%h4{style:'margin-left:15px;'} - = champ.libelle - - if champ.mandatory? - = '*' - %input{type: 'hidden', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", value: ''} - %input{type: 'checkbox', style:'margin-left: 15px;', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.value == 'on')} +%input{type: 'hidden', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", value: ''} +%input{type: 'checkbox', style:'margin-left: 15px;', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.value == 'on')} diff --git a/app/views/users/description/champs/_engagement.html.haml b/app/views/users/description/champs/_engagement.html.haml index 9381266cf..9addfed85 100644 --- a/app/views/users/description/champs/_engagement.html.haml +++ b/app/views/users/description/champs/_engagement.html.haml @@ -1,8 +1,3 @@ -%h4{style:'margin-left:15px;'} - = champ.libelle - - if champ.mandatory? - = '*' - %input{type: 'hidden', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", value: ''} - %input{type: 'checkbox', style:'margin-left: 15px;', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.value == 'on')} -%div{style:'margin-left: 5%; margin-right: 5%; text-align: justify; text-justify: inter-word;'} - = champ.description.gsub(/\r\n/, '
').html_safe \ No newline at end of file +%div + %input{type: 'hidden', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", value: ''} + %input{type: 'checkbox', style:'margin-left: 15px;', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.value == 'on')} diff --git a/app/views/users/description/champs/_render_list_champs.html.haml b/app/views/users/description/champs/_render_list_champs.html.haml index 021054b59..261ef88e1 100644 --- a/app/views/users/description/champs/_render_list_champs.html.haml +++ b/app/views/users/description/champs/_render_list_champs.html.haml @@ -3,54 +3,53 @@ - if champ.type_champ == 'header_section' - break - - unless champ.type_champ == 'checkbox' || champ.type_champ == 'engagement' - .row - %div{ class: if champ.type_champ == 'textarea' then 'col-md-12' else 'col-md-6' end } - .form-group - %label{ for: "champs_#{ champ.id }"} - = champ.libelle - - if champ.mandatory? - * + .row + %div{ class: if champ.type_champ == 'textarea' || champ.type_champ == 'engagement' then 'col-md-12' else 'col-md-6' end } + .form-group + %label{ for: "champs_#{ champ.id }"} + = champ.libelle + - if champ.mandatory? + * - - if champ.type_champ == 'textarea' - = render partial: 'users/description/champs/textarea', locals: { champ: champ } + - if champ.type_champ == 'textarea' + = render partial: 'users/description/champs/textarea', locals: { champ: champ } - - elsif champ.type_champ == 'checkbox' - = render partial: 'users/description/champs/checkbox', locals: { champ: champ } + - elsif champ.type_champ == 'checkbox' + = render partial: 'users/description/champs/checkbox', locals: { champ: champ } - - elsif champ.type_champ == 'civilite' - = render partial: 'users/description/champs/civilite', locals: { champ: champ } + - elsif champ.type_champ == 'civilite' + = render partial: 'users/description/champs/civilite', locals: { champ: champ } - - elsif champ.type_champ == 'datetime' - = render partial: 'users/description/champs/datetime', locals: { champ: champ } + - elsif champ.type_champ == 'datetime' + = render partial: 'users/description/champs/datetime', locals: { champ: champ } - - elsif champ.type_champ == 'yes_no' - = render partial: 'users/description/champs/yes_no', locals: { champ: champ } + - elsif champ.type_champ == 'yes_no' + = render partial: 'users/description/champs/yes_no', locals: { champ: champ } - - elsif champ.type_champ == 'drop_down_list' - = render partial: 'users/description/champs/drop_down_list', locals: { champ: champ } + - elsif champ.type_champ == 'drop_down_list' + = render partial: 'users/description/champs/drop_down_list', locals: { champ: champ } - - elsif champ.type_champ == 'pays' - = render partial: 'users/description/champs/pays', locals: { champ: champ } + - elsif champ.type_champ == 'pays' + = render partial: 'users/description/champs/pays', locals: { champ: champ } - - elsif champ.type_champ == 'regions' - = render partial: 'users/description/champs/regions', locals: { champ: champ } + - elsif champ.type_champ == 'regions' + = render partial: 'users/description/champs/regions', locals: { champ: champ } - - elsif champ.type_champ == 'engagement' - = render partial: 'users/description/champs/engagement', locals: { champ: champ } + - elsif champ.type_champ == 'engagement' + = render partial: 'users/description/champs/engagement', locals: { champ: champ } - - elsif champ.type_champ == 'departements' - = render partial: 'users/description/champs/departements', locals: { champ: champ } + - elsif champ.type_champ == 'departements' + = render partial: 'users/description/champs/departements', locals: { champ: champ } - - else - %input.form-control{name:"champs['#{ champ.id }']", - placeholder: champ.libelle, - id: "champs_#{ champ.id }", - value: champ.value, - type: champ.type_champ, - 'data-provide' => champ.data_provide, - 'data-date-format' => champ.data_date_format} + - else + %input.form-control{name:"champs['#{ champ.id }']", + placeholder: champ.libelle, + id: "champs_#{ champ.id }", + value: champ.value, + type: champ.type_champ, + 'data-provide' => champ.data_provide, + 'data-date-format' => champ.data_date_format} - - unless champ.description.empty? || champ.type_champ == 'engagement' - .help-block{ id:"description_champs_#{ champ.id }" } - = champ.description_with_links + - unless champ.description.empty? + %div{ id:"description_champs_#{ champ.id }", class: ('help-block' unless champ.type_champ == 'engagement') } + = champ.description_with_links From 1e3c5bf14ab3485d0f6e43631c5cbe8d54819956 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 14 Feb 2017 15:23:39 +0100 Subject: [PATCH 6/6] Fix engagement field --- app/views/users/description/champs/_engagement.html.haml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/users/description/champs/_engagement.html.haml b/app/views/users/description/champs/_engagement.html.haml index 9addfed85..bae7b55ad 100644 --- a/app/views/users/description/champs/_engagement.html.haml +++ b/app/views/users/description/champs/_engagement.html.haml @@ -1,3 +1,2 @@ -%div - %input{type: 'hidden', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", value: ''} - %input{type: 'checkbox', style:'margin-left: 15px;', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.value == 'on')} +%input{type: 'hidden', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", value: ''} +%input{type: 'checkbox', style:'margin-left: 15px;', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.value == 'on')}