aboutsummaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
Diffstat (limited to 'app/views')
-rw-r--r--app/views/resources/_edit.html.erb4
-rw-r--r--app/views/resources/_form.html.erb37
-rw-r--r--app/views/resources/new.html.erb4
3 files changed, 30 insertions, 15 deletions
diff --git a/app/views/resources/_edit.html.erb b/app/views/resources/_edit.html.erb
index 55c59f6..f22aee3 100644
--- a/app/views/resources/_edit.html.erb
+++ b/app/views/resources/_edit.html.erb
@@ -1,6 +1,6 @@
-<h3>Edit <%= @resource.presence.feature['properties']['name'] || 'new resource' %></h3>
+<h3>Edit <%= @resource.presence.name || 'new resource' %></h3>
<h2>Context: <%= current_agent %></h2>
-<%= form_with model: [current_agent,@resource], url: controller.action_name == 'new' ? agent_resources_path(agent: current_agent) : resource_path(@resource) do |f| %>
+<%= form_with model: @resource, url: @resource.presence.new_record? ? agent_resources_path(current_agent) : resource_path(@resource.resource) do |f| %>
<%= render partial: 'form', locals: { resource: resource, f: f } %>
<% end %>
diff --git a/app/views/resources/_form.html.erb b/app/views/resources/_form.html.erb
index 89745bd..648834d 100644
--- a/app/views/resources/_form.html.erb
+++ b/app/views/resources/_form.html.erb
@@ -1,12 +1,24 @@
-<fieldset>
+<% if resource.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(resource.errors.count, "error") %> prohibited this resource from being saved:</h2>
+
+ <ul>
+ <% resource.errors.each do |error| %>
+ <li><%= error.full_message %></li>
+ <% end %>
+ </ul>
+ </div>
+<% end %>
+
+ <fieldset>
<%= tag.legend "Propriétés de la ressource" %>
- <dl>
+ <dl class="field">
<dt><%= f.label :name %></dt>
- <dd><%= f.text_field :name, maxlength: 64, placeholder: 'La ferme des animaux', value: resource.name %></dd>
+ <dd><%= f.text_field :name, maxlength: 64, placeholder: 'La ferme des animaux' %></dd>
<dt><%= f.label :summary %></dt>
- <dd><%= f.text_field :summary, maxlength: 136, placeholder: 'Une ferme locale', value: resource.name %></dd>
+ <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
@@ -29,33 +41,34 @@ La description _peut_ comporter du [Markdown].
<fieldset>
<%= tag.legend "Classification" %>
<%# TODO Add a taxonomy selector %>
- <%= section_select(current_agent.taxonomies&.first || Taxonomy.first) %>
+ <%= section_select(current_agent.taxonomies&.first || Taxonomy.first, resource.section_ids, name: 'resource_form[section_ids]') %>
</fieldset>
<fieldset>
<%= tag.legend "Coordonées géographiques" %>
<%# TODO Add a graphical geo selector %>
- <dl>
+ <dl class="field">
<dt><%= f.label :address %></dt>
- <dd><%= f.text_field :address, value: resource.address, placeholder: 'Rue aux herbes, 123' %></dd>
+ <dd><%= f.text_field :address, placeholder: 'Rue aux herbes, 123' %></dd>
<dt><%= f.label :postal_code %></dt>
- <dd><%= f.text_field :postal_code, value: resource.postal_code, placeholder: '1000' %></dd>
+ <dd><%= f.text_field :postal_code, placeholder: '1000' %></dd>
<dt><%= f.label :city %></dt>
- <dd><%= f.text_field :city, value: resource.city, placeholder: 'Bruxelles' %></dd>
+ <dd><%= f.text_field :city, placeholder: 'Bruxelles' %></dd>
</dl>
- <dl>
+ <dl class="field">
<dt><%= f.label :longitude %></dt>
- <dd><%= f.text_field :longitude, value: resource.longitude, placeholder: '0.56789012' %></dd>
+ <dd><%= f.text_field :longitude, placeholder: '0.56789012', pattern: '[\d]+.[\d]+' %></dd>
<dt><%= f.label :latitude %></dt>
- <dd><%= f.text_field :latitude, value: resource.latitude, placeholder: '50.12345678' %></dd>
+ <dd><%= f.text_field :latitude, placeholder: '50.12345678', pattern: '[\d]+.[\d]+' %></dd>
</dl>
</fieldset>
<%= f.hidden_field :agent_id, value: current_agent.id %>
+<%= f.hidden_field :source, value: current_agent.name %>
<p><%= f.submit 'Save' %></p>
diff --git a/app/views/resources/new.html.erb b/app/views/resources/new.html.erb
index 80d8206..e8347b4 100644
--- a/app/views/resources/new.html.erb
+++ b/app/views/resources/new.html.erb
@@ -1,2 +1,4 @@
-<%= render partial: 'edit', locals: { resource: @resource } %>
+<%= render 'edit', resource: @resource %>
+
+<#%= render partial: 'edit', locals: { resource: @resource } %>