From b54a8458d5029b3494165b7430e21b3ae34ecc0c Mon Sep 17 00:00:00 2001 From: hellekin Date: Fri, 22 Jan 2021 05:32:15 +0100 Subject: Upgrade Rails and add StimulusJS support --- app/views/agents/_edit.html.erb | 6 ++++ app/views/agents/_form.html.erb | 22 +++++++++++++ app/views/agents/index.html.erb | 5 +++ app/views/agents/new.html.erb | 2 ++ app/views/agents/show.html.erb | 3 ++ app/views/categories/_category.html.erb | 17 ++++++++++ app/views/categories/_edit.html.erb | 6 ++++ app/views/categories/_form.html.erb | 25 +++++++++++++++ app/views/categories/edit.html.erb | 1 + app/views/categories/show.html.erb | 2 ++ app/views/layouts/application.html.erb | 55 +++++++++++++++++---------------- app/views/resources/_resource.json.erb | 1 + app/views/resources/show.json.erb | 1 + app/views/sections/show.html.erb | 11 +++++++ app/views/sections/show.json.erb | 1 + app/views/taxonomies/_taxonomy.html.erb | 1 - app/views/taxonomies/index.html.erb | 2 +- app/views/users/_user.html.erb | 3 ++ app/views/users/index.html.erb | 6 ++-- app/views/welcome/authenticate.html.erb | 2 +- app/views/welcome/index.html.erb | 5 +-- 21 files changed, 140 insertions(+), 37 deletions(-) create mode 100644 app/views/agents/_edit.html.erb create mode 100644 app/views/agents/_form.html.erb create mode 100644 app/views/agents/index.html.erb create mode 100644 app/views/agents/new.html.erb create mode 100644 app/views/agents/show.html.erb create mode 100644 app/views/categories/_category.html.erb create mode 100644 app/views/categories/_edit.html.erb create mode 100644 app/views/categories/_form.html.erb create mode 100644 app/views/categories/edit.html.erb create mode 100644 app/views/categories/show.html.erb create mode 100644 app/views/resources/_resource.json.erb create mode 100644 app/views/resources/show.json.erb create mode 100644 app/views/sections/show.html.erb create mode 100644 app/views/sections/show.json.erb create mode 100644 app/views/users/_user.html.erb (limited to 'app/views') diff --git a/app/views/agents/_edit.html.erb b/app/views/agents/_edit.html.erb new file mode 100644 index 0000000..72ce56d --- /dev/null +++ b/app/views/agents/_edit.html.erb @@ -0,0 +1,6 @@ +

Edit <%= @agent.presence&.name || 'new agent' %>

+

Context: <%= current_agent %>

+ +<%= form_with model: @agent, url: controller.action_name == 'new' ? agents_path : agent_path(@agent) do |f| %> + <%= render partial: 'form', locals: { agent: @agent, f: f } %> +<% end %> diff --git a/app/views/agents/_form.html.erb b/app/views/agents/_form.html.erb new file mode 100644 index 0000000..563e8ec --- /dev/null +++ b/app/views/agents/_form.html.erb @@ -0,0 +1,22 @@ +
+ <%= tag.legend "Propriétés de l'Agent" %> + +
+
<%= f.label :name %>
+
<%= f.text_field :name, maxlength: 64, placeholder: 'incommon' %> +
hint: this must match a group name on talk.incommon.cc
+ +
<%= f.label :summary %>
+
<%= f.text_field :summary, maxlength: 136, placeholder: 'Default Agent' %>
+ +
<%= f.label :description %>
+
<%= f.text_area :description, cols: 72, rows: 10, spellcheck: true, +placeholder: '## IN COMMON Default Agent + +La description _peut_ comporter du [Markdown]. + +[Markdown]: https://www.markdownguide.org/getting-started/' %>
+
+
+ +

<%= f.submit 'Save' %>

diff --git a/app/views/agents/index.html.erb b/app/views/agents/index.html.erb new file mode 100644 index 0000000..6cb9fb3 --- /dev/null +++ b/app/views/agents/index.html.erb @@ -0,0 +1,5 @@ +
+

Agents

