mirror of
https://github.com/pnp/sp-dev-fx-webparts.git
synced 2025-02-08 22:14:53 +00:00
Merge pull request #5285 from petkir/spfx-upgrade/js-modern-calendar
This commit is contained in:
commit
6376fbfb7a
38
samples/js-modern-calendar/.devcontainer/devcontainer.json
Normal file
38
samples/js-modern-calendar/.devcontainer/devcontainer.json
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "SPFx 1.20.0",
|
||||
"image": "docker.io/m365pnp/spfx:1.20.0",
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"editorconfig.editorconfig",
|
||||
"dbaeumer.vscode-eslint"
|
||||
]
|
||||
}
|
||||
},
|
||||
"forwardPorts": [
|
||||
4321,
|
||||
35729,
|
||||
5432
|
||||
],
|
||||
"portsAttributes": {
|
||||
"4321": {
|
||||
"protocol": "https",
|
||||
"label": "Manifest",
|
||||
"onAutoForward": "silent",
|
||||
"requireLocalPort": true
|
||||
},
|
||||
"5432": {
|
||||
"protocol": "https",
|
||||
"label": "Workbench",
|
||||
"onAutoForward": "silent"
|
||||
},
|
||||
"35729": {
|
||||
"protocol": "https",
|
||||
"label": "LiveReload",
|
||||
"onAutoForward": "silent",
|
||||
"requireLocalPort": true
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "bash .devcontainer/spfx-startup.sh",
|
||||
"remoteUser": "node"
|
||||
}
|
33
samples/js-modern-calendar/.devcontainer/spfx-startup.sh
Normal file
33
samples/js-modern-calendar/.devcontainer/spfx-startup.sh
Normal file
@ -0,0 +1,33 @@
|
||||
echo
|
||||
echo -e "\e[1;94mInstalling Node dependencies\e[0m"
|
||||
npm install
|
||||
|
||||
## commands to create dev certificate and copy it to the root folder of the project
|
||||
echo
|
||||
echo -e "\e[1;94mGenerating dev certificate\e[0m"
|
||||
gulp trust-dev-cert
|
||||
|
||||
# Convert the generated PEM certificate to a CER certificate
|
||||
openssl x509 -inform PEM -in ~/.rushstack/rushstack-serve.pem -outform DER -out ./spfx-dev-cert.cer
|
||||
|
||||
# Copy the PEM ecrtificate for non-Windows hosts
|
||||
cp ~/.rushstack/rushstack-serve.pem ./spfx-dev-cert.pem
|
||||
|
||||
## add *.cer to .gitignore to prevent certificates from being saved in repo
|
||||
if ! grep -Fxq '*.cer' ./.gitignore
|
||||
then
|
||||
echo "# .CER Certificates" >> .gitignore
|
||||
echo "*.cer" >> .gitignore
|
||||
fi
|
||||
|
||||
## add *.pem to .gitignore to prevent certificates from being saved in repo
|
||||
if ! grep -Fxq '*.pem' ./.gitignore
|
||||
then
|
||||
echo "# .PEM Certificates" >> .gitignore
|
||||
echo "*.pem" >> .gitignore
|
||||
fi
|
||||
|
||||
echo
|
||||
echo -e "\e[1;92mReady!\e[0m"
|
||||
|
||||
echo -e "\n\e[1;94m**********\nOptional: if you plan on using gulp serve, don't forget to add the container certificate to your local machine. Please visit https://aka.ms/spfx-devcontainer for more information\n**********"
|
5
samples/js-modern-calendar/.eslintrc.js
Normal file
5
samples/js-modern-calendar/.eslintrc.js
Normal file
@ -0,0 +1,5 @@
|
||||
require('@rushstack/eslint-config/patch/modern-module-resolution');
|
||||
module.exports = {
|
||||
extends: ['@microsoft/eslint-config-spfx/lib/profiles/default'],
|
||||
parserOptions: { tsconfigRootDir: __dirname }
|
||||
};
|
3
samples/js-modern-calendar/.gitignore
vendored
3
samples/js-modern-calendar/.gitignore
vendored
@ -34,3 +34,6 @@ obj
|
||||
*.cer
|
||||
# .PEM Certificates
|
||||
*.pem
|
||||
|
||||
.heft
|
||||
release
|
16
samples/js-modern-calendar/.npmignore
Normal file
16
samples/js-modern-calendar/.npmignore
Normal file
@ -0,0 +1,16 @@
|
||||
!dist
|
||||
config
|
||||
|
||||
gulpfile.js
|
||||
|
||||
release
|
||||
src
|
||||
temp
|
||||
|
||||
tsconfig.json
|
||||
tslint.json
|
||||
|
||||
*.log
|
||||
|
||||
.yo-rc.json
|
||||
.vscode
|
1
samples/js-modern-calendar/.nvmrc
Normal file
1
samples/js-modern-calendar/.nvmrc
Normal file
@ -0,0 +1 @@
|
||||
v18.20.3
|
@ -28,8 +28,8 @@ This is a modern web part built using the [SharePoint Framework](https://dev.off
|
||||
| Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.|
|
||||
|Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. |
|
||||
|
||||
![SPFx 1.11](https://img.shields.io/badge/SPFx-1.11.0-green.svg)
|
||||
![Node.js v10](https://img.shields.io/badge/Node.js-v10-green.svg)
|
||||
![SPFx 1.20.0](https://img.shields.io/badge/SPFx-1.20.0-green.svg)
|
||||
![Node.js v18](https://img.shields.io/badge/Node.js-v18-green.svg)
|
||||
![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg)
|
||||
![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower")
|
||||
![Does not work with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1")
|
||||
@ -61,6 +61,7 @@ Version|Date|Comments
|
||||
1.0.0.1|June 05, 2020|Updated the external CDN references to public CDN references
|
||||
1.0.2.0|February 9, 2021|Upgraded to SPFx 1.11 and fixed issues with missing dependencies
|
||||
1.0.3.0|October 28, 2021|fixed issues with Time zones. The Browser Time zone Settings are now used
|
||||
1.0.4.0|October 05, 2024|Upgraded to SPFx 1.20 and fixed issues with dependencies eslint
|
||||
|
||||
## Minimal Path to Awesome
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
"This is a modern web part built on the GA version of the SharePoint Framework demonstrating how to build a custom web part with a calendar capabilities in it."
|
||||
],
|
||||
"creationDateTime": "2020-06-05",
|
||||
"updateDateTime": "2021-10-28",
|
||||
"updateDateTime": "2024-10-05",
|
||||
"products": [
|
||||
"SharePoint"
|
||||
],
|
||||
@ -20,7 +20,7 @@
|
||||
},
|
||||
{
|
||||
"key": "SPFX-VERSION",
|
||||
"value": "1.11.0"
|
||||
"value": "1.20.0"
|
||||
}
|
||||
],
|
||||
"thumbnails": [
|
||||
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"deployCdnPath": "temp/deploy"
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"workingDir": "./temp/deploy/",
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "document-card-web-part",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
"container": "react-organization-chart",
|
||||
"accessKey": "<!-- ACCESS KEY -->",
|
||||
"workingDir": "./release/assets/"
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
"solution": {
|
||||
"name": "SPFx Modern Calendar",
|
||||
"id": "3d593a2f-73f1-486f-9dae-555c6f6b584d",
|
||||
"version": "1.0.3.0",
|
||||
"version": "1.0.4.0",
|
||||
"includeClientSideAssets": true,
|
||||
"developer": {
|
||||
"name": "",
|
||||
@ -10,7 +10,29 @@
|
||||
"privacyUrl": "",
|
||||
"termsOfUseUrl": "",
|
||||
"mpnId": ""
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"shortDescription": {
|
||||
"default": "modern-calendar description"
|
||||
},
|
||||
"longDescription": {
|
||||
"default": "modern-calendar description"
|
||||
},
|
||||
"screenshotPaths": [],
|
||||
"videoUrl": "",
|
||||
"categories": []
|
||||
},
|
||||
"features": [
|
||||
{
|
||||
"title": "modern-calendar ModernCalendarWebPart Feature",
|
||||
"description": "The feature that activates ModernCalendarWebPart from the modern-calendar solution.",
|
||||
"id": "c2a397d3-8c8f-47ab-b731-897178313c15",
|
||||
"version": "1.0.4.0",
|
||||
"componentIds": [
|
||||
"c2a397d3-8c8f-47ab-b731-897178313c15"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/modern-calendar.sppkg"
|
||||
|
3
samples/js-modern-calendar/config/sass.json
Normal file
3
samples/js-modern-calendar/config/sass.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
|
||||
"port": 4321,
|
||||
"initialPage": "https://localhost:5432/workbench",
|
||||
"https": true,
|
||||
"api": {
|
||||
"port": 5432,
|
||||
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
||||
}
|
||||
"initialPage": "https://{tenantDomain}/_layouts/workbench.aspx"
|
||||
}
|
||||
|
@ -1,6 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const gulp = require('gulp');
|
||||
const build = require('@microsoft/sp-build-web');
|
||||
|
||||
build.initialize(gulp);
|
||||
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
||||
|
||||
var getTasks = build.rig.getTasks;
|
||||
build.rig.getTasks = function () {
|
||||
var result = getTasks.call(build.rig);
|
||||
|
||||
result.set('serve', result.get('serve-deprecated'));
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
build.initialize(require('gulp'));
|
43863
samples/js-modern-calendar/package-lock.json
generated
43863
samples/js-modern-calendar/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,31 +1,39 @@
|
||||
{
|
||||
"name": "modern-calendar",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"private": true,
|
||||
"main": "lib/index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
"node": ">=18.17.1 <19.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/sp-core-library": "1.11.0",
|
||||
"@microsoft/sp-property-pane": "1.11.0",
|
||||
"@microsoft/sp-webpart-base": "1.11.0",
|
||||
"@types/fullcalendar": "^2.7.38",
|
||||
"@types/moment": "^2.13.0",
|
||||
"fullcalendar": "3.9.0",
|
||||
"sweetalert2": "^6.4.2"
|
||||
"@fullcalendar/core": "^6.1.15",
|
||||
"@fullcalendar/daygrid": "^6.1.15",
|
||||
"@microsoft/sp-adaptive-card-extension-base": "1.20.0",
|
||||
"@microsoft/sp-core-library": "1.20.0",
|
||||
"@microsoft/sp-lodash-subset": "1.20.0",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.20.0",
|
||||
"@microsoft/sp-property-pane": "1.20.0",
|
||||
"@microsoft/sp-webpart-base": "1.20.0",
|
||||
"fullcalendar": "6.1.15",
|
||||
"jquery": "^3.7.1",
|
||||
"moment": "2.30.1",
|
||||
"sweetalert2": "11.14.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/eslint-config-spfx": "1.20.2",
|
||||
"@microsoft/eslint-plugin-spfx": "1.20.2",
|
||||
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
|
||||
"@microsoft/sp-build-web": "1.16.1",
|
||||
"@microsoft/sp-module-interfaces": "1.11.0",
|
||||
"@microsoft/sp-tslint-rules": "1.11.0",
|
||||
"@microsoft/sp-webpart-workbench": "1.12.1",
|
||||
"@types/chai": ">=3.4.34 <3.6.0",
|
||||
"@types/es6-promise": "0.0.33",
|
||||
"@types/mocha": ">=2.2.33 <2.6.0",
|
||||
"@types/webpack-env": "1.13.1",
|
||||
"gulp": "~3.9.1"
|
||||
"@microsoft/rush-stack-compiler-4.7": "0.1.0",
|
||||
"@microsoft/sp-build-web": "1.20.2",
|
||||
"@microsoft/sp-module-interfaces": "1.20.2",
|
||||
"@rushstack/eslint-config": "4.0.1",
|
||||
"@types/jquery": "^3.5.31",
|
||||
"@types/webpack-env": "1.15.2",
|
||||
"ajv": "6.12.5",
|
||||
"eslint": "8.57.0",
|
||||
"gulp": "4.0.2",
|
||||
"typescript": "4.7.4"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
|
@ -1,5 +1,4 @@
|
||||
import styles from "./CalendarTemplate.module.scss";
|
||||
import { escape } from "@microsoft/sp-lodash-subset";
|
||||
import { IPropertyPaneDropdownOption } from "@microsoft/sp-property-pane";
|
||||
|
||||
export interface ISPLists {
|
||||
@ -12,7 +11,7 @@ export interface ISPList {
|
||||
}
|
||||
export default class CalendarTemplate {
|
||||
public static templateHtml: string = `
|
||||
<div class='spfxcalendar'></div>
|
||||
<div id='spfxcalendar' class='spfxcalendar'></div>
|
||||
`;
|
||||
|
||||
public static emptyHtml(title: string): string {
|
||||
@ -64,8 +63,8 @@ export default class CalendarTemplate {
|
||||
];
|
||||
|
||||
public static theme(): IPropertyPaneDropdownOption[] {
|
||||
var themes: IPropertyPaneDropdownOption[] = [];
|
||||
CalendarTemplate.themeNames.forEach((name, index)=> {
|
||||
const themes: IPropertyPaneDropdownOption[] = [];
|
||||
CalendarTemplate.themeNames.forEach((name)=> {
|
||||
themes.push({
|
||||
key: CalendarTemplate.themeBase + name + "/jquery-ui.min.css",
|
||||
text: name.toLocaleUpperCase(),
|
||||
|
@ -1,9 +1,9 @@
|
||||
export interface IModernCalendarWebPartProps {
|
||||
description: string;
|
||||
site: string;
|
||||
siteOther: string;
|
||||
siteOther: string|null;
|
||||
other: boolean;
|
||||
listTitle: string;
|
||||
listTitle: string|null;
|
||||
theme: string;
|
||||
start: string;
|
||||
end: string;
|
||||
|
@ -57,4 +57,5 @@ input[aria-label='hide-col'] {
|
||||
|
||||
#spPropertyPaneContainer input[aria-label='hide-col'] {
|
||||
display:none;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,29 +1,29 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { BaseClientSideWebPart } from "@microsoft/sp-webpart-base";
|
||||
import {
|
||||
IPropertyPaneConfiguration,
|
||||
IPropertyPaneDropdownOption,
|
||||
IPropertyPaneTextFieldProps,
|
||||
PropertyPaneTextField,
|
||||
PropertyPaneDropdown,
|
||||
IPropertyPaneDropdownProps,
|
||||
|
||||
} from "@microsoft/sp-property-pane";
|
||||
|
||||
import { Version } from "@microsoft/sp-core-library";
|
||||
|
||||
import { escape } from "@microsoft/sp-lodash-subset";
|
||||
import styles from "./ModernCalendar.module.scss";
|
||||
import * as strings from "modernCalendarStrings";
|
||||
import { IModernCalendarWebPartProps } from "./IModernCalendarWebPartProps";
|
||||
import CalendarTemplate from "./CalendarTemplate";
|
||||
|
||||
import * as jQuery from "jquery";
|
||||
import "fullcalendar";
|
||||
import * as moment from "moment";
|
||||
import * as swal2 from "sweetalert2";
|
||||
import Swal from "sweetalert2";
|
||||
import { SPComponentLoader } from "@microsoft/sp-loader";
|
||||
import { SPHttpClient, SPHttpClientResponse } from "@microsoft/sp-http";
|
||||
import { Environment, EnvironmentType } from "@microsoft/sp-core-library";
|
||||
import { EventObjectInput, OptionsInput } from "fullcalendar";
|
||||
import { Default as View } from "fullcalendar/View";
|
||||
|
||||
import { Calendar, EventClickArg, EventSourceInput } from '@fullcalendar/core';
|
||||
import dayGridPlugin from '@fullcalendar/daygrid';
|
||||
|
||||
|
||||
|
||||
export interface ISPLists {
|
||||
value: ISPList[];
|
||||
@ -34,20 +34,11 @@ export interface ISPList {
|
||||
Id: string;
|
||||
}
|
||||
|
||||
export interface EventObjects {
|
||||
value: EventObjectInput[];
|
||||
}
|
||||
|
||||
|
||||
export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModernCalendarWebPartProps> {
|
||||
public constructor() {
|
||||
super();
|
||||
// Modify with your a CDN or local path
|
||||
SPComponentLoader.loadCss(
|
||||
"https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/8.11.8/sweetalert2.min.css"
|
||||
);
|
||||
SPComponentLoader.loadCss(
|
||||
"https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.min.css"
|
||||
);
|
||||
}
|
||||
|
||||
public render(): void {
|
||||
@ -62,7 +53,7 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
//Check required properties before rendering list
|
||||
if (
|
||||
this.properties.listTitle == null ||
|
||||
this.properties.start == null ||
|
||||
this.properties.start==null||
|
||||
this.properties.end == null ||
|
||||
this.properties.title == null ||
|
||||
this.properties.detail == null
|
||||
@ -97,7 +88,25 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
!this.properties.title ||
|
||||
!this.properties.detail)
|
||||
) {
|
||||
//this._getColumnsAsync();
|
||||
console.log("this.properties.listTitle: "+this.properties.listTitle);
|
||||
|
||||
this._getListColumns(this.properties.listTitle, this.properties.site).then((response3) => {
|
||||
const col: IPropertyPaneDropdownOption[] = [];
|
||||
for (const _innerKey in response3.value) {
|
||||
col.push({
|
||||
key: response3.value[_innerKey]["InternalName"],
|
||||
text: response3.value[_innerKey]["Title"],
|
||||
});
|
||||
}
|
||||
this._columnOptions = col;
|
||||
this.colsDisabled = false;
|
||||
this.listDisabled = false;
|
||||
this.context.propertyPane.refresh();
|
||||
this.context.statusRenderer.clearLoadingIndicator(
|
||||
this.domElement
|
||||
);
|
||||
this.render();
|
||||
});
|
||||
}
|
||||
|
||||
if (!this.properties.other) {
|
||||
@ -119,13 +128,13 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
);
|
||||
this._getSiteRootWeb().then((response0) => {
|
||||
this._getSites(response0["Url"]).then((response) => {
|
||||
var sites: IPropertyPaneDropdownOption[] = [];
|
||||
const sites: IPropertyPaneDropdownOption[] = [];
|
||||
sites.push({
|
||||
key: this.context.pageContext.web.absoluteUrl,
|
||||
text: "This Site",
|
||||
});
|
||||
sites.push({ key: "other", text: "Other Site (Specify Url)" });
|
||||
for (var _key in response.value) {
|
||||
for (const _key in response.value) {
|
||||
if (
|
||||
this.context.pageContext.web.absoluteUrl !=
|
||||
response.value[_key]["Url"]
|
||||
@ -145,12 +154,13 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
text: list.Title,
|
||||
};
|
||||
});
|
||||
console.log("this.properties.site: "+this.properties.site );
|
||||
this._getListColumns(
|
||||
this.properties.listTitle,
|
||||
this.properties.listTitle!,
|
||||
this.properties.site
|
||||
).then((response3) => {
|
||||
var col: IPropertyPaneDropdownOption[] = [];
|
||||
for (var _innerKey in response3.value) {
|
||||
const col: IPropertyPaneDropdownOption[] = [];
|
||||
for (const _innerKey in response3.value) {
|
||||
col.push({
|
||||
key: response3.value[_innerKey]["InternalName"],
|
||||
text: response3.value[_innerKey]["Title"],
|
||||
@ -196,14 +206,14 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
if ((propertyPath === "site" || propertyPath === "siteOther") && newValue) {
|
||||
this.colsDisabled = true;
|
||||
this.listDisabled = true;
|
||||
var siteUrl = newValue;
|
||||
if (this.properties.other) {
|
||||
let siteUrl = newValue;
|
||||
if (this.properties.other && this.properties.siteOther) {
|
||||
siteUrl = this.properties.siteOther;
|
||||
} else {
|
||||
jQuery("input[aria-label=hide-col]").parent().hide();
|
||||
}
|
||||
if (
|
||||
(this.properties.other && this.properties.siteOther.length > 25) ||
|
||||
(this.properties.other && this.properties.siteOther && this.properties.siteOther.length > 25) ||
|
||||
!this.properties.other
|
||||
) {
|
||||
this._getListTitles(siteUrl).then((response) => {
|
||||
@ -213,21 +223,25 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
text: list.Title,
|
||||
};
|
||||
});
|
||||
|
||||
this.listDisabled = false;
|
||||
this.context.propertyPane.refresh();
|
||||
this.context.statusRenderer.clearLoadingIndicator(this.domElement);
|
||||
this.render();
|
||||
}).catch(() => {
|
||||
console.log("Error loading lists");
|
||||
});
|
||||
}
|
||||
} else if (propertyPath === "listTitle" && newValue) {
|
||||
// tslint:disable-next-line:no-duplicate-variable
|
||||
var siteUrl = newValue;
|
||||
if (this.properties.other) {
|
||||
let siteUrl = this.properties.site;
|
||||
if (this.properties.other && this.properties.siteOther) {
|
||||
siteUrl = this.properties.siteOther;
|
||||
}
|
||||
console.log("siteUrl: "+siteUrl );
|
||||
this._getListColumns(newValue, siteUrl).then((response) => {
|
||||
var col: IPropertyPaneDropdownOption[] = [];
|
||||
for (var _key in response.value) {
|
||||
const col: IPropertyPaneDropdownOption[] = [];
|
||||
for (const _key in response.value) {
|
||||
col.push({
|
||||
key: response.value[_key]["InternalName"],
|
||||
text: response.value[_key]["Title"],
|
||||
@ -249,7 +263,7 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
private listDisabled: boolean = true;
|
||||
|
||||
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||
var otherSiteAria = "hide-col";
|
||||
let otherSiteAria = "hide-col";
|
||||
if (this.properties.other) {
|
||||
otherSiteAria = "";
|
||||
}
|
||||
@ -316,12 +330,9 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
private _dropdownOptions: IPropertyPaneDropdownOption[] = [];
|
||||
private _columnOptions: IPropertyPaneDropdownOption[] = [];
|
||||
|
||||
public onInit<T>(): Promise<T> {
|
||||
//this._siteOptions.push({key:this.context.pageContext.web.absoluteUrl, text:'This Site'});
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
private _getSiteRootWeb(): Promise<ISPLists> {
|
||||
|
||||
private _getSiteRootWeb(): Promise<any> {
|
||||
return this.context.spHttpClient
|
||||
.get(
|
||||
this.context.pageContext.web.absoluteUrl +
|
||||
@ -333,7 +344,7 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
});
|
||||
}
|
||||
|
||||
private _getSites(rootWebUrl: string): Promise<ISPLists> {
|
||||
private _getSites(rootWebUrl: string): Promise<any> {
|
||||
return this.context.spHttpClient
|
||||
.get(
|
||||
rootWebUrl + `/_api/web/webs?$select=Title,Url`,
|
||||
@ -344,13 +355,14 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
});
|
||||
}
|
||||
|
||||
private _getListTitles(site: string): Promise<ISPLists> {
|
||||
private _getListTitles(site: string): Promise<any> {
|
||||
return this.context.spHttpClient
|
||||
.get(
|
||||
site + `/_api/web/lists?$filter=Hidden eq false and BaseType eq 0`,
|
||||
SPHttpClient.configurations.v1
|
||||
)
|
||||
.then((response: SPHttpClientResponse) => {
|
||||
console.log("response get List Titles ");
|
||||
return response.json();
|
||||
});
|
||||
}
|
||||
@ -366,11 +378,14 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
SPHttpClient.configurations.v1
|
||||
)
|
||||
.then((response: SPHttpClientResponse) => {
|
||||
console.log("listsite");
|
||||
console.log(listsite);
|
||||
return response.json();
|
||||
});
|
||||
}
|
||||
|
||||
private _getListData(listName: string, site: string): Promise<any> {
|
||||
console.log("listName: "+listName);
|
||||
return this.context.spHttpClient
|
||||
.get(
|
||||
site +
|
||||
@ -384,12 +399,14 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
SPHttpClient.configurations.v1
|
||||
)
|
||||
.then((response: SPHttpClientResponse) => {
|
||||
console.log("response get List Data ");
|
||||
console.log(response);
|
||||
return response.json();
|
||||
});
|
||||
}
|
||||
|
||||
private _renderList(items: any[]): void {
|
||||
var calItems: EventObjectInput[] = items.map((list: any) => {
|
||||
const calItems:EventSourceInput = items.map((list: any) => {
|
||||
const start = list[this.properties.start];
|
||||
const end = list[this.properties.end];
|
||||
return {
|
||||
@ -401,33 +418,57 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
};
|
||||
});
|
||||
this.context.statusRenderer.clearLoadingIndicator(this.domElement);
|
||||
const calendarOptions: EventObjectInput = {
|
||||
title: "test",
|
||||
theme: true,
|
||||
|
||||
const calendarEl = document.getElementById('spfxcalendar');
|
||||
if(calendarEl){
|
||||
const calendar = new Calendar(calendarEl, {
|
||||
eventClick: (args:EventClickArg) => {
|
||||
const calEvent = args.event;
|
||||
const eventDetail =
|
||||
moment.utc(calEvent.start).local().format('YYYY-MM-DD hh:mm A') +
|
||||
" - " +
|
||||
moment.utc(calEvent.end).local().format('YYYY-MM-DD hh:mm A') +
|
||||
"<br>" +
|
||||
args.event.extendedProps.detail;
|
||||
//swal2.default(calEvent.title, eventDetail, "info");
|
||||
Swal.fire({
|
||||
title: calEvent.title,
|
||||
html: eventDetail,
|
||||
icon: 'info',
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
plugins: [ dayGridPlugin ],
|
||||
initialView: 'dayGridMonth',
|
||||
eventSources: [
|
||||
{
|
||||
events: calItems,
|
||||
eventClick: (_event) => {
|
||||
var eventDetail =
|
||||
moment.utc(_event["start"]).local().format('YYYY-MM-DD hh:mm A') +
|
||||
" - " +
|
||||
moment.utc(_event["end"]).local().format('YYYY-MM-DD hh:mm A') +
|
||||
"<br>" +
|
||||
_event["detail"];
|
||||
swal2.default(_event.title, eventDetail, "info");
|
||||
},
|
||||
};
|
||||
jQuery(".spfxcalendar", this.domElement).fullCalendar(calendarOptions);
|
||||
|
||||
}
|
||||
],
|
||||
|
||||
headerToolbar: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'dayGridMonth,timeGridWeek,listWeek'
|
||||
}
|
||||
});
|
||||
calendar.render();
|
||||
}
|
||||
//jQuery(".spfxcalendar", this.domElement).fullCalendar(calendarOptions);
|
||||
}
|
||||
|
||||
private _getSitesAsync(): void {
|
||||
this._getSiteRootWeb().then((response) => {
|
||||
this._getSites(response["Url"]).then((response1) => {
|
||||
var sites: IPropertyPaneDropdownOption[] = [];
|
||||
const sites: IPropertyPaneDropdownOption[] = [];
|
||||
sites.push({
|
||||
key: this.context.pageContext.web.absoluteUrl,
|
||||
text: "This Site",
|
||||
});
|
||||
sites.push({ key: "other", text: "Other Site (Specify Url)" });
|
||||
for (var _key in response1.value) {
|
||||
for (const _key in response1.value) {
|
||||
sites.push({
|
||||
key: response1.value[_key]["Url"],
|
||||
text: response1.value[_key]["Title"],
|
||||
@ -435,9 +476,9 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
}
|
||||
this._siteOptions = sites;
|
||||
this.context.propertyPane.refresh();
|
||||
var siteUrl = this.properties.site;
|
||||
if (this.properties.other) {
|
||||
siteUrl = this.properties.siteOther;
|
||||
let siteUrl = this.properties.site;
|
||||
if (this.properties.other && this.properties.siteOther) {
|
||||
siteUrl = this.properties.siteOther
|
||||
}
|
||||
this._getListTitles(siteUrl).then((response2) => {
|
||||
this._dropdownOptions = response2.value.map((list: ISPList) => {
|
||||
@ -448,12 +489,13 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
});
|
||||
this.context.propertyPane.refresh();
|
||||
if (this.properties.listTitle) {
|
||||
console.log("this.properties.site: "+this.properties.site );
|
||||
this._getListColumns(
|
||||
this.properties.listTitle,
|
||||
this.properties.site
|
||||
).then((response3) => {
|
||||
var col: IPropertyPaneDropdownOption[] = [];
|
||||
for (var _innerKey in response3.value) {
|
||||
const col: IPropertyPaneDropdownOption[] = [];
|
||||
for (const _innerKey in response3.value) {
|
||||
col.push({
|
||||
key: response3.value[_innerKey]["InternalName"],
|
||||
text: response3.value[_innerKey]["Title"],
|
||||
@ -475,15 +517,20 @@ export default class ModernCalendarWebPart extends BaseClientSideWebPart<IModern
|
||||
}
|
||||
|
||||
private _renderListAsync(): void {
|
||||
var siteUrl = this.properties.site;
|
||||
if (this.properties.other) {
|
||||
let siteUrl = this.properties.site;
|
||||
if (this.properties.other && this.properties.siteOther) {
|
||||
siteUrl = this.properties.siteOther;
|
||||
}
|
||||
this._getListData(this.properties.listTitle, siteUrl)
|
||||
console.log("siteUrl");
|
||||
console.log(siteUrl);
|
||||
this._getListData(this.properties.listTitle!, siteUrl)
|
||||
.then((response) => {
|
||||
console.log("response");
|
||||
this._renderList(response.value);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log("Error loading list data");
|
||||
console.log(err);
|
||||
this.context.statusRenderer.clearLoadingIndicator(this.domElement);
|
||||
this.context.statusRenderer.renderError(
|
||||
this.domElement,
|
||||
|
@ -1,9 +0,0 @@
|
||||
/// <reference types="mocha" />
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
||||
describe('ModernCalendarWebPart', () => {
|
||||
it('should do something', () => {
|
||||
assert.ok(true);
|
||||
});
|
||||
});
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json",
|
||||
"extends": "./node_modules/@microsoft/rush-stack-compiler-4.7/includes/tsconfig-web.json",
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
@ -9,31 +9,27 @@
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"experimentalDecorators": true,
|
||||
"inlineSources": false,
|
||||
"skipLibCheck": true,
|
||||
"outDir": "lib",
|
||||
"strictNullChecks": false,
|
||||
"noUnusedLocals": false,
|
||||
"inlineSources": false,
|
||||
"noImplicitAny": true,
|
||||
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./node_modules/@microsoft"
|
||||
],
|
||||
"types": [
|
||||
"es6-promise",
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection"
|
||||
"es2015.collection",
|
||||
"es2015.promise"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib"
|
||||
]
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
{
|
||||
"rulesDirectory": [
|
||||
"tslint-microsoft-contrib"
|
||||
],
|
||||
"rules": {
|
||||
"class-name": false,
|
||||
"export-name": false,
|
||||
"forin": false,
|
||||
"label-position": false,
|
||||
"member-access": true,
|
||||
"no-arg": false,
|
||||
"no-console": false,
|
||||
"no-construct": false,
|
||||
"no-duplicate-variable": true,
|
||||
"no-eval": false,
|
||||
"no-function-expression": true,
|
||||
"no-internal-module": true,
|
||||
"no-shadowed-variable": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-unnecessary-semicolons": true,
|
||||
"no-unused-expression": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-with-statement": true,
|
||||
"semicolon": true,
|
||||
"trailing-comma": false,
|
||||
"typedef": false,
|
||||
"typedef-whitespace": false,
|
||||
"use-named-parameter": true,
|
||||
"variable-name": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user