Merged PR 205: Add new AddingBehavior ReplaceParent + Allow AddingBehavior override by response + fix double key in context menu + Rename node-http.js to http.js
This commit is contained in:
parent
34c00d267c
commit
38a6919192
7 changed files with 151 additions and 379 deletions
|
@ -39,7 +39,7 @@ export function GetAction(
|
|||
Container: container,
|
||||
PreviousContainer: prev,
|
||||
NextContainer: next,
|
||||
Action: action.Action,
|
||||
Action: action,
|
||||
ApplicationState: currentState
|
||||
};
|
||||
/* eslint-enable */
|
||||
|
@ -59,7 +59,7 @@ export function GetAction(
|
|||
};
|
||||
}
|
||||
|
||||
function GetPreviousAndNextSiblings(container: IContainerModel): { prev: IContainerModel | undefined; next: IContainerModel | undefined; } {
|
||||
function GetPreviousAndNextSiblings(container: IContainerModel): { prev: IContainerModel | undefined, next: IContainerModel | undefined } {
|
||||
let prev;
|
||||
let next;
|
||||
if (container.parent !== undefined &&
|
||||
|
@ -85,7 +85,8 @@ function HandleSetContainerList(
|
|||
historyCurrentStep: number,
|
||||
setNewHistory: (newHistory: IHistoryState[]) => void
|
||||
): void {
|
||||
switch (action.AddingBehavior) {
|
||||
const addingBehavior = response.AddingBehavior ?? action.AddingBehavior;
|
||||
switch (addingBehavior) {
|
||||
case AddMethod.Append:
|
||||
setNewHistory(
|
||||
AddContainers(
|
||||
|
@ -98,7 +99,7 @@ function HandleSetContainerList(
|
|||
));
|
||||
break;
|
||||
case AddMethod.Insert:
|
||||
break;
|
||||
throw new Error('Not yet supported');
|
||||
case AddMethod.Replace:
|
||||
setNewHistory(
|
||||
HandleReplace(
|
||||
|
@ -110,6 +111,25 @@ function HandleSetContainerList(
|
|||
)
|
||||
);
|
||||
break;
|
||||
case AddMethod.ReplaceParent:
|
||||
if (selectedContainer.parent === undefined || selectedContainer.parent === null) {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'The selected container has not parent to replace',
|
||||
icon: 'error'
|
||||
});
|
||||
return;
|
||||
}
|
||||
setNewHistory(
|
||||
HandleReplace(
|
||||
selectedContainer.parent,
|
||||
response,
|
||||
configuration,
|
||||
history,
|
||||
historyCurrentStep
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ export function Menu(props: IMenuProps): JSX.Element {
|
|||
|
||||
actions.forEach((action, index) => {
|
||||
children.push(<MenuItem
|
||||
key={`contextmenu-item-${count}`}
|
||||
key={`contextmenu-item-${count}-${index}`}
|
||||
className="contextmenu-item"
|
||||
text={action.text}
|
||||
onClick={() => action.action(target)} />);
|
||||
|
|
|
@ -8,5 +8,6 @@
|
|||
export enum AddMethod {
|
||||
Append,
|
||||
Insert,
|
||||
Replace
|
||||
Replace,
|
||||
ReplaceParent
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { IAction } from './IAction';
|
||||
import { IContainerModel } from './IContainerModel';
|
||||
import { IHistoryState } from './IHistoryState';
|
||||
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
export interface ISetContainerListRequest {
|
||||
/** Name of the action declared in the API */
|
||||
Action: string
|
||||
Action: IAction
|
||||
|
||||
/** Selected container */
|
||||
Container: IContainerModel
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { AddMethod } from '../Enums/AddMethod';
|
||||
import { IAvailableContainer } from './IAvailableContainer';
|
||||
|
||||
export interface ISetContainerListResponse {
|
||||
Containers: IAvailableContainer[]
|
||||
AddingBehavior?: AddMethod
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue