Skip to content

Refactor DotEditFieldDialogComponent#36341

Open
nicobytes wants to merge 13 commits into
mainfrom
35512-opening-field-variables-view-disables-saving-changes-to-any-field-until-hard-refresh
Open

Refactor DotEditFieldDialogComponent#36341
nicobytes wants to merge 13 commits into
mainfrom
35512-opening-field-variables-view-disables-saving-changes-to-any-field-until-hard-refresh

Conversation

@nicobytes

@nicobytes nicobytes commented Jun 26, 2026

Copy link
Copy Markdown
Member

This pull request refactors the field editing experience in the Content Type Fields Drop Zone component, moving from an inline dialog defined in the template to a dedicated dialog component (DotEditFieldDialogComponent) opened via the PrimeNG DialogService. It also cleans up unused code and dependencies, and simplifies how icons are determined for draggable field items.

Field editing dialog refactor:

  • Replaces the large inline dialog and tab logic in the template (content-type-fields-drop-zone.component.html) with a service-based modal dialog, removing all dialog-related state and logic from the component and template. ([[1]](https://github.com/dotCMS/core/pull/36341/files#diff-d9b6e2b0fd6eea4ba0d04be0c7da85b202e97b20584cf7042bcaea398dff26caL27-L138), [[2]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L46-L77), [[3]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L105-L126), [[4]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L169-L187), [[5]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L199-R140), [[6]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L234-R215), [[7]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L276-L289), [[8]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L310-L311), [[9]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L326-R286), [[10]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L351-L355))
  • Adds use of DialogService to open the new DotEditFieldDialogComponent and handle dialog results for saving, converting, or cancelling field edits. ([[1]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L11-R31), [[2]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L46-L77), [[3]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L234-R215))

Code cleanup and dependency updates:

  • Removes unused imports and providers, such as FieldService and Renderer2, from both the draggable item and drop zone components and their tests. ([[1]](https://github.com/dotCMS/core/pull/36341/files#diff-3235157a5fe0e93e4604adcd0a5a089e768879c9efb1414173819fd9330a8da2L19), [[2]](https://github.com/dotCMS/core/pull/36341/files#diff-3235157a5fe0e93e4604adcd0a5a089e768879c9efb1414173819fd9330a8da2L48-R47), [[3]](https://github.com/dotCMS/core/pull/36341/files#diff-545bf2f6f49386cb122451f7f59a9ceca8a40306d0bafbdf5232a06f5e4b0986L18-R18), [[4]](https://github.com/dotCMS/core/pull/36341/files#diff-545bf2f6f49386cb122451f7f59a9ceca8a40306d0bafbdf5232a06f5e4b0986L36), [[5]](https://github.com/dotCMS/core/pull/36341/files#diff-b1988fdbb798b95d236e7d8fe4d0225c7ae7d153a4490f8a7eb2a7cb197be6d9L11-R31))
  • Updates the icon logic in the draggable item component to use the getFieldIcon utility instead of the removed FieldService. ([[1]](https://github.com/dotCMS/core/pull/36341/files#diff-545bf2f6f49386cb122451f7f59a9ceca8a40306d0bafbdf5232a06f5e4b0986L18-R18), [[2]](https://github.com/dotCMS/core/pull/36341/files#diff-545bf2f6f49386cb122451f7f59a9ceca8a40306d0bafbdf5232a06f5e4b0986L86-R85))

Template and style improvements:

  • Minor reordering of class attributes in the drop zone container for consistency. ([core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-drop-zone/content-type-fields-drop-zone.component.htmlL1-R5](https://github.com/dotCMS/core/pull/36341/files#diff-d9b6e2b0fd6eea4ba0d04be0c7da85b202e97b20584cf7042bcaea398dff26caL1-R5))

These changes make the codebase more modular, maintainable, and easier to extend, while also improving the user experience for editing content type fields.

This PR fixes: #35512

…saving-changes-to-any-field-until-hard-refresh
@claude

claude Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Claude finished @nicobytes's task in 1m 6s —— View job


Rollback Safety Analysis

  • Read rollback-unsafe categories reference
  • Get full PR diff
  • Analyze diff against each unsafe category
  • Post result and apply label

Result: ✅ Safe To Rollback

All 34 changed files are pure frontend (Angular/TypeScript, HTML, .gitignore) — no Java, SQL, XML, or backend files were modified.

Category-by-category check:

Category Verdict
C-1 Structural Data Model Change ✅ No DB schema changes
C-2 Elasticsearch Mapping Change ✅ No ES mapping changes
C-3 Content JSON Model Version Bump ✅ No CURRENT_MODEL_VERSION changes
C-4 DROP TABLE / DROP COLUMN ✅ No DDL statements
H-1 One-Way Data Migration ✅ No data migrations
H-2 RENAME TABLE / COLUMN ✅ No renames
H-3 PK Restructuring ✅ No PK changes
H-4 New Field Type (backend) ✅ No new Java Field subclass registered in FieldTypeAPI
H-5 Storage Provider Change ✅ No storage changes
H-6 DROP PROCEDURE / FUNCTION ✅ No stored procedure changes
H-7 NOT NULL column without default ✅ No DDL
H-8 VTL Viewtool Contract Change ✅ No viewtool changes
M-1 Non-Broadening Column Type Change ✅ No DDL
M-2 Push Publishing Bundle Format ✅ No Bundler changes
M-3 REST / GraphQL API Contract ✅ Frontend only consumes existing endpoints; new DotFieldService methods call existing API endpoints (/api/v1/fieldTypes, /api/v3/contenttype/...) — no server-side contract changes
M-4 OSGi Interface Breakage ✅ No OSGi changes

The label "AI: Safe To Rollback" has been applied.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🤖 Bedrock Review — us.deepseek.r1-v1:0

New Issues

  • 🟡 Medium: core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-properties-form/content-type-fields-properties-form.component.ts:96 — Form reinitialization logic in ngOnChanges could discard unsaved changes if input changes while form is dirty. When formFieldData input changes after initial load, existing form state is overwritten without validation.

Run: #28264163248 · tokens: in: 20103 · out: 1484 · total: 21587

@github-actions github-actions Bot added the Area : Frontend PR changes Angular/TypeScript frontend code label Jun 26, 2026
Extract the field edit dialog into a standalone DotEditFieldDialog component and open it via PrimeNG DialogService instead of an inline p-dialog. Moved dialog open/close logic into openFieldDialog(), simplified component state by removing displayDialog/activeTab/dialogActions/renderer usage and related handlers, and updated drag-and-drop flows to call the new dialog flow. Tests were updated to mock DialogService and to assert dialog open/close outcomes; many dialog-related stubs and legacy test scaffolding were removed. Also added providedIn: 'root' to a couple of services (DotEditContentTypeCacheService, DotFieldVariablesService), improved typing and initialization guards in ContentTypeFieldsPropertiesFormComponent, and added a generated spec.json under libs/agentic-tools.
@nicobytes nicobytes changed the title sync Fix error Jun 26, 2026
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🤖 Bedrock Review — us.deepseek.r1-v1:0

Existing

  • 🟡 Medium: core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-properties-form/content-type-fields-properties-form.component.ts:96 — prior finding still present (unchanged or incomplete fix)

Run: #28264438236 · tokens: in: 20302 · out: 1010 · total: 21312

…saving-changes-to-any-field-until-hard-refresh
@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🤖 dotBot Review (Bedrock)

Reviewed 15 file(s); 11 candidate(s) → 10 confirmed, 0 uncertain (unverified, kept for review).

Confirmed findings

  • 🟠 High core-web/apps/dotcms-ui-e2e/src/utils/dot-clazzes.ts:5 — Incorrect Java class name mapping for COLUMN_BREAK
    The value 'contenttype.column.break' in dot-clazzes.ts line 5 is not a valid Java class name like other entries. Evidence from grep shows this value is used in test mocks and documentation as a field type identifier, but there's no corresponding Java class (unlike ImmutableColumnField which exists). This mismatch could break type detection logic that relies on fully-qualified class names.
  • 🟡 Medium core-web/.gitignore:3 — Leading slash in .gitignore path may prevent ignoring generated files in subdirectory
    The pattern '/dist' in .gitignore with a leading slash only ignores the root-level 'dist' directory. Generated 'dist' directories in subfolders (e.g. core-web/submodule/dist) would not be ignored. Removing the leading slash would match all 'dist' directories recursively.
  • 🟡 Medium core-web/apps/dotcms-ui-e2e/src/pages/contentTypeBuilder.page.ts:88 — CSS :has() pseudo-class may cause compatibility issues in E2E tests
    The selector p-dynamicdialog:has(dot-edit-field-dialog) in content-type builder page uses CSS :has() which has limited browser support. While Playwright 1.27+ supports :has() in Chromium 105+, this could still fail in older browser versions or non-Chromium browsers if cross-browser testing is enabled. The selector appears in test code added by this PR to detect the new dialog component.
  • 🟡 Medium core-web/apps/dotcms-ui-e2e/src/pages/contentTypeBuilder.page.ts:88 — Reliance on .first() for dialog selection in E2E test
    The test uses dialog.first() to target a PrimeNG dialog. While the component changes use DialogService which typically manages a single dialog, E2E tests run against the rendered DOM where multiple dialogs could exist if previous tests leak state or async actions overlap. The test should use a more specific selector (e.g., data-testid attribute added to DotEditFieldDialogComponent's template) to avoid flakiness from dialog ordering.
  • 🟡 Medium core-web/apps/dotcms-ui-e2e/src/pages/contentTypeBuilder.page.ts:19 — placedField() uses partial text match risking false positives
    The placedField method uses hasText: name which performs a partial text match. If two fields exist where one's name is a substring of another (e.g., 'Email' vs 'Email Address'), this could lead to incorrect field selection during testing. Use { exact: true } or a more precise locator strategy.
  • 🟡 Medium core-web/apps/dotcms-ui-e2e/src/tests/content-types/content-type-fields.spec.ts:25 — Test cleanup may leave orphaned content types due to stale ID
    The test uses let contentTypeId: string; which retains the last assigned value. If createFakeContentType() fails in a test, contentType remains undefined, but contentTypeId still holds the previous test's ID. The afterEach only deletes if contentType exists, leaving the failed test's ID undeleted. This can cause orphaned content types when setup fails but a prior ID exists.
  • 🟡 Medium core-web/apps/dotcms-ui-e2e/src/utils/dot-content-types.mock.ts:4 — Outdated mock data for DotCMSClazzes in E2E tests
    The E2E test mocks import DotCMSClazzes directly from '@utils/dot-clazzes' (line 4) rather than using service mocks. With FieldService.getClazzes() mock removed, these hardcoded class definitions (TEXT, HOST_FOLDER etc.) may not match actual API responses. This could cause test failures if real clazz values differ from the static DotCMSClazzes constants, as seen in 25+ field definitions using these constants across the mock file.
  • 🟡 Medium core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-drop-zone/content-type-fields-drop-zone.component.ts:275 — Missing scroll after WYSiwyg to Block conversion
    The original convertWysiwygToBlock method in content-type-fields-drop-zone.component.ts called this.scrollToNewField(fieldVariable) after conversion to scroll to the new field. The replacement logic in DotEditFieldDialogComponent's onConvertToBlock (line 275) performs the conversion but doesn't trigger scrolling, creating a UX regression where users aren't automatically taken to the converted field.
  • 🟡 Medium core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-properties-form/content-type-fields-properties-form.component.ts:176 — Unsafe type casting in transformFormValue
    The code casts a merged object to DotCMSContentTypeField without ensuring all required properties are present. By spreading originalField (DotCMSContentTypeField) and form values (FormValue) then using 'as' type assertion, this assumes the merged object matches the full interface. However, FormValue may not include all mandatory properties from DotCMSContentTypeField, risking incomplete objects being passed as valid fields. This could lead to runtime errors when missing properties are accessed downstream.
  • 🟡 Medium core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-types-fields-list/content-types-fields-icon-map.ts:45 — Missing test coverage for getFieldIcon function
    The getFieldIcon function in content-types-fields-icon-map.ts has no corresponding test file (content-types-fields-icon-map.spec.ts) in the directory. Grep shows no test file exists, and the component's main spec file (content-types-fields-list.component.spec.ts) does not import or test this utility function. This leaves the icon mapping logic untested, including fallback behavior when fieldType.clazz is undefined.

us.deepseek.r1-v1:0 · Run: #28403940336 · tokens: in: 117640 · out: 22244 · total: 139884 · calls: 32 · est. ~$0.279

@wezell

wezell commented Jun 27, 2026

Copy link
Copy Markdown
Member

🤖 dotBot Review (Bedrock)

Reviewed 8 file(s); 1 candidate(s) → 1 confirmed, 0 uncertain (unverified, kept for review).

Confirmed findings

  • 🟡 Medium core-web/apps/dotcms-ui/src/app/portlets/shared/dot-content-types-edit/components/fields/content-type-fields-properties-form/field-properties/dot-relationships-property/services/dot-edit-content-type-cache.service.ts:11 — Singleton service shares state across components
    The DotEditContentTypeCacheService is now providedIn: 'root' making it an application-wide singleton. Its currentContentType property will be shared across all components, leading to cross-contamination of cached content types when multiple editor instances are active. This violates the apparent intention of per-component caching for field relationships editing.

us.deepseek.r1-v1:0 · Run: #28265288178 · tokens: in: 52129 · out: 12811 · total: 64940 · calls: 11 · est. ~$0.140

This feels real if it is correct?

…saving-changes-to-any-field-until-hard-refresh
Removes the local `FieldService` from the content-types-edit portlet and merges its functionality into the shared `DotFieldService` in `@dotcms/data-access`. Moves the `FieldType` interface to `@dotcms/dotcms-models` as the canonical definition. Scopes `DotEditContentTypeCacheService` to the dialog instance instead of app-wide singleton, and extracts `getFieldIcon` as a pure utility function.
Update DotFieldService.deleteFields to accept string[] of field IDs instead of DotCMSContentTypeField[]. Also replaces http.request('DELETE') with http.delete(), and migrates subscribe() positional callbacks to observer object syntax throughout DotContentTypesEditComponent.
@nicobytes nicobytes changed the title Fix error Refactor DotEditFieldDialogComponent Jun 29, 2026
…saving-changes-to-any-field-until-hard-refresh
Comment thread core-web/apps/dotcms-ui-e2e/src/utils/dot-content-types.mock.ts
Tighten the content type builder E2E dialog locator so tests only target the field edit DynamicDialog and wait for that dialog to close, avoiding interference from unrelated PrimeNG dialogs. Also add a default field icon fallback for unknown field classes and correct the generated path entry in `core-web/.gitignore`.
Fixes a dialog bug where switching to Settings could replace the Save button action and leave Overview using the wrong handler. The component now rebuilds a canonical Overview Save button when returning to the Overview tab, preserving the correct form-save action and disabled state. Added a regression test to verify Settings -> Overview restores the original save behavior.
Comment thread core-web/apps/dotcms-ui-e2e/src/pages/contentTypeBuilder.page.ts
@nicobytes nicobytes requested a review from oidacra June 29, 2026 21:11
The content-type builder page object waited for the field persistence
request but never checked its status, so a 4xx/5xx response would still
resolve the wait and let the test pass without the field being saved.
Assert response.ok() after the save click to fail fast on API errors.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread core-web/apps/dotcms-ui-e2e/src/utils/dot-clazzes.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Frontend PR changes Angular/TypeScript frontend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Opening Field Variables view disables saving changes to any field until hard refresh

3 participants