Initial commit
This commit is contained in:
commit
64b7f9ebf1
|
@ -0,0 +1,13 @@
|
||||||
|
yo @microsoft/sharepoint
|
||||||
|
spfx-fast-serve
|
||||||
|
npm install react react-dom leaflet
|
||||||
|
npm i @spfxappdev/utility
|
||||||
|
npm i
|
||||||
|
npm install react-leaflet
|
||||||
|
npm install -D @types/leaflet
|
||||||
|
npm run serve
|
||||||
|
gulp serve
|
||||||
|
npm run serve
|
||||||
|
npm install -D @types/leaflet babel-loader @babel/core @babel/preset-env @babel/plugin-proposal-nullish-coalescing-operator
|
||||||
|
npm run serve
|
||||||
|
exit
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules
|
||||||
|
.npm
|
||||||
|
.cache
|
||||||
|
.config
|
||||||
|
.rushstack
|
||||||
|
|
||||||
|
|
||||||
|
# Build generated files
|
||||||
|
dist
|
||||||
|
lib
|
||||||
|
release
|
||||||
|
solution
|
||||||
|
temp
|
||||||
|
*.sppkg
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
|
||||||
|
# OSX
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Visual Studio files
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
.vs
|
||||||
|
bin
|
||||||
|
obj
|
||||||
|
|
||||||
|
# Resx Generated Code
|
||||||
|
*.resx.ts
|
||||||
|
|
||||||
|
# Styles Generated Code
|
||||||
|
*.scss.ts
|
||||||
|
*.scss.d.ts
|
|
@ -0,0 +1,16 @@
|
||||||
|
!dist
|
||||||
|
config
|
||||||
|
|
||||||
|
gulpfile.js
|
||||||
|
|
||||||
|
release
|
||||||
|
src
|
||||||
|
temp
|
||||||
|
|
||||||
|
tsconfig.json
|
||||||
|
tslint.json
|
||||||
|
|
||||||
|
*.log
|
||||||
|
|
||||||
|
.yo-rc.json
|
||||||
|
.vscode
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Hosted workbench",
|
||||||
|
"type": "pwa-chrome",
|
||||||
|
"request": "launch",
|
||||||
|
"url": "https://enter-your-SharePoint-site/_layouts/workbench.aspx",
|
||||||
|
"webRoot": "${workspaceRoot}",
|
||||||
|
"sourceMaps": true,
|
||||||
|
"sourceMapPathOverrides": {
|
||||||
|
"webpack:///.././src/*": "${webRoot}/src/*",
|
||||||
|
"webpack:///../../../src/*": "${webRoot}/src/*",
|
||||||
|
"webpack:///../../../../src/*": "${webRoot}/src/*",
|
||||||
|
"webpack:///../../../../../src/*": "${webRoot}/src/*"
|
||||||
|
},
|
||||||
|
"runtimeArgs": [
|
||||||
|
"--remote-debugging-port=9222",
|
||||||
|
"-incognito"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Place your settings in this file to overwrite default and user settings.
|
||||||
|
{
|
||||||
|
// Configure glob patterns for excluding files and folders in the file explorer.
|
||||||
|
"files.exclude": {
|
||||||
|
"**/.git": true,
|
||||||
|
"**/.DS_Store": true,
|
||||||
|
"**/bower_components": true,
|
||||||
|
"**/coverage": true,
|
||||||
|
"**/lib-amd": true,
|
||||||
|
"src/**/*.scss.ts": true
|
||||||
|
},
|
||||||
|
"typescript.tsdk": ".\\node_modules\\typescript\\lib"
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"@microsoft/generator-sharepoint": {
|
||||||
|
"plusBeta": false,
|
||||||
|
"isCreatingSolution": true,
|
||||||
|
"version": "1.14.0",
|
||||||
|
"libraryName": "spfxappdev-webparts-map",
|
||||||
|
"libraryId": "cc048abe-6531-4295-ab7a-12a1c95de606",
|
||||||
|
"environment": "spo",
|
||||||
|
"packageManager": "npm",
|
||||||
|
"solutionName": "spfxappdev.webparts.map",
|
||||||
|
"solutionShortDescription": "spfxappdev.webparts.map description",
|
||||||
|
"skipFeatureDeployment": true,
|
||||||
|
"isDomainIsolated": false,
|
||||||
|
"componentType": "webpart"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
# spfxappdev-webparts-map
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
Short summary on functionality and used technologies.
|
||||||
|
|
||||||
|
[picture of the solution in action, if possible]
|
||||||
|
|
||||||
|
## Used SharePoint Framework Version
|
||||||
|
|
||||||
|
![version](https://img.shields.io/badge/version-1.13-green.svg)
|
||||||
|
|
||||||
|
## Applies to
|
||||||
|
|
||||||
|
- [SharePoint Framework](https://aka.ms/spfx)
|
||||||
|
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||||
|
|
||||||
|
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
> Any special pre-requisites?
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
Solution|Author(s)
|
||||||
|
--------|---------
|
||||||
|
folder name | Author details (name, company, twitter alias with link)
|
||||||
|
|
||||||
|
## Version history
|
||||||
|
|
||||||
|
Version|Date|Comments
|
||||||
|
-------|----|--------
|
||||||
|
1.1|March 10, 2021|Update comment
|
||||||
|
1.0|January 29, 2021|Initial release
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Minimal Path to Awesome
|
||||||
|
|
||||||
|
- Clone this repository
|
||||||
|
- Ensure that you are at the solution folder
|
||||||
|
- in the command-line run:
|
||||||
|
- **npm install**
|
||||||
|
- **gulp serve**
|
||||||
|
|
||||||
|
> Include any additional steps as needed.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
Description of the extension that expands upon high-level summary above.
|
||||||
|
|
||||||
|
This extension illustrates the following concepts:
|
||||||
|
|
||||||
|
- topic 1
|
||||||
|
- topic 2
|
||||||
|
- topic 3
|
||||||
|
|
||||||
|
> Notice that better pictures and documentation will increase the sample usage and the value you are providing for others. Thanks for your submissions advance.
|
||||||
|
|
||||||
|
> Share your web part with others through Microsoft 365 Patterns and Practices program to get visibility and exposure. More details on the community, open-source projects and other activities from http://aka.ms/m365pnp.
|
||||||
|
|
||||||
|
## References
|
||||||
|
|
||||||
|
- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||||
|
- [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
|
||||||
|
- [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
|
||||||
|
- [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
|
||||||
|
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||||
|
"version": "2.0",
|
||||||
|
"bundles": {
|
||||||
|
"map-web-part": {
|
||||||
|
"components": [
|
||||||
|
{
|
||||||
|
"entrypoint": "./lib/webparts/map/MapWebPart.js",
|
||||||
|
"manifest": "./src/webparts/map/MapWebPart.manifest.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"externals": {},
|
||||||
|
"localizedResources": {
|
||||||
|
"MapWebPartStrings": "lib/webparts/map/loc/{locale}.js"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||||
|
"workingDir": "./release/assets/",
|
||||||
|
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||||
|
"container": "spfxappdev-webparts-map",
|
||||||
|
"accessKey": "<!-- ACCESS KEY -->"
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||||
|
"solution": {
|
||||||
|
"name": "SPFx app dev Map Webpart",
|
||||||
|
"id": "cc048abe-6531-4295-ab7a-12a1c95de606",
|
||||||
|
"version": "1.0.0.0",
|
||||||
|
"includeClientSideAssets": true,
|
||||||
|
"skipFeatureDeployment": true,
|
||||||
|
"isDomainIsolated": false,
|
||||||
|
"developer": {
|
||||||
|
"name": "",
|
||||||
|
"websiteUrl": "",
|
||||||
|
"privacyUrl": "",
|
||||||
|
"termsOfUseUrl": "",
|
||||||
|
"mpnId": "Undefined-1.14.0"
|
||||||
|
},
|
||||||
|
"metadata": {
|
||||||
|
"shortDescription": {
|
||||||
|
"default": "spfxappdev.webparts.map description"
|
||||||
|
},
|
||||||
|
"longDescription": {
|
||||||
|
"default": "spfxappdev.webparts.map description"
|
||||||
|
},
|
||||||
|
"screenshotPaths": [],
|
||||||
|
"videoUrl": "",
|
||||||
|
"categories": []
|
||||||
|
},
|
||||||
|
"features": [
|
||||||
|
{
|
||||||
|
"title": "spfxappdev-webparts-map Feature",
|
||||||
|
"description": "The feature that activates elements of the spfxappdev-webparts-map solution.",
|
||||||
|
"id": "e90a5f60-6586-4a90-925e-70a78df55b29",
|
||||||
|
"version": "1.0.0.0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"paths": {
|
||||||
|
"zippedPackage": "solution/spfxappdev-webparts-map.sppkg"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
|
||||||
|
"port": 4321,
|
||||||
|
"https": true,
|
||||||
|
"ipAddress": "0.0.0.0",
|
||||||
|
"initialPage": "https://sscwebdev.sharepoint.com/sites/showroom/_layouts/workbench.aspx"
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||||
|
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/s-KaiNet/spfx-fast-serve/master/schema/config.latest.schema.json",
|
||||||
|
"cli": {
|
||||||
|
"isLibraryComponent": false
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* User webpack settings file. You can add your own settings here.
|
||||||
|
* Changes from this file will be merged into the base webpack configuration file.
|
||||||
|
* This file will not be overwritten by the subsequent spfx-fast-serve calls.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// you can add your project related webpack configuration here, it will be merged using webpack-merge module
|
||||||
|
// i.e. plugins: [new webpack.Plugin()]
|
||||||
|
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const webpackConfig = {
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
"@webparts": path.resolve(__dirname, "..", "src/webparts"),
|
||||||
|
"@src": path.resolve(__dirname, "..", "src"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// for even more fine-grained control, you can apply custom webpack settings using below function
|
||||||
|
const transformConfig = function (initialWebpackConfig) {
|
||||||
|
// transform the initial webpack config here, i.e.
|
||||||
|
// initialWebpackConfig.plugins.push(new webpack.Plugin()); etc.
|
||||||
|
|
||||||
|
initialWebpackConfig.module.rules.push(
|
||||||
|
{
|
||||||
|
test: /node_modules[\/\\]@?react-leaflet[\/\\].*.js$/,
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
presets: [
|
||||||
|
['@babel/preset-env', { targets: "defaults" }]
|
||||||
|
],
|
||||||
|
plugins: ['@babel/plugin-proposal-nullish-coalescing-operator']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return initialWebpackConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
webpackConfig,
|
||||||
|
transformConfig
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const build = require('@microsoft/sp-build-web');
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* fast-serve */
|
||||||
|
const { addFastServe } = require("spfx-fast-serve-helpers");
|
||||||
|
addFastServe(build);
|
||||||
|
/* end of fast-serve */
|
||||||
|
|
||||||
|
|
||||||
|
/* CUSTOM ALIAS */
|
||||||
|
const path = require('path');
|
||||||
|
build.configureWebpack.mergeConfig({
|
||||||
|
additionalConfiguration: (generatedConfiguration) => {
|
||||||
|
if(!generatedConfiguration.resolve.alias){
|
||||||
|
generatedConfiguration.resolve.alias = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// webparts folder
|
||||||
|
generatedConfiguration.resolve.alias['@webparts'] = path.resolve( __dirname, 'lib/webparts')
|
||||||
|
|
||||||
|
//root src folder
|
||||||
|
generatedConfiguration.resolve.alias['@src'] = path.resolve( __dirname, 'lib')
|
||||||
|
|
||||||
|
|
||||||
|
//Nullish Operator
|
||||||
|
generatedConfiguration.module.rules.push(
|
||||||
|
{
|
||||||
|
test: /node_modules[\/\\]@?react-leaflet[\/\\].*.js$/,
|
||||||
|
use: {
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
presets: [
|
||||||
|
['@babel/preset-env', { targets: "defaults" }]
|
||||||
|
],
|
||||||
|
plugins: ['@babel/plugin-proposal-nullish-coalescing-operator']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return generatedConfiguration;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/* CUSTOM ALIAS END */
|
||||||
|
|
||||||
|
build.initialize(require('gulp'));
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<svg width="50px" height="50px" viewBox="0 0 50 50" version="1.2" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" overflow="inherit"><path d="M25.015 2.4c-7.8 0-14.121 6.204-14.121 13.854 0 7.652 14.121 32.746 14.121 32.746s14.122-25.094 14.122-32.746c0-7.65-6.325-13.854-14.122-13.854z"/></svg>
|
After Width: | Height: | Size: 301 B |
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
"name": "spfxappdev-webparts-map",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "gulp bundle",
|
||||||
|
"clean": "gulp clean",
|
||||||
|
"test": "gulp test",
|
||||||
|
"serve": "gulp bundle --custom-serve --max_old_space_size=4096 && fast-serve"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@microsoft/sp-core-library": "1.14.0",
|
||||||
|
"@microsoft/sp-lodash-subset": "1.14.0",
|
||||||
|
"@microsoft/sp-office-ui-fabric-core": "1.14.0",
|
||||||
|
"@microsoft/sp-property-pane": "1.14.0",
|
||||||
|
"@microsoft/sp-webpart-base": "1.14.0",
|
||||||
|
"@spfxappdev/utility": "^1.1.0",
|
||||||
|
"leaflet": "^1.7.1",
|
||||||
|
"office-ui-fabric-react": "7.174.1",
|
||||||
|
"react": "^16.13.1",
|
||||||
|
"react-dom": "^16.13.1",
|
||||||
|
"react-leaflet": "^3.2.5"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.17.5",
|
||||||
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
|
||||||
|
"@babel/preset-env": "^7.16.11",
|
||||||
|
"@microsoft/rush-stack-compiler-3.9": "0.4.47",
|
||||||
|
"@microsoft/sp-build-web": "1.14.0",
|
||||||
|
"@microsoft/sp-module-interfaces": "1.14.0",
|
||||||
|
"@microsoft/sp-tslint-rules": "1.14.0",
|
||||||
|
"@types/leaflet": "^1.7.9",
|
||||||
|
"@types/react": "16.9.51",
|
||||||
|
"@types/react-dom": "16.9.8",
|
||||||
|
"@types/webpack-env": "1.13.1",
|
||||||
|
"ajv": "~5.2.2",
|
||||||
|
"babel-loader": "^8.2.3",
|
||||||
|
"gulp": "~4.0.2",
|
||||||
|
"spfx-fast-serve-helpers": "~1.14.0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
.inline-color-picker {
|
||||||
|
padding: 5px;
|
||||||
|
background: rgb(255, 255, 255);
|
||||||
|
border-radius: 1px;
|
||||||
|
box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 1px;
|
||||||
|
display: inline-block;
|
||||||
|
border: 1px solid rgb(166, 166, 166);
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&-inner {
|
||||||
|
width: 36px;
|
||||||
|
height: 14px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import { ColorPicker, IColorPickerProps, getColorFromString, IColor, Callout, Label } from 'office-ui-fabric-react';
|
||||||
|
import styles from './InlineColorPicker.module.scss';
|
||||||
|
import { isset, isNullOrEmpty } from '@spfxappdev/utility';
|
||||||
|
|
||||||
|
export interface IInlineColorPickerProps extends IColorPickerProps {
|
||||||
|
label?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IInlineColorPickerState {
|
||||||
|
isPickerVisible: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class InlineColorPicker extends React.Component<IInlineColorPickerProps, IInlineColorPickerState> {
|
||||||
|
|
||||||
|
public state: IInlineColorPickerState = {
|
||||||
|
isPickerVisible: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
private targetElement: HTMLDivElement = null;
|
||||||
|
|
||||||
|
public render(): React.ReactElement<IInlineColorPickerProps> {
|
||||||
|
|
||||||
|
|
||||||
|
let bc: IColor = null;
|
||||||
|
|
||||||
|
if(typeof this.props.color != "string") {
|
||||||
|
bc = this.props.color;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bc = getColorFromString(this.props.color);
|
||||||
|
}
|
||||||
|
|
||||||
|
const customCss: React.CSSProperties = {
|
||||||
|
background: `rgba(${bc.r}, ${bc.g}, ${bc.b}, ${bc.a/100})`
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{!isNullOrEmpty(this.props.label) &&
|
||||||
|
<Label>{this.props.label}</Label>
|
||||||
|
}
|
||||||
|
<div
|
||||||
|
className={styles['inline-color-picker']}
|
||||||
|
ref={(r) => {
|
||||||
|
if(isset(r)) {
|
||||||
|
this.targetElement = r;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
this.setState({ isPickerVisible: true });
|
||||||
|
}}>
|
||||||
|
<div className={styles['inline-color-picker-inner']} style={customCss}></div>
|
||||||
|
</div>
|
||||||
|
{this.state.isPickerVisible &&
|
||||||
|
<Callout target={this.targetElement} onDismiss={() => {
|
||||||
|
this.setState({ isPickerVisible: false });
|
||||||
|
}}>
|
||||||
|
<ColorPicker {...this.props} />
|
||||||
|
</Callout>
|
||||||
|
}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||||
|
"id": "3f860b48-1dc3-496d-bd28-b145672289cc",
|
||||||
|
"alias": "MapWebPart",
|
||||||
|
"componentType": "WebPart",
|
||||||
|
|
||||||
|
// The "*" signifies that the version should be taken from the package.json
|
||||||
|
"version": "*",
|
||||||
|
"manifestVersion": 2,
|
||||||
|
|
||||||
|
// If true, the component can only be installed on sites where Custom Script is allowed.
|
||||||
|
// Components that allow authors to embed arbitrary script code should set this to true.
|
||||||
|
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
|
||||||
|
"requiresCustomScript": false,
|
||||||
|
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"],
|
||||||
|
"supportsThemeVariants": true,
|
||||||
|
|
||||||
|
"preconfiguredEntries": [{
|
||||||
|
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||||
|
"group": { "default": "Other" },
|
||||||
|
"title": { "default": "Map" },
|
||||||
|
"description": { "default": "Map description" },
|
||||||
|
"officeFabricIconFontName": "Page",
|
||||||
|
"properties": {
|
||||||
|
"description": "Map"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
|
@ -0,0 +1,134 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import * as ReactDom from 'react-dom';
|
||||||
|
import { DisplayMode, Version } from '@microsoft/sp-core-library';
|
||||||
|
import {
|
||||||
|
IPropertyPaneConfiguration,
|
||||||
|
PropertyPaneTextField
|
||||||
|
} from '@microsoft/sp-property-pane';
|
||||||
|
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
||||||
|
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||||
|
|
||||||
|
import * as strings from 'MapWebPartStrings';
|
||||||
|
import Map from './components/Map';
|
||||||
|
import { IMapProps, IMarker, IMarkerCategory } from './components/IMapProps';
|
||||||
|
|
||||||
|
|
||||||
|
export interface IMapWebPartProps {
|
||||||
|
markerItems: IMarker[];
|
||||||
|
markerCategories: IMarkerCategory[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class MapWebPart extends BaseClientSideWebPart<IMapWebPartProps> {
|
||||||
|
|
||||||
|
private _isDarkTheme: boolean = false;
|
||||||
|
private _environmentMessage: string = '';
|
||||||
|
|
||||||
|
protected onInit(): Promise<void> {
|
||||||
|
this._environmentMessage = this._getEnvironmentMessage();
|
||||||
|
|
||||||
|
return super.onInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public render(): void {
|
||||||
|
|
||||||
|
const dummyData: IMarker = {
|
||||||
|
id: "5828b794-0c76-4962-9faa-95e89aea6c37",
|
||||||
|
latitude: 49.318121,
|
||||||
|
longitude: 10.624094,
|
||||||
|
type: "Panel",
|
||||||
|
categoryId: "00000000-0000-0000-0000-000000000000",
|
||||||
|
markerClickProps: {
|
||||||
|
headerText: "",
|
||||||
|
content: ""
|
||||||
|
},
|
||||||
|
iconProperties: {
|
||||||
|
markerColor: "red",
|
||||||
|
iconName: "PageLink",
|
||||||
|
iconColor: "#000"
|
||||||
|
},
|
||||||
|
popuptext: "Hello"
|
||||||
|
}
|
||||||
|
|
||||||
|
const dummyData2: IMarker = {
|
||||||
|
id: "5828b794-0c76-4962-9faa-95e89aea6c37",
|
||||||
|
latitude: 49.508121,
|
||||||
|
longitude: 10.824094,
|
||||||
|
type: "None",
|
||||||
|
categoryId: "5828b794-0c76-4962-9faa-95e89aea6123"
|
||||||
|
}
|
||||||
|
|
||||||
|
const dummyCategory: IMarkerCategory = {
|
||||||
|
id: "5828b794-0c76-4962-9faa-95e89aea6123",
|
||||||
|
name: "teeeeest",
|
||||||
|
iconProperties: {
|
||||||
|
markerColor: "#000",
|
||||||
|
iconName: "Installation",
|
||||||
|
iconColor: "#fff"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const element: React.ReactElement<IMapProps> = React.createElement(
|
||||||
|
Map,
|
||||||
|
{
|
||||||
|
markerItems: this.properties.markerItems||[dummyData, dummyData2],
|
||||||
|
markerCategories: this.properties.markerCategories||[dummyCategory],
|
||||||
|
isEditMode: this.displayMode == DisplayMode.Edit
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
ReactDom.render(element, this.domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _getEnvironmentMessage(): string {
|
||||||
|
if (!!this.context.sdks.microsoftTeams) { // running in Teams
|
||||||
|
return this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void {
|
||||||
|
if (!currentTheme) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._isDarkTheme = !!currentTheme.isInverted;
|
||||||
|
const {
|
||||||
|
semanticColors
|
||||||
|
} = currentTheme;
|
||||||
|
this.domElement.style.setProperty('--bodyText', semanticColors.bodyText);
|
||||||
|
this.domElement.style.setProperty('--link', semanticColors.link);
|
||||||
|
this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onDispose(): void {
|
||||||
|
ReactDom.unmountComponentAtNode(this.domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get dataVersion(): Version {
|
||||||
|
return Version.parse('1.0');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||||
|
return {
|
||||||
|
pages: [
|
||||||
|
{
|
||||||
|
header: {
|
||||||
|
description: strings.PropertyPaneDescription
|
||||||
|
},
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
groupName: strings.BasicGroupName,
|
||||||
|
groupFields: [
|
||||||
|
PropertyPaneTextField('description', {
|
||||||
|
label: strings.DescriptionFieldLabel
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,53 @@
|
||||||
|
|
||||||
|
export type MarkerType = "Panel"|"Dialog"|"Url"|"None";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export type MarkerTypePanel = {
|
||||||
|
headerText: string;
|
||||||
|
content: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type MarkerTypeUrl = {
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type MarkerTypeDialog = {
|
||||||
|
headerText: string;
|
||||||
|
content?: string;
|
||||||
|
url?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IMarkerIcon {
|
||||||
|
markerColor: string;
|
||||||
|
iconName: string;
|
||||||
|
iconColor: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IMarkerCategory {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
popuptext?: string;
|
||||||
|
iconProperties: IMarkerIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IMarker {
|
||||||
|
id: string;
|
||||||
|
longitude: number;
|
||||||
|
latitude: number;
|
||||||
|
type: MarkerType;
|
||||||
|
categoryId: string;
|
||||||
|
iconProperties?: IMarkerIcon;
|
||||||
|
popuptext?: string;
|
||||||
|
markerClickProps?: MarkerTypePanel|MarkerTypeUrl|MarkerTypeDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IMapProps {
|
||||||
|
markerItems: IMarker[];
|
||||||
|
markerCategories: IMarkerCategory[];
|
||||||
|
onMarkerCollectionChanged?(markerItems: IMarker[]);
|
||||||
|
onMarkerCategoriesChanged?(markerCategories: IMarkerCategory[]);
|
||||||
|
isEditMode: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
@import '~office-ui-fabric-react/dist/sass/References.scss';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.map {
|
||||||
|
display: block;
|
||||||
|
min-height: 400px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global {
|
||||||
|
.map-icon {
|
||||||
|
position: absolute;
|
||||||
|
left: 8px;
|
||||||
|
top: 5px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,443 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
import * as ReactDom from 'react-dom';
|
||||||
|
import styles from './Map.module.scss';
|
||||||
|
import { IMapProps, IMarker, IMarkerCategory, IMarkerIcon, MarkerType, MarkerTypeDialog, MarkerTypePanel, MarkerTypeUrl } from './IMapProps';
|
||||||
|
import { clone } from '@microsoft/sp-lodash-subset';
|
||||||
|
import { MapContainer, TileLayer, Marker, Popup, Tooltip } from 'react-leaflet';
|
||||||
|
import "leaflet/dist/leaflet.css";
|
||||||
|
import * as L from 'leaflet';
|
||||||
|
import { Icon, ContextualMenu, ContextualMenuItemType, IContextualMenuItem, Panel, Dialog, IPanelProps, PrimaryButton, DefaultButton, IChoiceGroupOption, ChoiceGroup, IDropdownOption, Dropdown, getColorFromString, IColor, PanelType } from 'office-ui-fabric-react';
|
||||||
|
import { randomString, isset, isNullOrEmpty, getDeepOrDefault } from '@spfxappdev/utility';
|
||||||
|
import '@spfxappdev/utility/lib/extensions/StringExtensions';
|
||||||
|
import '@spfxappdev/utility/lib/extensions/ArrayExtensions';
|
||||||
|
import { Guid } from '@microsoft/sp-core-library';
|
||||||
|
import { InlineColorPicker, IInlineColorPickerProps } from '@src/components/inlineColorPicker/InlineColorPicker'
|
||||||
|
import { TextField } from '@microsoft/office-ui-fabric-react-bundle';
|
||||||
|
|
||||||
|
interface IMapState {
|
||||||
|
markerItems: IMarker[];
|
||||||
|
rightMouseTarget?: any;
|
||||||
|
showAddOrEditMarkerPanel: boolean;
|
||||||
|
currentMarker?: IMarker;
|
||||||
|
showClickContent: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Map extends React.Component<IMapProps, IMapState> {
|
||||||
|
|
||||||
|
public state: IMapState = {
|
||||||
|
markerItems: clone(this.props.markerItems),
|
||||||
|
showAddOrEditMarkerPanel: false,
|
||||||
|
showClickContent: false
|
||||||
|
};
|
||||||
|
|
||||||
|
private allCatagories: Record<string, IMarkerCategory> = {};
|
||||||
|
|
||||||
|
private menuItems: IContextualMenuItem[] = [
|
||||||
|
{
|
||||||
|
key: 'newItem',
|
||||||
|
text: 'New',
|
||||||
|
onClick: () => {
|
||||||
|
this.onCreateNewMarkerContextMenuItemClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
private map: L.Map = null;
|
||||||
|
|
||||||
|
private lastLatLngRightClickPosition: L.LatLng;
|
||||||
|
|
||||||
|
|
||||||
|
constructor(props: IMapProps) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
props.markerCategories.forEach((category: IMarkerCategory) => {
|
||||||
|
this.allCatagories[category.id] = category;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public render(): React.ReactElement<IMapProps> {
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.map} onContextMenu={(ev: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
||||||
|
|
||||||
|
}}>
|
||||||
|
<MapContainer center={[49.318121, 10.624094]} zoom={13} maxZoom={500} whenCreated={(map: L.Map) => {
|
||||||
|
map.on("contextmenu", (ev: L.LeafletEvent) => {
|
||||||
|
|
||||||
|
this.lastLatLngRightClickPosition = (ev as any).latlng;
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
rightMouseTarget: {x: ((ev as any).originalEvent as MouseEvent).clientX, y: ((ev as any).originalEvent as MouseEvent).clientY }
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
this.map = map;
|
||||||
|
|
||||||
|
}} style={{
|
||||||
|
height: "400px"
|
||||||
|
}}>
|
||||||
|
<TileLayer
|
||||||
|
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
|
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||||
|
/>
|
||||||
|
|
||||||
|
{this.state.markerItems.map((marker: IMarker, index: number): JSX.Element => {
|
||||||
|
const useCategory: boolean = isset(this.allCatagories[marker.categoryId]);
|
||||||
|
const markerCategory: IMarkerCategory = useCategory ? this.allCatagories[marker.categoryId] : null;
|
||||||
|
const popupText: string = !useCategory ? marker.popuptext : isNullOrEmpty(markerCategory.popuptext) ? markerCategory.name : markerCategory.popuptext;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Marker position={[marker.latitude, marker.longitude]} key={`marker_${index}`} icon={this.createIcon(marker, markerCategory)} eventHandlers={
|
||||||
|
{
|
||||||
|
|
||||||
|
click: (ev: L.LeafletMouseEvent) => {
|
||||||
|
|
||||||
|
let showEditPanel: boolean = this.props.isEditMode;
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
currentMarker: marker,
|
||||||
|
showClickContent: !showEditPanel,
|
||||||
|
showAddOrEditMarkerPanel: showEditPanel
|
||||||
|
});
|
||||||
|
},
|
||||||
|
mouseover: (ev: L.LeafletMouseEvent) => {
|
||||||
|
(ev.target as any).openPopup();
|
||||||
|
},
|
||||||
|
mouseout: (ev: L.LeafletMouseEvent) => {
|
||||||
|
(ev.target as any).closePopup();
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{!isNullOrEmpty(popupText) &&
|
||||||
|
<Popup>
|
||||||
|
{popupText}
|
||||||
|
</Popup>
|
||||||
|
}
|
||||||
|
</Marker>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
|
||||||
|
<ContextualMenu
|
||||||
|
items={this.menuItems}
|
||||||
|
hidden={typeof this.state.rightMouseTarget == "undefined"}
|
||||||
|
target={this.state.rightMouseTarget}
|
||||||
|
onItemClick={() => {
|
||||||
|
|
||||||
|
}}
|
||||||
|
onDismiss={() => {
|
||||||
|
this.setState({
|
||||||
|
rightMouseTarget: undefined
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{this.showAddOrEditMarkerPanel()}
|
||||||
|
{this.showClickContent()}
|
||||||
|
</MapContainer>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private showClickContent(): JSX.Element {
|
||||||
|
if(!this.state.showClickContent || isNullOrEmpty(this.state.currentMarker)) {
|
||||||
|
return (<></>);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.state.currentMarker.type == "Panel") {
|
||||||
|
return (<Panel
|
||||||
|
type={PanelType.medium}
|
||||||
|
isOpen={true}
|
||||||
|
onDismiss={() => { this.onContentPanelDismiss() }}
|
||||||
|
headerText={(this.state.currentMarker.markerClickProps as MarkerTypePanel).headerText}
|
||||||
|
closeButtonAriaLabel="Close"
|
||||||
|
onRenderFooterContent={(props: IPanelProps) => {
|
||||||
|
return (<div>
|
||||||
|
<DefaultButton onClick={() => { this.onContentPanelDismiss(); }}>Close</DefaultButton>
|
||||||
|
</div>);
|
||||||
|
}}
|
||||||
|
// Stretch panel content to fill the available height so the footer is positioned
|
||||||
|
// at the bottom of the page
|
||||||
|
isFooterAtBottom={true}
|
||||||
|
>
|
||||||
|
{(this.state.currentMarker.markerClickProps as MarkerTypePanel).headerText}
|
||||||
|
|
||||||
|
</Panel>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private showAddOrEditMarkerPanel(): JSX.Element {
|
||||||
|
|
||||||
|
if(!this.state.showAddOrEditMarkerPanel) {
|
||||||
|
return (<></>);
|
||||||
|
}
|
||||||
|
|
||||||
|
const headerText: string = !this.state.currentMarker.id.Equals(Guid.empty.toString()) ? "Bearbeiten" : "Neu";
|
||||||
|
|
||||||
|
const markerTypeOptions: IChoiceGroupOption[] = [
|
||||||
|
{ key: 'Panel', text: 'Panel', iconProps: { iconName: 'SidePanel' } },
|
||||||
|
{ key: 'Dialog', text: 'Dialog', iconProps: { iconName: 'Favicon' } },
|
||||||
|
{ key: 'Url', text: 'Url', iconProps: { iconName: 'Link' } },
|
||||||
|
{ key: 'None', text: 'None (not clickable)', iconProps: { iconName: 'FieldEmpty' } },
|
||||||
|
];
|
||||||
|
|
||||||
|
const categoryOptions: IDropdownOption[] = [
|
||||||
|
{ key: Guid.empty.toString(), text: 'None' }
|
||||||
|
];
|
||||||
|
|
||||||
|
this.props.markerCategories.forEach((category: IMarkerCategory) => {
|
||||||
|
categoryOptions.push({ key: category.id, text: category.name });
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Panel
|
||||||
|
type={PanelType.medium}
|
||||||
|
isOpen={this.state.showAddOrEditMarkerPanel}
|
||||||
|
onDismiss={() => { this.onConfigPanelDismiss() }}
|
||||||
|
headerText={headerText}
|
||||||
|
closeButtonAriaLabel="Close"
|
||||||
|
onRenderFooterContent={(props: IPanelProps) => {
|
||||||
|
return (<div>
|
||||||
|
<PrimaryButton onClick={() => {
|
||||||
|
this.state.currentMarker.id = Guid.newGuid().toString();
|
||||||
|
// this.onCreateNewMarkerClick(clone(this.state.currentMarker));
|
||||||
|
this.onCreateNewMarkerClick(this.state.currentMarker);
|
||||||
|
// this.state.currentMarker = null;
|
||||||
|
this.onConfigPanelDismiss();
|
||||||
|
}}>
|
||||||
|
Save
|
||||||
|
</PrimaryButton>
|
||||||
|
<DefaultButton onClick={() => { this.onConfigPanelDismiss(); }}>Cancel</DefaultButton>
|
||||||
|
</div>);
|
||||||
|
}}
|
||||||
|
// Stretch panel content to fill the available height so the footer is positioned
|
||||||
|
// at the bottom of the page
|
||||||
|
isFooterAtBottom={true}
|
||||||
|
>
|
||||||
|
<Dropdown
|
||||||
|
placeholder="Select a category"
|
||||||
|
label="Category"
|
||||||
|
defaultSelectedKey={this.state.currentMarker.categoryId}
|
||||||
|
onChange={(ev: any, option: IDropdownOption) => {
|
||||||
|
this.state.currentMarker.categoryId = option.key.toString();
|
||||||
|
this.setState({
|
||||||
|
currentMarker: this.state.currentMarker
|
||||||
|
});
|
||||||
|
|
||||||
|
}}
|
||||||
|
options={categoryOptions}
|
||||||
|
/>
|
||||||
|
<ChoiceGroup
|
||||||
|
label="Type of marker (on click)"
|
||||||
|
defaultSelectedKey={this.state.currentMarker.type}
|
||||||
|
onChange={(ev: any, option: IChoiceGroupOption) => {
|
||||||
|
this.state.currentMarker.type = option.key.toString() as MarkerType;
|
||||||
|
|
||||||
|
if( this.state.currentMarker.type == "Dialog") {
|
||||||
|
this.state.currentMarker.markerClickProps = {
|
||||||
|
headerText: "",
|
||||||
|
content: "",
|
||||||
|
url: ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if( this.state.currentMarker.type == "Panel") {
|
||||||
|
this.state.currentMarker.markerClickProps = {
|
||||||
|
headerText: "",
|
||||||
|
content: ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if( this.state.currentMarker.type == "None") {
|
||||||
|
this.state.currentMarker.markerClickProps = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( this.state.currentMarker.type == "Url") {
|
||||||
|
this.state.currentMarker.markerClickProps = { url: ""};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
currentMarker: this.state.currentMarker
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
options={markerTypeOptions} />
|
||||||
|
|
||||||
|
{this.state.currentMarker.categoryId == Guid.empty.toString() &&
|
||||||
|
<>
|
||||||
|
<InlineColorPicker
|
||||||
|
label='Marker Color'
|
||||||
|
alphaType='none'
|
||||||
|
color={getColorFromString(this.state.currentMarker.iconProperties.markerColor)}
|
||||||
|
onChange={(ev: any, color: IColor) => {
|
||||||
|
this.state.currentMarker.iconProperties.markerColor = "#" + color.hex;
|
||||||
|
this.setState({
|
||||||
|
currentMarker: this.state.currentMarker
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextField label='Icon' description='leaf blank for none' defaultValue={this.state.currentMarker.iconProperties.iconName} onChange={(ev: any, iconName: string) => {
|
||||||
|
this.state.currentMarker.iconProperties.iconName = iconName;
|
||||||
|
this.setState({
|
||||||
|
currentMarker: this.state.currentMarker
|
||||||
|
});
|
||||||
|
}} />
|
||||||
|
|
||||||
|
{!isNullOrEmpty(this.state.currentMarker.iconProperties.iconName) &&
|
||||||
|
<InlineColorPicker
|
||||||
|
label='Icon Color'
|
||||||
|
alphaType='none'
|
||||||
|
color={getColorFromString(this.state.currentMarker.iconProperties.iconColor)}
|
||||||
|
onChange={(ev: any, color: IColor) => {
|
||||||
|
this.state.currentMarker.iconProperties.iconColor = "#" + color.hex;
|
||||||
|
this.setState({
|
||||||
|
currentMarker: this.state.currentMarker
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/> }
|
||||||
|
|
||||||
|
<TextField label='Popup Text' description='leaf blank for none' defaultValue={this.state.currentMarker.popuptext} onChange={(ev: any, popuptext: string) => {
|
||||||
|
this.state.currentMarker.popuptext = popuptext;
|
||||||
|
this.setState({
|
||||||
|
currentMarker: this.state.currentMarker
|
||||||
|
});
|
||||||
|
}} />
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{this.state.currentMarker.type == "Url" &&
|
||||||
|
<>
|
||||||
|
<TextField label='Url' type='url' defaultValue={(this.state.currentMarker.markerClickProps as MarkerTypeUrl).url} onChange={(ev: any, url: string) => {
|
||||||
|
this.state.currentMarker.markerClickProps = { url: url };
|
||||||
|
this.setState({
|
||||||
|
currentMarker: this.state.currentMarker
|
||||||
|
});
|
||||||
|
}} />
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
|
||||||
|
{this.state.currentMarker.type == "Panel" &&
|
||||||
|
<>
|
||||||
|
<TextField label='Panel Header' defaultValue={(this.state.currentMarker.markerClickProps as MarkerTypePanel).headerText} onChange={(ev: any, headerText: string) => {
|
||||||
|
(this.state.currentMarker.markerClickProps as MarkerTypePanel).headerText = headerText;
|
||||||
|
this.setState({
|
||||||
|
currentMarker: this.state.currentMarker
|
||||||
|
});
|
||||||
|
}} />
|
||||||
|
|
||||||
|
<TextField label='Panel Content' multiline defaultValue={(this.state.currentMarker.markerClickProps as MarkerTypePanel).content} onChange={(ev: any, content: string) => {
|
||||||
|
(this.state.currentMarker.markerClickProps as MarkerTypePanel).content = content;
|
||||||
|
this.setState({
|
||||||
|
currentMarker: this.state.currentMarker
|
||||||
|
});
|
||||||
|
}} />
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
|
||||||
|
{this.state.currentMarker.type == "Dialog" &&
|
||||||
|
<>
|
||||||
|
<TextField label='Dialog Title' defaultValue={(this.state.currentMarker.markerClickProps as MarkerTypeDialog).headerText} onChange={(ev: any, headerText: string) => {
|
||||||
|
(this.state.currentMarker.markerClickProps as MarkerTypeDialog).headerText = headerText;
|
||||||
|
this.setState({
|
||||||
|
currentMarker: this.state.currentMarker
|
||||||
|
});
|
||||||
|
}} />
|
||||||
|
|
||||||
|
<TextField label='Dialog Content' multiline defaultValue={(this.state.currentMarker.markerClickProps as MarkerTypeDialog).content} onChange={(ev: any, content: string) => {
|
||||||
|
(this.state.currentMarker.markerClickProps as MarkerTypeDialog).content = content;
|
||||||
|
this.setState({
|
||||||
|
currentMarker: this.state.currentMarker
|
||||||
|
});
|
||||||
|
}} />
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
</Panel>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private onConfigPanelDismiss(): void {
|
||||||
|
this.setState({
|
||||||
|
showAddOrEditMarkerPanel: false,
|
||||||
|
currentMarker: null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private onContentPanelDismiss(): void {
|
||||||
|
this.setState({
|
||||||
|
showClickContent: false,
|
||||||
|
currentMarker: null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private createIcon(marker: IMarker, markerCategory: IMarkerCategory ): L.Icon {
|
||||||
|
const markerIcon = new L.Icon({
|
||||||
|
iconAnchor: [13, 36],
|
||||||
|
popupAnchor: [0, -36],
|
||||||
|
shadowUrl: null,
|
||||||
|
shadowSize: null,
|
||||||
|
shadowAnchor: null,
|
||||||
|
iconSize: new L.Point(27, 36),
|
||||||
|
className: 'leaflet-div-icon'
|
||||||
|
});
|
||||||
|
|
||||||
|
markerIcon.createIcon = (oldIcon: HTMLElement) => {
|
||||||
|
const wrapper = document.createElement("div");
|
||||||
|
wrapper.classList.add("leaflet-marker-icon");
|
||||||
|
|
||||||
|
wrapper.style.marginLeft = (markerIcon.options.iconAnchor[0] * -1) + "px";
|
||||||
|
wrapper.style.marginTop = (markerIcon.options.iconAnchor[1] * -1) + "px";
|
||||||
|
|
||||||
|
const iconProperties: IMarkerIcon = isNullOrEmpty(markerCategory) ? marker.iconProperties : markerCategory.iconProperties;
|
||||||
|
|
||||||
|
wrapper.innerHTML = `<span>
|
||||||
|
<svg height="36px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" fill="${iconProperties.markerColor}">
|
||||||
|
<!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) -->
|
||||||
|
<path d="M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0z"/>
|
||||||
|
</svg>
|
||||||
|
<span class="map-icon" style="color: ${iconProperties.iconColor}"></span>
|
||||||
|
</span>`;
|
||||||
|
|
||||||
|
ReactDom.render(<Icon iconName={iconProperties.iconName} /> , wrapper.querySelector(".map-icon"));
|
||||||
|
|
||||||
|
return wrapper;
|
||||||
|
};
|
||||||
|
|
||||||
|
return markerIcon as any as L.Icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
private onCreateNewMarkerContextMenuItemClick(): void {
|
||||||
|
|
||||||
|
|
||||||
|
this.state.currentMarker = {
|
||||||
|
id: Guid.empty.toString(),
|
||||||
|
latitude: this.lastLatLngRightClickPosition.lat,
|
||||||
|
longitude: this.lastLatLngRightClickPosition.lng,
|
||||||
|
type: "Panel",
|
||||||
|
markerClickProps: {
|
||||||
|
headerText: "",
|
||||||
|
content: ""
|
||||||
|
},
|
||||||
|
categoryId: Guid.empty.toString(),
|
||||||
|
iconProperties: {
|
||||||
|
markerColor: "#" + randomString(6, 'abcdef0123456789'),
|
||||||
|
iconName: "",
|
||||||
|
iconColor: "#000"
|
||||||
|
},
|
||||||
|
popuptext: null
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('New clicked', this.lastLatLngRightClickPosition);
|
||||||
|
this.state.showAddOrEditMarkerPanel = true;
|
||||||
|
|
||||||
|
this.setState({...this.state})
|
||||||
|
}
|
||||||
|
|
||||||
|
private onCreateNewMarkerClick(marker: IMarker): void {
|
||||||
|
this.state.markerItems.push(marker);
|
||||||
|
this.state.rightMouseTarget = undefined;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
define([], function() {
|
||||||
|
return {
|
||||||
|
"PropertyPaneDescription": "Description",
|
||||||
|
"BasicGroupName": "Group Name",
|
||||||
|
"DescriptionFieldLabel": "Description Field",
|
||||||
|
"AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part",
|
||||||
|
"AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app",
|
||||||
|
"AppSharePointEnvironment": "The app is running on SharePoint page",
|
||||||
|
"AppTeamsTabEnvironment": "The app is running in Microsoft Teams"
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,14 @@
|
||||||
|
declare interface IMapWebPartStrings {
|
||||||
|
PropertyPaneDescription: string;
|
||||||
|
BasicGroupName: string;
|
||||||
|
DescriptionFieldLabel: string;
|
||||||
|
AppLocalEnvironmentSharePoint: string;
|
||||||
|
AppLocalEnvironmentTeams: string;
|
||||||
|
AppSharePointEnvironment: string;
|
||||||
|
AppTeamsTabEnvironment: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module 'MapWebPartStrings' {
|
||||||
|
const strings: IMapWebPartStrings;
|
||||||
|
export = strings;
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
After Width: | Height: | Size: 542 B |
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.9/includes/tsconfig-web.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"jsx": "react",
|
||||||
|
"declaration": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"outDir": "lib",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@src/*": ["src/*"],
|
||||||
|
"@webparts/*": ["src/webparts/*"]
|
||||||
|
},
|
||||||
|
"inlineSources": false,
|
||||||
|
"strictNullChecks": false,
|
||||||
|
"noUnusedLocals": false,
|
||||||
|
"typeRoots": [
|
||||||
|
"./node_modules/@types",
|
||||||
|
"./node_modules/@microsoft"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"webpack-env"
|
||||||
|
],
|
||||||
|
"lib": [
|
||||||
|
"es5",
|
||||||
|
"dom",
|
||||||
|
"es2015.collection",
|
||||||
|
"es2015.promise"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*.ts",
|
||||||
|
"src/**/*.tsx"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"extends": "./node_modules/@microsoft/sp-tslint-rules/base-tslint.json",
|
||||||
|
"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-with-statement": true,
|
||||||
|
"semicolon": true,
|
||||||
|
"trailing-comma": false,
|
||||||
|
"typedef": false,
|
||||||
|
"typedef-whitespace": false,
|
||||||
|
"use-named-parameter": true,
|
||||||
|
"variable-name": false,
|
||||||
|
"whitespace": false
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue