-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2942] Add the Card DnD capability on Deck
- Make it possible to specify the card drop behavior on a Lane in the Deck view model. - Add the DropCard mutation to handle the front-end drag and drop and execute the tool. Bug: #2942 Signed-off-by: Florian Barbin <florian.barbin@obeo.fr> Signed-off-by: Florian ROUËNÉ <florian.rouene@obeosoft.com>
- Loading branch information
1 parent
d7ab5dc
commit 0e72358
Showing
48 changed files
with
1,150 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...in/java/org/eclipse/sirius/components/collaborative/deck/dto/input/DropDeckCardInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.collaborative.deck.dto.input; | ||
|
||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.collaborative.deck.api.IDeckInput; | ||
|
||
/** | ||
* The input of the "drop deck card" mutation. | ||
* | ||
* @author fbarbin | ||
*/ | ||
public record DropDeckCardInput(UUID id, String editingContextId, String representationId, String oldLaneId, String newLaneId, String cardId, int addedIndex) implements IDeckInput { | ||
} |
79 changes: 79 additions & 0 deletions
79
...a/org/eclipse/sirius/components/collaborative/deck/handlers/DropDeckCardEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.collaborative.deck.handlers; | ||
|
||
import java.util.Objects; | ||
|
||
import org.eclipse.sirius.components.collaborative.api.ChangeDescription; | ||
import org.eclipse.sirius.components.collaborative.api.ChangeKind; | ||
import org.eclipse.sirius.components.collaborative.api.Monitoring; | ||
import org.eclipse.sirius.components.collaborative.deck.api.IDeckCardService; | ||
import org.eclipse.sirius.components.collaborative.deck.api.IDeckEventHandler; | ||
import org.eclipse.sirius.components.collaborative.deck.api.IDeckInput; | ||
import org.eclipse.sirius.components.collaborative.deck.dto.input.DropDeckCardInput; | ||
import org.eclipse.sirius.components.collaborative.deck.message.ICollaborativeDeckMessageService; | ||
import org.eclipse.sirius.components.core.api.ErrorPayload; | ||
import org.eclipse.sirius.components.core.api.IEditingContext; | ||
import org.eclipse.sirius.components.core.api.IPayload; | ||
import org.eclipse.sirius.components.deck.Deck; | ||
import org.springframework.stereotype.Service; | ||
|
||
import io.micrometer.core.instrument.Counter; | ||
import io.micrometer.core.instrument.MeterRegistry; | ||
import reactor.core.publisher.Sinks.Many; | ||
import reactor.core.publisher.Sinks.One; | ||
|
||
/** | ||
* Handle "Drop Deck Card" events. | ||
* | ||
* @author fbarbin | ||
*/ | ||
@Service | ||
public class DropDeckCardEventHandler implements IDeckEventHandler { | ||
|
||
private final IDeckCardService deckCardService; | ||
|
||
private final ICollaborativeDeckMessageService messageService; | ||
|
||
private final Counter counter; | ||
|
||
public DropDeckCardEventHandler(IDeckCardService deckCardService, ICollaborativeDeckMessageService messageService, MeterRegistry meterRegistry) { | ||
this.deckCardService = Objects.requireNonNull(deckCardService); | ||
this.messageService = Objects.requireNonNull(messageService); | ||
|
||
this.counter = Counter.builder(Monitoring.EVENT_HANDLER).tag(Monitoring.NAME, this.getClass().getSimpleName()).register(meterRegistry); | ||
} | ||
|
||
@Override | ||
public boolean canHandle(IDeckInput deckInput) { | ||
return deckInput instanceof DropDeckCardInput; | ||
} | ||
|
||
@Override | ||
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, Deck deck, IDeckInput deckInput) { | ||
this.counter.increment(); | ||
|
||
String message = this.messageService.invalidInput(deckInput.getClass().getSimpleName(), DropDeckCardInput.class.getSimpleName()); | ||
IPayload payload = new ErrorPayload(deckInput.id(), message); | ||
ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, deckInput.representationId(), deckInput); | ||
|
||
if (deckInput instanceof DropDeckCardInput input) { | ||
payload = this.deckCardService.dropCard(input, editingContext, deck); | ||
|
||
changeDescription = new ChangeDescription(ChangeKind.SEMANTIC_CHANGE, deckInput.representationId(), deckInput); | ||
} | ||
|
||
payloadSink.tryEmitValue(payload); | ||
changeDescriptionSink.tryEmitNext(changeDescription); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...sirius/components/deck/graphql/datafetchers/mutation/MutationDropDeckCardDataFetcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.deck.graphql.datafetchers.mutation; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import java.util.Objects; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import org.eclipse.sirius.components.annotations.spring.graphql.MutationDataFetcher; | ||
import org.eclipse.sirius.components.collaborative.deck.dto.input.DropDeckCardInput; | ||
import org.eclipse.sirius.components.core.api.IPayload; | ||
import org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates; | ||
import org.eclipse.sirius.components.graphql.api.IEditingContextDispatcher; | ||
import org.eclipse.sirius.components.graphql.api.IExceptionWrapper; | ||
|
||
import graphql.schema.DataFetchingEnvironment; | ||
|
||
/** | ||
* The data fetcher used to drop a Deck card. | ||
* | ||
* @author fbarbin | ||
*/ | ||
@MutationDataFetcher(type = "Mutation", field = "dropDeckCard") | ||
public class MutationDropDeckCardDataFetcher implements IDataFetcherWithFieldCoordinates<CompletableFuture<IPayload>> { | ||
|
||
private static final String INPUT_ARGUMENT = "input"; | ||
|
||
private final ObjectMapper objectMapper; | ||
|
||
private final IExceptionWrapper exceptionWrapper; | ||
|
||
private final IEditingContextDispatcher editingContextDispatcher; | ||
|
||
public MutationDropDeckCardDataFetcher(ObjectMapper objectMapper, IExceptionWrapper exceptionWrapper, IEditingContextDispatcher editingContextDispatcher) { | ||
this.objectMapper = Objects.requireNonNull(objectMapper); | ||
this.exceptionWrapper = Objects.requireNonNull(exceptionWrapper); | ||
this.editingContextDispatcher = Objects.requireNonNull(editingContextDispatcher); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<IPayload> get(DataFetchingEnvironment environment) throws Exception { | ||
Object argument = environment.getArgument(INPUT_ARGUMENT); | ||
var input = this.objectMapper.convertValue(argument, DropDeckCardInput.class); | ||
|
||
return this.exceptionWrapper.wrapMono(() -> this.editingContextDispatcher.dispatchMutation(input.editingContextId(), input), input).toFuture(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.