mirror of
https://github.com/rickbarrette/redmine_qbo_vehicles.git
synced 2026-02-13 17:43:58 -05:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 48deb3b7c8 | |||
| e2ea22afdf | |||
| 717a61b024 | |||
| a932551b96 | |||
| e09990cd42 | |||
| ad8aa8e2e8 | |||
| 707abc00a9 |
@@ -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
|
||||||
@@ -64,6 +65,7 @@ class VehiclesController < ApplicationController
|
|||||||
@issues = @vehicle.issues.order(id: :desc)
|
@issues = @vehicle.issues.order(id: :desc)
|
||||||
@closed_issues = (@issues - @issues.open)
|
@closed_issues = (@issues - @issues.open)
|
||||||
rescue
|
rescue
|
||||||
|
flash[:error] = t :alert_vehicle_not_found
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -74,6 +76,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 +87,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 +95,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 +104,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
|
||||||
|
|||||||
@@ -23,4 +23,11 @@ en:
|
|||||||
label_edit_customer_vehicle: "Edit Customer Vehicle"
|
label_edit_customer_vehicle: "Edit Customer Vehicle"
|
||||||
label_cusomer_vehicles: "Customer Vehicles"
|
label_cusomer_vehicles: "Customer Vehicles"
|
||||||
label_new_vehicle: "New Customer Vehicle"
|
label_new_vehicle: "New Customer Vehicle"
|
||||||
button_new_vehice: "New Vehicle"
|
button_new_vehice: "New Vehicle"
|
||||||
|
notice_vehicle_created: "Vehicle was successfully created."
|
||||||
|
notice_vehicle_updated: "Vehicle was successfully updated."
|
||||||
|
notice_vehicle_deleted: "Vehicle was successfully deleted."
|
||||||
|
alert_vehicle_not_found: "Vehicle not found."
|
||||||
|
alert_vehicle_not_deleted: "Vehicle could not be deleted."
|
||||||
|
alert_vehicle_not_created: "Vehicle could not be created."
|
||||||
|
alert_vehicle_not_updated: "Vehicle could not be 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.1.6'
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user