44
SharePoint Framework webinaari Olli Jääskeläinen MVP, MCM, MCT

SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

SharePoint Framework webinaariOlli Jääskeläinen

MVP, MCM, MCT

Page 2: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

▪ SharePoint Framework▪ Johdanto

▪ Devaajan työasema

▪ Client-side webosat SharePoint Frameworkilla

▪ Keskustelua

Hyvää huomenta :)

Page 3: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

JohdantoSharePoint Framework

Page 4: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

SharePoint UX – Evolving cross versions

2009

SharePointServer 2010

2006

Office SharePointServer 2007

2003

SharePointPortal Server 2003

2001

SharePointPortal Server 2001

2012

SharePointServer 2013

2016 …

SharePointServer 2016, SPO

Page 5: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

▪ Julkaistiin helmikuun lopussa 2017 – Client side web parts

▪ Saatavilla tällä hetkellä SharePoint Online / Office 365 –ryhmätkehitykseen

▪ Extensions on preiview vaiheessa

▪ Tulossa SharePoint Server 2016 Feature Pack 2:ssa on-premiintoivottavasti vielä tänä vuonna

SharePoint Framework

Page 6: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

SharePoint Extensibility Principles

Page 7: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

SharePoint Framework

Page 8: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Modern Site Pages

Page 9: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

• Tooling• Node.js• Yeoman• Gulp• TypeScript• Visual Studio (Code)

• Frameworks – Choose yours• React• Angular.js• Knockout • Etc.

Typical tooling for SharePoint Framework

Page 10: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Open source tooling

Page 11: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

IIS Express

Project Templates

Server side tool comparison

MSBuild C#

Page 12: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

SharePoint Framework devaajan työasemaSharePoint Framework

Page 13: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

•Linux

Install developer tools – NodeJS and npmNodeJS

homebrew

sudo npm install -g npm

npm install -g npm

Page 14: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Install developer tools – Code EditorsVisual Studio Code

Sublime

Atom

Webstorm

Not all these tools are required. Just install he ones you want to use.

Page 15: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

•Yeoman helps you kick-start new projects

•SharePoint client-side development tools include a Yeoman generator for creating new web parts.

Install Yeoman and gulp

npm install -g yo gulp

Page 16: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

•The Yeoman SharePoint web part generator helps you quickly create a SharePoint client-side solution project with the right toolchain and project structure.

Install Yeoman SharePoint generator

npm install -g @microsoft/generator-sharepoint

Page 17: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Client-side webosienrakentaminenSharePoint Framework

Page 18: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Client-side Web Part Build Flow

Page 19: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Demo$ yo @microsoft/sharepoint

$ gulp serve

Page 20: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Client-side webosa –projektinrakenne ja tärkeimmät tiedostotSharePoint Framework

Page 21: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Top level folders

• .vscode: includes Visual Studio Code integration files

• config: includes all config files

• dist: created automatically when you build the project – holds debug builds

• lib: created automatically when you build the project

• node_modules: this is created automatically when you build your project, it includes all the npm packages your solution relies upon and their dependencies

• src: this is the main folder of the project, it includes the web part, styles, and a test file

• temp: created automatically when you build your project – holds production builds

• typings: includes some type definition files. Most type definitions are installed in node_modules\@types

Project Structure

Page 22: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

• Defines the main entry point for the web part

• Extends the BaseClientSideWebPart.

• All client-side webs part must extend the BaseClientSideWebPart class in order to be defined as a valid web part

import { IHelloWorldWebPartProps } from './IHelloWorldWebPartProps';

export default class HelloWorldWebPart extendsBaseClientSideWebPart<IHelloWorldWebPartProps>

{

// code omitted

}

Key Files – web part class

Page 23: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

• Defines the interface for moving properties between different classes in the web part

export interface IHelloWorldWebPartProps {

description: string;

}

Key Files – web part properties class

Page 24: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

• Defines the web part metadata• One entry in the preconfiguredEntries section is similar as classic .webpart file for server side web parts

{

"$schema": "../../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json",

"id": "318dd20d-0c02-4c3d-acc5-e2c0fa84cf3f",

"alias": "HelloWorldWebPart",

"componentType": "WebPart",

"version": "0.0.1",

"manifestVersion": 2,

"preconfiguredEntries": [{

"groupId": "318dd20d-0c02-4c3d-acc5-e2c0fa84cf3f",

"group": { "default": "Under Development" },

"title": { "default": "HelloWorld" },

"description": { "default": "HelloWorld description" },

"officeFabricIconFontName": "Page",

"properties": {

"description": "HelloWorld"

}

}]

}

Key Files – web part manifest

Page 25: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

• Defines the web part styles

.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);

}

Key Files – SCSS file

Page 26: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

• Defines the TypeScript typings for the web part styles

/* tslint:disable */

require('./HelloWorld.module.css');

const styles = {

helloWorld: 'helloWorld_68b3b0f6',

container: 'container_68b3b0f6',

row: 'row_68b3b0f6',

listItem: 'listItem_68b3b0f6',

button: 'button_68b3b0f6',

label: 'label_68b3b0f6',

};

export default styles;

/* tslint:enable */

Key Files – SCSS TypeScript file

Page 27: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

• Contains information about your bundle(s), any external dependencies, localized resources

• Specifies the AMD script libraries used in the web part{

"entries": [

{

"entry": "./lib/webparts/helloWorld/HelloWorldWebPart.js",

"manifest": "./src/webparts/helloWorld/HelloWorldWebPart.manifest.json",

"outputPath": "./dist/hello-world.bundle.js"

}

],

"externals": {

“jquery": "node_modules/jquery/dist/jquery.min.js"

},

"localizedResources": {

"helloWorldStrings": "webparts/helloWorld/loc/{locale}.js"

}

}

Key Files – config file

Page 28: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

DemoProjektin rakenne

Page 29: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Office UI Fabric ja Fabric ReactSharePoint Framework

Page 30: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Fabric and its sub-projects

Fabric React

Robust, up-to-date components built with the React framework.

Fabric JS

Simple, visuals-focused components that you can extend, rework, and build on.

ngFabric

Community-driven project to build components for Angular-based apps.

Fabric iOS

Native Swift colors, type ramp, and components for building iOS apps.

Page 31: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

UIFabric.io

Page 32: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Install the Fabric React NPM packagenpm --save install office-ui-fabric-react

Import componentsimport {

Button,

ButtonType

} from 'office-ui-fabric-react';

Use components in Render methodpublic render(): JSX.Element {

return (

<Button buttonType={ ButtonType.primary }>ADD NEW ACTIVITY</Button>

How to use Office UI Fabric React components

Page 33: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

DemoOffice UI Fabric ja Fabric React

Page 34: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Mock-data, SP-data + webosienkonfigurointiSharePoint Framework

Page 35: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Why use mock data?

•Local Workbench has no SharePoint context

•Use mock data to simulate SharePoint context

•Allows you to build the web part locally without even running in SharePoint• You can implement the UI behaviors even without accessing the SharePoint code

• It’s good practice to have mocked data for local workbench hosting

Page 36: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

•Create a data model for the mock data

How to use mock data?

export interface ISPList {Title: string;Id: string;

}

Page 37: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

•Create a MockHttpClient class• Import the data model into the MockHttpClient class

• Create an instance of the data model

• Populate the instance of the data model with mock data

• Create a method to return the mock data

How to use mock data?

import { ISPList } from './ISPList';

export default class MockHttpClient {

private static _items: ISPList[] = [{ Title: 'Mock List 1', Id: '1' },{ Title: 'Mock List 2', Id: '2' },

];

public static get(restUrl: string, options?: any): Promise<ISPList[]> {return new Promise<ISPList[]>((resolve) => {

resolve(MockHttpClient._items);});

}}

Page 38: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

• Import the MockHttpClient class and data model into the web part class

• Create a method to invoke the method in the MockHttpClient and return the mock data

• Check the EnvironmentType to determine if the web part is running in the local environment

• Invoke the method to return the mock data

How to use mock data?

import MockHttpClient from './MockHttpClient';import { ISPList } from './ISPList';

private _getMockListData(): Promise<ISPList[]> {return MockHttpClient.get(this.context.pageContext.web.absoluteUrl)

.then((data: ISPList[]) => {return data;

});}

if (this.context.environment.type === EnvironmentType.Local) { this._getMockListData() }

Page 39: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

• Import the data model into the web part class

• Create a method to return the mock data

• Use the SharePoint context SPHttpClient to call SharePoint REST APIs

How to talk to SharePoint

import { ISPList } from './ISPList';

private _getSharePointListData(): Promise<ISPList[]> {return this.context.

spHttpClient.get(this.context.pageContext.web.absoluteUrl + `/_api/web/lists?$filter=Hidden eq false`, SPHttpClient.configurations.v1).then(response => {

return response.json();}).then(json => {

return json.value}) as Promise<ISPList[]>;

}

Page 40: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

• Check the EnvironmentType to determine if the web part is running in the local environment

• Invoke the method to return the mock data when running in the local environment

• Invoke the method to call the SharePoint REST API when not running in the local environment

How to co-exist with mock data

private _getListData(): Promise<ISPList[]> {if(Environment.type === EnvironmentType.Local) {return this._getMockListData();

}else {return this._getSharePointListData();

}}

Page 41: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

The Property Pane: Overview

Page 42: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

Implementing the header, groups, and fieldsprotected get getPropertyPaneConfiguration(): IPropertyPaneConfiguration {

return {pages: [{header: {description: strings.PropertyPaneDescription

},groups: [{groupName: strings.BasicGroupName,groupFields: [PropertyPaneTextField('description', {label: strings.DescriptionFieldLabel

}),PropertyPaneLabel('labelField', {text: 'Label text'

}) ]

}]

}]

};}

Page 43: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

DemoMock Data

SharePoint Data

Web Part Properties

Page 44: SharePoint Framework webinaari - Sulava · SharePoint Framework Johdanto Devaajan työasema Client-side webosat SharePoint Frameworkilla ... Saatavilla tällä hetkellä SharePoint

- Miltä vaikuttaa? - Valmis oppimaan lisää? - Antakaa palauteta niin saatte materiaalithttps://fi.surveymonkey.com/r/SPFx-webinaari

Ilmoittaudu meidän SharePoint Framework –kurssille!https://www.onsight.fi/kurssit/sharepoint-framework-sovelluskehitys/ 28.8.2017, 23.10.2017

Keskustelua!