Skip to content

Commit e867abd

Browse files
douglaraYukioArie
andauthored
Add dragger to change stage order (#586)
* Add dragger to change stage order * Add animation to drag and drop system --------- Co-authored-by: Yukio Arie <yukioarie@gmail.com>
1 parent d1de577 commit e867abd

File tree

6 files changed

+9
-2
lines changed

6 files changed

+9
-2
lines changed

app/javascript/controllers/drag_stages_position_controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default class extends Controller {
66
connect() {
77
this.moveFormFieldInputsToNestedFields();
88
this.Sortable = Sortable.create(this.element, {
9+
animation: 150,
910
onEnd: this.end.bind(this)
1011
});
1112
}

app/views/accounts/pipelines/_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<h2 class= "typography-body-s-lh150 text-dark-gray-palette-p1">
2222
<%= t('activerecord.models.stage.other') %>
2323
</h2>
24-
<div class="grid gap-5" data-controller="drag-stages-position" <%= "data-drag-stages-position-url= #{account_pipeline_path(pipeline)}" if pipeline.id.present?%> >
24+
<div class="grid gap-3" data-controller="drag-stages-position" <%= "data-drag-stages-position-url= #{account_pipeline_path(pipeline)}" if pipeline.id.present?%> >
2525
<%= form.fields_for :stages, @stages do |stage| %>
2626
<div data-id= "<%= stage.object.id %>">
2727
<%= render 'stage_fields', :f => stage %>

app/views/accounts/pipelines/_stage_fields.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<div class='nested-fields' data-controller="load-lucid-icons">
22
<%= f.label :name, class: "typography-text-m-lh150 text-dark-gray-palette-p1" %>
3-
<div class="flex gap-2">
3+
<div class="flex gap-2 items-center">
44
<%= f.text_field :name, class: "form-input flex-1" %>
5+
<div class="cursor-grab active:cursor-grabbing text-dark-gray-palette-p3 hover:text-dark-gray-palette-p1 transition-colors" title="<%= t('views.accounts.pipelines.form.drag_to_reorder') %>">
6+
<i data-lucide="grip-vertical" class="w-5 h-5"></i>
7+
</div>
58
<%= link_to_remove_association f, class: 'btn-secondary !p-2', data: { confirm: t('views.accounts.pipelines.stage_fields.are_you_sure?') } do %>
69
<i data-lucide="trash-2"></i>
710
<% end %>

config/locales/views/accounts/pipelines/form/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ en:
44
pipelines:
55
form:
66
pipeline_data: Pipeline data
7+
drag_to_reorder: Drag to reorder

config/locales/views/accounts/pipelines/form/es.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ es:
44
pipelines:
55
form:
66
pipeline_data: Datos del embudo
7+
drag_to_reorder: Arrastrar para reordenar

config/locales/views/accounts/pipelines/form/pt-BR.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ pt-BR:
44
pipelines:
55
form:
66
pipeline_data: Dados do funil
7+
drag_to_reorder: Arrastar para reordenar
78

89

0 commit comments

Comments
 (0)