mirror of
https://github.com/rickbarrette/redmine_qbo_lineitems.git
synced 2026-04-02 07:01:59 -04:00
implemented some basic CRUD for QBO Items
This commit is contained in:
43
app/views/items/_form.html.erb
Normal file
43
app/views/items/_form.html.erb
Normal file
@@ -0,0 +1,43 @@
|
||||
<%= form_with model: @item, local: true do |f| %>
|
||||
|
||||
<% if @item.errors.any? %>
|
||||
<div id="errorExplanation">
|
||||
<h2><%= pluralize(@item.errors.count, "error") %></h2>
|
||||
<ul>
|
||||
<% @item.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
<%= f.label :name %><br>
|
||||
<%= f.text_field :name, required: true %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= f.label :sku %><br>
|
||||
<%= f.text_field :sku %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= f.label :description %><br>
|
||||
<%= f.text_area :description, rows: 3 %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= f.label :unit_price %><br>
|
||||
<%= f.number_field :unit_price, step: 0.01 %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= f.label :active %>
|
||||
<%= f.check_box :active %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= f.submit %>
|
||||
</p>
|
||||
|
||||
<% end %>
|
||||
5
app/views/items/edit.html.erb
Normal file
5
app/views/items/edit.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h2>Edit Item</h2>
|
||||
|
||||
<%= render "form" %>
|
||||
|
||||
<%= link_to "Back", items_path %>
|
||||
37
app/views/items/index.html.erb
Normal file
37
app/views/items/index.html.erb
Normal file
@@ -0,0 +1,37 @@
|
||||
<h2>Items</h2>
|
||||
|
||||
<div class="contextual">
|
||||
<%= link_to "New Item", new_item_path, class: "icon icon-add" %>
|
||||
</div>
|
||||
|
||||
<table class="list items">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>SKU</th>
|
||||
<th>Description</th>
|
||||
<th>Price</th>
|
||||
<th>Active</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @items.each do |item| %>
|
||||
<tr>
|
||||
<td><%= link_to item.name, item_path(item) %></td>
|
||||
<td><%= item.sku %></td>
|
||||
<td><%= item.description %></td>
|
||||
<td><%= number_to_currency(item.unit_price) %></td>
|
||||
<td><%= item.active ? "Yes" : "No" %></td>
|
||||
<td>
|
||||
<%= link_to "Edit", edit_item_path(item), class: "icon icon-edit" %>
|
||||
<%= link_to "Delete", item_path(item),
|
||||
method: :delete,
|
||||
data: { confirm: "Are you sure?" },
|
||||
class: "icon icon-del" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
5
app/views/items/new.html.erb
Normal file
5
app/views/items/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h2>New Item</h2>
|
||||
|
||||
<%= render "form" %>
|
||||
|
||||
<%= link_to "Back", items_path %>
|
||||
26
app/views/items/show.html.erb
Normal file
26
app/views/items/show.html.erb
Normal file
@@ -0,0 +1,26 @@
|
||||
<h2><%= @item.name %></h2>
|
||||
|
||||
<p>
|
||||
<strong>SKU:</strong>
|
||||
<%= @item.sku %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Description:</strong>
|
||||
<%= @item.description %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Unit Price:</strong>
|
||||
<%= number_to_currency(@item.unit_price) %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Active:</strong>
|
||||
<%= @item.active ? "Yes" : "No" %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= link_to "Edit", edit_item_path(@item), class: "icon icon-edit" %>
|
||||
<%= link_to "Back", items_path %>
|
||||
</p>
|
||||
Reference in New Issue
Block a user