Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
304851dc
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
304851dc
编写于
1月 04, 2018
作者:
J
Jarka Kadlecová
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor RelativePositioning so that it can be used by other classes
上级
1560c234
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
7 deletion
+17
-7
app/models/concerns/relative_positioning.rb
app/models/concerns/relative_positioning.rb
+11
-7
app/models/issue.rb
app/models/issue.rb
+6
-0
未找到文件。
app/models/concerns/relative_positioning.rb
浏览文件 @
304851dc
...
...
@@ -10,12 +10,12 @@ module RelativePositioning
after_save
:save_positionable_neighbours
end
def
project_ids
[
project
.
id
]
def
min_relative_position
self
.
class
.
in_parents
(
parent_ids
).
minimum
(
:relative_position
)
end
def
max_relative_position
self
.
class
.
in_p
rojects
(
projec
t_ids
).
maximum
(
:relative_position
)
self
.
class
.
in_p
arents
(
paren
t_ids
).
maximum
(
:relative_position
)
end
def
prev_relative_position
...
...
@@ -23,7 +23,7 @@ module RelativePositioning
if
self
.
relative_position
prev_pos
=
self
.
class
.
in_p
rojects
(
projec
t_ids
)
.
in_p
arents
(
paren
t_ids
)
.
where
(
'relative_position < ?'
,
self
.
relative_position
)
.
maximum
(
:relative_position
)
end
...
...
@@ -36,7 +36,7 @@ module RelativePositioning
if
self
.
relative_position
next_pos
=
self
.
class
.
in_p
rojects
(
projec
t_ids
)
.
in_p
arents
(
paren
t_ids
)
.
where
(
'relative_position > ?'
,
self
.
relative_position
)
.
minimum
(
:relative_position
)
end
...
...
@@ -63,7 +63,7 @@ module RelativePositioning
pos_after
=
before
.
next_relative_position
if
before
.
shift_after?
issue_to_move
=
self
.
class
.
in_p
rojects
(
projec
t_ids
).
find_by!
(
relative_position:
pos_after
)
issue_to_move
=
self
.
class
.
in_p
arents
(
paren
t_ids
).
find_by!
(
relative_position:
pos_after
)
issue_to_move
.
move_after
@positionable_neighbours
=
[
issue_to_move
]
# rubocop:disable Gitlab/ModuleWithInstanceVariables
...
...
@@ -78,7 +78,7 @@ module RelativePositioning
pos_before
=
after
.
prev_relative_position
if
after
.
shift_before?
issue_to_move
=
self
.
class
.
in_p
rojects
(
projec
t_ids
).
find_by!
(
relative_position:
pos_before
)
issue_to_move
=
self
.
class
.
in_p
arents
(
paren
t_ids
).
find_by!
(
relative_position:
pos_before
)
issue_to_move
.
move_before
@positionable_neighbours
=
[
issue_to_move
]
# rubocop:disable Gitlab/ModuleWithInstanceVariables
...
...
@@ -92,6 +92,10 @@ module RelativePositioning
self
.
relative_position
=
position_between
(
max_relative_position
||
START_POSITION
,
MAX_POSITION
)
end
def
move_to_start
self
.
relative_position
=
position_between
(
min_relative_position
||
START_POSITION
,
MIN_POSITION
)
end
# Indicates if there is an issue that should be shifted to free the place
def
shift_after?
next_pos
=
next_relative_position
...
...
app/models/issue.rb
浏览文件 @
304851dc
...
...
@@ -35,6 +35,8 @@ class Issue < ActiveRecord::Base
validates
:project
,
presence:
true
alias_attribute
:parent_id
,
:project_id
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
)
}
scope
:assigned
,
->
{
where
(
'EXISTS (SELECT TRUE FROM issue_assignees WHERE issue_id = issues.id)'
)
}
...
...
@@ -78,6 +80,10 @@ class Issue < ActiveRecord::Base
acts_as_paranoid
class
<<
self
alias_method
:in_parents
,
:in_projects
end
def
self
.
reference_prefix
'#'
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录