Skip to content

Commit

Permalink
Set initial form values for data object edit (#747)
Browse files Browse the repository at this point in the history
* Set initial form values

* Automatic frontend build

---------

Co-authored-by: vin0401 <[email protected]>
  • Loading branch information
vin0401 and vin0401 authored Nov 27, 2024
1 parent ad8dec9 commit 49b0d98
Show file tree
Hide file tree
Showing 29 changed files with 2,367 additions and 9 deletions.
2 changes: 1 addition & 1 deletion assets/build/api/docs.jsonopenapi.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions assets/js/src/core/modules/auth/user/user-api-slice.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ const injectedRtkApi = api
}),
invalidatesTags: ["User Management"],
}),
userGetImage: build.query<UserGetImageApiResponse, UserGetImageApiArg>({
query: (queryArg) => ({ url: `/pimcore-studio/api/user/image/${queryArg.id}` }),
providesTags: ["User Management"],
}),
userGetTree: build.query<UserGetTreeApiResponse, UserGetTreeApiArg>({
query: (queryArg) => ({
url: `/pimcore-studio/api/users/tree`,
Expand Down Expand Up @@ -199,6 +203,11 @@ export type UserUploadImageApiArg = {
userImage: Blob;
};
};
export type UserGetImageApiResponse = /** status 200 User profile image */ Blob;
export type UserGetImageApiArg = {
/** Id of the User */
id: number;
};
export type UserGetTreeApiResponse = /** status 200 Collection of users including folders for the given parent id. */ {
totalItems: number;
items: TreeNode[];
Expand Down Expand Up @@ -421,5 +430,6 @@ export const {
usePimcoreStudioApiUserSearchQuery,
useUserUpdatePasswordByIdMutation,
useUserUploadImageMutation,
useUserGetImageQuery,
useUserGetTreeQuery,
} = injectedRtkApi;
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,14 @@ export type DataObject = Element & {
additionalAttributes?: {
[key: string]: string | number | boolean | object | any[];
};
/** Inheritance allowed */
allowInheritance?: boolean;
/** Variants allowed */
allowVariants?: boolean;
/** Show variants */
showVariants?: boolean;
/** Has preview */
hasPreview?: boolean;
customAttributes?: CustomAttributes;
/** Has workflow available */
hasWorkflowAvailable?: boolean;
Expand All @@ -368,6 +376,8 @@ export type DataObject = Element & {
permissions?: DataObjectPermissions;
/** Custom index */
index?: number;
/** Detail object data */
objectData?: object;
};
export type DataObjectFolder = DataObject;
export type UpdateDataProperty = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import { type DataObjectGetLayoutByIdApiResponse } from '@Pimcore/modules/data-o

interface RootComponentProps {
layout: DataObjectGetLayoutByIdApiResponse
data: any
}

export const RootComponent = ({ layout }: RootComponentProps): React.JSX.Element => {
export const RootComponent = ({ layout, data }: RootComponentProps): React.JSX.Element => {
return (
<ConfigProvider theme={ {
components: {
Expand All @@ -32,9 +33,7 @@ export const RootComponent = ({ layout }: RootComponentProps): React.JSX.Element
} }
>
<Form
initialValues={ {
myRandomTestValue: 'Hello World'
} }
initialValues={ data }
layout='vertical'
onFinish={ onFinish }
preserve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@ import React from 'react'
import { type IEditorTab } from '@Pimcore/modules/element/editor/tab-manager/interface/IEditorTab'
import { Icon } from '@Pimcore/components/icon/icon'
import { RootComponent } from './components/root-component'
import { useDataObjectGetLayoutByIdQuery } from '@Pimcore/modules/data-object/data-object-api-slice-enhanced'
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'

export const EditContainer = (): React.JSX.Element => {
const { id } = useElementContext()
const { data, isLoading } = useDataObjectGetLayoutByIdQuery({ id })
const { data: layoutData, isLoading } = useDataObjectGetLayoutByIdQuery({ id })
const { data, isLoading: isDataLoading } = useDataObjectGetByIdQuery({ id })

if (data === undefined || isLoading) {
if (layoutData === undefined || isLoading || isDataLoading) {
return <Content loading />
}

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

export const TAB_EDIT: IEditorTab = {
Expand Down
2 changes: 2 additions & 0 deletions public/build/0f61d669-d8b5-4060-a534-d8f59716c395/105.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*!
*
* /**
* * Pimcore
* *
* * This source file is available under two different licenses:
* * - Pimcore Open Core License (POCL)
* * - Pimcore Commercial License (PCL)
* * Full copyright and license information is available in
* * LICENSE.md which is distributed with this source code.
* *
* * @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* * @license https://github.com/pimcore/studio-ui-bundle/blob/1.x/LICENSE.md POCL and PCL
* * /
*
*/
16 changes: 16 additions & 0 deletions public/build/0f61d669-d8b5-4060-a534-d8f59716c395/core-dll.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions public/build/0f61d669-d8b5-4060-a534-d8f59716c395/core-dll.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/* @preserve
* Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com
* (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
*/

/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/

/*!
*
* /**
* * Pimcore
* *
* * This source file is available under two different licenses:
* * - Pimcore Open Core License (POCL)
* * - Pimcore Commercial License (PCL)
* * Full copyright and license information is available in
* * LICENSE.md which is distributed with this source code.
* *
* * @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* * @license https://github.com/pimcore/studio-ui-bundle/blob/1.x/LICENSE.md POCL and PCL
* * /
*
*/

/*! @license DOMPurify 3.2.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.1/LICENSE */

/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

/**
* react-table
*
* Copyright (c) TanStack
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* table-core
*
* Copyright (c) TanStack
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/

/**
* @license React
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @license React
* use-sync-external-store-with-selector.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* @remix-run/router v1.21.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* React Router DOM v6.28.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* React Router v6.28.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* Pimcore
*
* This source file is available under two different licenses:
* - Pimcore Open Core License (POCL)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license https://github.com/pimcore/studio-ui-bundle/blob/1.x/LICENSE.md POCL and PCL
*/
12 changes: 12 additions & 0 deletions public/build/0f61d669-d8b5-4060-a534-d8f59716c395/entrypoints.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"entrypoints": {
"core-dll": {
"css": [
"/bundles/pimcorestudioui/build/0f61d669-d8b5-4060-a534-d8f59716c395/core-dll.css"
],
"js": [
"/bundles/pimcorestudioui/build/0f61d669-d8b5-4060-a534-d8f59716c395/core-dll.js"
]
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 49b0d98

Please sign in to comment.