aboutsummaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2021-01-22 05:32:15 +0100
committerhellekin <hellekin@cepheide.org>2021-01-22 05:32:15 +0100
commitb54a8458d5029b3494165b7430e21b3ae34ecc0c (patch)
tree32ea6fc6b8774f672325fec52f0ffc97229a9568 /app/views
parent1c1aead78192982e221179de6688b944e5b01bf6 (diff)
downloadincommon-map-b54a8458d5029b3494165b7430e21b3ae34ecc0c.tar.gz
Upgrade Rails and add StimulusJS support
Diffstat (limited to 'app/views')
-rw-r--r--app/views/agents/_edit.html.erb6
-rw-r--r--app/views/agents/_form.html.erb22
-rw-r--r--app/views/agents/index.html.erb5
-rw-r--r--app/views/agents/new.html.erb2
-rw-r--r--app/views/agents/show.html.erb3
-rw-r--r--app/views/categories/_category.html.erb17
-rw-r--r--app/views/categories/_edit.html.erb6
-rw-r--r--app/views/categories/_form.html.erb25
-rw-r--r--app/views/categories/edit.html.erb1
-rw-r--r--app/views/categories/show.html.erb2
-rw-r--r--app/views/layouts/application.html.erb55
-rw-r--r--app/views/resources/_resource.json.erb1
-rw-r--r--app/views/resources/show.json.erb1
-rw-r--r--app/views/sections/show.html.erb11
-rw-r--r--app/views/sections/show.json.erb1
-rw-r--r--app/views/taxonomies/_taxonomy.html.erb1
-rw-r--r--app/views/taxonomies/index.html.erb2
-rw-r--r--app/views/users/_user.html.erb3
-rw-r--r--app/views/users/index.html.erb6
-rw-r--r--app/views/welcome/authenticate.html.erb2
-rw-r--r--app/views/welcome/index.html.erb5
21 files changed, 140 insertions, 37 deletions
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 @@
+<h3>Edit <%= @agent.presence&.name || 'new agent' %></h3>
+<h2>Context: <%= current_agent %></h2>
+
+<%= 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 @@
+<fieldset>
+ <%= tag.legend "Propriétés de l'Agent" %>
+
+ <dl>
+ <dt><%= f.label :name %></dt>
+ <dd><%= f.text_field :name, maxlength: 64, placeholder: 'incommon' %>
+ <br>hint: this must match a group name on talk.incommon.cc</dd>
+
+ <dt><%= f.label :summary %></dt>
+ <dd><%= f.text_field :summary, maxlength: 136, placeholder: 'Default Agent' %></dd>
+
+ <dt><%= f.label :description %></dt>
+ <dd><%= 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/' %></dd>
+ </dl>
+</fieldset>
+
+<p><%= f.submit 'Save' %></p>
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 @@
+<article id="agents">
+ <h1>Agents</h1>
+
+ <%= render partial: @agents %>
+</article>
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 @@
+<article class="agent" id="agent-<%= @agent.to_param %>">
+ <%= render partial: @agent %>
+</article>
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 @@
+<article class="category" id="category-<%= category.id %>">
+ <header style="background-color: <%= category.color %>">
+ <h1><%= category.taxonomy.name %></h1>
+ <h2><%= category.name %></h2>
+ </header>
+ <p><%= h category.summary %></p>
+ <div class="markdown"><%= h category.description %></div>
+ <section id="stats"><h3>Info</h3>
+ <p><%= pluralize(category.sections_count, 'section') %></p>
+ <p><%= pluralize(category.sections.map { |s| s.resources }.sum(&:count) || 0, 'resources') %></p>
+ </section>
+ <section id="actions">
+ <ul>
+ <li><%= link_to 'edit', edit_category_path(category) %></li>
+ </ul>
+ </section>
+</article>
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 @@
+<h3>Edit <%= @category.presence&.name || 'new category' %></h3>
+<h2>Context: <%= @taxonomy %></h2>
+
+<%= 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 @@
+<fieldset>
+ <%= tag.legend "Categorie..." %>
+
+ <dl>
+ <dt><%= f.label :name %></dt>
+ <dd><%= f.text_field :name, maxlength: 64, placeholder: 'Se loger' %></dd>
+
+ <dt><%= f.label :summary %></dt>
+ <dd><%= f.text_field :summary, maxlength: 136, placeholder: 'Une ferme locale' %></dd>
+
+ <dt><%= f.label :description %></dt>
+ <dd><%= 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/' %></dd>
+
+ <dt><%= f.label :color %></dt>
+ <dd><%= f.color_field :color, placeholder: '#cc0077 (or: rgba(255 0 0 0.5)' %></dd>
+ </dl>
+</fieldset>
+
+<%= f.hidden_field :taxonomy_id, value: @category.taxonomy_id %>
+
+<p><%= f.submit 'Save' %></p>
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 @@
<meta charset="UTF-8">
<title>Carte IN COMMON</title>
<meta name="viewport" content="initial-width: device-width initial-scale=1.0 viewport-fit=cover">
- <%= 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 %>
- </head>
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
+ <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
+ <%= yield :head %>
+ </head>
- <body>
- <header>
- <h1><%= link_to image_tag("https://talk.incommon.cc/uploads/disc_6_incommon/original/1X/92f926e8210ea7a5412d6e2bdabfa825233e808b.png", alt: "IN COMMON", size: "x4em"), '/' %></h1>
- <%= render 'application/user_info' %>
- <%= yield :header %>
- </header>
- <main>
- <article>
- <%= yield %>
- </article>
- </main>
- <aside>
- <%= yield :aside %>
- </aside>
- <footer>
- <%= yield :footer %>
- </footer>
- <%= render partial: 'debug' %>
- <%= render partial: 'flash' %>
- <%= yield :body_end %>
- </body>
+ <body>
+ <header>
+ <h1><%= link_to image_tag("https://talk.incommon.cc/uploads/disc_6_incommon/original/1X/92f926e8210ea7a5412d6e2bdabfa825233e808b.png", alt: "IN COMMON", size: "x4em"), '/' %></h1>
+ <%= render 'application/user_info' %>
+ <%= yield :header %>
+ </header>
+ <main>
+ <article>
+ <%= yield %>
+ </article>
+ </main>
+ <aside>
+ <%= yield :aside %>
+ </aside>
+ <footer>
+ <%= yield :footer %>
+ </footer>
+ <%= render partial: 'debug' %>
+ <%= render partial: 'flash' %>
+ <%= yield :body_end %>
+ </body>
</html>
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 @@
+<pre><code lang="ecmascript">
+// 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)
+
+</code></pre>
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 @@
<button data-action="taxonomy#deploy">Preview</button>
<div class="deploy" data-target="taxonomy.deploy"></div>
</section>
-
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 @@
<section id="taxonomies">
<h2>Available Taxonomies</h2>
- <%= render collection: @taxonomies: %>
+ <%= render collection: @taxonomies %>
</section>
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 @@
+<div class="member">
+ <span class="name"><%= user.name %></span>
+</div>
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 @@
-<h1>Users#index</h1>
-<p>Find me in app/views/users/index.html.erb</p>
+<h1>Agent <%= current_agent %> Members</h1>
+<p>This agent counts (<%= pluralize(@users.count, "member") %>)</p>
-<p>Show a table with Agent <%= current_agent %> members (<%= pluralize(@users.count, "user") %>), their roles, and ways to change them.</p>
+<%= 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 @@
<p>Your Agents:
<ul>
<% @current_user&.agencies&.each do |a| %>
- <li><%= a.name %> (<%= a.roles %>)</li>
+ <li><%= a.name %></li>
<% end %>
</ul>
</p>
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 @@
<button data-action="taxonomy#toggle" data-target="taxonomy.toggle"></button>
</div>
<div data-target="taxonomy.filter"></div>
+ <div data-target="taxonomy.layers"></div>
</div>
<% end %>
<% content_for :debug do %>
<% if current_user.present? %>
- <p>Premier élément de la liste:</p>
- <% res = @resources.first %>
- <p><%= res.feature["properties"]["name"] %></p>
- <p><%= res.feature["geometry"]["coordinates"] %></p>
<% end %><%# ensure it does not break when we don't have a record... %>
<% end %>