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

Content Wizard - display name and path are cleared after opening a co… #3252

Merged
merged 2 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
&::before {
position: absolute;
right: -36px;
top: 12px;
top: 5px;
font-size: 24px;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class ProjectWizardPanel
private hasChildrenLayers: boolean = false;

protected getIconClass(): string {
return !!this.getPersistedItem() ? this.getPersistedItem().getIconClass() : this.getType().getIconClass();
return !!this.getPersistedItem() ? this.getPersistedItem().getIconClass() : this.getParams().type.getIconClass();
}

protected createWizardHeader(): WizardHeaderWithDisplayNameAndName {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import {Action} from 'lib-admin-ui/ui/Action';
import {Toolbar} from 'lib-admin-ui/ui/toolbar/Toolbar';
import {WizardStep} from 'lib-admin-ui/app/wizard/WizardStep';
import {i18n} from 'lib-admin-ui/util/Messages';
import {
WizardHeaderWithDisplayNameAndName,
WizardHeaderWithDisplayNameAndNameOptions
} from 'lib-admin-ui/app/wizard/WizardHeaderWithDisplayNameAndName';
import {WizardHeaderWithDisplayNameAndName} from 'lib-admin-ui/app/wizard/WizardHeaderWithDisplayNameAndName';
import {ResponsiveManager} from 'lib-admin-ui/ui/responsive/ResponsiveManager';
import {FormIcon} from 'lib-admin-ui/app/wizard/FormIcon';
import {SettingDataItemWizardStepForm} from './form/SettingDataItemWizardStepForm';
Expand Down Expand Up @@ -56,15 +53,9 @@ export abstract class SettingsDataItemWizardPanel<ITEM extends SettingsDataViewI

this.type = params.type;
this.loadData();
this.initElements();
this.listenEvents();
ResponsiveManager.onAvailableSizeChanged(this);
}

protected getType(): SettingsType {
return this.type;
}

public getFormIcon(): SettingsDataItemFormIcon {
return <SettingsDataItemFormIcon>this.formIcon;
}
Expand Down Expand Up @@ -111,7 +102,7 @@ export abstract class SettingsDataItemWizardPanel<ITEM extends SettingsDataViewI
const steps: WizardStep[] = [];

this.wizardStepForms.forEach((stepForm: SettingDataItemWizardStepForm<ITEM>) => {
steps.push(new WizardStep(stepForm.getName(this.getType()), stepForm));
steps.push(new WizardStep(stepForm.getName(this.getParams().type), stepForm));
});

return steps;
Expand Down Expand Up @@ -218,7 +209,8 @@ export abstract class SettingsDataItemWizardPanel<ITEM extends SettingsDataViewI

this.setPersistedItem(item);

this.wizardHeader.initNames(item.getDisplayName(), item.getId(), false);
this.wizardHeader.setDisplayName(item.getDisplayName());
this.wizardHeader.setName(item.getId());

if (item.getIconUrl()) {
this.getFormIcon().setSrc(item.getIconUrl());
Expand Down Expand Up @@ -328,14 +320,16 @@ export abstract class SettingsDataItemWizardPanel<ITEM extends SettingsDataViewI
}

protected createWizardHeader(): WizardHeaderWithDisplayNameAndName {
const wizardHeader: WizardHeaderWithDisplayNameAndName = new WizardHeaderWithDisplayNameAndName(
{displayNameLabel: this.type.getDisplayNamePlaceholder()});
const wizardHeader: WizardHeaderWithDisplayNameAndName = new WizardHeaderWithDisplayNameAndName();
wizardHeader.setPlaceholder(this.getParams().type.getDisplayNamePlaceholder());

const existing: ITEM = this.getPersistedItem();
const displayName: string = !!existing ? existing.getDisplayName() : '';

wizardHeader.toggleNameInput(false);
wizardHeader.setPath('');
wizardHeader.initNames(displayName, 'not_used', false, true, true);
wizardHeader.setDisplayName(displayName);
wizardHeader.setName('not_used');

wizardHeader.onPropertyChanged(() => {
this.handleDataChanged();
Expand All @@ -345,18 +339,16 @@ export abstract class SettingsDataItemWizardPanel<ITEM extends SettingsDataViewI
return wizardHeader;
}

protected initElements() {
//
}

protected deletePersistedItem() {
this.createDeleteRequest().sendAndParse().then(() => {
showFeedback(this.getSuccessfulDeleteMessage());
this.close();
}).catch(DefaultErrorHandler.handle);
}

protected listenEvents() {
protected initEventsListeners() {
super.initEventsListeners();

this.wizardActions.getDeleteAction().onExecuted(() => {
if (!this.getPersistedItem()) {
return;
Expand Down Expand Up @@ -395,4 +387,8 @@ export abstract class SettingsDataItemWizardPanel<ITEM extends SettingsDataViewI
listener(this.wizardHeader.getDisplayName());
});
}

protected getParams(): SettingsWizardPanelParams<ITEM> {
return <SettingsWizardPanelParams<ITEM>>super.getParams();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
WizardHeaderWithDisplayNameAndName,
WizardHeaderWithDisplayNameAndNameOptions
} from 'lib-admin-ui/app/wizard/WizardHeaderWithDisplayNameAndName';
import {WizardHeaderWithDisplayNameAndName} from 'lib-admin-ui/app/wizard/WizardHeaderWithDisplayNameAndName';
import {SpanEl} from 'lib-admin-ui/dom/SpanEl';
import {i18n} from 'lib-admin-ui/util/Messages';
import {PropertyChangedEvent} from 'lib-admin-ui/PropertyChangedEvent';
Expand Down Expand Up @@ -33,8 +30,8 @@ export class ContentWizardHeader

private lockElem: ButtonEl;

constructor(options?: WizardHeaderWithDisplayNameAndNameOptions) {
super(options);
constructor() {
super();
}

protected initElements() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ import {UrlAction} from '../UrlAction';
import {ContentWizardHeader} from './ContentWizardHeader';
import {NotifyManager} from 'lib-admin-ui/notify/NotifyManager';
import {ContentIconUrlResolver} from '../content/ContentIconUrlResolver';
import {WizardHeaderWithDisplayNameAndNameOptions} from 'lib-admin-ui/app/wizard/WizardHeaderWithDisplayNameAndName';
import {Descriptor} from '../page/Descriptor';
import {GetPageDescriptorsByApplicationsRequest} from './page/contextwindow/inspect/page/GetPageDescriptorsByApplicationsRequest';
import {ContentId} from '../content/ContentId';
Expand Down Expand Up @@ -406,7 +405,6 @@ export class ContentWizardPanel
}

toggleMinimize(navigationIndex: number = -1) {

this.stepsPanel.setListenToScroll(false);

let scroll = this.stepsPanel.getScroll();
Expand Down Expand Up @@ -518,6 +516,16 @@ export class ContentWizardPanel
});
}

this.wizardHeader.setPlaceholder(this.contentType?.getDisplayNameLabel());
this.wizardHeader.setPersistedPath(this.isItemPersisted() ? this.getPersistedItem() : null);
this.wizardHeader.setPath(this.getWizardHeaderPath());

const existing: Content = this.getPersistedItem();
if (existing) {
this.wizardHeader.setDisplayName(existing.getDisplayName());
this.wizardHeader.setName(existing.getName().toString());
}

}).then(() => super.doLoadData());
}

