Commit 657f2cb9 authored by Markus Koller's avatar Markus Koller

Add relative positioning on design model

- Add a `relative_position` column.
- Include the `RelativePositioning` concern and its shared examples.
parent 5508b605
......@@ -9,6 +9,7 @@ module DesignManagement
include Referable
include Mentionable
include WhereComposite
include RelativePositioning
belongs_to :project, inverse_of: :designs
belongs_to :issue
......@@ -87,6 +88,14 @@ module DesignManagement
# A design is current if the most recent event is not a deletion
scope :current, -> { visible_at_version(nil) }
def self.relative_positioning_query_base(design)
on_issue(design.issue_id)
end
def self.relative_positioning_parent_column
:issue_id
end
def status
if new_design?
:new
......
---
title: Add relative positioning on designs
merge_request: 37835
author:
type: changed
# frozen_string_literal: true
class AddRelativePositionToDesignManagementDesigns < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :design_management_designs, :relative_position, :integer
end
end
d4e389b1469b968b703432de9ece6c362e45ec4ba3ad20d1f6c6418253969379
\ No newline at end of file
......@@ -11203,7 +11203,8 @@ CREATE TABLE public.design_management_designs (
id bigint NOT NULL,
project_id integer NOT NULL,
issue_id integer,
filename character varying NOT NULL
filename character varying NOT NULL,
relative_position integer
);
CREATE SEQUENCE public.design_management_designs_id_seq
......
......@@ -767,6 +767,7 @@ DesignManagement::Design:
- id
- project_id
- filename
- relative_position
DesignManagement::Action:
- id
- event
......
......@@ -11,6 +11,11 @@ RSpec.describe DesignManagement::Design do
let_it_be(:design3) { create(:design, :with_versions, issue: issue, versions_count: 1) }
let_it_be(:deleted_design) { create(:design, :with_versions, deleted: true) }
it_behaves_like 'a class that supports relative positioning' do
let(:factory) { :design }
let(:default_params) { { issue: issue } }
end
describe 'relations' do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:issue) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment