This repository has been archived by the owner on Dec 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
dotCMS/core#21558 Edit Template Properties Modal makes changes get lost #1865
Merged
fmontes
merged 22 commits into
release-22.02
from
issue-21558-edit-template-properties-modal-makes-changes-get-lost
Feb 7, 2022
Merged
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
be791f3
fix: Must supply a value for form control with name: 'title'
rjvelazco 0908123
remove dot-template store service from Dot Template Advanced Component
rjvelazco 82d8760
fix: Edit Template Properties Modal makes changes get lost on advance…
rjvelazco 4e97dbd
fix: Edit Template Properties Modal makes changes get lost on design …
rjvelazco bb466df
update template design
rjvelazco e8a1ba9
clean up
rjvelazco 4151ca5
feedback
rjvelazco 0d66388
clean up
rjvelazco f9e8dbb
fix dot-template store tests
rjvelazco cb1f12a
fix tests on dot-template-create-edit
rjvelazco 9e74d1c
fix dot-template-builder tests
rjvelazco 1d5e4bb
fix dot-template tests
rjvelazco a920a5b
fix DotEditLayoutComponent
rjvelazco 6324d71
clean up
rjvelazco a840470
rename saveDraft to updateTemplate
rjvelazco edf277d
add docs
rjvelazco 827daa9
feedback
rjvelazco fab0229
feedback
rjvelazco ab61472
clean up
rjvelazco 3b3be5d
feedback
rjvelazco acee63a
clean up
rjvelazco a0c801c
fix doc
rjvelazco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
...s-ui/src/app/portlets/dot-edit-page/layout/dot-edit-layout/dot-edit-layout.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...lates/dot-template-create-edit/dot-template-advanced/dot-template-advanced.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { Component, EventEmitter, OnDestroy, OnInit, Output } from '@angular/core'; | ||
import { Component, EventEmitter, OnDestroy, OnInit, Output, Input, SimpleChanges, OnChanges } from '@angular/core'; | ||
import { FormBuilder, FormGroup } from '@angular/forms'; | ||
|
||
import { Observable, Subject } from 'rxjs'; | ||
import { filter, map, take, takeUntil } from 'rxjs/operators'; | ||
import { Subject } from 'rxjs'; | ||
import { takeUntil } from 'rxjs/operators'; | ||
|
||
import { DotContainer } from '@shared/models/container/dot-container.model'; | ||
import { DotTemplateItem, DotTemplateStore } from '../store/dot-template.store'; | ||
import { DotTemplateItem } from '../store/dot-template.store'; | ||
import { DotPortletToolbarActions } from '@models/dot-portlet-toolbar.model/dot-portlet-toolbar-actions.model'; | ||
import { DotMessageService } from '@services/dot-message/dot-messages.service'; | ||
|
||
|
@@ -14,47 +14,39 @@ import { DotMessageService } from '@services/dot-message/dot-messages.service'; | |
templateUrl: './dot-template-advanced.component.html', | ||
styleUrls: ['./dot-template-advanced.scss'] | ||
}) | ||
export class DotTemplateAdvancedComponent implements OnInit, OnDestroy { | ||
export class DotTemplateAdvancedComponent implements OnInit, OnDestroy, OnChanges { | ||
@Output() updateTemplate = new EventEmitter<DotTemplateItem>(); | ||
@Output() save = new EventEmitter<DotTemplateItem>(); | ||
@Output() cancel = new EventEmitter(); | ||
|
||
@Input() body: string; | ||
@Input() didTemplateChanged: boolean; | ||
|
||
// `any` because the type of the editor in the ngx-monaco-editor package is not typed | ||
editor: any; | ||
form: FormGroup; | ||
actions$: Observable<DotPortletToolbarActions>; | ||
actions: DotPortletToolbarActions; | ||
private destroy$: Subject<boolean> = new Subject<boolean>(); | ||
|
||
constructor( | ||
private store: DotTemplateStore, | ||
fmontes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private fb: FormBuilder, | ||
private dotMessageService: DotMessageService | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.store.vm$.pipe(take(1)).subscribe(({ original }) => { | ||
if (original.type === 'advanced') { | ||
this.form = this.fb.group({ | ||
title: original.title, | ||
body: original.body, | ||
identifier: original.identifier, | ||
friendlyName: original.friendlyName | ||
}); | ||
} | ||
}); | ||
this.form = this.fb.group({ body: this.body }); | ||
|
||
this.form | ||
.get('body') | ||
.valueChanges.pipe( | ||
takeUntil(this.destroy$), | ||
filter((body: string) => body !== undefined) | ||
) | ||
.subscribe((body: string) => { | ||
this.store.updateBody(body); | ||
}); | ||
|
||
this.actions$ = this.store.didTemplateChanged$.pipe( | ||
map((templateChange: boolean) => this.getActions(!templateChange)) | ||
); | ||
.valueChanges.pipe(takeUntil(this.destroy$)) | ||
.subscribe(() => this.updateTemplate.emit(this.form.value)); | ||
|
||
this.actions = this.getActions(!this.didTemplateChanged); | ||
} | ||
|
||
ngOnChanges(changes: SimpleChanges){ | ||
if( changes.didTemplateChanged ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does your vscode is not running the formatter on save? |
||
this.actions = this.getActions(!changes.didTemplateChanged.currentValue); | ||
} | ||
} | ||
|
||
ngOnDestroy(): void { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add doc explaining why this approach and if you can the link where you found this solution.