aboutsummaryrefslogtreecommitdiffstats
path: root/app/views
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2023-12-20 20:34:25 +0000
committerMatthew Lemon <y@yulqen.org>2023-12-20 20:34:25 +0000
commit6b1a1834ad1715145f047790c8391b8a5558bece (patch)
treee20cdddb20477b56a013eb3bc357b9b5ff0488a3 /app/views
parenta3e98876e2f88b69fef2a9da7d65b3704b6bf0d2 (diff)
Created new Operation model and fixed Event associations with it
Diffstat (limited to 'app/views')
-rw-r--r--app/views/operations/_form.html.erb22
-rw-r--r--app/views/operations/_operation.html.erb7
-rw-r--r--app/views/operations/_operation.json.jbuilder2
-rw-r--r--app/views/operations/edit.html.erb10
-rw-r--r--app/views/operations/index.html.erb14
-rw-r--r--app/views/operations/index.json.jbuilder1
-rw-r--r--app/views/operations/new.html.erb9
-rw-r--r--app/views/operations/show.html.erb10
-rw-r--r--app/views/operations/show.json.jbuilder1
9 files changed, 76 insertions, 0 deletions
diff --git a/app/views/operations/_form.html.erb b/app/views/operations/_form.html.erb
new file mode 100644
index 0000000..adadad8
--- /dev/null
+++ b/app/views/operations/_form.html.erb
@@ -0,0 +1,22 @@
+<%= form_with(model: operation) do |form| %>
+ <% if operation.errors.any? %>
+ <div style="color: red">
+ <h2><%= pluralize(operation.errors.count, "error") %> prohibited this operation from being saved:</h2>
+
+ <ul>
+ <% operation.errors.each do |error| %>
+ <li><%= error.full_message %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div>
+ <%= form.label :name, style: "display: block" %>
+ <%= form.text_field :name %>
+ </div>
+
+ <div>
+ <%= form.submit %>
+ </div>
+<% end %>
diff --git a/app/views/operations/_operation.html.erb b/app/views/operations/_operation.html.erb
new file mode 100644
index 0000000..6349848
--- /dev/null
+++ b/app/views/operations/_operation.html.erb
@@ -0,0 +1,7 @@
+<div id="<%= dom_id operation %>">
+ <p>
+ <strong>Name:</strong>
+ <%= operation.name %>
+ </p>
+
+</div>
diff --git a/app/views/operations/_operation.json.jbuilder b/app/views/operations/_operation.json.jbuilder
new file mode 100644
index 0000000..8016989
--- /dev/null
+++ b/app/views/operations/_operation.json.jbuilder
@@ -0,0 +1,2 @@
+json.extract! operation, :id, :name, :created_at, :updated_at
+json.url operation_url(operation, format: :json)
diff --git a/app/views/operations/edit.html.erb b/app/views/operations/edit.html.erb
new file mode 100644
index 0000000..650350a
--- /dev/null
+++ b/app/views/operations/edit.html.erb
@@ -0,0 +1,10 @@
+<h1>Editing operation</h1>
+
+<%= render "form", operation: @operation %>
+
+<br>
+
+<div>
+ <%= link_to "Show this operation", @operation %> |
+ <%= link_to "Back to operations", operations_path %>
+</div>
diff --git a/app/views/operations/index.html.erb b/app/views/operations/index.html.erb
new file mode 100644
index 0000000..8bf9009
--- /dev/null
+++ b/app/views/operations/index.html.erb
@@ -0,0 +1,14 @@
+<p style="color: green"><%= notice %></p>
+
+<h1>Operations</h1>
+
+<div id="operations">
+ <% @operations.each do |operation| %>
+ <%= render operation %>
+ <p>
+ <%= link_to "Show this operation", operation %>
+ </p>
+ <% end %>
+</div>
+
+<%= link_to "New operation", new_operation_path %>
diff --git a/app/views/operations/index.json.jbuilder b/app/views/operations/index.json.jbuilder
new file mode 100644
index 0000000..bef1085
--- /dev/null
+++ b/app/views/operations/index.json.jbuilder
@@ -0,0 +1 @@
+json.array! @operations, partial: "operations/operation", as: :operation
diff --git a/app/views/operations/new.html.erb b/app/views/operations/new.html.erb
new file mode 100644
index 0000000..be6230d
--- /dev/null
+++ b/app/views/operations/new.html.erb
@@ -0,0 +1,9 @@
+<h1>New operation</h1>
+
+<%= render "form", operation: @operation %>
+
+<br>
+
+<div>
+ <%= link_to "Back to operations", operations_path %>
+</div>
diff --git a/app/views/operations/show.html.erb b/app/views/operations/show.html.erb
new file mode 100644
index 0000000..d19705b
--- /dev/null
+++ b/app/views/operations/show.html.erb
@@ -0,0 +1,10 @@
+<p style="color: green"><%= notice %></p>
+
+<%= render @operation %>
+
+<div>
+ <%= link_to "Edit this operation", edit_operation_path(@operation) %> |
+ <%= link_to "Back to operations", operations_path %>
+
+ <%= button_to "Destroy this operation", @operation, method: :delete %>
+</div>
diff --git a/app/views/operations/show.json.jbuilder b/app/views/operations/show.json.jbuilder
new file mode 100644
index 0000000..ada5250
--- /dev/null
+++ b/app/views/operations/show.json.jbuilder
@@ -0,0 +1 @@
+json.partial! "operations/operation", operation: @operation