Refresh tutorial for jQuery datatables

This commit is contained in:
Andrew Connell 2020-06-28 11:02:27 -04:00
parent ea21470dcd
commit d85c6182e7
95 changed files with 51596 additions and 28380 deletions

View File

@ -1,14 +0,0 @@
# Folders
.vscode
coverage
node_modules
sharepoint
src
temp
# Files
*.csproj
.git*
.yo-rc.json
gulpfile.js
tsconfig.json

View File

@ -1,8 +1,12 @@
{ {
"@microsoft/generator-sharepoint": { "@microsoft/generator-sharepoint": {
"libraryName": "spfx-js-datatables", "isCreatingSolution": true,
"framework": "none", "environment": "spo",
"version": "1.0.2", "version": "1.10.0",
"libraryId": "1e1ac667-cac9-4a86-97fb-f5abda8a8926" "libraryName": "datatables-itrequests",
"libraryId": "6c467145-feee-4d44-beb3-0e995e266dd0",
"packageManager": "npm",
"isDomainIsolated": false,
"componentType": "webpart"
} }
} }

View File

@ -1,18 +1,26 @@
# Tutorial: Migrate jQuery and DataTables solution built using Script Editor Web Part to SharePoint Framework ## datatables-itrequests
Sample jQuery DataTables solution migrated from a Script Editor Web Part to the SharePoint Framework. This is where you include your WebPart documentation.
![jQuery DataTables solution built using Script Editor Web Part](https://devofficecdn.azureedge.net/sharepointdocumentation/images/datatables-sewp.png) ### Building the code
More information about the solution is available at [https://docs.microsoft.com/sharepoint/dev/spfx/web-parts/guidance/migrate-jquery-datatables-script-to-spfx](https://docs.microsoft.com/sharepoint/dev/spfx/web-parts/guidance/migrate-jquery-datatables-script-to-spfx). ```bash
git clone the repo
## Minimal Path to Awesome npm i
npm i -g gulp
- In the command line run: gulp
- `npm i` ```
- `gulp serve --nobrowser`
- In the web browser navigate to the hosted version of the SharePoint workbench located in the same site as where the Tasks list is, eg. *https://contoso.sharepoint.com/sites/team/_layouts/15/workbench.aspx*. This package produces the following:
[More information](../README.md) * lib/* - intermediate-stage commonjs build artifacts
* dist/* - the bundled script, along with other resources
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/tutorial-migrate-datatables/01" /> * 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

View File

@ -1,17 +1,31 @@
{ {
"entries": [ "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
{ "version": "2.0",
"entry": "./lib/webparts/itRequests/ItRequestsWebPart.js", "bundles": {
"manifest": "./src/webparts/itRequests/ItRequestsWebPart.manifest.json", "it-requests-web-part": {
"outputPath": "./dist/it-requests.bundle.js" "components": [
{
"entrypoint": "./lib/webparts/itRequests/ItRequestsWebPart.js",
"manifest": "./src/webparts/itRequests/ItRequestsWebPart.manifest.json"
}
]
} }
], },
"externals": { "externals": {
"jquery": "https://code.jquery.com/jquery-1.12.4.min.js", "jquery": {
"datatables.net": "https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js", "path": "https://code.jquery.com/jquery-1.12.4.min.js",
"moment": "https://momentjs.com/downloads/moment.min.js" "globalName": "jQuery"
},
"datatables.net": {
"path": "https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js",
"globalName": "jQuery",
"globalDependencies": [
"jquery"
]
},
"moment": "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment.min.js"
}, },
"localizedResources": { "localizedResources": {
"itRequestsStrings": "webparts/itRequests/loc/{locale}.js" "ItRequestsWebPartStrings": "lib/webparts/itRequests/loc/{locale}.js"
} }
} }

View File

@ -1,3 +1,4 @@
{ {
"deployCdnPath": "temp/deploy" "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
} "deployCdnPath": "temp/deploy"
}

View File

@ -1,6 +1,7 @@
{ {
"workingDir": "./temp/deploy/", "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"account": "<!-- STORAGE ACCOUNT NAME -->", "workingDir": "./temp/deploy/",
"container": "spfx-js-datatables", "account": "<!-- STORAGE ACCOUNT NAME -->",
"accessKey": "<!-- ACCESS KEY -->" "container": "datatables-itrequests",
"accessKey": "<!-- ACCESS KEY -->"
} }

View File

@ -1,10 +1,13 @@
{ {
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": { "solution": {
"name": "spfx-js-datatables-client-side-solution", "name": "datatables-itrequests-client-side-solution",
"id": "1e1ac667-cac9-4a86-97fb-f5abda8a8926", "id": "6c467145-feee-4d44-beb3-0e995e266dd0",
"version": "1.0.0.0" "version": "1.0.0.0",
"includeClientSideAssets": true,
"isDomainIsolated": false
}, },
"paths": { "paths": {
"zippedPackage": "solution/spfx-js-datatables.sppkg" "zippedPackage": "solution/datatables-itrequests.sppkg"
} }
} }

View File

@ -1,7 +1,8 @@
{ {
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
"port": 4321, "port": 4321,
"initialPage": "https://localhost:5432/workbench",
"https": true, "https": true,
"initialPage": "https://localhost:5432/workbench",
"api": { "api": {
"port": 5432, "port": 5432,
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/" "entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"

View File

@ -1,45 +0,0 @@
{
// 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-unused-imports": 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
}
}
}

View File

@ -1,3 +1,4 @@
{ {
"cdnBasePath": "<!-- PATH TO CDN -->" "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->"
} }

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
const gulp = require('gulp'); const build = require('@microsoft/sp-build-web');
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);
build.initialize(require('gulp'));

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,34 @@
{ {
"name": "spfx-js-datatables", "name": "datatables-itrequests",
"version": "0.0.1", "version": "0.0.1",
"private": true, "private": true,
"main": "lib/index.js",
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
}, },
"author": {
"name": "Waldek Mastykarz",
"url": "https://blog.mastykarz.nl"
},
"dependencies": {
"@microsoft/sp-client-base": "~1.0.0",
"@microsoft/sp-core-library": "~1.0.0",
"@microsoft/sp-webpart-base": "~1.0.0",
"@types/webpack-env": ">=1.12.1 <1.14.0"
},
"devDependencies": {
"@microsoft/sp-build-web": "~1.0.1",
"@microsoft/sp-module-interfaces": "~1.0.0",
"@microsoft/sp-webpart-workbench": "~1.0.0",
"gulp": "~3.9.1",
"@types/chai": ">=3.4.34 <3.6.0",
"@types/mocha": ">=2.2.33 <2.6.0"
},
"scripts": { "scripts": {
"build": "gulp bundle", "build": "gulp bundle",
"clean": "gulp clean", "clean": "gulp clean",
"test": "gulp test" "test": "gulp test"
},
"dependencies": {
"@microsoft/sp-core-library": "1.10.0",
"@microsoft/sp-property-pane": "1.10.0",
"@microsoft/sp-webpart-base": "1.10.0",
"@microsoft/sp-lodash-subset": "1.10.0",
"@microsoft/sp-office-ui-fabric-core": "1.10.0",
"@types/webpack-env": "1.13.1",
"@types/es6-promise": "0.0.33"
},
"devDependencies": {
"@microsoft/sp-build-web": "1.10.0",
"@microsoft/sp-tslint-rules": "1.10.0",
"@microsoft/sp-module-interfaces": "1.10.0",
"@microsoft/sp-webpart-workbench": "1.10.0",
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
"gulp": "~3.9.1",
"@types/chai": "3.4.34",
"@types/mocha": "2.2.38",
"ajv": "~5.2.2"
} }
} }

View File

@ -0,0 +1 @@
// A file is required to be in the root of the /src directory by the TypeScript compiler

View File

@ -1,3 +0,0 @@
export interface IItRequestsWebPartProps {
description: string;
}

View File

@ -1,52 +0,0 @@
.helloWorld {
.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 {
padding: 20px;
}
.listItem {
max-width: 715px;
margin: 5px auto 5px auto;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
}
.button {
// Our button
text-decoration: none;
height: 32px;
// Primary Button
min-width: 80px;
background-color: #0078d7;
border-color: #0078d7;
color: #ffffff;
// 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: 14px;
font-weight: 400;
border-width: 0;
text-align: center;
cursor: pointer;
display: inline-block;
padding: 0 16px;
.label {
font-weight: 600;
font-size: 14px;
height: 32px;
line-height: 32px;
margin: 0 4px;
vertical-align: top;
display: inline-block;
}
}
}

View File

@ -1,20 +1,27 @@
{ {
"$schema": "../../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json", "$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "25895f30-c41d-4c63-ad83-93570fae720c",
"id": "61119bb3-fa48-4ded-bde9-6593ed155cbb", "alias": "ItRequestsWebPart",
"alias": "ItRequestsWebPart", "componentType": "WebPart",
"componentType": "WebPart",
"version": "0.0.1", // The "*" signifies that the version should be taken from the package.json
"manifestVersion": 2, "version": "*",
"manifestVersion": 2,
"preconfiguredEntries": [{
"groupId": "61119bb3-fa48-4ded-bde9-6593ed155cbb", // If true, the component can only be installed on sites where Custom Script is allowed.
"group": { "default": "Under Development" }, // Components that allow authors to embed arbitrary script code should set this to true.
"title": { "default": "IT Requests" }, // https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
"description": { "default": "Shows list of IT requests" }, "requiresCustomScript": false,
"officeFabricIconFontName": "Page", "supportedHosts": ["SharePointWebPart"],
"properties": {
"description": "IT Requests" "preconfiguredEntries": [{
} "groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
}] "group": { "default": "Other" },
} "title": { "default": "IT requests" },
"description": { "default": "Shows overview of IT support requests" },
"officeFabricIconFontName": "Page",
"properties": {
"description": "Hello World"
}
}]
}

View File

@ -0,0 +1,74 @@
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
.itRequests {
.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;
}
}
}

View File

@ -1,63 +1,67 @@
import { Version } from '@microsoft/sp-core-library'; import { Version } from '@microsoft/sp-core-library';
import { import {
BaseClientSideWebPart, IPropertyPaneConfiguration,
IPropertyPaneConfiguration, PropertyPaneTextField
PropertyPaneTextField } from '@microsoft/sp-property-pane';
} from '@microsoft/sp-webpart-base'; import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import { escape } from '@microsoft/sp-lodash-subset';
import styles from './ItRequests.module.scss';
import * as strings from 'itRequestsStrings'; import styles from './ItRequestsWebPart.module.scss';
import { IItRequestsWebPartProps } from './IItRequestsWebPartProps'; import * as strings from 'ItRequestsWebPartStrings';
import 'jquery'; import 'jquery';
import 'datatables.net'; import 'datatables.net';
import 'moment'; import 'moment';
import './moment-plugin'; import './moment-plugin';
export default class ItRequestsWebPart extends BaseClientSideWebPart<IItRequestsWebPartProps> { export interface IItRequestsWebPartProps {
description: string;
public render(): void { }
this.domElement.innerHTML = `
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css" /> export default class ItRequestsWebPart extends BaseClientSideWebPart<IItRequestsWebPartProps> {
<table id="requests" class="display ${styles.helloWorld}" cellspacing="0" width="100%">
<thead> public render(): void {
<tr> this.domElement.innerHTML = `
<th>ID</th> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css" />
<th>Business unit</th> <table id="requests" class="display ${styles.itRequests}" cellspacing="0" width="100%">
<th>Category</th> <thead>
<th>Status</th> <tr>
<th>Due date</th> <th>ID</th>
<th>Assigned to</th> <th>Business unit</th>
</tr> <th>Category</th>
</thead> <th>Status</th>
</table>`; <th>Due date</th>
<th>Assigned to</th>
require('./script'); </tr>
} </thead>
</table>`;
protected get dataVersion(): Version {
return Version.parse('1.0'); require('./script');
} }
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration { protected get dataVersion(): Version {
return { return Version.parse('1.0');
pages: [ }
{
header: { protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
description: strings.PropertyPaneDescription return {
}, pages: [
groups: [ {
{ header: {
groupName: strings.BasicGroupName, description: strings.PropertyPaneDescription
groupFields: [ },
PropertyPaneTextField('description', { groups: [
label: strings.DescriptionFieldLabel {
}) groupName: strings.BasicGroupName,
] groupFields: [
} PropertyPaneTextField('description', {
] label: strings.DescriptionFieldLabel
} })
] ]
}; }
} ]
} }
]
};
}
}

View File

@ -1,7 +1,7 @@
define([], function() { define([], function() {
return { return {
"PropertyPaneDescription": "Description", "PropertyPaneDescription": "Description",
"BasicGroupName": "Group Name", "BasicGroupName": "Group Name",
"DescriptionFieldLabel": "Description Field" "DescriptionFieldLabel": "Description Field"
} }
}); });

View File

@ -1,10 +1,10 @@
declare interface IItRequestsStrings { declare interface IItRequestsWebPartStrings {
PropertyPaneDescription: string; PropertyPaneDescription: string;
BasicGroupName: string; BasicGroupName: string;
DescriptionFieldLabel: string; DescriptionFieldLabel: string;
} }
declare module 'itRequestsStrings' { declare module 'ItRequestsWebPartStrings' {
const strings: IItRequestsStrings; const strings: IItRequestsWebPartStrings;
export = strings; export = strings;
} }

View File

@ -1,54 +1,53 @@
// UMD // UMD
(function (factory) { (
function (factory) {
"use strict"; "use strict";
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// AMD // AMD
define(['jquery'], function ($) { define(['jquery'], function ($) {
return factory($, window, document); return factory($, window, document);
}); });
} } else if (typeof exports === 'object') {
else if (typeof exports === 'object') { // CommonJS
// CommonJS module.exports = function (root, $) {
module.exports = function (root, $) { if (!root) {
if (!root) { root = window;
root = window; }
}
if (!$) { if (!$) {
$ = typeof window !== 'undefined' ? $ = typeof window !== 'undefined'
require('jquery') : ? require('jquery')
require('jquery')(root); : require('jquery')(root);
} }
return factory($, root, root.document); return factory($, root, root.document);
}; };
} else {
// Browser
factory(jQuery, window, document);
} }
else { }
// Browser
factory(jQuery, window, document);
}
}
(function ($, window, document) { (function ($, window, document) {
$.fn.dataTable.render.moment = function (from, to, locale) { $.fn.dataTable.render.moment = function (from, to, locale) {
// Argument shifting // Argument shifting
if (arguments.length === 1) { if (arguments.length === 1) {
locale = 'en'; locale = 'en';
to = from; to = from;
from = 'YYYY-MM-DD'; from = 'YYYY-MM-DD';
} } else if (arguments.length === 2) {
else if (arguments.length === 2) { locale = 'en';
locale = 'en'; }
}
return function (d, type, row) { return function (d, type, row) {
var moment = require('moment'); var moment = require('moment');
var m = moment(d, from, locale, true); var m = moment(d, from, locale, true);
// Order and type get a number value from Moment, everything else // Order and type get a number value from Moment, everything else
// sees the rendered value // sees the rendered value
return m.format(type === 'sort' || type === 'type' ? 'x' : to); return m.format(type === 'sort' || type === 'type' ? 'x' : to);
}; };
}; };
})); })
);

View File

@ -1,24 +1,24 @@
$(document).ready(function () { $(document).ready(function () {
$('#requests').DataTable({ $('#requests').DataTable({
'ajax': { 'ajax': {
'url': "../../_api/web/lists/getbytitle('IT Requests')/items?$select=ID,BusinessUnit,Category,Status,DueDate,AssignedTo/Title&$expand=AssignedTo/Title", 'url': "../../_api/web/lists/getbytitle('IT Requests')/items?$select=ID,BusinessUnit,Category,Status,DueDate,AssignedTo/Title&$expand=AssignedTo/Title",
'headers': { 'Accept': 'application/json;odata=nometadata' }, 'headers': { 'Accept': 'application/json;odata=nometadata' },
'dataSrc': function (data) { 'dataSrc': function (data) {
return data.value.map(function (item) { return data.value.map(function (item) {
return [ return [
item.ID, item.ID,
item.BusinessUnit, item.BusinessUnit,
item.Category, item.Category,
item.Status, item.Status,
new Date(item.DueDate), new Date(item.DueDate),
item.AssignedTo.Title item.AssignedTo.Title
]; ];
}); });
} }
}, },
columnDefs: [{ columnDefs: [{
targets: 4, targets: 4,
render: $.fn.dataTable.render.moment('YYYY/MM/DD') render: $.fn.dataTable.render.moment('YYYY/MM/DD')
}] }]
}); });
}); });

View File

@ -1,9 +0,0 @@
/// <reference types="mocha" />
import { assert } from 'chai';
describe('ItRequestsWebPart', () => {
it('should do something', () => {
assert.ok(true);
});
});

View File

@ -1,15 +1,38 @@
{ {
"compilerOptions": { "extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json",
"target": "es5", "compilerOptions": {
"forceConsistentCasingInFileNames": true, "target": "es5",
"module": "commonjs", "forceConsistentCasingInFileNames": true,
"jsx": "react", "module": "esnext",
"declaration": true, "moduleResolution": "node",
"sourceMap": true, "jsx": "react",
"types": [ "declaration": true,
"es6-promise", "sourceMap": true,
"es6-collections", "experimentalDecorators": true,
"webpack-env" "skipLibCheck": true,
] "outDir": "lib",
} "inlineSources": false,
} "strictNullChecks": false,
"noUnusedLocals": false,
"typeRoots": [
"./node_modules/@types",
"./node_modules/@microsoft"
],
"types": [
"es6-promise",
"webpack-env"
],
"lib": [
"es5",
"dom",
"es2015.collection"
]
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
"lib"
]
}

View File

@ -1,3 +1,30 @@
{ {
"rulesDirectory": "./config" "extends": "@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-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
}
} }

View File

@ -1,8 +0,0 @@
// Type definitions for Microsoft ODSP projects
// Project: ODSP
/* Global definition for UNIT_TEST builds
Code that is wrapped inside an if(UNIT_TEST) {...}
block will not be included in the final bundle when the
--ship flag is specified */
declare const UNIT_TEST: boolean;

View File

@ -1 +0,0 @@
/// <reference path="@ms/odsp.d.ts" />

View File

@ -1,14 +0,0 @@
# Folders
.vscode
coverage
node_modules
sharepoint
src
temp
# Files
*.csproj
.git*
.yo-rc.json
gulpfile.js
tsconfig.json

View File

@ -1,8 +1,12 @@
{ {
"@microsoft/generator-sharepoint": { "@microsoft/generator-sharepoint": {
"libraryName": "spfx-js-datatables", "isCreatingSolution": true,
"framework": "none", "environment": "spo",
"version": "1.0.2", "version": "1.10.0",
"libraryId": "1e1ac667-cac9-4a86-97fb-f5abda8a8926" "libraryName": "datatables-itrequests",
"libraryId": "6c467145-feee-4d44-beb3-0e995e266dd0",
"packageManager": "npm",
"isDomainIsolated": false,
"componentType": "webpart"
} }
} }

View File

@ -1,18 +1,26 @@
# Tutorial: Migrate jQuery and DataTables solution built using Script Editor Web Part to SharePoint Framework ## datatables-itrequests
Sample jQuery DataTables solution migrated from a Script Editor Web Part to the SharePoint Framework. This is where you include your WebPart documentation.
![jQuery DataTables solution built using Script Editor Web Part](https://devofficecdn.azureedge.net/sharepointdocumentation/images/datatables-sewp.png) ### Building the code
More information about the solution is available at [https://docs.microsoft.com/sharepoint/dev/spfx/web-parts/guidance/migrate-jquery-datatables-script-to-spfx](https://docs.microsoft.com/sharepoint/dev/spfx/web-parts/guidance/migrate-jquery-datatables-script-to-spfx). ```bash
git clone the repo
## Minimal Path to Awesome npm i
npm i -g gulp
- In the command line run: gulp
- `npm i` ```
- `gulp serve --nobrowser`
- In the web browser navigate to the hosted version of the SharePoint workbench located in the same site as where the Tasks list is, eg. *https://contoso.sharepoint.com/sites/team/_layouts/15/workbench.aspx*. This package produces the following:
[More information](../README.md) * lib/* - intermediate-stage commonjs build artifacts
* dist/* - the bundled script, along with other resources
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/tutorial-migrate-datatables/02" /> * 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

View File

@ -1,17 +1,31 @@
{ {
"entries": [ "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
{ "version": "2.0",
"entry": "./lib/webparts/itRequests/ItRequestsWebPart.js", "bundles": {
"manifest": "./src/webparts/itRequests/ItRequestsWebPart.manifest.json", "it-requests-web-part": {
"outputPath": "./dist/it-requests.bundle.js" "components": [
{
"entrypoint": "./lib/webparts/itRequests/ItRequestsWebPart.js",
"manifest": "./src/webparts/itRequests/ItRequestsWebPart.manifest.json"
}
]
} }
], },
"externals": { "externals": {
"jquery": "https://code.jquery.com/jquery-1.12.4.min.js", "jquery": {
"datatables.net": "https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js", "path": "https://code.jquery.com/jquery-1.12.4.min.js",
"moment": "https://momentjs.com/downloads/moment.min.js" "globalName": "jQuery"
},
"datatables.net": {
"path": "https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js",
"globalName": "jQuery",
"globalDependencies": [
"jquery"
]
},
"moment": "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment.min.js"
}, },
"localizedResources": { "localizedResources": {
"itRequestsStrings": "webparts/itRequests/loc/{locale}.js" "ItRequestsWebPartStrings": "lib/webparts/itRequests/loc/{locale}.js"
} }
} }

View File

@ -1,3 +1,4 @@
{ {
"deployCdnPath": "temp/deploy" "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
} "deployCdnPath": "temp/deploy"
}

View File

@ -1,6 +1,7 @@
{ {
"workingDir": "./temp/deploy/", "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"account": "<!-- STORAGE ACCOUNT NAME -->", "workingDir": "./temp/deploy/",
"container": "spfx-js-datatables", "account": "<!-- STORAGE ACCOUNT NAME -->",
"accessKey": "<!-- ACCESS KEY -->" "container": "datatables-itrequests",
"accessKey": "<!-- ACCESS KEY -->"
} }

View File

@ -1,10 +1,13 @@
{ {
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": { "solution": {
"name": "spfx-js-datatables-client-side-solution", "name": "datatables-itrequests-client-side-solution",
"id": "1e1ac667-cac9-4a86-97fb-f5abda8a8926", "id": "6c467145-feee-4d44-beb3-0e995e266dd0",
"version": "1.0.0.0" "version": "1.0.0.0",
"includeClientSideAssets": true,
"isDomainIsolated": false
}, },
"paths": { "paths": {
"zippedPackage": "solution/spfx-js-datatables.sppkg" "zippedPackage": "solution/datatables-itrequests.sppkg"
} }
} }

View File

@ -1,7 +1,8 @@
{ {
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
"port": 4321, "port": 4321,
"initialPage": "https://localhost:5432/workbench",
"https": true, "https": true,
"initialPage": "https://localhost:5432/workbench",
"api": { "api": {
"port": 5432, "port": 5432,
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/" "entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"

View File

@ -1,45 +0,0 @@
{
// 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-unused-imports": 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
}
}
}

View File

@ -1,3 +1,4 @@
{ {
"cdnBasePath": "<!-- PATH TO CDN -->" "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->"
} }

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
const gulp = require('gulp'); const build = require('@microsoft/sp-build-web');
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);
build.initialize(require('gulp'));

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +1,34 @@
{ {
"name": "spfx-js-datatables", "name": "datatables-itrequests",
"version": "0.0.1", "version": "0.0.1",
"private": true, "private": true,
"main": "lib/index.js",
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
}, },
"author": {
"name": "Waldek Mastykarz",
"url": "https://blog.mastykarz.nl"
},
"dependencies": {
"@microsoft/sp-client-base": "~1.0.0",
"@microsoft/sp-core-library": "~1.0.0",
"@microsoft/sp-webpart-base": "~1.0.0",
"@types/webpack-env": ">=1.12.1 <1.14.0"
},
"devDependencies": {
"@microsoft/sp-build-web": "~1.0.1",
"@microsoft/sp-module-interfaces": "~1.0.0",
"@microsoft/sp-webpart-workbench": "~1.0.0",
"gulp": "~3.9.1",
"@types/chai": ">=3.4.34 <3.6.0",
"@types/mocha": ">=2.2.33 <2.6.0"
},
"scripts": { "scripts": {
"build": "gulp bundle", "build": "gulp bundle",
"clean": "gulp clean", "clean": "gulp clean",
"test": "gulp test" "test": "gulp test"
},
"dependencies": {
"@microsoft/sp-core-library": "1.10.0",
"@microsoft/sp-property-pane": "1.10.0",
"@microsoft/sp-webpart-base": "1.10.0",
"@microsoft/sp-lodash-subset": "1.10.0",
"@microsoft/sp-office-ui-fabric-core": "1.10.0",
"@types/webpack-env": "1.13.1",
"@types/es6-promise": "0.0.33"
},
"devDependencies": {
"@microsoft/sp-build-web": "1.10.0",
"@microsoft/sp-tslint-rules": "1.10.0",
"@microsoft/sp-module-interfaces": "1.10.0",
"@microsoft/sp-webpart-workbench": "1.10.0",
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
"gulp": "~3.9.1",
"@types/chai": "3.4.34",
"@types/mocha": "2.2.38",
"ajv": "~5.2.2"
} }
} }

View File

@ -0,0 +1 @@
// A file is required to be in the root of the /src directory by the TypeScript compiler

View File

@ -1,3 +0,0 @@
export interface IItRequestsWebPartProps {
listName: string;
}

View File

@ -1,52 +0,0 @@
.helloWorld {
.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 {
padding: 20px;
}
.listItem {
max-width: 715px;
margin: 5px auto 5px auto;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
}
.button {
// Our button
text-decoration: none;
height: 32px;
// Primary Button
min-width: 80px;
background-color: #0078d7;
border-color: #0078d7;
color: #ffffff;
// 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: 14px;
font-weight: 400;
border-width: 0;
text-align: center;
cursor: pointer;
display: inline-block;
padding: 0 16px;
.label {
font-weight: 600;
font-size: 14px;
height: 32px;
line-height: 32px;
margin: 0 4px;
vertical-align: top;
display: inline-block;
}
}
}

View File

@ -1,20 +1,27 @@
{ {
"$schema": "../../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json", "$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "25895f30-c41d-4c63-ad83-93570fae720c",
"id": "61119bb3-fa48-4ded-bde9-6593ed155cbb", "alias": "ItRequestsWebPart",
"alias": "ItRequestsWebPart", "componentType": "WebPart",
"componentType": "WebPart",
"version": "0.0.1", // The "*" signifies that the version should be taken from the package.json
"manifestVersion": 2, "version": "*",
"manifestVersion": 2,
"preconfiguredEntries": [{
"groupId": "61119bb3-fa48-4ded-bde9-6593ed155cbb", // If true, the component can only be installed on sites where Custom Script is allowed.
"group": { "default": "Under Development" }, // Components that allow authors to embed arbitrary script code should set this to true.
"title": { "default": "IT Requests" }, // https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
"description": { "default": "Shows list of IT requests" }, "requiresCustomScript": false,
"officeFabricIconFontName": "Page", "supportedHosts": ["SharePointWebPart"],
"properties": {
"listName": "IT Requests" "preconfiguredEntries": [{
} "groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
}] "group": { "default": "Other" },
} "title": { "default": "IT requests" },
"description": { "default": "Shows overview of IT support requests" },
"officeFabricIconFontName": "Page",
"properties": {
"listName": "IT requests"
}
}]
}

View File

@ -0,0 +1,74 @@
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
.itRequests {
.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;
}
}
}

View File

@ -1,93 +1,96 @@
import { Version } from '@microsoft/sp-core-library'; import { Version } from '@microsoft/sp-core-library';
import { import {
BaseClientSideWebPart, IPropertyPaneConfiguration,
IPropertyPaneConfiguration, PropertyPaneTextField
PropertyPaneTextField } from '@microsoft/sp-property-pane';
} from '@microsoft/sp-webpart-base'; import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import { escape } from '@microsoft/sp-lodash-subset'; import { escape } from '@microsoft/sp-lodash-subset';
import styles from './ItRequests.module.scss'; import styles from './ItRequestsWebPart.module.scss';
import * as strings from 'itRequestsStrings'; import * as strings from 'ItRequestsWebPartStrings';
import { IItRequestsWebPartProps } from './IItRequestsWebPartProps';
import 'jquery';
import 'jquery'; import 'datatables.net';
import 'datatables.net'; import 'moment';
import 'moment'; import './moment-plugin';
import './moment-plugin';
export interface IItRequestsWebPartProps {
var $: any = (window as any).$; listName: string;
}
export default class ItRequestsWebPart extends BaseClientSideWebPart<IItRequestsWebPartProps> {
var $: any = (window as any).$;
public render(): void {
this.domElement.innerHTML = ` export default class ItRequestsWebPart extends BaseClientSideWebPart<IItRequestsWebPartProps> {
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css" />
<table class="display ${styles.helloWorld}" cellspacing="0" width="100%"> public render(): void {
<thead> this.domElement.innerHTML = `
<tr> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css" />
<th>ID</th> <table id="requests" class="display ${styles.itRequests}" cellspacing="0" width="100%">
<th>Business unit</th> <thead>
<th>Category</th> <tr>
<th>Status</th> <th>ID</th>
<th>Due date</th> <th>Business unit</th>
<th>Assigned to</th> <th>Category</th>
</tr> <th>Status</th>
</thead> <th>Due date</th>
</table>`; <th>Assigned to</th>
</tr>
$(document).ready(() => { </thead>
$('table', this.domElement).DataTable({ </table>`;
'ajax': {
'url': `../../_api/web/lists/getbytitle('${escape(this.properties.listName)}')/items?$select=ID,BusinessUnit,Category,Status,DueDate,AssignedTo/Title&$expand=AssignedTo/Title`, $(document).ready(() => {
'headers': { 'Accept': 'application/json;odata=nometadata' }, $('table', this.domElement).DataTable({
'dataSrc': function (data) { 'ajax': {
return data.value.map(function (item) { 'url': `../../_api/web/lists/getbytitle('${escape(this.properties.listName)}')/items?$select=ID,BusinessUnit,Category,Status,DueDate,AssignedTo/Title&$expand=AssignedTo/Title`,
return [ 'headers': { 'Accept': 'application/json;odata=nometadata' },
item.ID, 'dataSrc': function (data) {
item.BusinessUnit, return data.value.map(function (item) {
item.Category, return [
item.Status, item.ID,
new Date(item.DueDate), item.BusinessUnit,
item.AssignedTo.Title item.Category,
]; item.Status,
}); new Date(item.DueDate),
} item.AssignedTo.Title
}, ];
columnDefs: [{ });
targets: 4, }
render: $.fn.dataTable.render.moment('YYYY/MM/DD') },
}] columnDefs: [{
}); targets: 4,
}); render: $.fn.dataTable.render.moment('YYYY/MM/DD')
} }]
});
protected get dataVersion(): Version { });
return Version.parse('1.0'); }
}
protected get dataVersion(): Version {
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration { return Version.parse('1.0');
return { }
pages: [
{ protected get disableReactivePropertyChanges(): boolean {
header: { return true;
description: strings.PropertyPaneDescription }
},
groups: [ protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
{ return {
groupName: strings.BasicGroupName, pages: [
groupFields: [ {
PropertyPaneTextField('listName', { header: {
label: strings.ListNameFieldLabel description: strings.PropertyPaneDescription
}) },
] groups: [
} {
] groupName: strings.BasicGroupName,
} groupFields: [
] PropertyPaneTextField('listName', {
}; label: strings.ListNameFieldLabel
} })
]
protected get disableReactivePropertyChanges(): boolean { }
return true; ]
} }
} ]
};
}
}

View File

@ -1,7 +1,7 @@
define([], function() { define([], function() {
return { return {
"PropertyPaneDescription": "IT Requests settings", "PropertyPaneDescription": "IT Requests settings",
"BasicGroupName": "Data", "BasicGroupName": "Data",
"ListNameFieldLabel": "List name" "ListNameFieldLabel": "List Name"
} }
}); });

View File

@ -1,10 +1,10 @@
declare interface IItRequestsStrings { declare interface IItRequestsWebPartStrings {
PropertyPaneDescription: string; PropertyPaneDescription: string;
BasicGroupName: string; BasicGroupName: string;
ListNameFieldLabel: string; ListNameFieldLabel: string;
} }
declare module 'itRequestsStrings' { declare module 'ItRequestsWebPartStrings' {
const strings: IItRequestsStrings; const strings: IItRequestsWebPartStrings;
export = strings; export = strings;
} }

View File

@ -1,54 +1,53 @@
// UMD // UMD
(function (factory) { (
function (factory) {
"use strict"; "use strict";
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// AMD // AMD
define(['jquery'], function ($) { define(['jquery'], function ($) {
return factory($, window, document); return factory($, window, document);
}); });
} } else if (typeof exports === 'object') {
else if (typeof exports === 'object') { // CommonJS
// CommonJS module.exports = function (root, $) {
module.exports = function (root, $) { if (!root) {
if (!root) { root = window;
root = window; }
}
if (!$) { if (!$) {
$ = typeof window !== 'undefined' ? $ = typeof window !== 'undefined'
require('jquery') : ? require('jquery')
require('jquery')(root); : require('jquery')(root);
} }
return factory($, root, root.document); return factory($, root, root.document);
}; };
} else {
// Browser
factory(jQuery, window, document);
} }
else { }
// Browser
factory(jQuery, window, document);
}
}
(function ($, window, document) { (function ($, window, document) {
$.fn.dataTable.render.moment = function (from, to, locale) { $.fn.dataTable.render.moment = function (from, to, locale) {
// Argument shifting // Argument shifting
if (arguments.length === 1) { if (arguments.length === 1) {
locale = 'en'; locale = 'en';
to = from; to = from;
from = 'YYYY-MM-DD'; from = 'YYYY-MM-DD';
} } else if (arguments.length === 2) {
else if (arguments.length === 2) { locale = 'en';
locale = 'en'; }
}
return function (d, type, row) { return function (d, type, row) {
var moment = require('moment'); var moment = require('moment');
var m = moment(d, from, locale, true); var m = moment(d, from, locale, true);
// Order and type get a number value from Moment, everything else // Order and type get a number value from Moment, everything else
// sees the rendered value // sees the rendered value
return m.format(type === 'sort' || type === 'type' ? 'x' : to); return m.format(type === 'sort' || type === 'type' ? 'x' : to);
}; };
}; };
})); })
);

View File

@ -1,9 +0,0 @@
/// <reference types="mocha" />
import { assert } from 'chai';
describe('ItRequestsWebPart', () => {
it('should do something', () => {
assert.ok(true);
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -1,15 +1,38 @@
{ {
"compilerOptions": { "extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json",
"target": "es5", "compilerOptions": {
"forceConsistentCasingInFileNames": true, "target": "es5",
"module": "commonjs", "forceConsistentCasingInFileNames": true,
"jsx": "react", "module": "esnext",
"declaration": true, "moduleResolution": "node",
"sourceMap": true, "jsx": "react",
"types": [ "declaration": true,
"es6-promise", "sourceMap": true,
"es6-collections", "experimentalDecorators": true,
"webpack-env" "skipLibCheck": true,
] "outDir": "lib",
} "inlineSources": false,
} "strictNullChecks": false,
"noUnusedLocals": false,
"typeRoots": [
"./node_modules/@types",
"./node_modules/@microsoft"
],
"types": [
"es6-promise",
"webpack-env"
],
"lib": [
"es5",
"dom",
"es2015.collection"
]
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
"lib"
]
}

View File

@ -1,3 +1,30 @@
{ {
"rulesDirectory": "./config" "extends": "@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-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
}
} }

View File

@ -1,8 +0,0 @@
// Type definitions for Microsoft ODSP projects
// Project: ODSP
/* Global definition for UNIT_TEST builds
Code that is wrapped inside an if(UNIT_TEST) {...}
block will not be included in the final bundle when the
--ship flag is specified */
declare const UNIT_TEST: boolean;

View File

@ -1 +0,0 @@
/// <reference path="@ms/odsp.d.ts" />

View File

@ -1,14 +0,0 @@
# Folders
.vscode
coverage
node_modules
sharepoint
src
temp
# Files
*.csproj
.git*
.yo-rc.json
gulpfile.js
tsconfig.json

View File

@ -1,8 +1,12 @@
{ {
"@microsoft/generator-sharepoint": { "@microsoft/generator-sharepoint": {
"libraryName": "spfx-js-datatables", "isCreatingSolution": true,
"framework": "none", "environment": "spo",
"version": "1.0.2", "version": "1.10.0",
"libraryId": "1e1ac667-cac9-4a86-97fb-f5abda8a8926" "libraryName": "datatables-itrequests",
"libraryId": "6c467145-feee-4d44-beb3-0e995e266dd0",
"packageManager": "npm",
"isDomainIsolated": false,
"componentType": "webpart"
} }
} }

View File

@ -1,18 +1,26 @@
# Tutorial: Migrate jQuery and DataTables solution built using Script Editor Web Part to SharePoint Framework ## datatables-itrequests
Sample jQuery DataTables solution migrated from a Script Editor Web Part to the SharePoint Framework. This is where you include your WebPart documentation.
![jQuery DataTables solution built using Script Editor Web Part](https://devofficecdn.azureedge.net/sharepointdocumentation/images/datatables-sewp.png) ### Building the code
More information about the solution is available at [https://docs.microsoft.com/sharepoint/dev/spfx/web-parts/guidance/migrate-jquery-datatables-script-to-spfx](https://docs.microsoft.com/sharepoint/dev/spfx/web-parts/guidance/migrate-jquery-datatables-script-to-spfx). ```bash
git clone the repo
## Minimal Path to Awesome npm i
npm i -g gulp
- In the command line run: gulp
- `npm i` ```
- `gulp serve --nobrowser`
- In the web browser navigate to the hosted version of the SharePoint workbench located in the same site as where the Tasks list is, eg. *https://contoso.sharepoint.com/sites/team/_layouts/15/workbench.aspx*. This package produces the following:
[More information](../README.md) * lib/* - intermediate-stage commonjs build artifacts
* dist/* - the bundled script, along with other resources
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/tutorial-migrate-datatables/03" /> * 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

View File

@ -1,17 +1,31 @@
{ {
"entries": [ "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
{ "version": "2.0",
"entry": "./lib/webparts/itRequests/ItRequestsWebPart.js", "bundles": {
"manifest": "./src/webparts/itRequests/ItRequestsWebPart.manifest.json", "it-requests-web-part": {
"outputPath": "./dist/it-requests.bundle.js" "components": [
{
"entrypoint": "./lib/webparts/itRequests/ItRequestsWebPart.js",
"manifest": "./src/webparts/itRequests/ItRequestsWebPart.manifest.json"
}
]
} }
], },
"externals": { "externals": {
"jquery": "https://code.jquery.com/jquery-1.12.4.min.js", "jquery": {
"datatables.net": "https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js", "path": "https://code.jquery.com/jquery-1.12.4.min.js",
"moment": "https://momentjs.com/downloads/moment.min.js" "globalName": "jQuery"
},
"datatables.net": {
"path": "https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js",
"globalName": "jQuery",
"globalDependencies": [
"jquery"
]
},
"moment": "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment.min.js"
}, },
"localizedResources": { "localizedResources": {
"itRequestsStrings": "webparts/itRequests/loc/{locale}.js" "ItRequestsWebPartStrings": "lib/webparts/itRequests/loc/{locale}.js"
} }
} }

View File

@ -1,3 +1,4 @@
{ {
"deployCdnPath": "temp/deploy" "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
} "deployCdnPath": "temp/deploy"
}

View File

@ -1,6 +1,7 @@
{ {
"workingDir": "./temp/deploy/", "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"account": "<!-- STORAGE ACCOUNT NAME -->", "workingDir": "./temp/deploy/",
"container": "spfx-js-datatables", "account": "<!-- STORAGE ACCOUNT NAME -->",
"accessKey": "<!-- ACCESS KEY -->" "container": "datatables-itrequests",
"accessKey": "<!-- ACCESS KEY -->"
} }

View File

@ -1,10 +1,13 @@
{ {
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": { "solution": {
"name": "spfx-js-datatables-client-side-solution", "name": "datatables-itrequests-client-side-solution",
"id": "1e1ac667-cac9-4a86-97fb-f5abda8a8926", "id": "6c467145-feee-4d44-beb3-0e995e266dd0",
"version": "1.0.0.0" "version": "1.0.0.0",
"includeClientSideAssets": true,
"isDomainIsolated": false
}, },
"paths": { "paths": {
"zippedPackage": "solution/spfx-js-datatables.sppkg" "zippedPackage": "solution/datatables-itrequests.sppkg"
} }
} }

View File

@ -1,7 +1,8 @@
{ {
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
"port": 4321, "port": 4321,
"initialPage": "https://localhost:5432/workbench",
"https": true, "https": true,
"initialPage": "https://localhost:5432/workbench",
"api": { "api": {
"port": 5432, "port": 5432,
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/" "entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"

View File

@ -1,45 +0,0 @@
{
// 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-unused-imports": 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
}
}
}

View File

@ -1,3 +1,4 @@
{ {
"cdnBasePath": "<!-- PATH TO CDN -->" "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->"
} }

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
const gulp = require('gulp'); const build = require('@microsoft/sp-build-web');
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);
build.initialize(require('gulp'));

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +1,37 @@
{ {
"name": "spfx-js-datatables", "name": "datatables-itrequests",
"version": "0.0.1", "version": "0.0.1",
"private": true, "private": true,
"main": "lib/index.js",
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
}, },
"author": {
"name": "Waldek Mastykarz",
"url": "https://blog.mastykarz.nl"
},
"dependencies": {
"@microsoft/sp-client-base": "~1.0.0",
"@microsoft/sp-core-library": "~1.0.0",
"@microsoft/sp-webpart-base": "~1.0.0",
"@types/webpack-env": ">=1.12.1 <1.14.0",
"moment": "^2.18.1"
},
"devDependencies": {
"@microsoft/sp-build-web": "~1.0.1",
"@microsoft/sp-module-interfaces": "~1.0.0",
"@microsoft/sp-webpart-workbench": "~1.0.0",
"@types/chai": ">=3.4.34 <3.6.0",
"@types/jquery": "^2.0.45",
"@types/jquery.datatables": "^1.10.36",
"@types/mocha": ">=2.2.33 <2.6.0",
"gulp": "~3.9.1"
},
"scripts": { "scripts": {
"build": "gulp bundle", "build": "gulp bundle",
"clean": "gulp clean", "clean": "gulp clean",
"test": "gulp test" "test": "gulp test"
},
"dependencies": {
"@microsoft/sp-core-library": "1.10.0",
"@microsoft/sp-lodash-subset": "1.10.0",
"@microsoft/sp-office-ui-fabric-core": "1.10.0",
"@microsoft/sp-property-pane": "1.10.0",
"@microsoft/sp-webpart-base": "1.10.0",
"@types/es6-promise": "0.0.33",
"@types/webpack-env": "1.13.1",
"moment": "2.27.0"
},
"devDependencies": {
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
"@microsoft/sp-build-web": "1.10.0",
"@microsoft/sp-module-interfaces": "1.10.0",
"@microsoft/sp-tslint-rules": "1.10.0",
"@microsoft/sp-webpart-workbench": "1.10.0",
"@types/chai": "3.4.34",
"@types/datatables.net": "1.10.15",
"@types/jquery": "1.10.34",
"@types/mocha": "2.2.38",
"ajv": "~5.2.2",
"gulp": "~3.9.1"
} }
} }

View File

@ -0,0 +1 @@
// A file is required to be in the root of the /src directory by the TypeScript compiler

View File

@ -1,3 +0,0 @@
export interface IItRequestsWebPartProps {
listName: string;
}

View File

@ -1,52 +0,0 @@
.helloWorld {
.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 {
padding: 20px;
}
.listItem {
max-width: 715px;
margin: 5px auto 5px auto;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
}
.button {
// Our button
text-decoration: none;
height: 32px;
// Primary Button
min-width: 80px;
background-color: #0078d7;
border-color: #0078d7;
color: #ffffff;
// 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: 14px;
font-weight: 400;
border-width: 0;
text-align: center;
cursor: pointer;
display: inline-block;
padding: 0 16px;
.label {
font-weight: 600;
font-size: 14px;
height: 32px;
line-height: 32px;
margin: 0 4px;
vertical-align: top;
display: inline-block;
}
}
}

View File

@ -1,20 +1,27 @@
{ {
"$schema": "../../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json", "$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "25895f30-c41d-4c63-ad83-93570fae720c",
"id": "61119bb3-fa48-4ded-bde9-6593ed155cbb", "alias": "ItRequestsWebPart",
"alias": "ItRequestsWebPart", "componentType": "WebPart",
"componentType": "WebPart",
"version": "0.0.1", // The "*" signifies that the version should be taken from the package.json
"manifestVersion": 2, "version": "*",
"manifestVersion": 2,
"preconfiguredEntries": [{
"groupId": "61119bb3-fa48-4ded-bde9-6593ed155cbb", // If true, the component can only be installed on sites where Custom Script is allowed.
"group": { "default": "Under Development" }, // Components that allow authors to embed arbitrary script code should set this to true.
"title": { "default": "IT Requests" }, // https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
"description": { "default": "Shows list of IT requests" }, "requiresCustomScript": false,
"officeFabricIconFontName": "Page", "supportedHosts": ["SharePointWebPart"],
"properties": {
"listName": "IT Requests" "preconfiguredEntries": [{
} "groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
}] "group": { "default": "Other" },
} "title": { "default": "IT requests" },
"description": { "default": "Shows overview of IT support requests" },
"officeFabricIconFontName": "Page",
"properties": {
"listName": "IT requests"
}
}]
}

View File

@ -0,0 +1,74 @@
@import '~@microsoft/sp-office-ui-fabric-core/dist/sass/SPFabricCore.scss';
.itRequests {
.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;
}
}
}

View File

@ -1,98 +1,101 @@
import { Version } from '@microsoft/sp-core-library'; import { Version } from '@microsoft/sp-core-library';
import { import {
BaseClientSideWebPart, IPropertyPaneConfiguration,
IPropertyPaneConfiguration, PropertyPaneTextField
PropertyPaneTextField } from '@microsoft/sp-property-pane';
} from '@microsoft/sp-webpart-base'; import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import { escape } from '@microsoft/sp-lodash-subset'; import { escape } from '@microsoft/sp-lodash-subset';
import styles from './ItRequests.module.scss'; import styles from './ItRequestsWebPart.module.scss';
import * as strings from 'itRequestsStrings'; import * as strings from 'ItRequestsWebPartStrings';
import { IItRequestsWebPartProps } from './IItRequestsWebPartProps';
import * as $ from 'jquery';
import * as $ from 'jquery'; import 'datatables.net';
import 'datatables.net'; import 'moment';
import 'moment'; import './moment-plugin';
import './moment-plugin';
export interface IItRequestsWebPartProps {
interface IRequestItem { listName: string;
ID: number; }
BusinessUnit: string;
Category: string; interface IRequestItem {
Status: string; ID: number;
DueDate: string; BusinessUnit: string;
AssignedTo: { Title: string; }; Category: string;
} Status: string;
DueDate: string;
export default class ItRequestsWebPart extends BaseClientSideWebPart<IItRequestsWebPartProps> { AssignedTo: { Title: string; };
}
public render(): void {
this.domElement.innerHTML = ` export default class ItRequestsWebPart extends BaseClientSideWebPart<IItRequestsWebPartProps> {
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css" />
<table class="display ${styles.helloWorld}" cellspacing="0" width="100%"> public render(): void {
<thead> this.domElement.innerHTML = `
<tr> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css" />
<th>ID</th> <table id="requests" class="display ${styles.itRequests}" cellspacing="0" width="100%">
<th>Business unit</th> <thead>
<th>Category</th> <tr>
<th>Status</th> <th>ID</th>
<th>Due date</th> <th>Business unit</th>
<th>Assigned to</th> <th>Category</th>
</tr> <th>Status</th>
</thead> <th>Due date</th>
</table>`; <th>Assigned to</th>
</tr>
$('table', this.domElement).DataTable({ </thead>
'ajax': { </table>`;
'url': `../../_api/web/lists/getbytitle('${escape(this.properties.listName)}')/items?$select=ID,BusinessUnit,Category,Status,DueDate,AssignedTo/Title&$expand=AssignedTo/Title`,
'headers': { 'Accept': 'application/json;odata=nometadata' }, $('table', this.domElement).DataTable({
'dataSrc': (data: { value: IRequestItem[] }): any[][] => { 'ajax': {
return data.value.map((item: IRequestItem): any[] => { 'url': `../../_api/web/lists/getbytitle('${escape(this.properties.listName)}')/items?$select=ID,BusinessUnit,Category,Status,DueDate,AssignedTo/Title&$expand=AssignedTo/Title`,
return [ 'headers': { 'Accept': 'application/json;odata=nometadata' },
item.ID, 'dataSrc': (data: { value: IRequestItem[] }): any[][] => {
item.BusinessUnit, return data.value.map((item: IRequestItem): any[] => {
item.Category, return [
item.Status, item.ID,
new Date(item.DueDate), item.BusinessUnit,
item.AssignedTo.Title item.Category,
]; item.Status,
}); new Date(item.DueDate),
} item.AssignedTo.Title
}, ];
columnDefs: [{ });
targets: 4, }
render: ($.fn.DataTable as any).render.moment('YYYY/MM/DD') },
}] columnDefs: [{
}); targets: 4,
} render: ($.fn.dataTable.render as any).moment('YYYY/MM/DD')
}]
protected get dataVersion(): Version { });
return Version.parse('1.0'); }
}
protected get dataVersion(): Version {
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration { return Version.parse('1.0');
return { }
pages: [
{ protected get disableReactivePropertyChanges(): boolean {
header: { return true;
description: strings.PropertyPaneDescription }
},
groups: [ protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
{ return {
groupName: strings.BasicGroupName, pages: [
groupFields: [ {
PropertyPaneTextField('listName', { header: {
label: strings.ListNameFieldLabel description: strings.PropertyPaneDescription
}) },
] groups: [
} {
] groupName: strings.BasicGroupName,
} groupFields: [
] PropertyPaneTextField('listName', {
}; label: strings.ListNameFieldLabel
} })
]
protected get disableReactivePropertyChanges(): boolean { }
return true; ]
} }
} ]
};
}
}

View File

@ -1,7 +1,7 @@
define([], function() { define([], function() {
return { return {
"PropertyPaneDescription": "IT Requests settings", "PropertyPaneDescription": "IT Requests settings",
"BasicGroupName": "Data", "BasicGroupName": "Group Name",
"ListNameFieldLabel": "List name" "ListNameFieldLabel": "List Name"
} }
}); });

View File

@ -1,10 +1,10 @@
declare interface IItRequestsStrings { declare interface IItRequestsWebPartStrings {
PropertyPaneDescription: string; PropertyPaneDescription: string;
BasicGroupName: string; BasicGroupName: string;
ListNameFieldLabel: string; ListNameFieldLabel: string;
} }
declare module 'itRequestsStrings' { declare module 'ItRequestsWebPartStrings' {
const strings: IItRequestsStrings; const strings: IItRequestsWebPartStrings;
export = strings; export = strings;
} }

View File

@ -2,23 +2,22 @@ import * as $ from 'jquery';
import * as moment from 'moment'; import * as moment from 'moment';
/* tslint:disable:no-function-expression */ /* tslint:disable:no-function-expression */
($.fn.DataTable as any).render.moment = function (from: string, to: string, locale: string): (d: any, type: string, row: any) => string { ($.fn.dataTable.render as any).moment = function (from: string, to: string, locale: string): (d: any, type: string, row: any) => string {
/* tslint:enable */ /* tslint:enable */
// Argument shifting // Argument shifting
if (arguments.length === 1) { if (arguments.length === 1) {
locale = 'en'; locale = 'en';
to = from; to = from;
from = 'YYYY-MM-DD'; from = 'YYYY-MM-DD';
} } else if (arguments.length === 2) {
else if (arguments.length === 2) { locale = 'en';
locale = 'en'; }
}
return (d, type, row): string => { return (d: any, type: string, row: any): string => {
var m = moment(d, from, locale, true); let m: moment.Moment = moment(d, from, locale, true);
// Order and type get a number value from Moment, everything else // Order and type get a number value from Moment, everything else
// sees the rendered value // sees the rendered value
return m.format(type === 'sort' || type === 'type' ? 'x' : to); return m.format(type === 'sort' || type === 'type' ? 'x' : to);
}; };
}; };

View File

@ -1,9 +0,0 @@
/// <reference types="mocha" />
import { assert } from 'chai';
describe('ItRequestsWebPart', () => {
it('should do something', () => {
assert.ok(true);
});
});

View File

@ -1,16 +1,38 @@
{ {
"compilerOptions": { "extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json",
"target": "es5", "compilerOptions": {
"forceConsistentCasingInFileNames": true, "target": "es5",
"module": "commonjs", "forceConsistentCasingInFileNames": true,
"jsx": "react", "module": "esnext",
"declaration": true, "moduleResolution": "node",
"sourceMap": true, "jsx": "react",
"types": [ "declaration": true,
"jquery.datatables", "sourceMap": true,
"es6-promise", "experimentalDecorators": true,
"es6-collections", "skipLibCheck": true,
"webpack-env" "outDir": "lib",
] "inlineSources": false,
} "strictNullChecks": false,
} "noUnusedLocals": false,
"typeRoots": [
"./node_modules/@types",
"./node_modules/@microsoft"
],
"types": [
"es6-promise",
"webpack-env"
],
"lib": [
"es5",
"dom",
"es2015.collection"
]
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
"lib"
]
}

View File

@ -1,3 +1,30 @@
{ {
"rulesDirectory": "./config" "extends": "@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-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
}
} }

View File

@ -1,8 +0,0 @@
// Type definitions for Microsoft ODSP projects
// Project: ODSP
/* Global definition for UNIT_TEST builds
Code that is wrapped inside an if(UNIT_TEST) {...}
block will not be included in the final bundle when the
--ship flag is specified */
declare const UNIT_TEST: boolean;

View File

@ -1 +0,0 @@
/// <reference path="@ms/odsp.d.ts" />

View File

@ -13,7 +13,8 @@ Sub folders represent the different stages of the migration process. Each folder
| 03-transformed-js-to-typescript | Transformed plain JavaScript to TypeScript | [details](https://docs.microsoft.com/sharepoint/dev/spfx/web-parts/guidance/migrate-jquery-datatables-script-to-spfx#transform-the-plain-javascript-code-to-typescript) | 03-transformed-js-to-typescript | Transformed plain JavaScript to TypeScript | [details](https://docs.microsoft.com/sharepoint/dev/spfx/web-parts/guidance/migrate-jquery-datatables-script-to-spfx#transform-the-plain-javascript-code-to-typescript)
## Used SharePoint Framework Version ## Used SharePoint Framework Version
![v1.0.2](https://img.shields.io/badge/SPFx-v1.0.2-green.svg)
![v1.10.0](https://img.shields.io/badge/SPFx-v1.10.0-green.svg)
## Applies to ## Applies to
@ -24,13 +25,14 @@ Sub folders represent the different stages of the migration process. Each folder
Solution | Author(s) Solution | Author(s)
------------- | ------------- ------------- | -------------
tutorial-migrate-datatables | Waldek Mastykarz (MVP, [Rencore](https://rencore.com), @waldekm) tutorial-migrate-datatables | Waldek Mastykarz (MVP, [Rencore](https://rencore.com), @waldekm) & Andrew Connell (MVP, [Voitanos](//github.com/voitanos), [@andrewconnell](//github.com/andrewconnell))
## Version history ## Version history
Version | Date | Comments Version | Date | Comments
--------| --------------- | -------- --------| --------------- | --------
1.0.0 | June, 27 2017 | Initial commit 1.0.0 | June 27, 2017 | Initial commit
1.1.0 | June 28, 2017 | Updated tutorial code for SPFx v1.10
## Disclaimer ## Disclaimer
@ -44,31 +46,31 @@ To build and run this client-side project, you will need to clone and build the
Clone this repo by executing the following command in your console: Clone this repo by executing the following command in your console:
```sh ```console
git clone https://github.com/SharePoint/sp-dev-fx-webparts.git git clone https://github.com/SharePoint/sp-dev-fx-webparts.git
``` ```
Navigate to the cloned repo folder which should be the same as the repo name: Navigate to the cloned repo folder which should be the same as the repo name:
```sh ```console
cd sp-dev-fx-webparts cd sp-dev-fx-webparts
``` ```
Navigate to the `tutorials-migrate-datatables` folder: Navigate to the `tutorials-migrate-datatables` folder:
```sh ```console
cd tutorials cd tutorials
``` ```
Navigate to the `specific web part` folder: Navigate to the `specific web part` folder:
```sh ```console
cd 'subfolder' cd 'subfolder'
``` ```
Now run the following command to install the npm packages: Now run the following command to install the npm packages:
```sh ```console
npm install npm install
``` ```
@ -76,7 +78,7 @@ This will install the required npm packages and dependencies to build and run th
Once the npm packages are installed, run the command to preview your web parts in SharePoint Workbench: Once the npm packages are installed, run the command to preview your web parts in SharePoint Workbench:
```sh ```console
gulp serve --nobrowser gulp serve --nobrowser
``` ```