Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v3.2.7 (2024.12) #2001

Merged
merged 26 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c924ad4
WEG-86 - Add model propagation to react-lobby (#1990)
TehAwol Oct 14, 2024
28bed43
Add relative position to ensure loadingStyle is correctly displayed
TehAwol Oct 16, 2024
acc789d
Improve propagation UX
TehAwol Oct 16, 2024
bee7d9d
Merge pull request #1991 from Heigvd/WEG-95
fsantaniello-heigvd Oct 21, 2024
a561092
WEG-107 Update the path of the file selector when changing the language
SandraMonnier Nov 5, 2024
26c31c9
WEG-101 Fix ServerGlobalMethodRegister type (#1992)
SandraMonnier Nov 5, 2024
ecb70b4
WEG-105 Order the WRequirement when exporting
SandraMonnier Nov 6, 2024
22e83a0
Merge pull request #1993 from Heigvd/WEG-107
xgo-work Nov 12, 2024
561390b
WEG-105 Order the WRequirement when exporting - review fix
SandraMonnier Nov 13, 2024
06da0f0
Merge pull request #1994 from Heigvd/WEG-105
xgo-work Nov 14, 2024
8f7431a
WEG-114 Task label : add index
SandraMonnier Nov 15, 2024
d864901
WEG-114 Task label : add index - code styling fix
SandraMonnier Nov 18, 2024
ad1f08e
WEG-113 Order the Occupation when exporting (#1995)
SandraMonnier Nov 18, 2024
ea79ed0
Merge pull request #1996 from Heigvd/WEG-114-task-label
TehAwol Nov 20, 2024
b97a3aa
Fix placeholder, add placeholder component options and add CSS selectors
TehAwol Dec 2, 2024
2d4911c
Label associated to a 0 value in a select component is displayed corr…
xgo-work Dec 3, 2024
7b0fbc8
Merge pull request #1998 from Heigvd/select-fix
fsantaniello-heigvd Dec 10, 2024
4738b92
Add noOptionsMessage component property to Select component
TehAwol Dec 10, 2024
06cf0eb
WEG-126 Add disabled property for Select Choices
SandraMonnier Dec 12, 2024
91f5f9d
Select component : move placeholder style
SandraMonnier Dec 13, 2024
42dd697
Select component : move translation
SandraMonnier Dec 13, 2024
0657974
placeholder and noOptionsMessage undefined if empty
TehAwol Dec 13, 2024
bc73c51
Merge pull request #1997 from Heigvd/select-placerholder
TehAwol Dec 13, 2024
eddb740
Merge branch 'dev' into WEG-126
TehAwol Dec 13, 2024
61ac96d
Add undefined to returnType
TehAwol Dec 16, 2024
79a4552
Merge pull request #2000 from Heigvd/WEG-126
TehAwol Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions wegas-app/src/main/node/wegas-react/src/API/gameModel.api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
import { managedModeRequest, rest } from './rest';

/** PatchDiff and changes */
interface LineChange {
lineNumber: number;
tag: string;
content: string;
}

interface SideBySideChange {
oldValue: string;
newValue: string;
}

type Change = LineChange | SideBySideChange;

interface DiffCollection {
title: string;
diffs: PatchDiff[];
}

interface PrimitiveDiff {
title: string;
changes: Change[];
}

export type PatchDiff = DiffCollection | PrimitiveDiff;

export const GameModelApi = {
get(gameModelId: number | string) {
return managedModeRequest('/GameModel/' + gameModelId);
Expand All @@ -25,10 +51,22 @@ export const GameModelApi = {
);
},
createExtraTestPlayer(gameModelId: number) {
return managedModeRequest(`/GameModel/${gameModelId}/ExtraTestPlayer`, {
method: 'POST',
});
},
getModelDiff(gameModelId: number | string): Promise<PatchDiff> {
return managedModeRequest(`/GameModel/${gameModelId}/Diff`).then(
res => res.updatedEntities[0] as Promise<PatchDiff>,
);
},
propagateModel(gameModelId: number) {
return managedModeRequest(
`/GameModel/${ gameModelId}/ExtraTestPlayer`,
`/GameModel/${gameModelId}/Propagate`,
{
method: 'POST',
});
}
method: 'PUT',
},
false,
);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import * as React from 'react';
import { commonTranslations } from '../../i18n/common/common';
import { useInternalTranslate } from '../../i18n/internalTranslator';
import { CheckBox } from '../Inputs/Boolean/CheckBox';
import {GameModel} from "../../data/selectors";

const availableFeatures: FeatureLevel[] = ['ADVANCED', 'INTERNAL'];

export const defaultFeatures: FeaturesSelecta = {
DEFAULT: true,
ADVANCED: false,
INTERNAL: false,
MODELER: false,
};

export interface FeatureContext {
Expand Down Expand Up @@ -75,6 +77,12 @@ function FeaturesContext({
};
}, [listener]);

React.useEffect(() => {
if (GameModel.selectCurrent().type === 'MODEL') {
toggleFeature('MODELER');
}
}, []);

return (
<featuresCTX.Provider
value={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function ajustVertically(values: ContainerValues) {
return newValues;
}

function ajustVerticalOverlap(values: ContainerValues, parent: HTMLElement) {
function adjustVerticalOverlap(values: ContainerValues, parent: HTMLElement) {
let newTopUp = parent.getBoundingClientRect().top - values.height;
const newTopDown =
parent.getBoundingClientRect().top + parent.getBoundingClientRect().height;
Expand Down Expand Up @@ -127,7 +127,7 @@ function ajustVerticalOverlap(values: ContainerValues, parent: HTMLElement) {
}
}

function ajustHorizontalOverlap(values: ContainerValues, parent: HTMLElement) {
function adjustHorizontalOverlap(values: ContainerValues, parent: HTMLElement) {
let newLeftUp = parent.getBoundingClientRect().left - values.width;
const newLeftDown =
parent.getBoundingClientRect().left + parent.getBoundingClientRect().width;
Expand Down Expand Up @@ -250,9 +250,9 @@ export function justifyDropMenu(
values = ajustVertically(values);

if (vertical && isOverlappingVertically(values, selector)) {
values = ajustVerticalOverlap(values, selector);
values = adjustVerticalOverlap(values, selector);
} else if (!vertical && isOverlappingHorizontally(values, selector)) {
values = ajustHorizontalOverlap(values, selector);
values = adjustHorizontalOverlap(values, selector);
}

menu.style.setProperty('left', values.left + 'px');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const loadingStyle = cx(
);

export const buttonStyle = css({
position: 'relative',
display: 'flex',
alignItems: 'center',
backgroundColor: themeVar.colors.PrimaryColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ interface PlayerSelectInputProps extends WegasComponentProps {
* choices - the allowed choices
*/
choices?: Choice[] | IScript;
/**
* placeholder - the grey text inside the box when nothing is selected
*/
placeholder?: IScript;
/**
* noOptionsMessage - the text to inform that there is no available choice
*/
noOptionsMessage?: IScript;
onVariableChange?: OnVariableChange;
}

Expand All @@ -50,6 +58,8 @@ function PlayerSelectInput({
onVariableChange,
pageId,
path,
placeholder,
noOptionsMessage,
}: PlayerSelectInputProps) {
const { somethingIsUndefined } = useInternalTranslate(commonTranslations);
const descriptor = useScript<SStringDescriptor | SNumberDescriptor | string>(
Expand All @@ -62,15 +72,19 @@ function PlayerSelectInput({
context,
);

const value = useStore(
() =>
(descriptor != null && typeof descriptor === 'object'
const value = useStore(() => {
const v =
descriptor != null && typeof descriptor === 'object'
? descriptor.getValue(Player.self())
: descriptor) || '',
);
: descriptor;
return v == undefined ? '' : v;
});

const { lang } = React.useContext(languagesCTX);
const { handleOnChange } = useOnVariableChange(onVariableChange, context);
const placeholderText = useScript<string>(placeholder, context) || undefined;
const noOptionsMessageText =
useScript<string>(noOptionsMessage, context) || undefined;

if (descriptor == null) {
return (
Expand Down Expand Up @@ -106,6 +120,8 @@ function PlayerSelectInput({
id={id}
value={String(value)}
choices={computedChoices}
placeholder={placeholderText}
noOptionsMessage={noOptionsMessageText}
onChange={v => {
const newValue = v;
if (handleOnChange) {
Expand Down Expand Up @@ -154,16 +170,27 @@ registerComponent(
label: 'Choices',
scriptProps: {
language: 'TypeScript',
returnType: ['{label:string, value: string}[]'],
returnType: [
'{label:string, value: string, disabled?: boolean}[] | undefined',
],
},
literalSchema: schemaProps.array({
itemSchema: {
label: schemaProps.string({ label: 'Label' }),
value: schemaProps.string({ label: 'Value' }),
disabled: schemaProps.boolean({ label: 'Disabled' }),
},
}),
},
},
placeholder: schemaProps.scriptString({
label: 'Placeholder',
richText: false,
}),
noOptionsMessage: schemaProps.scriptString({
label: 'No options message',
richText: false,
}),
onVariableChange: onVariableChangeSchema('On text change action'),
...classStyleIdSchema,
},
Expand Down
24 changes: 19 additions & 5 deletions wegas-app/src/main/node/wegas-react/src/Components/Selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import Select from 'react-select';
import CreatableSelect from 'react-select/creatable';
import { classNameOrEmpty } from '../Helper/className';
import { commonTranslations } from '../i18n/common/common';
import { componentsTranslations } from '../i18n/components/components';
import { useInternalTranslate } from '../i18n/internalTranslator';
import { inputStyleCSS } from './Inputs/SimpleInput';
import { themeVar } from './Theme/ThemeVars';
Expand All @@ -18,6 +18,7 @@ export interface Choice {
};
children?: Choice[];
}

export type Choices = (string | Choice)[];

const selectStyle = css({
Expand Down Expand Up @@ -134,6 +135,13 @@ export const selectStyles: SelectProps['styles'] = {
return { ...provided };
}
},
placeholder: (provided) => {
return {
...provided,
color: themeVar.colors.DarkTextColor,
opacity: '0.3',
}
}
};

// interface SelectorProps extends ClassStyleId, DisabledReadonly {
Expand All @@ -151,6 +159,8 @@ interface SelectorProps<
DisabledReadonly {
choices: Choices;
value: string | undefined;
placeholder?: string | undefined;
noOptionsMessage?: string | undefined;
onChange?: (value: R) => void;
allowUndefined?: T;
allowAnyValue?: boolean;
Expand All @@ -163,15 +173,16 @@ export function Selector<T extends true | false>({
className,
/*style,*/
value,
placeholder,
noOptionsMessage,
onChange,
allowUndefined,
clearable,
allowAnyValue = false,
readOnly,
disabled,
}: SelectorProps<T>): JSX.Element {
const i18nValues = useInternalTranslate(commonTranslations);
const placeholder = i18nValues.plzChooseValue;
const i18nValues = useInternalTranslate(componentsTranslations).select;

const options = buildOptions(choices);

Expand Down Expand Up @@ -201,10 +212,13 @@ export function Selector<T extends true | false>({
id={id}
isDisabled={readOnly || disabled}
className={selectStyle + classNameOrEmpty(className)}
classNamePrefix={'wegas-select'}
isClearable={clearable}
options={options}
placeholder={placeholder}
value={currentOption}
placeholder={placeholder ?? i18nValues.plzChooseValue}
noOptionsMessage={() => noOptionsMessage ?? i18nValues.noChoiceInfo}
// Providing an empty object overrides the placeholder
value={currentOption.value?.length === 0 ? null : currentOption}
onChange={onChangeCb}
styles={selectStyles}
menuPosition="fixed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ export function WindowedEditor<T extends IMergeable>({
? (entity as { editorTag?: string }).editorTag
: undefined,
name: getClassLabel(pathEntity),
index: entity
? (entity as { index?: string }).index
: undefined,
})}
</>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ export function CustomFileSelector<T extends keyof AllowedTypes>({
inputId,
labelNode,
}: CustomFileSelectProps<T>) {
const [currentPath, setCurrentPath] = React.useState<string | undefined>(
value
const [currentPath, setCurrentPath] = React.useState<string | undefined>(undefined);
const [showBrowser, setShowBrowser] = React.useState(false);

React.useEffect(() => {
setCurrentPath(value
? valueType === 'string'
? (value as string)
: generateAbsolutePath(value as IAbstractContentDescriptor)
: undefined,
);
const [showBrowser, setShowBrowser] = React.useState(false);
: undefined);
}, [value, valueType]);

return (
<>
Expand Down
Loading
Loading