aboutsummaryrefslogtreecommitdiffstats
path: root/app/views
diff options
context:
space:
mode:
Diffstat (limited to 'app/views')
-rw-r--r--app/views/pdfresources/_form.html.erb4
-rw-r--r--app/views/pdfresources/_pdfresource.html.erb6
-rw-r--r--app/views/resource_types/_form.html.erb22
-rw-r--r--app/views/resource_types/_resource_type.html.erb7
-rw-r--r--app/views/resource_types/_resource_type.json.jbuilder2
-rw-r--r--app/views/resource_types/edit.html.erb8
-rw-r--r--app/views/resource_types/index.html.erb21
-rw-r--r--app/views/resource_types/index.json.jbuilder1
-rw-r--r--app/views/resource_types/new.html.erb7
-rw-r--r--app/views/resource_types/show.html.erb15
-rw-r--r--app/views/resource_types/show.json.jbuilder1
11 files changed, 93 insertions, 1 deletions
diff --git a/app/views/pdfresources/_form.html.erb b/app/views/pdfresources/_form.html.erb
index 1ad8fb1..a15bd67 100644
--- a/app/views/pdfresources/_form.html.erb
+++ b/app/views/pdfresources/_form.html.erb
@@ -90,6 +90,10 @@
<p class="text-sm text-gray-700">Number of credits required to purchase this resource.</p>
</div>
+ <div class="my-5">
+ <%= required_label_tag(form, :resource_type) %>
+ <%= form.collection_select :resource_type_id, ResourceType.all, :id, :name, {}, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+ </div>
<div class="my-5">
<%= form.label :stripe_product_id, "Stripe Product ID", class: "font-bold" %>
diff --git a/app/views/pdfresources/_pdfresource.html.erb b/app/views/pdfresources/_pdfresource.html.erb
index 12b2b58..8c96080 100644
--- a/app/views/pdfresources/_pdfresource.html.erb
+++ b/app/views/pdfresources/_pdfresource.html.erb
@@ -4,7 +4,7 @@
</div>
<p class="my-5">
- <strong class="block font-bold mb-2"><%= pdfresource.name %></strong>
+ <%= link_to pdfresource.name, pdfresource, class: "text-blue-500 font-bold" %>
</p>
<div class="px-6 pt-4 pb-2">
@@ -39,6 +39,10 @@
<% end %>
</div>
+ <p class="my-5">
+ <strong class="block font-medium mb-1">Resource type:</strong>
+ <%= pdfresource.resource_type&.name if pdfresource.respond_to?(:resource_type) %>
+ </p>
<p class="my-5">
<strong class="block font-medium mb-1">Price:</strong>
diff --git a/app/views/resource_types/_form.html.erb b/app/views/resource_types/_form.html.erb
new file mode 100644
index 0000000..5675729
--- /dev/null
+++ b/app/views/resource_types/_form.html.erb
@@ -0,0 +1,22 @@
+<%= form_with(model: resource_type, class: "contents") do |form| %>
+ <% if resource_type.errors.any? %>
+ <div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-lg mt-3">
+ <h2><%= pluralize(resource_type.errors.count, "error") %> prohibited this resource_type from being saved:</h2>
+
+ <ul>
+ <% resource_type.errors.each do |error| %>
+ <li><%= error.full_message %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="my-5">
+ <%= form.label :name %>
+ <%= form.text_field :name, class: "block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full" %>
+ </div>
+
+ <div class="inline">
+ <%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
+ </div>
+<% end %>
diff --git a/app/views/resource_types/_resource_type.html.erb b/app/views/resource_types/_resource_type.html.erb
new file mode 100644
index 0000000..b144a58
--- /dev/null
+++ b/app/views/resource_types/_resource_type.html.erb
@@ -0,0 +1,7 @@
+<div id="<%= dom_id resource_type %>">
+ <p class="my-5">
+ <strong class="block font-medium mb-1">Name:</strong>
+ <%= resource_type.name %>
+ </p>
+
+</div>
diff --git a/app/views/resource_types/_resource_type.json.jbuilder b/app/views/resource_types/_resource_type.json.jbuilder
new file mode 100644
index 0000000..18f57c5
--- /dev/null
+++ b/app/views/resource_types/_resource_type.json.jbuilder
@@ -0,0 +1,2 @@
+json.extract! resource_type, :id, :name, :created_at, :updated_at
+json.url resource_type_url(resource_type, format: :json)
diff --git a/app/views/resource_types/edit.html.erb b/app/views/resource_types/edit.html.erb
new file mode 100644
index 0000000..fa2bc6b
--- /dev/null
+++ b/app/views/resource_types/edit.html.erb
@@ -0,0 +1,8 @@
+<div class="mx-auto md:w-2/3 w-full">
+ <h1 class="font-bold text-4xl">Editing resource type</h1>
+
+ <%= render "form", resource_type: @resource_type %>
+
+ <%= link_to "Show this resource type", @resource_type, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+ <%= link_to "Back to resource types", resource_types_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+</div>
diff --git a/app/views/resource_types/index.html.erb b/app/views/resource_types/index.html.erb
new file mode 100644
index 0000000..417e04e
--- /dev/null
+++ b/app/views/resource_types/index.html.erb
@@ -0,0 +1,21 @@
+<div class="w-full">
+ <% if notice.present? %>
+ <p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
+ <% end %>
+
+ <% content_for :title, "Resource types" %>
+
+ <div class="flex justify-between items-center">
+ <h1 class="font-bold text-4xl">Resource types</h1>
+ <%= link_to "New resource type", new_resource_type_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
+ </div>
+
+ <div id="resource_types" class="min-w-full">
+ <% @resource_types.each do |resource_type| %>
+ <%= render resource_type %>
+ <p>
+ <%= link_to "Show this resource type", resource_type, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+ </p>
+ <% end %>
+ </div>
+</div>
diff --git a/app/views/resource_types/index.json.jbuilder b/app/views/resource_types/index.json.jbuilder
new file mode 100644
index 0000000..7f19801
--- /dev/null
+++ b/app/views/resource_types/index.json.jbuilder
@@ -0,0 +1 @@
+json.array! @resource_types, partial: "resource_types/resource_type", as: :resource_type
diff --git a/app/views/resource_types/new.html.erb b/app/views/resource_types/new.html.erb
new file mode 100644
index 0000000..0c15be3
--- /dev/null
+++ b/app/views/resource_types/new.html.erb
@@ -0,0 +1,7 @@
+<div class="mx-auto md:w-1/2 w-full">
+ <h1 class="font-bold text-4xl">New resource type</h1>
+
+ <%= render "form", resource_type: @resource_type %>
+
+ <%= link_to "Back to resource types", resource_types_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+</div>
diff --git a/app/views/resource_types/show.html.erb b/app/views/resource_types/show.html.erb
new file mode 100644
index 0000000..463156d
--- /dev/null
+++ b/app/views/resource_types/show.html.erb
@@ -0,0 +1,15 @@
+<div class="mx-auto md:w-2/3 w-full flex">
+ <div class="mx-auto">
+ <% if notice.present? %>
+ <p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
+ <% end %>
+
+ <%= render @resource_type %>
+
+ <%= link_to "Edit this resource type", edit_resource_type_path(@resource_type), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+ <%= link_to "Back to resource types", resource_types_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
+ <div class="inline-block ml-2">
+ <%= button_to "Destroy this resource type", @resource_type, method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
+ </div>
+ </div>
+</div>
diff --git a/app/views/resource_types/show.json.jbuilder b/app/views/resource_types/show.json.jbuilder
new file mode 100644
index 0000000..0e77d2a
--- /dev/null
+++ b/app/views/resource_types/show.json.jbuilder
@@ -0,0 +1 @@
+json.partial! "resource_types/resource_type", resource_type: @resource_type