From d242fb5bbc423876f4c192b5f133619a2d4f0113 Mon Sep 17 00:00:00 2001 From: hellekin Date: Fri, 9 Oct 2020 10:29:34 +0200 Subject: Scope routes to Agent Since an Agent is required for all records, we scope the routes and get it present for free ;) This commit also adds resource views. --- app/views/resources/_edit.html.erb | 6 ++++ app/views/resources/_form.html.erb | 61 ++++++++++++++++++++++++++++++++++++++ app/views/resources/edit.html.erb | 17 +---------- app/views/resources/new.html.erb | 4 +-- 4 files changed, 70 insertions(+), 18 deletions(-) create mode 100644 app/views/resources/_edit.html.erb create mode 100644 app/views/resources/_form.html.erb (limited to 'app/views/resources') 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 @@ +

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

+

Context: <%= current_agent %>

+ +<%= 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 @@ +
+ <%= tag.legend "Propriétés de la ressource" %> + +
+
<%= f.label :name %>
+
<%= f.text_field :name, maxlength: 64, placeholder: 'La ferme des animaux', value: resource.name %>
+ +
<%= f.label :summary %>
+
<%= f.text_field :summary, maxlength: 136, placeholder: 'Une ferme locale', value: resource.name %>
+ +
<%= 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 :email %>
+
<%= f.email_field :email, placeholder: 'bonjour@la-ferme-des-animaux.example' %>
+ +
<%= f.label :website %>
+
<%= f.url_field :website, placeholder: 'https://la-ferme-des-animaux.example' %>
+ +
<%= f.label :phone_number %>
+
<%= f.telephone_field :phone_number, placeholder: '+32 489 000 0000' %>
+
+
+ +
+ <%= tag.legend "Classification" %> + <%# TODO Add a taxonomy selector %> + <%= section_select(current_agent.taxonomies.first) %> +
+ +
+ <%= tag.legend "Coordonées géographiques" %> + <%# TODO Add a graphical geo selector %> + +
+
<%= f.label :address %>
+
<%= f.text_field :address, value: resource.address, placeholder: 'Rue aux herbes, 123' %>
+ +
<%= f.label :postal_code %>
+
<%= f.text_field :postal_code, value: resource.postal_code, placeholder: '1000' %>
+ +
<%= f.label :city %>
+
<%= f.text_field :city, value: resource.city, placeholder: 'Bruxelles' %>
+
+ +
+
<%= f.label :longitude %>
+
<%= f.text_field :longitude, value: resource.longitude, placeholder: '0.56789012' %>
+ +
<%= f.label :latitude %>
+
<%= f.text_field :latitude, value: resource.latitude, placeholder: '50.12345678' %>
+
+
+ +<%= f.hidden_field :agent_id, value: current_agent.id %> + +

<%= f.submit 'Save' %>

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 @@ -

Resources#new

-

Find me in app/views/resources/new.html.erb

+<%= render partial: 'edit', locals: { resource: @resource } %> + -- cgit v1.2.3