simplify web part
This commit is contained in:
parent
aca6759495
commit
b48c3a91a0
|
@ -1,6 +1,4 @@
|
||||||
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
||||||
.workbenchCustomizer {
|
.workbenchCustomizer {
|
||||||
.redMessage {
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import { Version } from '@microsoft/sp-core-library';
|
import { Version } from '@microsoft/sp-core-library';
|
||||||
import { BaseClientSideWebPart } from "@microsoft/sp-webpart-base";
|
import { BaseClientSideWebPart } from "@microsoft/sp-webpart-base";
|
||||||
import { IPropertyPaneConfiguration, PropertyPaneToggle } from "@microsoft/sp-property-pane";
|
import { IPropertyPaneConfiguration, PropertyPaneToggle, PropertyPaneHorizontalRule, PropertyPaneLabel } from "@microsoft/sp-property-pane";
|
||||||
import styles from './WorkbenchCustomizerWebPart.module.scss';
|
// import styles from './WorkbenchCustomizerWebPart.module.scss';
|
||||||
|
|
||||||
import * as strings from 'WorkbenchCustomizerWebPartStrings';
|
import * as strings from 'WorkbenchCustomizerWebPartStrings';
|
||||||
|
|
||||||
export interface IWorkbenchCustomizerWebPartProps {
|
export interface IWorkbenchCustomizerWebPartProps {
|
||||||
requiresPageRefresh: boolean;
|
|
||||||
customWorkbenchStyles: boolean;
|
customWorkbenchStyles: boolean;
|
||||||
customWorkbenchStylesFullWidth: boolean;
|
customWorkbenchStylesFullWidth: boolean;
|
||||||
previewMode: boolean;
|
previewMode: boolean;
|
||||||
|
@ -14,11 +13,6 @@ export interface IWorkbenchCustomizerWebPartProps {
|
||||||
|
|
||||||
export default class WorkbenchCustomizerWebPart extends BaseClientSideWebPart<IWorkbenchCustomizerWebPartProps> {
|
export default class WorkbenchCustomizerWebPart extends BaseClientSideWebPart<IWorkbenchCustomizerWebPartProps> {
|
||||||
|
|
||||||
public onInit(): Promise<void> {
|
|
||||||
this.properties.requiresPageRefresh = false;
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async render(): Promise<void> {
|
public async render(): Promise<void> {
|
||||||
|
|
||||||
if (!this.renderedOnce) {
|
if (!this.renderedOnce) {
|
||||||
|
@ -37,22 +31,14 @@ export default class WorkbenchCustomizerWebPart extends BaseClientSideWebPart<IW
|
||||||
}
|
}
|
||||||
|
|
||||||
this.domElement.innerHTML = `
|
this.domElement.innerHTML = `
|
||||||
<div class="${styles.workbenchCustomizer}">
|
<div>
|
||||||
${this.properties.requiresPageRefresh
|
*** ${strings.TitleLabel} ***
|
||||||
? `<div class="${styles.redMessage}">Please refresh the page to remove custom workbench styles</div>`
|
|
||||||
: ''
|
|
||||||
}
|
|
||||||
*** Workbench Customizer web part ***
|
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public onPropertyPaneFieldChanged(path: string, oldValue: any, newValue: any): void {
|
protected get disableReactivePropertyChanges(): boolean {
|
||||||
if (!newValue) {
|
return true;
|
||||||
// request a page refresh if any of the options was disabled
|
|
||||||
// no real smart logic implemented at this point
|
|
||||||
this.properties.requiresPageRefresh = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected get dataVersion(): Version {
|
protected get dataVersion(): Version {
|
||||||
|
@ -64,22 +50,26 @@ export default class WorkbenchCustomizerWebPart extends BaseClientSideWebPart<IW
|
||||||
pages: [
|
pages: [
|
||||||
{
|
{
|
||||||
header: {
|
header: {
|
||||||
description: strings.PropertyPaneDescription
|
description: strings.PropertyPaneDescription,
|
||||||
},
|
},
|
||||||
groups: [
|
groups: [
|
||||||
{
|
{
|
||||||
groupName: strings.BasicGroupName,
|
groupName: strings.BasicGroupName,
|
||||||
groupFields: [
|
groupFields: [
|
||||||
PropertyPaneToggle('customWorkbenchStyles', {
|
PropertyPaneToggle('customWorkbenchStyles', {
|
||||||
label: strings.CustomWorkbenchStylesFieldLabel
|
label: strings.CustomWorkbenchStylesFieldLabel,
|
||||||
}),
|
}),
|
||||||
PropertyPaneToggle('customWorkbenchStylesFullWidth', {
|
PropertyPaneToggle('customWorkbenchStylesFullWidth', {
|
||||||
label: strings.customWorkbenchStylesFullWidthFieldLabel,
|
label: strings.customWorkbenchStylesFullWidthFieldLabel,
|
||||||
disabled: !this.properties.customWorkbenchStyles
|
disabled: !this.properties.customWorkbenchStyles,
|
||||||
}),
|
}),
|
||||||
PropertyPaneToggle('previewMode', {
|
PropertyPaneToggle('previewMode', {
|
||||||
label: strings.PreviewModeFieldLabel
|
label: strings.PreviewModeFieldLabel,
|
||||||
})
|
}),
|
||||||
|
PropertyPaneHorizontalRule(),
|
||||||
|
PropertyPaneLabel('', {
|
||||||
|
text: strings.RequestPageRefresh,
|
||||||
|
}),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
define([], function() {
|
define([], function() {
|
||||||
return {
|
return {
|
||||||
"PropertyPaneDescription": "Web part that can customize the behaviour of the workbench page to work around some of the existing limitations. It's recommended that you refresh the page after changing web part properties.",
|
"PropertyPaneDescription": "Web part that can customize the behaviour of the workbench page to work around some of the existing limitations.",
|
||||||
"BasicGroupName": "Configuration",
|
"BasicGroupName": "Configuration",
|
||||||
"CustomWorkbenchStylesFieldLabel": "Enable custom styles for Workbench",
|
"CustomWorkbenchStylesFieldLabel": "Enable custom styles for Workbench",
|
||||||
"customWorkbenchStylesFullWidthFieldLabel": "Enable custom styles for full-width",
|
"customWorkbenchStylesFullWidthFieldLabel": "Enable custom styles for full-width",
|
||||||
"PreviewModeFieldLabel": "Enable Preview mode by default",
|
"PreviewModeFieldLabel": "Enable Preview mode by default",
|
||||||
|
"TitleLabel": "Workbench Customizer web part",
|
||||||
|
"RequestPageRefresh": "IMPORTANT: Please refresh the page after you click the Apply button to update workbench styles",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,8 @@ declare interface IWorkbenchCustomizerWebPartStrings {
|
||||||
CustomWorkbenchStylesFieldLabel: string;
|
CustomWorkbenchStylesFieldLabel: string;
|
||||||
customWorkbenchStylesFullWidthFieldLabel: string;
|
customWorkbenchStylesFullWidthFieldLabel: string;
|
||||||
PreviewModeFieldLabel: string;
|
PreviewModeFieldLabel: string;
|
||||||
|
TitleLabel: string;
|
||||||
|
RequestPageRefresh: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module 'WorkbenchCustomizerWebPartStrings' {
|
declare module 'WorkbenchCustomizerWebPartStrings' {
|
||||||
|
|
Loading…
Reference in New Issue