+ + <%= render partial: @agents %> +
diff --git a/app/views/agents/new.html.erb b/app/views/agents/new.html.erb new file mode 100644 index 0000000..3794662 --- /dev/null +++ b/app/views/agents/new.html.erb @@ -0,0 +1,2 @@ +<%= render partial: 'edit', locals: { agent: @agent } %> + diff --git a/app/views/agents/show.html.erb b/app/views/agents/show.html.erb new file mode 100644 index 0000000..0652dc8 --- /dev/null +++ b/app/views/agents/show.html.erb @@ -0,0 +1,3 @@ +
+ <%= render partial: @agent %> +
diff --git a/app/views/categories/_category.html.erb b/app/views/categories/_category.html.erb new file mode 100644 index 0000000..d301fe6 --- /dev/null +++ b/app/views/categories/_category.html.erb @@ -0,0 +1,17 @@ +
+
+

<%= category.taxonomy.name %>

+

<%= category.name %>

+
+

<%= h category.summary %>

+
<%= h category.description %>
+

Info

+

<%= pluralize(category.sections_count, 'section') %>

+

<%= pluralize(category.sections.map { |s| s.resources }.sum(&:count) || 0, 'resources') %>

+
+
+
    +
  • <%= link_to 'edit', edit_category_path(category) %>
  • +
+
+
diff --git a/app/views/categories/_edit.html.erb b/app/views/categories/_edit.html.erb new file mode 100644 index 0000000..4a2da94 --- /dev/null +++ b/app/views/categories/_edit.html.erb @@ -0,0 +1,6 @@ +

Edit <%= @category.presence&.name || 'new category' %>

+

Context: <%= @taxonomy %>

+ +<%= form_with model: [@taxonomy,@category], url: controller.action_name == 'new' ? taxonomy_categories_path(taxonomy: @taxonomy) : category_path(@category) do |f| %> + <%= render partial: 'form', locals: { category: category, f: f } %> +<% end %> diff --git a/app/views/categories/_form.html.erb b/app/views/categories/_form.html.erb new file mode 100644 index 0000000..c4c77c6 --- /dev/null +++ b/app/views/categories/_form.html.erb @@ -0,0 +1,25 @@ +
+ <%= tag.legend "Categorie..." %> + +
+
<%= f.label :name %>
+
<%= f.text_field :name, maxlength: 64, placeholder: 'Se loger' %>
+ +
<%= f.label :summary %>
+
<%= f.text_field :summary, maxlength: 136, placeholder: 'Une ferme locale' %>
+ +
<%= f.label :description %>
+
<%= f.text_area :description, cols: 72, rows: 10, placeholder: '## Un choix pertinent + +La description _peut_ comporter du [Markdown]. + +[Markdown]: https://www.markdownguide.org/getting-started/' %>
+ +
<%= f.label :color %>
+
<%= f.color_field :color, placeholder: '#cc0077 (or: rgba(255 0 0 0.5)' %>
+
+
+ +<%= f.hidden_field :taxonomy_id, value: @category.taxonomy_id %> + +

<%= f.submit 'Save' %>

diff --git a/app/views/categories/edit.html.erb b/app/views/categories/edit.html.erb new file mode 100644 index 0000000..054bed3 --- /dev/null +++ b/app/views/categories/edit.html.erb @@ -0,0 +1 @@ +<%= render partial: 'edit', locals: { category: @category } %> diff --git a/app/views/categories/show.html.erb b/app/views/categories/show.html.erb new file mode 100644 index 0000000..ed548c6 --- /dev/null +++ b/app/views/categories/show.html.erb @@ -0,0 +1,2 @@ +<%= @category.inspect %> +<%= render @category %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 210ace8..bc02585 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,33 +4,34 @@ Carte IN COMMON - <%= csrf_meta_tags %> - <%= csp_meta_tag %> + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + <%= display_meta_tags site: 'IN COMMON Map' %> - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> - <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> - <%= yield :head %> - + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %> + <%= yield :head %> + - -
-

<%= link_to image_tag("https://talk.incommon.cc/uploads/disc_6_incommon/original/1X/92f926e8210ea7a5412d6e2bdabfa825233e808b.png", alt: "IN COMMON", size: "x4em"), '/' %>

- <%= render 'application/user_info' %> - <%= yield :header %> -
-
-
- <%= yield %> -
-
- - - <%= render partial: 'debug' %> - <%= render partial: 'flash' %> - <%= yield :body_end %> - + +
+

<%= link_to image_tag("https://talk.incommon.cc/uploads/disc_6_incommon/original/1X/92f926e8210ea7a5412d6e2bdabfa825233e808b.png", alt: "IN COMMON", size: "x4em"), '/' %>

+ <%= render 'application/user_info' %> + <%= yield :header %> +
+
+
+ <%= yield %> +
+
+ + + <%= render partial: 'debug' %> + <%= render partial: 'flash' %> + <%= yield :body_end %> + diff --git a/app/views/resources/_resource.json.erb b/app/views/resources/_resource.json.erb new file mode 100644 index 0000000..a3769d6 --- /dev/null +++ b/app/views/resources/_resource.json.erb @@ -0,0 +1 @@ +<%= resource.as_json %> diff --git a/app/views/resources/show.json.erb b/app/views/resources/show.json.erb new file mode 100644 index 0000000..5855d72 --- /dev/null +++ b/app/views/resources/show.json.erb @@ -0,0 +1 @@ +<%= render @resource %> diff --git a/app/views/sections/show.html.erb b/app/views/sections/show.html.erb new file mode 100644 index 0000000..9a69891 --- /dev/null +++ b/app/views/sections/show.html.erb @@ -0,0 +1,11 @@ +

+// First, create a section layer on the map, then assign all resource markers to it.
+sec<%= @section.id %> = L.layerGroup
+
+<% @section.resources.each_with_index do |res, i| %>
+mk_<%= i %> = L.marker([<%= res.latitude %>, <%= res.longitude %>]).addTo(sec<%= @section.id %>)
+<% end %>
+
+sec<%= @section.id %>.addTo(map)
+
+
diff --git a/app/views/sections/show.json.erb b/app/views/sections/show.json.erb new file mode 100644 index 0000000..9520404 --- /dev/null +++ b/app/views/sections/show.json.erb @@ -0,0 +1 @@ +<%= geojson_feature_collection(@section) %> diff --git a/app/views/taxonomies/_taxonomy.html.erb b/app/views/taxonomies/_taxonomy.html.erb index eff6931..eb2dd79 100644 --- a/app/views/taxonomies/_taxonomy.html.erb +++ b/app/views/taxonomies/_taxonomy.html.erb @@ -5,4 +5,3 @@
- diff --git a/app/views/taxonomies/index.html.erb b/app/views/taxonomies/index.html.erb index d060f6c..705b0d4 100644 --- a/app/views/taxonomies/index.html.erb +++ b/app/views/taxonomies/index.html.erb @@ -1,5 +1,5 @@

Available Taxonomies

- <%= render collection: @taxonomies: %> + <%= render collection: @taxonomies %>
diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb new file mode 100644 index 0000000..2da5239 --- /dev/null +++ b/app/views/users/_user.html.erb @@ -0,0 +1,3 @@ +
+ <%= user.name %> +
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 0d53728..3451981 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,4 +1,4 @@ -

Users#index

-

Find me in app/views/users/index.html.erb

+

Agent <%= current_agent %> Members

+

This agent counts (<%= pluralize(@users.count, "member") %>)

-

Show a table with Agent <%= current_agent %> members (<%= pluralize(@users.count, "user") %>), their roles, and ways to change them.

+<%= render partial: 'user', collection: @users %> diff --git a/app/views/welcome/authenticate.html.erb b/app/views/welcome/authenticate.html.erb index 548101b..ba9f1c5 100644 --- a/app/views/welcome/authenticate.html.erb +++ b/app/views/welcome/authenticate.html.erb @@ -5,7 +5,7 @@

Your Agents:

diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 2a154ae..d9fd0f6 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -8,14 +8,11 @@
+
<% end %> <% content_for :debug do %> <% if current_user.present? %> -

Premier élément de la liste:

- <% res = @resources.first %> -

<%= res.feature["properties"]["name"] %>

-

<%= res.feature["geometry"]["coordinates"] %>

<% end %><%# ensure it does not break when we don't have a record... %> <% end %> -- cgit v1.2.3