-
Notifications
You must be signed in to change notification settings - Fork 2
Feature: redesign orderscreen #1213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
7775c9b
a884ff7
cb7b4ed
b010cf4
b0924b3
d236a84
b2974c7
dcdba74
4b8babb
53c7df1
a5dedaa
b7a3961
4369fc5
5329711
51ecf4d
99955cf
c5bd856
08d6ae5
ab71c13
4f2c9a5
20bd86c
adf39c0
acfa7a6
a0091fb
778d290
c606335
edb96b5
7f16574
572f1f1
3564f1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,78 @@ | ||||||||
| class ProductPriceFoldersController < ApplicationController | ||||||||
| before_action :authenticate_user! | ||||||||
| before_action :set_price_list, only: %i[index create reorder] | ||||||||
| before_action :set_folder, only: %i[update destroy] | ||||||||
|
|
||||||||
| def index | ||||||||
| authorize ProductPriceFolder, :index? | ||||||||
| @folders = @price_list.product_price_folders.order(:position) | ||||||||
| render json: @folders | ||||||||
| end | ||||||||
|
|
||||||||
| def create | ||||||||
| @folder = @price_list.product_price_folders.new(folder_params) | ||||||||
| authorize @folder | ||||||||
|
|
||||||||
| if @folder.save | ||||||||
| render json: @folder, status: :created | ||||||||
| else | ||||||||
| render json: { errors: @folder.errors.full_messages }, status: :unprocessable_content | ||||||||
| end | ||||||||
| end | ||||||||
|
|
||||||||
| def update | ||||||||
| authorize @folder | ||||||||
|
|
||||||||
| if @folder.update(folder_params) | ||||||||
| render json: @folder | ||||||||
| else | ||||||||
| render json: { errors: @folder.errors.full_messages }, status: :unprocessable_content | ||||||||
| end | ||||||||
| end | ||||||||
|
|
||||||||
| def destroy | ||||||||
| authorize @folder | ||||||||
|
|
||||||||
| orphaned_products = @folder.product_prices | ||||||||
| max_position = @folder.price_list.product_prices.without_folder.maximum(:position) || -1 | ||||||||
|
|
||||||||
| orphaned_products.each_with_index do |product_prices, index| | ||||||||
| product_prices.update(product_price_folder_id: nil, position: max_position + index + 1) | ||||||||
| end | ||||||||
|
|
||||||||
| @folder.destroy | ||||||||
|
|
||||||||
| head :no_content | ||||||||
| end | ||||||||
|
|
||||||||
| def reorder # rubocop:disable Metrics/MethodLength | ||||||||
| authorize ProductPriceFolder, :reorder? | ||||||||
|
|
||||||||
| folder_positions = params.require(:folder_positions) | ||||||||
|
|
||||||||
| ActiveRecord::Base.transaction do | ||||||||
| folder_positions.each do |folder_data| | ||||||||
| folder = @price_list.product_price_folders.find(folder_data[:id]) | ||||||||
|
||||||||
| folder = @price_list.product_price_folders.find(folder_data[:id]) | |
| folder = @price_list.product_price_folders.find(folder_data[:id]) | |
| authorize folder, :reorder? |
Copilot
AI
Feb 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new ProductPriceFoldersController lacks test coverage. The codebase has comprehensive test coverage for other controllers (as evidenced by the spec/controllers directory), but there are no tests for this new controller. Tests should be added to cover the index, create, update, destroy, and reorder actions, including authorization checks for different user roles.
Uh oh!
There was an error while loading. Please reload this page.