Skip to content

Commit

Permalink
tech(clean): drop drag and drop champs in editor, ux not ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin committed Jan 12, 2024
1 parent 69346ad commit 68e9d35
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 106 deletions.
8 changes: 0 additions & 8 deletions app/components/types_de_champ_editor/block_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ def initialize(block:, coordinates:, upper_coordinates: [])

private

def sortable_options
{
controller: 'sortable',
sortable_handle_value: '.handle',
sortable_group_value: block_id
}
end

def block_id
dom_id(@block, :types_de_champ_editor_block)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- c = TypesDeChampEditor::SelectChampTemplatePositionComponent.new(block: @block, coordinates: @coordinates)
%ul.types-de-champ-block{ id: block_id, data: sortable_options.merge(controller: 'select-champ-position-template', 'select-champ-position-template-template-id-value': c.block_id ) }
%ul.types-de-champ-block{ id: block_id, data: { controller: 'select-champ-position-template', 'select-champ-position-template-template-id-value': c.block_id } }
- @coordinates.each do |coordinate|
= render TypesDeChampEditor::ChampComponent.new(coordinate:, upper_coordinates: coordinate.upper_coordinates)
%li.hidden= render c
Expand Down
1 change: 0 additions & 1 deletion app/components/types_de_champ_editor/champ_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def html_options
last: coordinate.last?),
data: {
controller: 'type-de-champ-editor',
type_de_champ_editor_move_url_value: move_admin_procedure_type_de_champ_path(procedure, type_de_champ.stable_id),
type_de_champ_editor_move_up_url_value: move_up_admin_procedure_type_de_champ_path(procedure, type_de_champ.stable_id),
type_de_champ_editor_move_down_url_value: move_down_admin_procedure_type_de_champ_path(procedure, type_de_champ.stable_id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
.type-de-champ-container
.flex.justify-between.section.head
.position.flex.align-center= @coordinate.position.to_s
.fr-btn.fr-btn--tertiary-no-outline.handle.fr-icon-drag-move-2-line{ title: "Déplacer le champ vers le haut ou vers le bas" }
%button.fr-btn.fr-btn--tertiary-no-outline.fr-icon-arrow-up-line.move-up{ move_button_options(:up) }
%button.fr-btn.fr-btn--tertiary-no-outline.fr-icon-arrow-down-line.move-down{ move_button_options(:down) }

Expand Down
4 changes: 0 additions & 4 deletions app/controllers/administrateurs/types_de_champ_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ def notice_explicative
end
end

def move
draft.move_type_de_champ(params[:stable_id], params[:position].to_i)
end

def move_and_morph
source_type_de_champ = draft.find_and_ensure_exclusive_use(params[:stable_id])
target_type_de_champ = draft.find_and_ensure_exclusive_use(params[:target_stable_id])
Expand Down
68 changes: 0 additions & 68 deletions app/javascript/controllers/sortable_controller.ts

This file was deleted.

14 changes: 0 additions & 14 deletions app/javascript/controllers/type_de_champ_editor_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ const AUTOSAVE_DEBOUNCE_DELAY = debounce_delay;
export class TypeDeChampEditorController extends ApplicationController {
static values = {
typeDeChampStableId: String,
moveUrl: String,
moveUpUrl: String,
moveDownUrl: String
};

declare readonly moveUrlValue: string;
declare readonly moveUpUrlValue: string;
declare readonly moveDownUrlValue: string;
declare readonly isVisible: boolean;
Expand All @@ -33,9 +31,6 @@ export class TypeDeChampEditorController extends ApplicationController {
this.#latestPromise = Promise.resolve();
this.on('change', (event) => this.onChange(event));
this.on('input', (event) => this.onInput(event));
this.on('sortable:end', (event) =>
this.onSortableEnd(event as CustomEvent)
);
}

disconnect() {
Expand Down Expand Up @@ -77,15 +72,6 @@ export class TypeDeChampEditorController extends ApplicationController {
});
}

private onSortableEnd(event: CustomEvent<{ position: number }>) {
const position = event.detail.position;
if (event.target == this.element) {
const form = createForm(this.moveUrlValue, 'patch');
createHiddenInput(form, 'position', position);
this.requestSubmitForm(form);
}
}

private save(form?: HTMLFormElement | null): void {
if (form) {
createHiddenInput(form, 'should_render', true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
= turbo_stream.replace dom_id(@coordinate.revision, :estimated_fill_duration) do
- render TypesDeChampEditor::EstimatedFillDurationComponent.new(revision: @coordinate.revision, is_annotation: @coordinate.private?)

= turbo_stream.dispatch 'sortable:sort'

- if @created&.coordinate&.child?
= turbo_stream.hide dom_id(@created.coordinate.parent, :type_de_champ_add_button)
- elsif @destroyed&.child? && @destroyed.parent.empty?
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,6 @@

resources :types_de_champ, only: [:create, :update, :destroy], param: :stable_id do
member do
patch :move
patch :move_and_morph
patch :move_up
patch :move_down
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"react-dom": "^18.2.0",
"react-popper": "^2.3.0",
"react-query": "^3.39.3",
"sortablejs": "^1.15.0",
"spectaql": "^2.3.0",
"stimulus-use": "^0.52.0",
"terser": "^5.18.2",
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7777,11 +7777,6 @@ slash@^4.0.0:
resolved "https://registry.yarnpkg.com/slash/-/slash-4.0.0.tgz#2422372176c4c6c5addb5e2ada885af984b396a7"
integrity sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==

sortablejs@^1.15.0:
version "1.15.0"
resolved "https://registry.yarnpkg.com/sortablejs/-/sortablejs-1.15.0.tgz#53230b8aa3502bb77a29e2005808ffdb4a5f7e2a"
integrity sha512-bv9qgVMjUMf89wAvM6AxVvS/4MX3sPeN0+agqShejLU5z5GX4C75ow1O2e5k4L6XItUyAK3gH6AxSbXrOM5e8w==

"source-map-js@>=0.6.2 <2.0.0", source-map-js@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
Expand Down

0 comments on commit 68e9d35

Please sign in to comment.