Expand Down Expand Up @@ -545,22 +553,7 @@ export class ContentWizardPanel
}

protected createWizardHeader(): WizardHeader {
const headerOptions: WizardHeaderWithDisplayNameAndNameOptions = {
displayNameGenerator: this.displayNameResolver,
displayNameLabel: this.contentType ? this.contentType.getDisplayNameLabel() : null
};

const header: ContentWizardHeader = new ContentWizardHeader(headerOptions);

header.setPersistedPath(this.isItemPersisted() ? this.getPersistedItem() : null);
header.setPath(this.getWizardHeaderPath());

const existing: Content = this.getPersistedItem();
if (existing) {
header.initNames(existing.getDisplayName(), existing.getName().toString(), false);
}

return header;
return new ContentWizardHeader();
}

private getWizardHeaderPath(): string {
Expand Down Expand Up @@ -2224,11 +2217,9 @@ export class ContentWizardPanel
}

private enableDisplayNameScriptExecution(formView: FormView) {

if (this.displayNameResolver.hasExpression()) {

formView.onKeyUp((event: KeyboardEvent) => {
this.getWizardHeader().setDisplayName(this.displayNameResolver.execute());
this.getWizardHeader().setDisplayName(this.displayNameResolver.execute(), true);
});
}
}
Expand Down Expand Up @@ -2541,7 +2532,8 @@ export class ContentWizardPanel
private updateWizardHeader(content: Content) {
this.updateThumbnailWithContent(content);

this.getWizardHeader().initNames(content.getDisplayName(), content.getName().toString(), true, false);
this.getWizardHeader().setDisplayName(content.getDisplayName());
this.getWizardHeader().setName(content.getName().toString());

// case when content was moved
this.getWizardHeader()
Expand Down