mirror of
https://github.com/rickbarrette/redmine_qbo_vehicles.git
synced 2026-02-14 01:43:58 -05:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4bcccbd2f1 | |||
| 92cc7222fb | |||
| c5318a3528 | |||
| 9315433cb1 | |||
| 82e25314f3 | |||
| 5cad4a6856 | |||
| 12fb8b47ef | |||
| b02a40827d | |||
| 5165bc20b4 | |||
| f30d735e52 | |||
| a30d8f56d8 | |||
| d22fcd4f66 | |||
| f649d4e902 | |||
| 2db17f3675 | |||
| d37933fe82 | |||
| 3efc545f0a | |||
| adcc116841 | |||
| 8bb98d2408 | |||
| 88b0ffcd6b | |||
| 48deb3b7c8 | |||
| e2ea22afdf | |||
| 717a61b024 | |||
| a932551b96 | |||
| e09990cd42 | |||
| ad8aa8e2e8 | |||
| 707abc00a9 |
42
README.md
42
README.md
@@ -1,53 +1,55 @@
|
|||||||
# Redmine QuickBooks Online Vehicles
|
# Redmine QuickBooks Online Vehicles
|
||||||
|
|
||||||
A redmine plugin to compliment the Redmine QuickBooks Online Vehicles plug in.
|
A Redmine plugin to complement the [Redmine QuickBooks Online](https://github.com/rickbarrette/redmine_qbo) plugin.
|
||||||
|
|
||||||
The goal of this project is to allow add vehicle tracking for customer vehicles.
|
The goal of this project is to enable vehicle tracking for customer vehicles within Redmine.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
* **Redmine:** 6.1+
|
||||||
|
* **Parent Plugin:** [Redmine QuickBooks Online](https://github.com/rickbarrette/redmine_qbo)
|
||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
| Redmine QBO Plugin Version | Redmine Version |
|
| Plugin Version | Redmine Version | Ruby Version |
|
||||||
| :--- | :--- |
|
| :--- | :--- | :--- |
|
||||||
| Version 2026.1.2+ | Redmine 6.1 |
|
| 2026.1.2+ | Redmine 6.1 | 3.2+ |
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
Adds vehicles that are owned by customers that can be attached to issues.
|
* **Asset Tracking:** Adds vehicles owned by customers to the system.
|
||||||
|
* **Issue Association:** Allows these vehicles to be attached directly to Redmine issues for better service tracking.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. **Clone the plugin:**
|
1. **Clone the plugin:**
|
||||||
Clone this repo into your plugin folder and checkout a tagged version.
|
Navigate to your Redmine plugins directory and clone the repository.
|
||||||
```bash
|
```bash
|
||||||
cd path/to/redmine/plugins
|
cd path/to/redmine/plugins
|
||||||
git clone git@github.com:rickbarrette/redmine_qbo_vehicles.git
|
git clone git@github.com:rickbarrette/redmine_qbo_vehicles.git
|
||||||
cd redmine_qbo_vehicles
|
cd redmine_qbo_vehicles
|
||||||
git checkout <tag>
|
git checkout <tag>
|
||||||
```
|
```
|
||||||
|
*(Note: Replace `<tag>` with the specific release version you wish to use, or omit the last line to use the main branch.)*
|
||||||
|
|
||||||
2. **Install dependencies:** *Crucial for Redmine 6 / Rails 7 compatibility.*
|
2. **Install dependencies:**
|
||||||
|
*Crucial for Redmine 6 / Rails 7 compatibility.*
|
||||||
Bash
|
```bash
|
||||||
|
|
||||||
```
|
|
||||||
bundle install
|
bundle install
|
||||||
```
|
```
|
||||||
|
|
||||||
3. **Migrate your database:**
|
3. **Migrate your database:**
|
||||||
|
```bash
|
||||||
Bash
|
|
||||||
|
|
||||||
```
|
|
||||||
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
|
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
|
||||||
```
|
```
|
||||||
|
|
||||||
4. **Restart Redmine:** You must restart your Redmine server instance for the plugin and hooks to load.
|
4. **Restart Redmine:**
|
||||||
|
You must restart your Redmine server instance (e.g., Puma, Passenger, Unicorn) for the plugin and hooks to load correctly.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Simply add vehicles to customers via Customer Profile
|
1. **Add a Vehicle:** Navigate to a Customer Profile. You will see a new option to add vehicles to that customer.
|
||||||
|
2. **Link to Issue:** Once a vehicle is added to a customer, it can be selected and attached to an Issue relevant to that customer.
|
||||||
Once a customer is attached to the customer, they can be attached to an issue.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class VehiclesController < ApplicationController
|
|||||||
begin
|
begin
|
||||||
@vehicles = Customer.find_by_id(params[:customer_id]).vehicles.paginate(page: params[:page])
|
@vehicles = Customer.find_by_id(params[:customer_id]).vehicles.paginate(page: params[:page])
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
flash[:error] = t :alert_vehicle_not_found
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -48,7 +49,7 @@ class VehiclesController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@vehicle = Vehicle.new(allowed_params)
|
@vehicle = Vehicle.new(allowed_params)
|
||||||
if @vehicle.save
|
if @vehicle.save
|
||||||
flash[:notice] = "New Vehicle Created"
|
flash[:notice] = t :notice_vehicle_created
|
||||||
redirect_to @vehicle
|
redirect_to @vehicle
|
||||||
else
|
else
|
||||||
flash[:error] = @vehicle.errors.full_messages.to_sentence
|
flash[:error] = @vehicle.errors.full_messages.to_sentence
|
||||||
@@ -63,7 +64,9 @@ class VehiclesController < ApplicationController
|
|||||||
@vin = @vehicle.vin.scan(/.{1,9}/) if @vehicle.vin
|
@vin = @vehicle.vin.scan(/.{1,9}/) if @vehicle.vin
|
||||||
@issues = @vehicle.issues.order(id: :desc)
|
@issues = @vehicle.issues.order(id: :desc)
|
||||||
@closed_issues = (@issues - @issues.open)
|
@closed_issues = (@issues - @issues.open)
|
||||||
|
flash[:error] = t :alert_no_customer if @vehicle.customer.nil?
|
||||||
rescue
|
rescue
|
||||||
|
flash[:error] = t :alert_vehicle_not_found
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -74,6 +77,7 @@ class VehiclesController < ApplicationController
|
|||||||
@vehicle = Vehicle.find_by_id(params[:id])
|
@vehicle = Vehicle.find_by_id(params[:id])
|
||||||
@customer = @vehicle.customer
|
@customer = @vehicle.customer
|
||||||
rescue
|
rescue
|
||||||
|
flash[:error] = t :alert_vehicle_not_found
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -84,7 +88,7 @@ class VehiclesController < ApplicationController
|
|||||||
begin
|
begin
|
||||||
@vehicle = Vehicle.find_by_id(params[:id])
|
@vehicle = Vehicle.find_by_id(params[:id])
|
||||||
if @vehicle.update(allowed_params)
|
if @vehicle.update(allowed_params)
|
||||||
flash[:notice] = "Vehicle updated"
|
flash[:notice] = t :notice_vehicle_updated
|
||||||
redirect_to @vehicle
|
redirect_to @vehicle
|
||||||
else
|
else
|
||||||
redirect_to edit_vehicle_path
|
redirect_to edit_vehicle_path
|
||||||
@@ -92,6 +96,7 @@ class VehiclesController < ApplicationController
|
|||||||
#show any errors anyways
|
#show any errors anyways
|
||||||
flash[:error] = @vehicle.errors.full_messages.to_sentence unless @vehicle.errors.empty?
|
flash[:error] = @vehicle.errors.full_messages.to_sentence unless @vehicle.errors.empty?
|
||||||
rescue
|
rescue
|
||||||
|
flash[:error] = t :alert_vehicle_not_updated
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -100,9 +105,10 @@ class VehiclesController < ApplicationController
|
|||||||
def destroy
|
def destroy
|
||||||
begin
|
begin
|
||||||
Vehicle.find_by_id(params[:id]).destroy
|
Vehicle.find_by_id(params[:id]).destroy
|
||||||
flash[:notice] = "Vehicle deleted successfully"
|
flash[:notice] = t :notice_vehicle_deleted
|
||||||
redirect_to action: :index
|
redirect_to action: :index
|
||||||
rescue
|
rescue
|
||||||
|
flash[:error] = t :alert_vehicle_not_deleted
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -72,6 +72,16 @@ class Vehicle < ActiveRecord::Base
|
|||||||
self.name = to_s
|
self.name = to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# reurns all invoices for this vehicle
|
||||||
|
def invoices
|
||||||
|
self.issues.flat_map(&:invoices).uniq.compact
|
||||||
|
end
|
||||||
|
|
||||||
|
# returns all estimates for this vehicle
|
||||||
|
def estimates
|
||||||
|
self.issues.flat_map(&:estimate).uniq.compact
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# init method to pull JSON details from NHTSA
|
# init method to pull JSON details from NHTSA
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<h4><%=t(:field_vehicles)%>:</h4>
|
<h4><%=t(:field_vehicles)%>:</h4>
|
||||||
<%= render partial: 'vehicles/list', locals: { vehicles: customer.vehicles.paginate(page: params[:page]) } %>
|
<%= render partial: 'vehicles/list', locals: { vehicles: customer.vehicles.paginate(page: params[:page]) } %>
|
||||||
<div style="float: right;">
|
<div style="float: right;">
|
||||||
<%= button_to t(:button_new_vehice), new_customer_vehicle_path(customer), method: :get %>
|
<%= button_to t(:button_new_vehicle), new_customer_vehicle_path(customer), method: :get %>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,18 +1,17 @@
|
|||||||
<div class="vehicle attribute">
|
<div class="vehicle attribute">
|
||||||
<div class="label"><span><%=t(:field_vehicle)%></span>:</div>
|
<div class="label"><%=t(:field_vehicle)%>:</div>
|
||||||
<div class="value"><%= vehicle %></div>
|
<div class="value"><%= vehicle %></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="vehicle_vin attribute">
|
<div class="vehicle_vin attribute">
|
||||||
<div class="label"><span><%=t(:field_vin)%></span>:</div>
|
<div class="label"><%=t(:field_vin)%>:</div>
|
||||||
<div class="value"><%=split_vin[0] if split_vin%><b><%=split_vin[1] if split_vin%></b></div>
|
<div class="value" id="vin">
|
||||||
|
<a href="#" id="copyLink" onclick="handleCopy(event)"><%=split_vin[0] if split_vin%><b><%=split_vin[1] if split_vin%></b></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="vehicle_notes attribute">
|
<div class="vehicle_notes attribute">
|
||||||
<div class="label"><span><%=t(:field_notes)%></span>:</div>
|
<div class="label"><%=t(:field_notes)%>:</div>
|
||||||
<div class="value">
|
<pre class="value" id="note-display" style="text-align: left; white-space: pre-wrap; font-family: inherit; "><%=notes%></pre>
|
||||||
<pre id="note-display" style="text-align: left; white-space: pre-wrap; font-family: inherit; ">
|
|
||||||
<%=notes%>
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= t(:field_customer)%></th>
|
<th><%= t(:field_customer)%></th>
|
||||||
<td><%= link_to vehicle.customer.name, customer_path(vehicle.customer) %></td>
|
<td><%= vehicle.customer ? link_to(vehicle.customer.name, customer_path(vehicle.customer)) : t(:no_customer) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
@@ -18,7 +18,9 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= t(:field_vin) %></th>
|
<th><%= t(:field_vin) %></th>
|
||||||
<td><%= @vin[0] if @vin %><b><%=@vin[1] if @vin%></b></td>
|
<td id="vin">
|
||||||
|
<a href="#" onclick="handleCopy(event)"><%= @vin[0] if @vin %><b><%=@vin[1] if @vin%></b></a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<th><%= t(:label_trim) %></th>
|
<th><%= t(:label_trim) %></th>
|
||||||
|
|||||||
@@ -2,26 +2,29 @@
|
|||||||
|
|
||||||
<% vehicles.each do |vehicle| %>
|
<% vehicles.each do |vehicle| %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div>
|
|
||||||
<b><%= link_to "##{vehicle.id}", vehicle_path(vehicle) %> </b>
|
<div class="container">
|
||||||
|
|
||||||
|
<%= check_box_tag "vehicle_ids[]", vehicle.id, false, onchange: "updateLink()", data: { url: vehicle_path(vehicle).html_safe, text: vehicle.to_s }, class: "appointment checkbox" %>
|
||||||
|
|
||||||
|
<div class='label-main'>
|
||||||
|
<%= link_to vehicle.to_s, vehicle_path(vehicle) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div class="label-sub">
|
||||||
<%= vehicle.to_s %>
|
|
||||||
<br/>
|
|
||||||
<%= vehicle.customer %>
|
|
||||||
<br/>
|
|
||||||
<%= vehicle.vin.scan(/.{1,9}/)[0] if vehicle.vin %><b><%=vehicle.vin.scan(/.{1,9}/)[1] if vehicle.vin%></b>
|
<%= vehicle.vin.scan(/.{1,9}/)[0] if vehicle.vin %><b><%=vehicle.vin.scan(/.{1,9}/)[1] if vehicle.vin%></b>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<%= will_paginate vehicles %>
|
<%= will_paginate vehicles %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p><%=t(:label_matching)%> <%=vehicles.count%> <%=t(:field_vehicles) %> </p>
|
<%=t(:label_matching)%> <%=vehicles.count%> <%=t(:field_vehicles) %>
|
||||||
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<p><%=t(:label_no_vehicles)%> <%= params[:search] %>.</p>
|
<p><%=t(:label_no_vehicles)%> <%= params[:search] %>.</p>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<h2><%=t(:label_cusomer_vehicles)%> <span style="float:right"> <%= render partial: 'vehicles/search' %> </span> </h2>
|
<h2><%=t(:label_customer_vehicles)%> <span style="float:right"> <%= render partial: 'vehicles/search' %> </span> </h2>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<%= render partial: 'vehicles/list', locals: {vehicles: @vehicles} %>
|
<%= render partial: 'vehicles/list', locals: {vehicles: @vehicles} %>
|
||||||
|
|||||||
@@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
<%= render partial: 'vehicles/details', locals: {vehicle: @vehicle} %>
|
<%= render partial: 'vehicles/details', locals: {vehicle: @vehicle} %>
|
||||||
|
|
||||||
|
<div class="splitcontent">
|
||||||
|
<div class="splitcontentleft">
|
||||||
|
<h4><%=t(:estimates)%>:</h4>
|
||||||
|
<%= render partial: 'estimates/list', locals: {estimates: @vehicle.estimates} %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="splitcontentleft">
|
||||||
|
<h4><%=t(:label_invoices)%>:</h4>
|
||||||
|
<%= render partial: 'invoices/list', locals: {invoices: @vehicle.invoices} %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h3><%=@issues.open.count%> <%=t(:label_open_issues)%></h3>
|
<h3><%=@issues.open.count%> <%=t(:label_open_issues)%></h3>
|
||||||
|
|
||||||
<%= render partial: 'issues/list_simple', locals: {issues: @issues.open} %>
|
<%= render partial: 'issues/list_simple', locals: {issues: @issues.open} %>
|
||||||
|
|||||||
35
assets/javascripts/copy.js
Normal file
35
assets/javascripts/copy.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
async function handleCopy(event) {
|
||||||
|
console.log("Copy link clicked");
|
||||||
|
// 1. Prevent the link from actually navigating
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
// 2. Grab the text from our span
|
||||||
|
const text = document.getElementById('vin').innerText;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 3. Write to clipboard
|
||||||
|
await navigator.clipboard.writeText(text);
|
||||||
|
|
||||||
|
// 4. Update the UI to show it worked
|
||||||
|
const link = event.target;
|
||||||
|
const originalText = link.innerText;
|
||||||
|
link.innerHTML = "<b>Copied!</b>";
|
||||||
|
link.style.color = "#4CAF50"; // Turn green
|
||||||
|
|
||||||
|
// 5. Reset after 2 seconds
|
||||||
|
setTimeout(() => {
|
||||||
|
// Check if the text is long enough to prevent errors
|
||||||
|
if (originalText.length >= 8) {
|
||||||
|
const firstPart = originalText.slice(0, -8);
|
||||||
|
const lastEight = originalText.slice(-8);
|
||||||
|
link.innerHTML = `${firstPart}<b>${lastEight}</b>`;
|
||||||
|
} else {
|
||||||
|
link.innerText = originalText;
|
||||||
|
}
|
||||||
|
link.style.color = "";
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Unable to copy', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
23
assets/stylesheets/style.css
Normal file
23
assets/stylesheets/style.css
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
.container {
|
||||||
|
display: grid;
|
||||||
|
/* Column 1 for checkbox, Column 2 for text */
|
||||||
|
grid-template-columns: auto 1fr;
|
||||||
|
/* Row 1 for 'Vehicle', Row 2 for 'VIN' */
|
||||||
|
grid-template-rows: auto auto;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0 10px; /* Adjust spacing between checkbox and text */
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox {
|
||||||
|
/* This makes the checkbox take up both rows */
|
||||||
|
grid-row: span 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-main {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label-sub {
|
||||||
|
font-size: 0.85em;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
@@ -10,17 +10,27 @@
|
|||||||
|
|
||||||
# English strings go here for Rails i18n
|
# English strings go here for Rails i18n
|
||||||
# Usage I18n.t(:label)
|
# Usage I18n.t(:label)
|
||||||
|
|
||||||
en:
|
en:
|
||||||
field_vehicles: "Vehicles"
|
alert_no_customer: "Customer no longer exists, check for merged customers or deleted customers in QuickBooks Online."
|
||||||
|
alert_vehicle_not_created: "Vehicle could not be created."
|
||||||
|
alert_vehicle_not_deleted: "Vehicle could not be deleted."
|
||||||
|
alert_vehicle_not_found: "Vehicle not found."
|
||||||
|
alert_vehicle_not_updated: "Vehicle could not be updated."
|
||||||
|
button_new_vehicle: "New Vehicle"
|
||||||
field_vehicle: "Vehicle"
|
field_vehicle: "Vehicle"
|
||||||
|
field_vehicles: "Vehicles"
|
||||||
field_vin: "VIN"
|
field_vin: "VIN"
|
||||||
|
label_customer_vehicles: "Customer Vehicles"
|
||||||
label_edit: "Edit"
|
label_edit: "Edit"
|
||||||
label_year: "Year"
|
label_edit_customer_vehicle: "Edit Customer Vehicle"
|
||||||
label_make: "Make"
|
label_make: "Make"
|
||||||
label_model: "Model"
|
label_model: "Model"
|
||||||
|
label_new_vehicle: "New Customer Vehicle"
|
||||||
label_no_vehicles: "There are no vehicles containing the term(s)"
|
label_no_vehicles: "There are no vehicles containing the term(s)"
|
||||||
label_search_vin: "Search Vehicles by VIN"
|
label_search_vin: "Search Vehicles by VIN"
|
||||||
label_edit_customer_vehicle: "Edit Customer Vehicle"
|
label_year: "Year"
|
||||||
label_cusomer_vehicles: "Customer Vehicles"
|
no_customer: "Customer no longer exists"
|
||||||
label_new_vehicle: "New Customer Vehicle"
|
notice_vehicle_created: "Vehicle was successfully created."
|
||||||
button_new_vehice: "New Vehicle"
|
notice_vehicle_deleted: "Vehicle was successfully deleted."
|
||||||
|
notice_vehicle_updated: "Vehicle was successfully updated."
|
||||||
6
init.rb
6
init.rb
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
|
|||||||
name 'Redmine QBO Vehicles plugin'
|
name 'Redmine QBO Vehicles plugin'
|
||||||
author 'Rick Barrette'
|
author 'Rick Barrette'
|
||||||
description 'This is a plugin for Redmine to intergrate with the redmine_qbo plugin to provide vehicle data tracking'
|
description 'This is a plugin for Redmine to intergrate with the redmine_qbo plugin to provide vehicle data tracking'
|
||||||
version '2026.1.4'
|
version '2026.2.2'
|
||||||
url 'https://github.com/rickbarrette/redmine_qbo_vehicles'
|
url 'https://github.com/rickbarrette/redmine_qbo_vehicles'
|
||||||
author_url 'https://barrettefabrication.com'
|
author_url 'https://barrettefabrication.com'
|
||||||
requires_redmine version_or_higher: '6.1.0'
|
requires_redmine version_or_higher: '6.1.0'
|
||||||
@@ -27,13 +27,13 @@ Redmine::Plugin.register :redmine_qbo_vehicles do
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Add safe attributes for core models
|
# Add safe attributes for core models
|
||||||
Issue.safe_attributes 'vehicle_id'
|
Issue.safe_attributes :vehicle_id
|
||||||
|
|
||||||
# Permissions for security
|
# Permissions for security
|
||||||
permission :view_vehicles, vehicles: :new, public: false
|
permission :view_vehicles, vehicles: :new, public: false
|
||||||
|
|
||||||
# Register top menu items
|
# Register top menu items
|
||||||
menu :top_menu, :vehicles, { controller: :vehicles, action: :index }, caption: 'Vehicles', if: Proc.new { User.current.logged? }
|
menu :top_menu, :vehicles, { controller: :vehicles, action: :index }, caption: :field_vehicles, if: Proc.new { User.current.logged? }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ module Vehicles
|
|||||||
context[:controller].send(:render_to_string, {
|
context[:controller].send(:render_to_string, {
|
||||||
partial: 'issues/show_issue_view_right',
|
partial: 'issues/show_issue_view_right',
|
||||||
locals: {
|
locals: {
|
||||||
vehicle: link_to(context[:issue].vehicle),
|
vehicle: context[:issue].vehicle ? link_to(context[:issue].vehicle) : nil,
|
||||||
split_vin: context[:issue].vehicle ? context[:issue].vehicle.vin.to_s.scan(/.{1,9}/) : nil,
|
split_vin: context[:issue].vehicle ? context[:issue].vehicle.vin.to_s.scan(/.{1,9}/) : nil,
|
||||||
notes: context[:issue].vehicle ? context[:issue].vehicle.notes : nil
|
notes: context[:issue].vehicle ? context[:issue].vehicle.notes : nil
|
||||||
}
|
}
|
||||||
|
|||||||
24
lib/vehicles/hooks/view_hook_listener.rb
Normal file
24
lib/vehicles/hooks/view_hook_listener.rb
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#The MIT License (MIT)
|
||||||
|
#
|
||||||
|
#Copyright (c) 2016 - 2026 rick barrette
|
||||||
|
#
|
||||||
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
module Vehicles
|
||||||
|
module Hooks
|
||||||
|
class ViewHookListener < Redmine::Hook::ViewListener
|
||||||
|
|
||||||
|
def view_layouts_base_html_head(context = {})
|
||||||
|
safe_join([
|
||||||
|
stylesheet_link_tag('style', plugin: :redmine_qbo_vehicles, media: :all),
|
||||||
|
javascript_include_tag('copy', plugin: :redmine_qbo_vehicles)
|
||||||
|
])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user