aboutsummaryrefslogtreecommitdiff
path: root/app/views/resources
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/resources')
-rw-r--r--app/views/resources/_edit.html.erb6
-rw-r--r--app/views/resources/_form.html.erb61
-rw-r--r--app/views/resources/edit.html.erb17
-rw-r--r--app/views/resources/new.html.erb4
4 files changed, 70 insertions, 18 deletions
diff --git a/app/views/resources/_edit.html.erb b/app/views/resources/_edit.html.erb
new file mode 100644
index 0000000..fdb2921
--- /dev/null
+++ b/app/views/resources/_edit.html.erb
@@ -0,0 +1,6 @@
+<h3>Edit <%= resource.presence&.name || 'new resource' %></h3>
+<h2>Context: <%= current_agent %></h2>
+
+<%= form_with model: [current_agent,@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
new file mode 100644
index 0000000..fe5f532
--- /dev/null
+++ b/app/views/resources/_form.html.erb
@@ -0,0 +1,61 @@
+<fieldset>
+ <%= tag.legend "Propriétés de la ressource" %>
+
+ <dl>
+ <dt><%= f.label :name %></dt>
+ <dd><%= f.text_field :name, maxlength: 64, placeholder: 'La ferme des animaux', value: resource.name %></dd>
+
+ <dt><%= f.label :summary %></dt>
+ <dd><%= f.text_field :summary, maxlength: 136, placeholder: 'Une ferme locale', value: resource.name %></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 :email %></dt>
+ <dd><%= f.email_field :email, placeholder: 'bonjour@la-ferme-des-animaux.example' %></dd>
+
+ <dt><%= f.label :website %></dt>
+ <dd><%= f.url_field :website, placeholder: 'https://la-ferme-des-animaux.example' %></dd>
+
+ <dt><%= f.label :phone_number %></dt>
+ <dd><%= f.telephone_field :phone_number, placeholder: '+32 489 000 0000' %></dd>
+ </dl>
+</fieldset>
+
+<fieldset>
+ <%= tag.legend "Classification" %>
+ <%# TODO Add a taxonomy selector %>
+ <%= section_select(current_agent.taxonomies.first) %>
+</fieldset>
+
+<fieldset>
+ <%= tag.legend "Coordonées géographiques" %>
+ <%# TODO Add a graphical geo selector %>
+
+ <dl>
+ <dt><%= f.label :address %></dt>
+ <dd><%= f.text_field :address, value: resource.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>
+
+ <dt><%= f.label :city %></dt>
+ <dd><%= f.text_field :city, value: resource.city, placeholder: 'Bruxelles' %></dd>
+ </dl>
+
+ <dl>
+ <dt><%= f.label :longitude %></dt>
+ <dd><%= f.text_field :longitude, value: resource.longitude, placeholder: '0.56789012' %></dd>
+
+ <dt><%= f.label :latitude %></dt>
+ <dd><%= f.text_field :latitude, value: resource.latitude, placeholder: '50.12345678' %></dd>
+ </dl>
+</fieldset>
+
+<%= f.hidden_field :agent_id, value: current_agent.id %>
+
+<p><%= f.submit 'Save' %></p>
diff --git a/app/views/resources/edit.html.erb b/app/views/resources/edit.html.erb
index b051bae..80d8206 100644
--- a/app/views/resources/edit.html.erb
+++ b/app/views/resources/edit.html.erb
@@ -1,17 +1,2 @@
-<%= form_with model: @resource, local: true do |f| %>
- <%= tag.legend " " %>
- <%= f.label :name %>
- <%= f.text_field :name, value: @resource.name %>
-
- <%= tag.legend " " %>
- <%= f.label :categories %>
- <%= f.text_field :categories, value: @resource.categories %>
+<%= render partial: 'edit', locals: { resource: @resource } %>
- <%= tag.legend "Coordonées géographiques" %>
- <%= f.label :longitude %>
- <%= f.text_field :longitude, value: @resource.lon %>
- <%= f.label :latitude %>
- <%= f.text_field :latitude, value: @resource.lat %>
-
- <%= f.submit 'Save' %>
-<% end %>
diff --git a/app/views/resources/new.html.erb b/app/views/resources/new.html.erb
index c29e88a..80d8206 100644
--- a/app/views/resources/new.html.erb
+++ b/app/views/resources/new.html.erb
@@ -1,2 +1,2 @@
-<h1>Resources#new</h1>
-<p>Find me in app/views/resources/new.html.erb</p>
+<%= render partial: 'edit', locals: { resource: @resource } %>
+