Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
e725ee0c
Commit
e725ee0c
authored
Jan 29, 2019
by
Brett Walker
Committed by
Fatih Acet
Jan 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes for review comments
parent
19dc2fb0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
25 deletions
+30
-25
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+10
-10
app/services/task_list_toggle_service.rb
app/services/task_list_toggle_service.rb
+19
-14
changelogs/unreleased/19745-forms-with-task-lists-can-be-overwritten-when-editing-simultaneously.yml
...-lists-can-be-overwritten-when-editing-simultaneously.yml
+1
-1
No files found.
app/services/issuable_base_service.rb
View file @
e725ee0c
...
@@ -266,18 +266,18 @@ class IssuableBaseService < BaseService
...
@@ -266,18 +266,18 @@ class IssuableBaseService < BaseService
update_task_params
=
params
.
delete
(
:update_task
)
update_task_params
=
params
.
delete
(
:update_task
)
return
unless
update_task_params
return
unless
update_task_params
toggler
=
TaskListToggleService
.
new
(
issuable
.
description
,
issuable
.
description_html
,
t
asklist_t
oggler
=
TaskListToggleService
.
new
(
issuable
.
description
,
issuable
.
description_html
,
line_source:
update_task_params
[
:line_source
],
line_source:
update_task_params
[
:line_source
],
line_number:
update_task_params
[
:line_number
],
line_number:
update_task_params
[
:line_number
],
currently_checked:
!
update_task_params
[
:checked
],
toggle_as_checked:
update_task_params
[
:checked
],
index:
update_task_params
[
:index
],
index:
update_task_params
[
:index
],
sourcepos:
!
issuable
.
legacy_markdown?
)
sourcepos:
!
issuable
.
legacy_markdown?
)
if
toggler
.
execute
if
t
asklist_t
oggler
.
execute
# by updating the description_html field at the same time,
# by updating the description_html field at the same time,
# the markdown cache won't be considered invalid
# the markdown cache won't be considered invalid
params
[
:description
]
=
toggler
.
updated_markdown
params
[
:description
]
=
t
asklist_t
oggler
.
updated_markdown
params
[
:description_html
]
=
toggler
.
updated_markdown_html
params
[
:description_html
]
=
t
asklist_t
oggler
.
updated_markdown_html
# since we're updating a very specific line, we don't care whether
# since we're updating a very specific line, we don't care whether
# the `lock_version` sent from the FE is the same or not. Just
# the `lock_version` sent from the FE is the same or not. Just
...
...
app/services/task_list_toggle_service.rb
View file @
e725ee0c
...
@@ -11,10 +11,10 @@
...
@@ -11,10 +11,10 @@
class
TaskListToggleService
class
TaskListToggleService
attr_reader
:updated_markdown
,
:updated_markdown_html
attr_reader
:updated_markdown
,
:updated_markdown_html
def
initialize
(
markdown
,
markdown_html
,
line_source
:,
line_number
:,
currently
_checked
:,
index
:,
sourcepos:
true
)
def
initialize
(
markdown
,
markdown_html
,
line_source
:,
line_number
:,
toggle_as
_checked
:,
index
:,
sourcepos:
true
)
@markdown
,
@markdown_html
=
markdown
,
markdown_html
@markdown
,
@markdown_html
=
markdown
,
markdown_html
@line_source
,
@line_number
=
line_source
,
line_number
@line_source
,
@line_number
=
line_source
,
line_number
@
currently_checked
=
currently
_checked
@
toggle_as_checked
=
toggle_as
_checked
@index
,
@use_sourcepos
=
index
,
sourcepos
@index
,
@use_sourcepos
=
index
,
sourcepos
@updated_markdown
,
@updated_markdown_html
=
nil
@updated_markdown
,
@updated_markdown_html
=
nil
...
@@ -23,40 +23,45 @@ class TaskListToggleService
...
@@ -23,40 +23,45 @@ class TaskListToggleService
def
execute
def
execute
return
false
unless
markdown
&&
markdown_html
return
false
unless
markdown
&&
markdown_html
!!
(
toggle_markdown
&&
toggle_html
)
!!
(
toggle_markdown
&&
toggle_
markdown_
html
)
end
end
private
private
attr_reader
:markdown
,
:markdown_html
,
:index
,
:
currently
_checked
attr_reader
:markdown
,
:markdown_html
,
:index
,
:
toggle_as
_checked
attr_reader
:line_source
,
:line_number
,
:use_sourcepos
attr_reader
:line_source
,
:line_number
,
:use_sourcepos
def
toggle_markdown
def
toggle_markdown
source_lines
=
markdown
.
split
(
"
\n
"
)
source_lines
=
markdown
.
split
(
"
\n
"
)
markdown_task
=
source_lines
[
line_number
-
1
]
source_line_index
=
line_number
-
1
markdown_task
=
source_lines
[
source_line_index
]
return
unless
markdown_task
==
line_source
return
unless
markdown_task
==
line_source
return
unless
source_checkbox
=
Taskable
::
ITEM_PATTERN
.
match
(
markdown_task
)
return
unless
source_checkbox
=
Taskable
::
ITEM_PATTERN
.
match
(
markdown_task
)
if
TaskList
::
Item
.
new
(
source_checkbox
[
1
]).
complete?
currently_checked
=
TaskList
::
Item
.
new
(
source_checkbox
[
1
]).
complete?
markdown_task
.
sub!
(
Taskable
::
COMPLETE_PATTERN
,
'[ ]'
)
if
currently_checked
# Check `toggle_as_checked` to make sure we don't accidentally replace
# any `[ ]` or `[x]` in the middle of the text
if
currently_checked
markdown_task
.
sub!
(
Taskable
::
COMPLETE_PATTERN
,
'[ ]'
)
unless
toggle_as_checked
else
else
markdown_task
.
sub!
(
Taskable
::
INCOMPLETE_PATTERN
,
'[x]'
)
unless
currently
_checked
markdown_task
.
sub!
(
Taskable
::
INCOMPLETE_PATTERN
,
'[x]'
)
if
toggle_as
_checked
end
end
source_lines
[
line_number
-
1
]
=
markdown_task
source_lines
[
source_line_index
]
=
markdown_task
@updated_markdown
=
source_lines
.
join
(
"
\n
"
)
@updated_markdown
=
source_lines
.
join
(
"
\n
"
)
end
end
def
toggle_html
def
toggle_
markdown_
html
html
=
Nokogiri
::
HTML
.
fragment
(
markdown_html
)
html
=
Nokogiri
::
HTML
.
fragment
(
markdown_html
)
html_checkbox
=
get_html_checkbox
(
html
)
html_checkbox
=
get_html_checkbox
(
html
)
return
unless
html_checkbox
return
unless
html_checkbox
if
currently_checked
if
toggle_as_checked
html_checkbox
.
remove_attribute
(
'checked'
)
else
html_checkbox
[
:checked
]
=
'checked'
html_checkbox
[
:checked
]
=
'checked'
else
html_checkbox
.
remove_attribute
(
'checked'
)
end
end
@updated_markdown_html
=
html
.
to_html
@updated_markdown_html
=
html
.
to_html
...
...
changelogs/unreleased/19745-forms-with-task-lists-can-be-overwritten-when-editing-simultaneously.yml
View file @
e725ee0c
---
---
title
:
Increase reliability and performance of
click
ing task items
title
:
Increase reliability and performance of
toggl
ing task items
merge_request
:
23938
merge_request
:
23938
author
:
author
:
type
:
fixed
type
:
fixed
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment