Dev (#664)
* initial version * using sp-dev-fx-controls-react * switched to native ouifr * fix linktitle * still working * gonna brealk it now * cool * working * Update README.md * Update README.md * Update README.md * clean linging and remove unused code * Added additional field Types * added azure relay service demo * ok
This commit is contained in:
parent
fce5326d50
commit
9173f7d06f
|
@ -0,0 +1,25 @@
|
|||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
|
||||
[*]
|
||||
|
||||
# change these settings to your own preference
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# we recommend you to keep these unchanged
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[{package,bower}.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
|
@ -0,0 +1,32 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
|
||||
# Build generated files
|
||||
dist
|
||||
lib
|
||||
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
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"@microsoft/generator-sharepoint": {
|
||||
"version": "1.4.1",
|
||||
"libraryName": "react-relay-service",
|
||||
"libraryId": "3d8b2b8b-cc29-4cf9-b3f1-62edd5ca9b52",
|
||||
"environment": "spo"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
## react-relay-service
|
||||
|
||||
This is where you include your WebPart documentation.
|
||||
|
||||
### Building the code
|
||||
|
||||
```bash
|
||||
git clone the repo
|
||||
npm i
|
||||
npm i -g gulp
|
||||
gulp
|
||||
```
|
||||
|
||||
This package produces the following:
|
||||
|
||||
* lib/* - intermediate-stage commonjs build artifacts
|
||||
* dist/* - the bundled script, along with other resources
|
||||
* deploy/* - all resources which should be uploaded to a CDN.
|
||||
|
||||
### Build options
|
||||
|
||||
gulp clean - TODO
|
||||
gulp test - TODO
|
||||
gulp serve - TODO
|
||||
gulp bundle - TODO
|
||||
gulp package-solution - TODO
|
Binary file not shown.
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||
"version": "2.0",
|
||||
"bundles": {
|
||||
"hello-azure-relay-service-web-part": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/webparts/helloAzureRelayService/HelloAzureRelayServiceWebPart.js",
|
||||
"manifest": "./src/webparts/helloAzureRelayService/HelloAzureRelayServiceWebPart.manifest.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"externals": {},
|
||||
"localizedResources": {
|
||||
"HelloAzureRelayServiceWebPartStrings": "lib/webparts/helloAzureRelayService/loc/{locale}.js"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/spfx-build/copy-assets.schema.json",
|
||||
"deployCdnPath": "temp/deploy"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./temp/deploy/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "react-relay-service",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||
"solution": {
|
||||
"name": "react-relay-service-client-side-solution",
|
||||
"id": "3d8b2b8b-cc29-4cf9-b3f1-62edd5ca9b52",
|
||||
"version": "1.0.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"skipFeatureDeployment": true
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/react-relay-service.sppkg"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/core-build/serve.schema.json",
|
||||
"port": 4321,
|
||||
"https": true,
|
||||
"initialPage": "https://localhost:5432/workbench",
|
||||
"api": {
|
||||
"port": 5432,
|
||||
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/core-build/tslint.schema.json",
|
||||
// Display errors as warnings
|
||||
"displayAsWarning": true,
|
||||
// The TSLint task may have been configured with several custom lint rules
|
||||
// before this config file is read (for example lint rules from the tslint-microsoft-contrib
|
||||
// project). If true, this flag will deactivate any of these rules.
|
||||
"removeExistingRules": true,
|
||||
// When true, the TSLint task is configured with some default TSLint "rules.":
|
||||
"useDefaultConfigAsBase": false,
|
||||
// Since removeExistingRules=true and useDefaultConfigAsBase=false, there will be no lint rules
|
||||
// which are active, other than the list of rules below.
|
||||
"lintConfig": {
|
||||
// Opt-in to Lint rules which help to eliminate bugs in JavaScript
|
||||
"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-case": true,
|
||||
"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,
|
||||
"valid-typeof": true,
|
||||
"variable-name": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const gulp = require('gulp');
|
||||
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.`);
|
||||
|
||||
build.initialize(gulp);
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "react-relay-service",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
"clean": "gulp clean",
|
||||
"test": "gulp test"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "15.6.2",
|
||||
"react-dom": "15.6.2",
|
||||
"@types/react": "15.6.6",
|
||||
"@types/react-dom": "15.5.6",
|
||||
"@microsoft/sp-core-library": "~1.4.1",
|
||||
"@microsoft/sp-webpart-base": "~1.4.1",
|
||||
"@microsoft/sp-lodash-subset": "~1.4.1",
|
||||
"@microsoft/sp-office-ui-fabric-core": "~1.4.1",
|
||||
"@types/webpack-env": ">=1.12.1 <1.14.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/sp-build-web": "~1.4.1",
|
||||
"@microsoft/sp-module-interfaces": "~1.4.1",
|
||||
"@microsoft/sp-webpart-workbench": "~1.4.1",
|
||||
"gulp": "~3.9.1",
|
||||
"@types/chai": ">=3.4.34 <3.6.0",
|
||||
"@types/mocha": ">=2.2.33 <2.6.0",
|
||||
"ajv": "~5.2.2"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||
"id": "6ddbb470-dced-4bcb-ad30-2956dd91dce9",
|
||||
"alias": "HelloAzureRelayServiceWebPart",
|
||||
"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,
|
||||
|
||||
"preconfiguredEntries": [{
|
||||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||
"group": { "default": "Other" },
|
||||
"title": { "default": "HelloAzureRelayService" },
|
||||
"description": { "default": "HelloAzureRelayService description" },
|
||||
"officeFabricIconFontName": "Page",
|
||||
"properties": {
|
||||
"description": "HelloAzureRelayService"
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
import { Version } from '@microsoft/sp-core-library';
|
||||
import {
|
||||
BaseClientSideWebPart,
|
||||
IPropertyPaneConfiguration,
|
||||
PropertyPaneTextField
|
||||
} from '@microsoft/sp-webpart-base';
|
||||
|
||||
import * as strings from 'HelloAzureRelayServiceWebPartStrings';
|
||||
import HelloAzureRelayService from './components/HelloAzureRelayService';
|
||||
import { IHelloAzureRelayServiceProps } from './components/IHelloAzureRelayServiceProps';
|
||||
import { HttpClient, IHttpClientOptions, HttpClientResponse } from '@microsoft/sp-http';
|
||||
|
||||
export interface IHelloAzureRelayServiceWebPartProps {
|
||||
description: string;
|
||||
}
|
||||
|
||||
export default class HelloAzureRelayServiceWebPart extends BaseClientSideWebPart<IHelloAzureRelayServiceWebPartProps> {
|
||||
private results: Array<any>;
|
||||
public onInit(): Promise<any> {
|
||||
debugger;
|
||||
const requestHeaders: Headers = new Headers();
|
||||
requestHeaders.append('Content-type', 'application/json');
|
||||
requestHeaders.append('Cache-Control', 'no-cache');
|
||||
const httpClientOptions: IHttpClientOptions = {
|
||||
|
||||
headers: requestHeaders
|
||||
};
|
||||
|
||||
const url = "https://relayserviceproxy20180831034031.azurewebsites.net/api/Document?webID=917E82F1-FDF8-4298-AE73-1DD60E244C67";
|
||||
return this.context.httpClient.get(url, HttpClient.configurations.v1, httpClientOptions).then((response) => {
|
||||
response.json().then((r => {
|
||||
debugger;
|
||||
this.results = r;
|
||||
}))
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
public render(): void {
|
||||
const element: React.ReactElement<IHelloAzureRelayServiceProps> = React.createElement(
|
||||
HelloAzureRelayService,
|
||||
{
|
||||
description: this.properties.description,
|
||||
documents: this.results
|
||||
}
|
||||
);
|
||||
|
||||
ReactDom.render(element, 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
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
||||
|
||||
.helloAzureRelayService {
|
||||
.container {
|
||||
max-width: 700px;
|
||||
margin: 0px auto;
|
||||
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.row {
|
||||
@include ms-Grid-row;
|
||||
@include ms-fontColor-white;
|
||||
background-color: $ms-color-themeDark;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.column {
|
||||
@include ms-Grid-col;
|
||||
@include ms-lg10;
|
||||
@include ms-xl8;
|
||||
@include ms-xlPush2;
|
||||
@include ms-lgPush1;
|
||||
}
|
||||
|
||||
.title {
|
||||
@include ms-font-xl;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.subTitle {
|
||||
@include ms-font-l;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.description {
|
||||
@include ms-font-l;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.button {
|
||||
// Our button
|
||||
text-decoration: none;
|
||||
height: 32px;
|
||||
|
||||
// Primary Button
|
||||
min-width: 80px;
|
||||
background-color: $ms-color-themePrimary;
|
||||
border-color: $ms-color-themePrimary;
|
||||
color: $ms-color-white;
|
||||
|
||||
// Basic Button
|
||||
outline: transparent;
|
||||
position: relative;
|
||||
font-family: "Segoe UI WestEuropean","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-size: $ms-font-size-m;
|
||||
font-weight: $ms-font-weight-regular;
|
||||
border-width: 0;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
padding: 0 16px;
|
||||
|
||||
.label {
|
||||
font-weight: $ms-font-weight-semibold;
|
||||
font-size: $ms-font-size-m;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
margin: 0 4px;
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
import * as React from 'react';
|
||||
import styles from './HelloAzureRelayService.module.scss';
|
||||
import { IHelloAzureRelayServiceProps } from './IHelloAzureRelayServiceProps';
|
||||
import { escape } from '@microsoft/sp-lodash-subset';
|
||||
|
||||
export default class HelloAzureRelayService extends React.Component<IHelloAzureRelayServiceProps, {}> {
|
||||
|
||||
public render(): React.ReactElement<IHelloAzureRelayServiceProps> {
|
||||
return (
|
||||
<div className={styles.helloAzureRelayService}>
|
||||
<div className={styles.container}>
|
||||
<div className={styles.row}>
|
||||
<div className={styles.column}>
|
||||
<span className={styles.title}>Welcome to SharePoint!</span>
|
||||
<p className={styles.subTitle}>Customize SharePoint experiences using Web Parts.</p>
|
||||
<p className={styles.description}>{escape(this.props.description)}</p>
|
||||
<a href="https://aka.ms/spfx" className={styles.button}>
|
||||
<ul>
|
||||
{this.props.documents.map((d, i) => {
|
||||
debugger;
|
||||
return <li>{d.Title}</li>;
|
||||
})}
|
||||
</ul>
|
||||
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export interface IHelloAzureRelayServiceProps {
|
||||
description: string;
|
||||
documents:Array<any>;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
define([], function() {
|
||||
return {
|
||||
"PropertyPaneDescription": "Description",
|
||||
"BasicGroupName": "Group Name",
|
||||
"DescriptionFieldLabel": "Description Field"
|
||||
}
|
||||
});
|
10
samples/react-RelayService/src/webparts/helloAzureRelayService/loc/mystrings.d.ts
vendored
Normal file
10
samples/react-RelayService/src/webparts/helloAzureRelayService/loc/mystrings.d.ts
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
declare interface IHelloAzureRelayServiceWebPartStrings {
|
||||
PropertyPaneDescription: string;
|
||||
BasicGroupName: string;
|
||||
DescriptionFieldLabel: string;
|
||||
}
|
||||
|
||||
declare module 'HelloAzureRelayServiceWebPartStrings' {
|
||||
const strings: IHelloAzureRelayServiceWebPartStrings;
|
||||
export = strings;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "commonjs",
|
||||
"jsx": "react",
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"experimentalDecorators": true,
|
||||
"skipLibCheck": true,
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./node_modules/@microsoft"
|
||||
],
|
||||
"types": [
|
||||
"es6-promise",
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
|
||||
[*]
|
||||
|
||||
# change these settings to your own preference
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# we recommend you to keep these unchanged
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[{package,bower}.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
|
@ -0,0 +1,32 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
|
||||
# Build generated files
|
||||
dist
|
||||
lib
|
||||
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
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"@microsoft/generator-sharepoint": {
|
||||
"version": "1.4.1",
|
||||
"libraryName": "react-item-history",
|
||||
"libraryId": "bc845683-0162-4f0c-b58a-f7f4237a1c46",
|
||||
"environment": "spo"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 53 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
|
@ -0,0 +1,55 @@
|
|||
## react-item-history
|
||||
|
||||
## Summary
|
||||
This listview command is used to show the past versions of the selected list item in a grid.
|
||||
|
||||
![Item History](./Capture.PNG)
|
||||
|
||||
## Used SharePoint Framework Version
|
||||
![drop](https://img.shields.io/badge/version-GA-green.svg)
|
||||
|
||||
## Applies to
|
||||
|
||||
* [SharePoint Framework](https:/dev.office.com/sharepoint)
|
||||
* [Office 365 tenant](https://dev.office.com/sharepoint/docs/spfx/set-up-your-development-environment)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
> No pre-requisites
|
||||
|
||||
## Solution
|
||||
|
||||
Solution|Author(s)
|
||||
--------|---------
|
||||
react-item-History|Russell Gove
|
||||
|
||||
|
||||
## Version history
|
||||
|
||||
Version|Date|Comments
|
||||
-------|----|--------
|
||||
1.0|June 15, 2018|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
|
||||
- in the command line run:
|
||||
- `npm install`
|
||||
- `gulp serve`
|
||||
|
||||
## Features
|
||||
This listview command is used to show the past versions of the selected list item in a grid.
|
||||
Add-PnPCustomAction `
|
||||
-Name 'Item History(GRID)' `
|
||||
-Title 'Item History(GRID)' `
|
||||
-Location 'ClientSideExtension.ListViewCommandSet.CommandBar' `
|
||||
-ClientSideComponentId "f6b9bab2-00a1-4ff1-8bc2-04fea3d64fed" `
|
||||
-RegistrationType List `
|
||||
-RegistrationId "101" `
|
||||
-ClientSideComponentProperties "{}"
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||
"version": "2.0",
|
||||
"bundles": {
|
||||
"item-history-command-set": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/extensions/itemHistory/ItemHistoryCommandSet.js",
|
||||
"manifest": "./src/extensions/itemHistory/ItemHistoryCommandSet.manifest.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"externals": {},
|
||||
"localizedResources": {
|
||||
"ItemHistoryCommandSetStrings": "lib/extensions/itemHistory/loc/{locale}.js",
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/spfx-build/copy-assets.schema.json",
|
||||
"deployCdnPath": "temp/deploy"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./temp/deploy/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "react-item-history",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||
"solution": {
|
||||
"name": "react-item-history-client-side-solution",
|
||||
"id": "bc845683-0162-4f0c-b58a-f7f4237a1c46",
|
||||
"version": "1.0.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"skipFeatureDeployment": true
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/react-item-history.sppkg"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/core-build/serve.schema.json",
|
||||
"port": 4321,
|
||||
"https": true,
|
||||
"serveConfigurations": {
|
||||
"default": {
|
||||
"pageUrl": "https://tronoxglobal.sharepoint.com/sites/GLMasterData/Lists/Account%20Requests/AllItems.aspx",
|
||||
"customActions": {
|
||||
"f6b9bab2-00a1-4ff1-8bc2-04fea3d64fed": {
|
||||
"location": "ClientSideExtension.ListViewCommandSet.CommandBar",
|
||||
"properties": {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"itemHistory": {
|
||||
"pageUrl": "https://tronoxglobal.sharepoint.com/sites/GLMasterData/Lists/Account%20Requests/AllItems.aspx",
|
||||
"customActions": {
|
||||
"f6b9bab2-00a1-4ff1-8bc2-04fea3d64fed": {
|
||||
"location": "ClientSideExtension.ListViewCommandSet.CommandBar",
|
||||
"properties": {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/core-build/tslint.schema.json",
|
||||
// Display errors as warnings
|
||||
"displayAsWarning": true,
|
||||
// The TSLint task may have been configured with several custom lint rules
|
||||
// before this config file is read (for example lint rules from the tslint-microsoft-contrib
|
||||
// project). If true, this flag will deactivate any of these rules.
|
||||
"removeExistingRules": true,
|
||||
// When true, the TSLint task is configured with some default TSLint "rules.":
|
||||
"useDefaultConfigAsBase": false,
|
||||
// Since removeExistingRules=true and useDefaultConfigAsBase=false, there will be no lint rules
|
||||
// which are active, other than the list of rules below.
|
||||
"lintConfig": {
|
||||
// Opt-in to Lint rules which help to eliminate bugs in JavaScript
|
||||
"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-case": true,
|
||||
"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,
|
||||
"valid-typeof": true,
|
||||
"variable-name": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const gulp = require('gulp');
|
||||
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.`);
|
||||
|
||||
build.initialize(gulp);
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "react-item-history",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
"clean": "gulp clean",
|
||||
"test": "gulp test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/decorators": "~1.4.1",
|
||||
"@microsoft/sp-core-library": "~1.4.1",
|
||||
"@microsoft/sp-dialog": "~1.4.1",
|
||||
"@microsoft/sp-listview-extensibility": "~1.4.1",
|
||||
"@pnp/common": "^1.1.1",
|
||||
"@pnp/logging": "^1.1.1",
|
||||
"@pnp/odata": "^1.1.1",
|
||||
"@pnp/sp": "^1.1.1",
|
||||
"@types/webpack-env": ">=1.12.1 <1.14.0",
|
||||
"date-fns": "^1.29.0",
|
||||
"lodash": "^4.17.10",
|
||||
"office-ui-fabric-react": "^5.41.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/sp-build-web": "~1.4.1",
|
||||
"@microsoft/sp-module-interfaces": "~1.4.1",
|
||||
"@microsoft/sp-webpart-workbench": "~1.4.1",
|
||||
"gulp": "~3.9.1",
|
||||
"@types/chai": ">=3.4.34 <3.6.0",
|
||||
"@types/mocha": ">=2.2.33 <2.6.0",
|
||||
"ajv": "~5.2.2"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,323 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import { BaseDialog, IDialogConfiguration } from '@microsoft/sp-dialog';
|
||||
|
||||
import { find } from "lodash";
|
||||
import {
|
||||
autobind,
|
||||
PrimaryButton,
|
||||
Button,
|
||||
DialogFooter,
|
||||
DialogContent
|
||||
} from 'office-ui-fabric-react';
|
||||
|
||||
|
||||
import {
|
||||
DetailsList, DetailsListLayoutMode, IColumn, SelectionMode, Selection,
|
||||
ColumnActionsMode
|
||||
} from "office-ui-fabric-react/lib/DetailsList";
|
||||
|
||||
import { parse, format } from "date-fns";
|
||||
|
||||
|
||||
|
||||
|
||||
//import { ListView, IViewField, SelectionMode, GroupOrder, IGrouping } from "@pnp/spfx-controls-react/lib/ListView";
|
||||
import { sp, Fields, Field } from "@pnp/sp";
|
||||
interface IItemHistoryDialogContentProps {
|
||||
versions: Array<any>;
|
||||
columns: Array<string>;
|
||||
columnDefs: Array<Field>;
|
||||
close: () => void;
|
||||
}
|
||||
class ItemHistoryDialogContent extends React.Component<IItemHistoryDialogContentProps, {}> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@autobind
|
||||
public fieldChanged(item?: any, index?: number, column?: IColumn, columnType: string = "Text"): boolean {
|
||||
if (index < this.props.versions.length - 1) {
|
||||
switch (columnType) {
|
||||
case "User":
|
||||
|
||||
if (this.props.versions[index][column.fieldName]["LookupId"] !== this.props.versions[index + 1][column.fieldName]["LookupId"]) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case "LookupMulti":
|
||||
debugger; // if the length is different true; if the values are diffent fales
|
||||
if (this.props.versions[index][column.fieldName].length !== this.props.versions[index + 1][column.fieldName].length) {
|
||||
return true;
|
||||
}
|
||||
// length is the same, compare values
|
||||
for (let i = 0; i < this.props.versions[index][column.fieldName].length; i++) {
|
||||
if (this.props.versions[index][column.fieldName][i]["LookupId"] !== this.props.versions[index + 1][column.fieldName][i]["LookupId"]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
default:
|
||||
if (this.props.versions[index][column.fieldName] !== this.props.versions[index + 1][column.fieldName]) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@autobind
|
||||
public getStyle(item?: any, index?: number, column?: IColumn, columnType: string = "Text"): React.CSSProperties {
|
||||
if (this.fieldChanged(item, index, column, columnType)) {
|
||||
return {
|
||||
backgroundColor: 'yellow',
|
||||
};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
public onRenderDateTime(item?: any, index?: number, column?: IColumn): any {
|
||||
return (<div style={this.getStyle(item, index, column)}>
|
||||
{format(parse(item[column.fieldName]), "DD-MMM-YYYY")}
|
||||
</div>);
|
||||
}
|
||||
@autobind
|
||||
public onRenderUser(item?: any, index?: number, column?: IColumn): any {
|
||||
debugger;
|
||||
return (<div style={this.getStyle(item, index, column, "User")}>
|
||||
{item[column.fieldName]["LookupValue"]}
|
||||
</div>);
|
||||
|
||||
|
||||
}
|
||||
@autobind
|
||||
public onRenderLookupMulti(item?: any, index?: number, column?: IColumn): any {
|
||||
debugger;
|
||||
let display = "";
|
||||
for (let val of item[column.fieldName]) {
|
||||
display += val["LookupValue"]+";";
|
||||
}
|
||||
return (<div style={this.getStyle(item, index, column, "LookupMulti")}>
|
||||
{display}
|
||||
</div>);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@autobind
|
||||
public onRenderChoice(item?: any, index?: number, column?: IColumn): any {
|
||||
|
||||
return (<div style={this.getStyle(item, index, column)}>
|
||||
{item[column.fieldName]}
|
||||
</div>);
|
||||
}
|
||||
@autobind
|
||||
public onRenderText(item?: any, index?: number, column?: IColumn): any {
|
||||
debugger;
|
||||
return (<div style={this.getStyle(item, index, column)}>
|
||||
{item[column.fieldName]}
|
||||
</div>);
|
||||
}
|
||||
@autobind
|
||||
public onRenderAttachments(item?: any, index?: number, column?: IColumn): any {
|
||||
debugger;
|
||||
let value=item[column.fieldName]?"Yes":"No";
|
||||
return (<div style={this.getStyle(item, index, column)}>
|
||||
{value}
|
||||
</div>);
|
||||
}
|
||||
@autobind
|
||||
public render(): JSX.Element {
|
||||
|
||||
debugger;
|
||||
try {
|
||||
let testviewFields: Array<IColumn> = this.props.columns.map(cname => {
|
||||
let columnDef: Field = find(this.props.columnDefs, (colunmDef) => { return colunmDef["InternalName"] === cname; });
|
||||
switch (columnDef["TypeAsString"]) {
|
||||
case "Attachments":
|
||||
return {
|
||||
name: columnDef["Title"],
|
||||
isResizable: true,
|
||||
key: cname,
|
||||
fieldName: cname,
|
||||
minWidth: 100,
|
||||
onRender: this.onRenderAttachments,
|
||||
};
|
||||
case "LookupMulti":
|
||||
return {
|
||||
name: columnDef["Title"],
|
||||
isResizable: true,
|
||||
key: cname,
|
||||
fieldName: cname,
|
||||
minWidth: 100,
|
||||
onRender: this.onRenderLookupMulti,
|
||||
};
|
||||
|
||||
case "DateTime":
|
||||
return {
|
||||
name: columnDef["Title"],
|
||||
isResizable: true,
|
||||
key: cname,
|
||||
fieldName: cname,
|
||||
minWidth: 100,
|
||||
onRender: this.onRenderDateTime,
|
||||
};
|
||||
case "Choice":
|
||||
return {
|
||||
name: columnDef["Title"],
|
||||
isResizable: true,
|
||||
key: cname,
|
||||
fieldName: cname,
|
||||
minWidth: 100,
|
||||
onRender: this.onRenderChoice
|
||||
};
|
||||
case "Lookup":
|
||||
case "User":
|
||||
return {
|
||||
name: columnDef["Title"],
|
||||
isResizable: true,
|
||||
key: cname,
|
||||
fieldName: cname,
|
||||
minWidth: 100,
|
||||
onRender: this.onRenderUser
|
||||
};
|
||||
|
||||
case "Text":
|
||||
case "Note":
|
||||
return {
|
||||
name: columnDef["Title"],
|
||||
isResizable: true,
|
||||
key: cname,
|
||||
fieldName: cname,
|
||||
minWidth: 100,
|
||||
onRender: this.onRenderText
|
||||
};
|
||||
|
||||
|
||||
default:
|
||||
console.log("the colum type " + columnDef["TypeAsString"] + "HAS NOT BEENTESTED, default to text")
|
||||
return {
|
||||
name: columnDef["Title"],
|
||||
isResizable: true,
|
||||
key: cname,
|
||||
fieldName: cname,
|
||||
minWidth: 100,
|
||||
onRender: this.onRenderText
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
testviewFields.unshift({
|
||||
name: "Version",
|
||||
isResizable: true,
|
||||
key: "Version",
|
||||
fieldName: "VersionLabel",
|
||||
minWidth: 50
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
return (<DialogContent
|
||||
title='Version History(Grid)'
|
||||
onDismiss={this.props.close}
|
||||
showCloseButton={true}
|
||||
|
||||
>
|
||||
<DetailsList
|
||||
items={this.props.versions}
|
||||
columns={testviewFields}
|
||||
compact={false}
|
||||
selectionMode={SelectionMode.none}
|
||||
key={"ID"}
|
||||
onShouldVirtualize={() => { return false; }}
|
||||
layoutMode={DetailsListLayoutMode.justified}
|
||||
skipViewportMeasures={true}
|
||||
|
||||
/>
|
||||
<DialogFooter>
|
||||
<Button text='Cancel' title='Cancel' onClick={this.props.close} />
|
||||
|
||||
</DialogFooter>
|
||||
</DialogContent>);
|
||||
}
|
||||
catch (e) {
|
||||
debugger;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
export default class ItemHistoryDialog extends BaseDialog {
|
||||
public itemId: number;
|
||||
public listId: string;
|
||||
public viewId: string;
|
||||
public fieldInterntalNames: Array<string>;
|
||||
public fieldDefinitions: Array<Field>;
|
||||
public versionHistory: Array<any>;
|
||||
public onBeforeOpen(): Promise<void> {
|
||||
// set up pnp here
|
||||
// let viewId = this.context.pageContext.legacyPageContext.viewId //get the view id and then used pnp to query view columns/fields as follows,
|
||||
let batch = sp.createBatch();
|
||||
// get the fields in the view
|
||||
sp.web.lists.getById(this.listId).views.getById(this.viewId).fields.inBatch(batch).get().then((results: any) => {
|
||||
|
||||
this.fieldInterntalNames = results.Items.map(f => {
|
||||
switch (f) {
|
||||
case "LinkTitle":
|
||||
case "LinkTitleNoMenu":
|
||||
return "Title";
|
||||
//break;
|
||||
default:
|
||||
return f;
|
||||
}
|
||||
});
|
||||
|
||||
}).catch((err: any) => {
|
||||
debugger;
|
||||
});
|
||||
// get the field definitions for the list
|
||||
sp.web.lists.getById(this.listId).fields.inBatch(batch).get().then((results: any) => {
|
||||
|
||||
this.fieldDefinitions = results;
|
||||
}).catch((err: any) => {
|
||||
debugger;
|
||||
});
|
||||
// get the field versionHostory
|
||||
sp.web.lists.getById(this.listId).items.getById(this.itemId).versions.inBatch(batch).get().then((versions) => {
|
||||
this.versionHistory = versions;
|
||||
|
||||
return;
|
||||
}).catch((err: any) => {
|
||||
debugger;
|
||||
});
|
||||
return batch.execute().then(e => {
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
public render(): void {
|
||||
|
||||
ReactDOM.render(<ItemHistoryDialogContent
|
||||
versions={this.versionHistory}
|
||||
columns={this.fieldInterntalNames}
|
||||
columnDefs={this.fieldDefinitions}
|
||||
close={this.close}
|
||||
|
||||
|
||||
/>, this.domElement);
|
||||
}
|
||||
|
||||
public getConfig(): IDialogConfiguration {
|
||||
return {
|
||||
isBlocking: false
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"$schema": "https://dev.office.com/json-schemas/spfx/command-set-extension-manifest.schema.json",
|
||||
|
||||
"id": "f6b9bab2-00a1-4ff1-8bc2-04fea3d64fed",
|
||||
"alias": "ItemHistoryCommandSet",
|
||||
"componentType": "Extension",
|
||||
"extensionType": "ListViewCommandSet",
|
||||
|
||||
// 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,
|
||||
|
||||
"items": {
|
||||
"COMMAND_ViewHistory": {
|
||||
"title": { "default": "Version History (Grid)" },
|
||||
"type": "command"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
import { override } from '@microsoft/decorators';
|
||||
import { Log } from '@microsoft/sp-core-library';
|
||||
//import { RowAccessor} from '@microsoft/sp-listview-extensibility';
|
||||
import {
|
||||
BaseListViewCommandSet,
|
||||
Command,
|
||||
IListViewCommandSetListViewUpdatedParameters,
|
||||
IListViewCommandSetExecuteEventParameters
|
||||
} from '@microsoft/sp-listview-extensibility';
|
||||
import { Dialog } from '@microsoft/sp-dialog';
|
||||
import { setup as pnpSetup } from "@pnp/common";
|
||||
import { sp } from "@pnp/sp";
|
||||
|
||||
import * as strings from 'ItemHistoryCommandSetStrings';
|
||||
import ItemHistoryDialog from "./ItemHistory";
|
||||
import { find } from "lodash";
|
||||
|
||||
/**
|
||||
* If your command set uses the ClientSideComponentProperties JSON input,
|
||||
* it will be deserialized into the BaseExtension.properties object.
|
||||
* You can define an interface to describe it.
|
||||
*/
|
||||
export interface IItemHistoryCommandSetProperties {
|
||||
// This is an example; replace with your own properties
|
||||
|
||||
}
|
||||
|
||||
const LOG_SOURCE: string = 'ItemHistoryCommandSet';
|
||||
|
||||
export default class ItemHistoryCommandSet extends BaseListViewCommandSet<IItemHistoryCommandSetProperties> {
|
||||
public fields: Array<string>;
|
||||
@override
|
||||
public onInit(): Promise<void> {
|
||||
Log.info(LOG_SOURCE, 'Initialized ItemHistoryCommandSet');
|
||||
pnpSetup({
|
||||
spfxContext: this.context
|
||||
});
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@override
|
||||
public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters): void {
|
||||
const compareOneCommand: Command = this.tryGetCommand('COMMAND_1');
|
||||
if (compareOneCommand) {
|
||||
// This command should be hidden unless exactly one row is selected.
|
||||
compareOneCommand.visible = event.selectedRows.length === 1;
|
||||
}
|
||||
}
|
||||
@override
|
||||
public onExecute(event: IListViewCommandSetExecuteEventParameters): void {
|
||||
switch (event.itemId) {
|
||||
case 'COMMAND_ViewHistory':
|
||||
const dialog: ItemHistoryDialog = new ItemHistoryDialog();
|
||||
dialog.itemId = event.selectedRows[0].getValueByName("ID");
|
||||
dialog.listId = this.context.pageContext.list.id.toString();
|
||||
dialog.viewId = this.context.pageContext.legacyPageContext.viewId;
|
||||
dialog.show()
|
||||
.then(() => {
|
||||
debugger;
|
||||
})
|
||||
.catch((e) => {
|
||||
debugger;
|
||||
});
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unknown command');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<html>
|
||||
|
||||
<body>
|
||||
<div style='width: 320px; height: 140px;position: relative'>
|
||||
<img style=' transform:rotate(45deg);transform-origin: bottom; width:30px;margin:auto;left:0;right:0;bottom:0;position:
|
||||
absolute; ' src='http://tronet.global.tronox.com/_layouts/Tronet/Images/Tronox-logo.png '>
|
||||
</img>
|
||||
</div>
|
||||
<hr>
|
||||
<img src='http://tronet.global.tronox.com/_layouts/Tronet/Images/Tronox-logo.png '>
|
||||
</img>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1 @@
|
|||
{ '__metadata': { 'type': 'SP.Data.OMSAlertsListItem' }, 'Title': 'Test'}
|
|
@ -0,0 +1 @@
|
|||
[{"Claims":"i:0#.f|membership|russell.gove@tronox.com","DisplayName":"Gove, Russell","Email":"Russell.Gove@tronox.com","Picture":"https://tronoxglobal.sharepoint.com/sites/GLMasterData/_layouts/15/UserPhoto.aspx?Size=L&AccountName=Russell.Gove@tronox.com","Department":"Infrastructure Services","JobTitle":"Sr SharePoint Architect"},{"Claims":"i:0#.f|membership|john.njoroge@tronox.com","DisplayName":"Njoroge, John","Email":"John.Njoroge@tronox.com","Picture":"https://tronoxglobal.sharepoint.com/sites/GLMasterData/_layouts/15/UserPhoto.aspx?Size=L&AccountName=John.Njoroge@tronox.com","Department":"CFO Staff","JobTitle":"Manager Accounting Analysis"}]
|
|
@ -0,0 +1,6 @@
|
|||
define([], function() {
|
||||
return {
|
||||
"Command1": "Command 1",
|
||||
"Command2": "Command 2"
|
||||
}
|
||||
});
|
|
@ -0,0 +1,9 @@
|
|||
declare interface IItemHistoryCommandSetStrings {
|
||||
Command1: string;
|
||||
Command2: string;
|
||||
}
|
||||
|
||||
declare module 'ItemHistoryCommandSetStrings' {
|
||||
const strings: IItemHistoryCommandSetStrings;
|
||||
export = strings;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "commonjs",
|
||||
"jsx": "react",
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"experimentalDecorators": true,
|
||||
"skipLibCheck": true,
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./node_modules/@microsoft"
|
||||
],
|
||||
"types": [
|
||||
"es6-promise",
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
|
||||
[*]
|
||||
|
||||
# change these settings to your own preference
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# we recommend you to keep these unchanged
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[{package,bower}.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
|
@ -0,0 +1,32 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
|
||||
# Build generated files
|
||||
dist
|
||||
lib
|
||||
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
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"@microsoft/generator-sharepoint": {
|
||||
"isCreatingSolution": true,
|
||||
"environment": "spo",
|
||||
"version": "1.6.0",
|
||||
"libraryName": "react-related-items",
|
||||
"libraryId": "53f15df0-a022-4c53-91f7-dc9b33371eb5",
|
||||
"packageManager": "npm",
|
||||
"componentType": "webpart"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -0,0 +1,26 @@
|
|||
## react-related-items
|
||||
|
||||
This is where you include your WebPart documentation.
|
||||
|
||||
### Building the code
|
||||
|
||||
```bash
|
||||
git clone the repo
|
||||
npm i
|
||||
npm i -g gulp
|
||||
gulp
|
||||
```
|
||||
|
||||
This package produces the following:
|
||||
|
||||
* lib/* - intermediate-stage commonjs build artifacts
|
||||
* dist/* - the bundled script, along with other resources
|
||||
* deploy/* - all resources which should be uploaded to a CDN.
|
||||
|
||||
### Build options
|
||||
|
||||
gulp clean - TODO
|
||||
gulp test - TODO
|
||||
gulp serve - TODO
|
||||
gulp bundle - TODO
|
||||
gulp package-solution - TODO
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||
"version": "2.0",
|
||||
"bundles": {
|
||||
"react-related-items-web-part": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/webparts/reactRelatedItems/ReactRelatedItemsWebPart.js",
|
||||
"manifest": "./src/webparts/reactRelatedItems/ReactRelatedItemsWebPart.manifest.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"externals": {},
|
||||
"localizedResources": {
|
||||
"ReactRelatedItemsWebPartStrings": "lib/webparts/reactRelatedItems/loc/{locale}.js"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
|
||||
"deployCdnPath": "temp/deploy"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./temp/deploy/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "react-related-items",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||
"solution": {
|
||||
"name": "react-related-items-client-side-solution",
|
||||
"id": "53f15df0-a022-4c53-91f7-dc9b33371eb5",
|
||||
"version": "1.0.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"skipFeatureDeployment": true
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/react-related-items.sppkg"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
|
||||
"port": 4321,
|
||||
"https": true,
|
||||
"initialPage": "https://localhost:5432/workbench",
|
||||
"api": {
|
||||
"port": 5432,
|
||||
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const gulp = require('gulp');
|
||||
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.`);
|
||||
|
||||
build.initialize(gulp);
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"name": "react-related-items",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
"clean": "gulp clean",
|
||||
"test": "gulp test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/sp-core-library": "1.6.0",
|
||||
"@microsoft/sp-lodash-subset": "1.6.0",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.6.0",
|
||||
"@microsoft/sp-webpart-base": "1.6.0",
|
||||
"@pnp/common": "1.2.4",
|
||||
"@pnp/logging": "1.2.4",
|
||||
"@pnp/odata": "1.2.4",
|
||||
"@pnp/sp": "1.2.4",
|
||||
"@types/es6-promise": "0.0.33",
|
||||
"@types/react": "15.6.6",
|
||||
"@types/react-dom": "15.5.6",
|
||||
"@types/webpack-env": "1.13.1",
|
||||
"react": "15.6.2",
|
||||
"react-dom": "15.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/sp-build-web": "1.6.0",
|
||||
"@microsoft/sp-module-interfaces": "1.6.0",
|
||||
"@microsoft/sp-webpart-workbench": "1.6.0",
|
||||
"tslint-microsoft-contrib": "~5.0.0",
|
||||
"gulp": "~3.9.1",
|
||||
"@types/chai": "3.4.34",
|
||||
"@types/mocha": "2.2.38",
|
||||
"ajv": "~5.2.2"
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||
"id": "f4c39319-e77d-4e69-805f-7893d0fbd2b3",
|
||||
"alias": "ReactRelatedItemsWebPart",
|
||||
"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,
|
||||
|
||||
"preconfiguredEntries": [{
|
||||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
|
||||
"group": { "default": "Other" },
|
||||
"title": { "default": "react-related-items" },
|
||||
"description": { "default": "Webpart to display related items on a task edit form." },
|
||||
"officeFabricIconFontName": "Page",
|
||||
"properties": {
|
||||
"fieldInternalName": "RelatedItems"
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
import { Version, UrlQueryParameterCollection } from '@microsoft/sp-core-library';
|
||||
import {
|
||||
BaseClientSideWebPart,
|
||||
IPropertyPaneConfiguration,
|
||||
PropertyPaneTextField
|
||||
} from '@microsoft/sp-webpart-base';
|
||||
|
||||
import * as strings from 'ReactRelatedItemsWebPartStrings';
|
||||
import ReactRelatedItems from './components/ReactRelatedItems';
|
||||
import { IReactRelatedItemsProps } from './components/IReactRelatedItemsProps';
|
||||
|
||||
|
||||
import { SPListItem, SPList } from '@microsoft/sp-page-context';
|
||||
import { sp, OpenWebByIdResult } from "@pnp/sp";
|
||||
|
||||
export interface IReactRelatedItemsWebPartProps {
|
||||
fieldInternalName: string;
|
||||
}
|
||||
|
||||
export default class ReactRelatedItemsWebPart extends BaseClientSideWebPart<IReactRelatedItemsWebPartProps> {
|
||||
|
||||
private _docTitle : string;
|
||||
public get docTitle() : string {
|
||||
return this._docTitle;
|
||||
}
|
||||
public set docTitle(v : string) {
|
||||
this._docTitle = v;
|
||||
}
|
||||
|
||||
|
||||
private _docUrl : string;
|
||||
public get docUrl() : string {
|
||||
return this._docUrl;
|
||||
}
|
||||
public set docUrl(v : string) {
|
||||
this._docUrl = v;
|
||||
}
|
||||
|
||||
public onInit(): Promise<void> {
|
||||
|
||||
debugger;
|
||||
const webpart=this;
|
||||
return super.onInit()
|
||||
.then(_ => {
|
||||
|
||||
sp.setup({
|
||||
spfxContext: this.context
|
||||
});
|
||||
var list: SPList = this.context.pageContext.list;
|
||||
var queryParameters = new UrlQueryParameterCollection(window.location.href);
|
||||
const id: number = parseInt(queryParameters.getValue("ID"));
|
||||
return sp.web.lists.getById(list.id.toString()).items.getById(id).expand("File").get()
|
||||
.then((task) => {
|
||||
//"[{"ItemId":6209,"WebId":"346b0229-1468-4344-8701-b2b300e5dbe1","ListId":"cfe9f983-f972-406d-840d-ac981a305ad7"}]"
|
||||
let relatedItems = JSON.parse(task[webpart.properties.fieldInternalName]);
|
||||
debugger;
|
||||
|
||||
let relatedItemID: number = relatedItems[0]["ItemId"];
|
||||
let relatedItemListId: string = relatedItems[0]["ListId"];
|
||||
let relatedItemWebId: string = relatedItems[0]["WebId"];
|
||||
return sp.site.openWebById(relatedItemWebId)
|
||||
.then((results: OpenWebByIdResult) => {
|
||||
debugger;
|
||||
return results.web.lists.getById(relatedItemListId).items.getById(relatedItemID).expand("File").get()
|
||||
.then((item) => {
|
||||
this.docTitle= item.File["Title"];
|
||||
this.docUrl= item.File["LinkingUrl"];
|
||||
debugger;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log("error getting item");
|
||||
debugger;
|
||||
});
|
||||
|
||||
})
|
||||
.catch((err) => {
|
||||
debugger;
|
||||
console.log(`Error openning web with id ${relatedItemWebId}`);
|
||||
});
|
||||
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(`Error fetching task. Task ID is ${id}. List ID is ${list.id.toString()}`);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
public render(): void {
|
||||
const element: React.ReactElement<IReactRelatedItemsProps > = React.createElement(
|
||||
ReactRelatedItems,
|
||||
{
|
||||
title: this.docTitle,
|
||||
url:this.docUrl,
|
||||
}
|
||||
);
|
||||
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export interface IReactRelatedItemsProps {
|
||||
title: string;
|
||||
url: string;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
|
||||
|
||||
.reactRelatedItems {
|
||||
.container {
|
||||
max-width: 700px;
|
||||
margin: 0px auto;
|
||||
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.row {
|
||||
@include ms-Grid-row;
|
||||
@include ms-fontColor-white;
|
||||
background-color: $ms-color-themeDark;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.column {
|
||||
@include ms-Grid-col;
|
||||
@include ms-lg10;
|
||||
@include ms-xl8;
|
||||
@include ms-xlPush2;
|
||||
@include ms-lgPush1;
|
||||
}
|
||||
|
||||
.title {
|
||||
@include ms-font-xl;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.subTitle {
|
||||
@include ms-font-l;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.description {
|
||||
@include ms-font-l;
|
||||
@include ms-fontColor-white;
|
||||
}
|
||||
|
||||
.button {
|
||||
// Our button
|
||||
text-decoration: none;
|
||||
height: 32px;
|
||||
|
||||
// Primary Button
|
||||
min-width: 80px;
|
||||
background-color: $ms-color-themePrimary;
|
||||
border-color: $ms-color-themePrimary;
|
||||
color: $ms-color-white;
|
||||
|
||||
// Basic Button
|
||||
outline: transparent;
|
||||
position: relative;
|
||||
font-family: "Segoe UI WestEuropean","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-size: $ms-font-size-m;
|
||||
font-weight: $ms-font-weight-regular;
|
||||
border-width: 0;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
padding: 0 16px;
|
||||
|
||||
.label {
|
||||
font-weight: $ms-font-weight-semibold;
|
||||
font-size: $ms-font-size-m;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
margin: 0 4px;
|
||||
vertical-align: top;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
import * as React from 'react';
|
||||
import styles from './ReactRelatedItems.module.scss';
|
||||
import { IReactRelatedItemsProps } from './IReactRelatedItemsProps';
|
||||
import { escape } from '@microsoft/sp-lodash-subset';
|
||||
|
||||
import { Link } from 'office-ui-fabric-react/lib/Link';
|
||||
import { Label } from 'office-ui-fabric-react/lib/Label';
|
||||
|
||||
export default class ReactRelatedItems extends React.Component<IReactRelatedItemsProps, {}> {
|
||||
public render(): React.ReactElement<IReactRelatedItemsProps> {
|
||||
return (
|
||||
<div className={styles.reactRelatedItems}>
|
||||
|
||||
<Link href={this.props.url}>
|
||||
<Label>
|
||||
Related Item :
|
||||
|
||||
</Label>
|
||||
{this.props.title}
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
define([], function() {
|
||||
return {
|
||||
"PropertyPaneDescription": "Description",
|
||||
"BasicGroupName": "Group Name",
|
||||
"DescriptionFieldLabel": "Description Field"
|
||||
}
|
||||
});
|
10
samples/react-related-items/src/webparts/reactRelatedItems/loc/mystrings.d.ts
vendored
Normal file
10
samples/react-related-items/src/webparts/reactRelatedItems/loc/mystrings.d.ts
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
declare interface IReactRelatedItemsWebPartStrings {
|
||||
PropertyPaneDescription: string;
|
||||
BasicGroupName: string;
|
||||
DescriptionFieldLabel: string;
|
||||
}
|
||||
|
||||
declare module 'ReactRelatedItemsWebPartStrings' {
|
||||
const strings: IReactRelatedItemsWebPartStrings;
|
||||
export = strings;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"jsx": "react",
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"experimentalDecorators": true,
|
||||
"skipLibCheck": true,
|
||||
"outDir": "lib",
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./node_modules/@microsoft"
|
||||
],
|
||||
"types": [
|
||||
"es6-promise",
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"lib"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"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…
Reference in New Issue