Skip to content

Commit

Permalink
merged changes from the main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeriaMaltseva committed Nov 29, 2024
2 parents 3a68a20 + 4a71b53 commit be47a2d
Show file tree
Hide file tree
Showing 48 changed files with 4,190 additions and 1,863 deletions.
2 changes: 1 addition & 1 deletion assets/build/api/docs.jsonopenapi.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions assets/build/api/openapi-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ const config: ConfigFile = {
},
'../../js/src/core/modules/auth/authorization-api-slice.gen.ts': {
filterEndpoints: pathMatcher(/(login|logout)/i)
},
'../../js/src/core/modules/class-definition/class-definition-slice.gen.ts': {
filterEndpoints: pathMatcher(/\/class\//i)
}
},
exportName: 'api',
Expand Down
2 changes: 2 additions & 0 deletions assets/js/src/core/app/config/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ import {
import {
DynamicTypeBatchEditTextArea
} from '@Pimcore/modules/element/dynamic-types/defintinitions/batch-edits/types/text/dynamic-type-batch-edit-text-area'
import { DynamicTypeObjectDataFieldCollection } from '@Pimcore/modules/element/dynamic-types/defintinitions/objects/data-related/types/dynamic-type-object-data-field-collection'

// Widget manager
container.bind(serviceIds.widgetManager).to(WidgetRegistry).inSingletonScope()
Expand Down Expand Up @@ -243,6 +244,7 @@ container.bind(serviceIds['DynamicTypes/ObjectData/GeoPolyLine']).to(DynamicType
container.bind(serviceIds['DynamicTypes/ObjectData/ManyToManyRelation']).to(DynamicTypeObjectDataManyToManyRelation).inSingletonScope()
container.bind(serviceIds['DynamicTypes/ObjectData/Block']).to(DynamicTypeObjectDataBlock).inSingletonScope()
container.bind(serviceIds['DynamicTypes/ObjectData/LocalizedFields']).to(DynamicTypeObjectDataLocalizedFields).inSingletonScope()
container.bind(serviceIds['DynamicTypes/ObjectData/FieldCollection']).to(DynamicTypeObjectDataFieldCollection).inSingletonScope()

// Execution engine
container.bind(serviceIds['ExecutionEngine/JobComponentRegistry']).to(JobComponentRegistry).inSingletonScope()
Expand Down
1 change: 1 addition & 0 deletions assets/js/src/core/app/config/services/service-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export const serviceIds = {
'DynamicTypes/ObjectData/ManyToManyRelation': 'DynamicTypes/ObjectData/ManyToManyRelation',
'DynamicTypes/ObjectData/Block': 'DynamicTypes/ObjectData/Block',
'DynamicTypes/ObjectData/LocalizedFields': 'DynamicTypes/ObjectData/LocalizedFields',
'DynamicTypes/ObjectData/FieldCollection': 'DynamicTypes/ObjectData/FieldCollection',

// Execution engine
'ExecutionEngine/JobComponentRegistry': 'ExecutionEngine/JobComponentRegistry',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import { api } from "../../app/api/pimcore/index";
export const addTagTypes = ["Class Definition"] as const;
const injectedRtkApi = api
.enhanceEndpoints({
addTagTypes,
})
.injectEndpoints({
endpoints: (build) => ({
classFieldCollectionObjectLayout: build.query<
ClassFieldCollectionObjectLayoutApiResponse,
ClassFieldCollectionObjectLayoutApiArg
>({
query: (queryArg) => ({
url: `/pimcore-studio/api/class/field-collection/${queryArg.objectId}/object/layout`,
}),
providesTags: ["Class Definition"],
}),
classQuantityValueUnitConvertAll: build.mutation<
ClassQuantityValueUnitConvertAllApiResponse,
ClassQuantityValueUnitConvertAllApiArg
>({
query: (queryArg) => ({
url: `/pimcore-studio/api/class/quantity-value/convert-all`,
method: "POST",
body: queryArg.convertAllParameters,
}),
invalidatesTags: ["Class Definition"],
}),
classQuantityValueUnitConvert: build.mutation<
ClassQuantityValueUnitConvertApiResponse,
ClassQuantityValueUnitConvertApiArg
>({
query: (queryArg) => ({
url: `/pimcore-studio/api/class/quantity-value/convert`,
method: "POST",
body: queryArg.convertParameters,
}),
invalidatesTags: ["Class Definition"],
}),
classQuantityValueUnitList: build.query<
ClassQuantityValueUnitListApiResponse,
ClassQuantityValueUnitListApiArg
>({
query: () => ({ url: `/pimcore-studio/api/class/quantity-value/unit-list` }),
providesTags: ["Class Definition"],
}),
}),
overrideExisting: false,
});
export { injectedRtkApi as api };
export type ClassFieldCollectionObjectLayoutApiResponse = /** status 200 List of layouts */ {
totalItems: number;
items: FieldCollectionLayoutDefinition[];
};
export type ClassFieldCollectionObjectLayoutApiArg = {
/** ObjectId of the element */
objectId: number;
};
export type ClassQuantityValueUnitConvertAllApiResponse =
/** status 200 Converted quantity value */ ConvertedQuantityValues;
export type ClassQuantityValueUnitConvertAllApiArg = {
convertAllParameters: ConvertAllUnitsParameters;
};
export type ClassQuantityValueUnitConvertApiResponse = /** status 200 Converted quantity value */ {
/** Converted value */
data: any | number;
};
export type ClassQuantityValueUnitConvertApiArg = {
convertParameters: UnitConvertParameters;
};
export type ClassQuantityValueUnitListApiResponse = /** status 200 List of quantity value units */ {
items: QuantityValueUnit[];
};
export type ClassQuantityValueUnitListApiArg = void;
export type FieldCollectionLayoutDefinition = {
/** AdditionalAttributes */
additionalAttributes?: {
[key: string]: string | number | boolean | object | any[];
};
/** Key of Field Collection */
key: string;
/** Data Type */
datatype: string;
/** Group */
group?: string | null;
/** Name */
name?: string | null;
/** Type */
type?: string | null;
/** Region */
region?: string | null;
/** Title */
title: string | null;
/** Width */
width: number;
/** Height */
height: number;
/** Collapsible */
collapsible: boolean;
/** collapsed */
collapsed: boolean;
/** Children */
children: any[];
};
export type Error = {
/** Message */
message: string;
};
export type DevError = {
/** Message */
message: string;
/** Details */
details: string;
};
export type ConvertedQuantityValues2 = {
/** Unit Abbreviation */
unitAbbreviation?: string;
/** Unit Long Name */
unitLongName?: string;
/** Converted Values */
convertedValue?: number;
};
export type ConvertedQuantityValues = {
/** AdditionalAttributes */
additionalAttributes?: {
[key: string]: string | number | boolean | object | any[];
};
/** Original Value */
originalValue: any | number;
/** From Unit Id */
fromUnitId: string;
/** Converted Values */
convertedValues: ConvertedQuantityValues2[];
};
export type ConvertAllUnitsParameters = {
/** From Unit Id */
fromUnitId: string;
/** Value */
value: any | number;
};
export type UnitConvertParameters = {
/** From Unit Id */
fromUnitId: string;
/** To Unit Id */
toUnitId: string;
/** Value */
value: any | number;
};
export type QuantityValueUnit = {
/** AdditionalAttributes */
additionalAttributes?: {
[key: string]: string | number | boolean | object | any[];
};
/** ID */
id: string | null;
/** Abbreviation */
abbreviation: string | null;
/** Group */
group: string | null;
/** Long Name */
longName: string | null;
/** Base Unit */
baseUnit: string | null;
/** Reference */
reference: string | null;
/** Factor */
factor: number | null;
/** Conversion Offset */
conversionOffset: number | null;
/** Converter */
converter: string | null;
};
export const {
useClassFieldCollectionObjectLayoutQuery,
useClassQuantityValueUnitConvertAllMutation,
useClassQuantityValueUnitConvertMutation,
useClassQuantityValueUnitListQuery,
} = injectedRtkApi;
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,26 @@ export interface DataComponentProps extends ObjectComponentProps {
export const DataComponent = (props: DataComponentProps): React.JSX.Element => {
const objectDataRegistry = useInjection<DynamicTypeObjectDataRegistry>(serviceIds['DynamicTypes/ObjectDataRegistry'])
const localizedFields = useLocalizedFields()
const { name } = props
const { fieldType, fieldtype } = props
const { name, fieldType, fieldtype } = props
const formList = useFormList()
const hasFormList = formList !== undefined
const hasLocalizedFields = localizedFields !== undefined && !hasFormList
const hasLocalizedFields = localizedFields !== undefined
let formFieldName: Array<number | string> = [name]
let title = props.title as ReactNode
const { currentLanguage } = useLanguageSelection()

if (hasFormList) {
formFieldName = [formList.field.name, name]
formFieldName = [...formList.getComputedFieldName(), name]
}

if (hasLocalizedFields) {
// @todo should handle multiple locales
formFieldName = ['localizedfields', name, localizedFields.locales[0]]

if (hasFormList) {
formFieldName = [...formList.getComputedFieldName(), ...formFieldName]
}

title = (
<>
{title}<Text type='secondary'>({currentLanguage.toUpperCase()})</Text>
Expand All @@ -73,7 +77,7 @@ export const DataComponent = (props: DataComponentProps): React.JSX.Element => {
const _props = {
...props,
title,
name: hasLocalizedFields ? formFieldName : name
name: formFieldName
}

if (!objectDataType.isCollectionType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { RootComponent } from './components/root-component'
import { useDataObjectGetByIdQuery, useDataObjectGetLayoutByIdQuery } from '@Pimcore/modules/data-object/data-object-api-slice-enhanced'
import { useElementContext } from '@Pimcore/modules/element/hooks/use-element-context'
import { Content } from '@Pimcore/components/content/content'
import { FieldCollectionProvider } from '@Pimcore/modules/element/dynamic-types/defintinitions/objects/data-related/components/field-collection/providers/field-collection-provider'

export const EditContainer = (): React.JSX.Element => {
const { id } = useElementContext()
Expand All @@ -29,10 +30,12 @@ export const EditContainer = (): React.JSX.Element => {
}

return (
<RootComponent
data={ data?.objectData }
layout={ layoutData }
/>
<FieldCollectionProvider>
<RootComponent
data={ data?.objectData }
layout={ layoutData }
/>
</FieldCollectionProvider>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import React, { useMemo } from 'react'
export interface IFormListContext {
field: FormListFieldData
operation: FormListOperation
fieldSuffix?: string
}

export const FormListContext = React.createContext<IFormListContext | undefined>(undefined)
Expand All @@ -25,10 +26,10 @@ export interface FormListProviderProps extends IFormListContext {
children: React.ReactNode
}

export const FormListProvider = ({ field, operation, children }: FormListProviderProps): React.JSX.Element => {
export const FormListProvider = ({ field, fieldSuffix, operation, children }: FormListProviderProps): React.JSX.Element => {
return useMemo(() => {
return (
<FormListContext.Provider value={ { field, operation } }>
<FormListContext.Provider value={ { field, fieldSuffix, operation } }>
{ children }
</FormListContext.Provider>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,30 @@
import { useContext } from 'react'
import { FormListContext, type IFormListContext } from './form-list-provider'

interface UseFormListReturn extends IFormListContext {}
interface UseFormListReturn extends IFormListContext {
getComputedFieldName: () => Array<string | number>
}

export const useFormList = (): UseFormListReturn | undefined => {
const formListContext = useContext(FormListContext)

return formListContext
if (formListContext === undefined) {
return undefined
}

const getComputedFieldName = (): Array<string | number> => {
const { field, fieldSuffix } = formListContext
const computedFieldName: Array<string | number> = [field.name]

if (fieldSuffix !== undefined) {
computedFieldName.push(fieldSuffix)
}

return computedFieldName
}

return {
...formListContext,
getComputedFieldName
}
}
Loading

0 comments on commit be47a2d

Please sign in to comment.