diff --git a/Gemfile b/Gemfile index 33b634e..d25662e 100644 --- a/Gemfile +++ b/Gemfile @@ -24,6 +24,7 @@ gem "font-awesome-sass" gem "rails-i18n" gem "devise-i18n" gem "devise-i18n-views" +gem 'react-rails', '~> 1.0.0.pre', github: 'reactjs/react-rails' gem "mechanize" diff --git a/Gemfile.lock b/Gemfile.lock index 2d4e904..2c0495b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,6 +16,17 @@ GIT ransack (~> 1.3) sass-rails +GIT + remote: git://github.com/reactjs/react-rails.git + revision: 901c8f68445df849642394cdf9859d293dc13f04 + specs: + react-rails (1.0.0.pre) + coffee-script-source (~> 1.9) + connection_pool + execjs + rails (>= 3.1) + react-source (~> 0.12) + GEM remote: https://rubygems.org/ remote: https://rails-assets.org/ @@ -105,6 +116,7 @@ GEM execjs coffee-script-source (1.9.1) columnize (0.9.0) + connection_pool (2.1.2) countries (0.9.3) currencies (~> 0.4.2) country_select (2.1.1) @@ -259,6 +271,7 @@ GEM activesupport (>= 3.0) i18n polyamorous (~> 1.1) + react-source (0.12.2) responders (2.1.0) railties (>= 4.2.0, < 5) sass (3.4.12) @@ -332,6 +345,7 @@ DEPENDENCIES rails (= 4.2.0) rails-i18n rails_12factor + react-rails (~> 1.0.0.pre)! sass-rails (~> 5.0) simple_form spring diff --git a/app/assets/javascripts/app/sideBoxService.js b/app/assets/javascripts/app/sideBoxService.js index b0015cb..8987d8e 100644 --- a/app/assets/javascripts/app/sideBoxService.js +++ b/app/assets/javascripts/app/sideBoxService.js @@ -9,7 +9,8 @@ $(document).ready(function() { if ($('.bg-active').length) { // si il y a déjà un amendement displayed if (that.hasClass('active')) { // si on click sur le l'amendment déjà display - // il ne se passe rien car c'est déjà display ;) + $('.active').removeClass('active'); + $('.bg-active').removeClass('bg-active').addClass('hidden') // on reclique et la box se ferme } else { $('.active').removeClass('active'); // sinon, on remove l'état actif des éléments actifs $('.bg-active').removeClass('bg-active').addClass('hidden'); // on enlève l'amendement précédent de la box @@ -31,6 +32,9 @@ $(document).ready(function() { // mode edition d'un amendement $(document).on('click', '.btn-edition', function(){ // enter edition mode +console.log("je ferme toutes les box actives de lecture d'amendement") + $('.active').removeClass('active'); // ferme les boxes d'amendement + $('.bg-active').removeClass('bg-active').addClass('hidden') console.log("j'édite") $(this).removeClass('btn-edition').addClass('btn-edition-close') // btn pour js makeEditable() @@ -48,7 +52,8 @@ $(document).on('click', '.btn-edition-close', function(){ // escape edition mode function editionMode() { $(document).on('mouseup', '.editable', function(){ if (window.getSelection().toString().length != 0) { - $('.initial-selection h3 span').text(window.getSelection().toString()) + $('.initial-selection p span').text(window.getSelection().toString()) + $('.btn-text-replace').removeClass('hidden') // TODO : remove hidden class on add box $('.new-amendment').removeClass('hidden'); @@ -69,9 +74,9 @@ function editionMode() { function textIncrementation() { var selection = window.getSelection().toString() var selectionToMatch = $("").text(window.getSelection().toString())[0].outerHTML - var textToReplace = $('.article-area p').html() + var textToReplace = $('.article-area article').html() var newText = textToReplace.replace(selection, selectionToMatch) - $('.article-area p').html(newText) + $('.article-area article').html(newText) $('.editable-amendment').after("") @@ -84,6 +89,13 @@ function textIncrementation() { }) } +//annuler saisie et sortir du formulaire +$('.cancel').on('click', function(){ + $('.active').removeClass('active'); // sinon, on remove l'état actif des éléments actifs + $('.form-container').addClass('hidden'); // on enlève l'amendement précédent de la box +} + ) + function makeEditable() { $('.article-area').addClass('editable'); } diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 443464b..519780a 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -2,6 +2,9 @@ //= require jquery_ujs //= require bootstrap-sprockets +//= require react +//= require react_ujs +//= require components //= require_tree ./app diff --git a/app/assets/javascripts/components.js b/app/assets/javascripts/components.js new file mode 100644 index 0000000..9ce7a4f --- /dev/null +++ b/app/assets/javascripts/components.js @@ -0,0 +1 @@ +//= require_tree ./components diff --git a/app/assets/javascripts/components/.gitkeep b/app/assets/javascripts/components/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/components/EditableMode.js.jsx b/app/assets/javascripts/components/EditableMode.js.jsx new file mode 100644 index 0000000..40be38f --- /dev/null +++ b/app/assets/javascripts/components/EditableMode.js.jsx @@ -0,0 +1,46 @@ +var EditableMode = React.createClass({ + render: function() { + return ( +
+
+

+
+ + Déposer un amendement + +
+
+ + +
+ + + +
+ +
+ + +
+ +
    +
  • + +
  • + +
  • + +
  • +
+
+
+
+ ) + } +}) \ No newline at end of file diff --git a/app/assets/stylesheets/pages/_law.scss b/app/assets/stylesheets/pages/_law.scss index 06cd2cf..077db07 100644 --- a/app/assets/stylesheets/pages/_law.scss +++ b/app/assets/stylesheets/pages/_law.scss @@ -1,8 +1,8 @@ .list-article { font-size: 20px; font-style: italic; - color: #29A4AB; + color: $red-parol; &:hover { - color: #024462; + color: $red-parol-hover; } -} \ No newline at end of file +} diff --git a/app/views/amendments/edit.html.erb b/app/views/amendments/edit.html.erb index 77ec71b..039d24f 100644 --- a/app/views/amendments/edit.html.erb +++ b/app/views/amendments/edit.html.erb @@ -1,21 +1,21 @@ -
+ -
-

Modifier un Amendment

- <%= simple_form_for(@amendment) do |f| %> - <%= f.error_notification %> - <%= f.input :chamber, label: "Chambre :" %> - <%= f.input :author, label: "Auteur(s) :" %> - <%= f.input :amendment_number, label: "N° Amendement :" %> - <%= f.input :content, label: "Contenu :" %> - <%= f.input :object, label: "Exposé des motifs :" %> - <%= f.input :date, label: "Date de vote :", placeholder: "12/02/2015" %> - <%= f.input :status, label: "Statut :" %> +
--> + + <%#= simple_form_for(@amendment) do |f| %> + <%#= f.error_notification %> + <%#= f.input :chamber, label: "Chambre :" %> + <%#= f.input :author, label: "Auteur(s) :" %> + <%#= f.input :amendment_number, label: "N° Amendement :" %> + <%#= f.input :content, label: "Contenu :" %> + <%#= f.input :object, label: "Exposé des motifs :" %> + <%#= f.input :date, label: "Date de vote :", placeholder: "12/02/2015" %> + <%#= f.input :status, label: "Statut :" %> <%#= f.string :porteur %> - <%= f.button :submit, value: "Mettre à jour", class:"center-block btn btn-success" %> - <% end %> -
+ <%#= f.button :submit, value: "Mettre à jour", class:"center-block btn btn-success" %> + <%# end %> + \ No newline at end of file diff --git a/app/views/amendments/new.html.erb b/app/views/amendments/new.html.erb index 04e8b3b..f31a866 100644 --- a/app/views/amendments/new.html.erb +++ b/app/views/amendments/new.html.erb @@ -1,21 +1,21 @@ -
+ - <%= f.input :author, label: "Auteur(s) :" %> - <%= f.input :amendment_number, label: "N° Amendement :" %> - <%= f.input :content, label: "Contenu :" %> - <%= f.input :object, label: "Exposé des motifs :" %> - <%= f.input :date, label: "Date de vote :", placeholder: "12/02/2015" %> - <%= f.input :status, label: "Statut :" %> +

Créer un Amendment

--> + <%#= simple_form_for(@amendment) do |f| %> + <%#= f.error_notification %> + <%#= f.input :chamber, label: "Chambre :" %> + <%#= f.input :author, label: "Auteur(s) :" %> + <%#= f.input :amendment_number, label: "N° Amendement :" %> + <%#= f.input :content, label: "Contenu :" %> + <%#= f.input :object, label: "Exposé des motifs :" %> + <%#= f.input :date, label: "Date de vote :", placeholder: "12/02/2015" %> + <%#= f.input :status, label: "Statut :" %> <%#= f.string :porteur %> - <%= f.button :submit, value: "Enregistrer", class:"center-block btn btn-success" %> - <% end %> -
+ <%#= f.button :submit, value: "Enregistrer", class:"center-block btn btn-success" %> + <%# end %> + \ No newline at end of file diff --git a/app/views/code_article/index.html.erb b/app/views/code_article/index.html.erb index b3f3833..738f28d 100644 --- a/app/views/code_article/index.html.erb +++ b/app/views/code_article/index.html.erb @@ -27,8 +27,8 @@
    -
  • <%= link_to 'Retour au Code', code_path(@code), class: 'btn btn-primary' %>
  • -
  • <%= link_to 'Retour à la liste', codes_path, class: 'btn btn-success' %>
  • +
  • <%= link_to 'Retour au code', code_path(@code), class: 'btn btn-default' %>
  • +
  • <%= link_to 'Retour à la liste', codes_path, class: 'btn btn-default' %>
diff --git a/app/views/codes/index.html.erb b/app/views/codes/index.html.erb index df2c661..b8a4483 100644 --- a/app/views/codes/index.html.erb +++ b/app/views/codes/index.html.erb @@ -6,14 +6,14 @@
-

Les codes de Loi

+

Les codes de loi


    <% @codes.each do |code| %>
  • <%= code.title %>

    <%= code.description %>

    -

    <%= link_to 'Details', code_path(code) %>

    +

    <%= link_to 'Details', code_path(code), class: 'btn btn-default' %>

  • <% end %>
diff --git a/app/views/codes/show.html.erb b/app/views/codes/show.html.erb index 585c8b5..a8e3749 100644 --- a/app/views/codes/show.html.erb +++ b/app/views/codes/show.html.erb @@ -17,7 +17,7 @@ <% @code.code_articles.each do |code_article| %>
  • - <%= link_to code_code_article_index_path(@code, path: code_article.article_path) do %> + <%= link_to code_code_article_index_path(@code, path: code_article.article_path), class: 'list-article' do %> <%= code_article.article_number %> <% end %>
  • @@ -25,7 +25,7 @@ <% end %> <%#= link_to amendment.title, law_amendment_path%>
    -

    <%= link_to 'Retour à la liste', codes_path, class: 'btn btn-primary' %> +

    <%= link_to 'Retour à la liste', codes_path, class: 'btn btn-default' %>

diff --git a/app/views/law_articles/show.html.erb b/app/views/law_articles/show.html.erb index 942f598..7a6ebf5 100644 --- a/app/views/law_articles/show.html.erb +++ b/app/views/law_articles/show.html.erb @@ -1,6 +1,5 @@
-
  • @@ -29,11 +28,13 @@
-
+

<%= @law.title %> - <%= @article.article_number %>

<%= @article.object %> :

- <%= format_article_content(@article) %> +
+ <%= format_article_content(@article) %> +
diff --git a/db/seeds.rb b/db/seeds.rb index 079007e..909e2f6 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,7 +10,7 @@ codes = Code.create! [ { title: "Code de l'éducation", - description: "Ensemble des lois portant sur l'éducation, de l'école et de la formation.", + description: "Ensemble des lois portant sur l'éducation, l'école et la formation", github_path: "french_law/code_education" }, {