際際滷

際際滷Share a Scribd company logo
Sharepoint framework nivel avanzado
@levalencia - luisevalencia.com
SharePoint UX  Evolving cross versions
2009
SharePoint
Server 2010
2006
Office SharePoint
Server 2007
2003
SharePoint
Portal Server 2003
2001
SharePoint
Portal Server 2001
2012
SharePoint
Server 2013
2016 
SharePoint
Server 2016, SPO
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
Sharepoint framework nivel avanzado
@levalencia - luisevalencia.com
No
In similar ways as with SharePoint Add-in
model, server side development is needed for
back end services
SharePoint Framework concentrates on user
interface, not on fundamentals around the API
usage
@levalencia - luisevalencia.com
Sharepoint framework nivel avanzado
@levalencia - luisevalencia.com
IIS Express
Project Templates
MSBuild C#
@levalencia - luisevalencia.com
https://www.npmjs.com/
@levalencia - luisevalencia.com
http://yeoman.io
@levalencia - luisevalencia.com
http://gulpjs.com/
@levalencia - luisevalencia.com
https://www.typescriptlang.org/
@levalencia - luisevalencia.com
Fonts, icons Colors
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
Sharepoint framework nivel avanzado
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
https://www.eliostruyf.com/automate-publishing-of-
your-sharepoint-framework-scripts-to-office-365-
public-cdn/
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
Sharepoint framework nivel avanzado
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
https://localhost
https://<your-sharepoint-site>/_layouts/workbench.aspx
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
import { IHelloWorldWebPartProps } from './IHelloWorldWebPartProps';
export default class HelloWorldWebPart extends
BaseClientSideWebPart<IHelloWorldWebPartProps>
{
// code omitted
}
@levalencia - luisevalencia.com
export interface IHelloWorldWebPartProps {
description: string;
}
@levalencia - luisevalencia.com
{
"$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"
}
}]
}
@levalencia - luisevalencia.com
.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);
}
@levalencia - luisevalencia.com
/* 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 */
@levalencia - luisevalencia.com
 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"
}
}
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
Sharepoint framework nivel avanzado
@levalencia - luisevalencia.com
this.context.statusRenderer.displayLoadingIndicator(this.domElement, "message");
this.context.statusRenderer.clearLoadingIndicator(this.domElement);
@levalencia - luisevalencia.com
this.context.statusRenderer.renderError(this.domElement, err);
this.context.statusRenderer.clearError(this.domElement);
@levalencia - luisevalencia.com
import { DisplayMode } from '@microsoft/sp-core-library';
const pageMode : string = this.displayMode === DisplayMode.Edit ?
'You are in edit mode' : 'You are in read mode';
<p class="ms-font-l ms-fontColor-white">${pageMode}</p>
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
<p class='ms-font-l ms-fontColor-white'>
Loading from ${this.context.pageContext.web.title}
</p>
@levalencia - luisevalencia.com
web part in the SharePoint Workbench, a modern, or a classic page
@levalencia - luisevalencia.com
import { EnvironmentType } from '@microsoft/sp-core-library';
const environmentType : string = EnvironmentType.Local ? 'You are in local environment' :
'You are in sharepoint environment';
<p class="ms-font-l ms-fontColor-white">${environmentType}</p>
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
import { Log } from '@microsoft/sp-client-base';
Log.info('HelloWorld', 'Info message',
this.context.serviceScope);
Log.warn('HelloWorld', 'Warn message',
this.context.serviceScope);
Log.error('HelloWorld', new Error('Error message'),
this.context.serviceScope);
Log.verbose('HelloWorld', 'Verbose message',
this.context.serviceScope);
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
export interface ISPList {
Title: string;
Id: string;
}
@levalencia - luisevalencia.com
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);
});
}
}
@levalencia - luisevalencia.com
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() }
@levalencia - luisevalencia.com
export interface ISPList {
Title: string;
Id: string;
}
@levalencia - luisevalencia.com
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[]>;
}
@levalencia - luisevalencia.com
private _getListData(): Promise<ISPList[]> {
if(Environment.type === EnvironmentType.Local) {
return this._getMockListData();
}
else {
return this._getSharePointListData();
}
}
@levalencia - luisevalencia.com
Sharepoint framework nivel avanzado
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
{
"cdnBasePath": "<!-- PATH TO CDN -->"
}
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
https://publiccdn.sharepointonline.com/<TENANCY>.sharepoint.com/<your-CDN-origin-Id>
{
"cdnBasePath": "https://publiccdn.sharepointonline.com/<TENANCY>.sharepoint.com/<your-CDN-origin-Id>"
}
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
protected get getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
PropertyPaneTextField('description', {
label: strings.DescriptionFieldLabel
}),
PropertyPaneLabel('labelField', {
text: 'Label text'
})
]
}
]
}
]
};
}
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
{
"$schema": "../../../node_modules/@microsoft/sp-module-
interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json",
"id": "b64ff4a0-5f1c-4cd9-b959-613a0a6d95c9",
"alias": "HelloWorldWebPart",
"componentType": "WebPart",
"version": "0.0.1",
"manifestVersion": 2,
"preconfiguredEntries": [{
"groupId": "b64ff4a0-5f1c-4cd9-b959-613a0a6d95c9",
"group": { "default": "Under Development" },
"title": { "default": "HelloWorld" },
"description": { "default": "HelloWorld description" },
"officeFabricIconFontName": "Page",
"properties": {
"description": "HelloWorld"
}
}]
}
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
public render(): void {
const element: React.ReactElement<IHelloWorldWebPartProps> = React.createElement(HelloWorldComponent, {
description: this.properties.description
});
ReactDom.render(element, this.domElement);
}
@levalencia - luisevalencia.com
public componentDidMount(): void {
this.doSomething(this.props.description);
}
public componentDidUpdate(prevProps: IHelloWorldWebPartProps, prevState: IHelloWorldWebPartState):
void {
if (this.props.description !== prevProps.description) {
this.doSomething(this.props.description);
}
}
private doSomething(description: string): void {
// Do something with the property
}
@levalencia - luisevalencia.com
Sharepoint framework nivel avanzado
built with the React framework.
 Reusable patterns
 Used in Office products
http://dev.office.com/fabric#/components
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
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.
@levalencia - luisevalencia.com
https://github.com/OfficeDev/Office-UI-Fabric-React/releases
https://github.com/OfficeDev/Office-UI-Fabric-React
@levalencia - luisevalencia.com
@levalencia - luisevalencia.com
http://dev.office.com/fabric#/components
@levalencia - luisevalencia.com
http://dev.office.com/fabric#/components
http://dev.office.com/fabric#/get-started#react
https://github.com/OfficeDev/Office-UI-Fabric-React
@levalencia - luisevalencia.com
Install the Fabric React NPM package
npm --save install office-ui-fabric-react
Import components
import {
Button,
ButtonType
} from 'office-ui-fabric-react';
Use components in the Render method
public render(): JSX.Element {
return (
<Button buttonType={ ButtonType.primary }>ADD NEW ACTIVITY</Button>
@levalencia - luisevalencia.com
Type Styles for text elements
<span className="ms-fontColor-neutralDark ms-font-xxl ms-fontWeight-
semibold">ACTIVITIES</span>
Icons
const contextualMenuItems: Array<IContextualMenuItem> = [];
contextualMenuItems.push({
key: 'Sort',
name: 'Sort',
icon: 'sortLines',
@levalencia - luisevalencia.com
.menubutton{
display: none;
position: relative;
border-width: 1px;
border-style: solid;
padding: 16px 20px;
margin-bottom: 9px;
}
.menubutton > i{
position: absolute;
right: 10px;
top: 13px;
}
<div className={css("ms-fontColor-neutralSecondaryAlt ms-font-xl ms-fontWeight-semibold",
styles.menubutton)}>
@levalencia - luisevalencia.com
Sharepoint framework nivel avanzado
Sharepoint framework nivel avanzado
Sharepoint framework nivel avanzado

More Related Content

Sharepoint framework nivel avanzado

Editor's Notes

  • #4: Tahoe/SPS 2001 ASP Based, Single Box SP 2003 Moved to ASP.NET, scale out, enterprise manageability SP 2007 Added ECM, Publishing, Shared Services SP 2010 FAST acquisition, search driven portals, scaled up doclibs SP 2013 Multitenant, base for our cloud based release SP 2016 First version migrated back from Cloud
  • #5: Over the past several years, with the evolution of Office 365, development of SharePoint solutions has encountered a new set of challenges: while on one hand IT and Tenant administrators require a new set of tools to control how data get accessed and consumed in their tenancies, developers, on the other hand, want to programmatically control the whole lifecycle, experience, and data access capabilities of a Site. Unfortunately, developers today find themselves constraint around building app parts as a result of iFrames, a reduced set of APIs, and no integration with cross Office 365 workloads. This in turn limits their ability to develop powerful portals that extend SharePoint. The client-side development framework will deliver capabilities that will help both first party and third party developers build powerful, rich applications and provide an enjoyable web experience in Office 365 for end users that are both intuitive and simple to consume.
  • #6: Built into the SharePoint mobileapps
  • #7: Client-side rendered using Open Source web tech, predominantly React and Office Fabric CDN deployed single-page web apps with client side interactivity and fast page routing Client-side web parts Client-side and persisted caches Mobile optimized (responsive)
  • #10: Use Exercise 3: Use different JavaScript libraries (jQuery, Chartist, Moment) in a SPFx client-side web part in the lab manual.
  • #17: Built into the SharePoint mobileapps
  • #18: Built into the SharePoint mobileapps
  • #19: Use Exercise 3: Use different JavaScript libraries (jQuery, Chartist, Moment) in a SPFx client-side web part in the lab manual.
  • #20: Gulp Automation - gulp is a toolkit that helps you automate painful or time-consuming tasks in your development workflow. Platform-agnostic - Integrations are built into all major IDEs and people are using gulp with PHP, .NET, Node.js, Java, and other platforms. Strong Ecosystem - Use npm modules to do anything you want + over 2000 curated plugins for streaming file transformations Simple - By providing only a minimal API surface, gulp is easy to learn and simple to use
  • #23: The package-solution task uses a SharePoint Feature to package your web part. By default, the gulp task creates afeature for your web part. You can view the raw package contents in thesharepointfolder. The contents are then packaged into a.sppkgfile. The package format is very similar to a SharePoint Add-in package and uses the Microsoft Open Packaging Conventions to package your solution. The JavaScript files, CSS and other assets are not packaged and you will have to deploy them to an external location such as a CDN.In order to test the web part during development, you can load all the assets from your local computer.
  • #24: Use Exercise 3: Use different JavaScript libraries (jQuery, Chartist, Moment) in a SPFx client-side web part in the lab manual.
  • #32: BaseClientSideWebPartimplements the minimal functionality that is required to build a web part. This class also provides many parameters to validate and access to read-only properties such asdisplayMode, web part properties, web part context, the web partinstanceId, the web partdomElementand much more. Notice that the web part class is defined to accept a property typeIHelloWorldWebPartProps. The property type is defined as an interface in a separate fileIHelloWorldWebPartProps.ts. export interface IHelloWorldWebPartProps { description: string; }
  • #34: Defines the web part metadata such as version, id, componentType, manifestVersion, and description. Every web part must contain this manifest.
  • #36: HelloWorld.module.scss.ts is the typescript file that includes the corresponding typings ofHelloWorld.module.scss, you can then import and reference these styles in your web part code.
  • #37: This file contains information about your bundle(s) and any external dependencies and localized resources. - The entries section contains the default bundle information. - The externals section contains the libraries that are not bundled with the default bundle.
  • #39: Use Exercise 3: Use different JavaScript libraries (jQuery, Chartist, Moment) in a SPFx client-side web part in the lab manual.
  • #43: Lodashis a great JavaScript utility library that you can use to perform operations on various objects like arrays, numbers, strings etc., SharePoint Framework includes thelodashutility libraryfor use with SharePoint Framework out-of-the-box so you do not need to install it separately. To improve run-time performance, it only includes a subset of the most essential lodash functions.
  • #44: SharePoint pages have display modes which indicate in which mode that page and/or its contents (e.g. text and web parts) are displayed. In the classic server-side SharePoint page, the web page and the web part can be in different modes.For example, the web page can be in edit mode while the web part is not in edit mode.In the modern client-side SharePoint page, both the page and/or its contents are in the same mode.
  • #47: When the SharePoint workbench is hosted locally, you do not have the SharePoint page context. However, you can still test your web part in many different ways. For example, you can build the web part's UX and use mock data to simulate SharePoint interaction when you don't have the SharePoint context. However, when the workbench is hosted in SharePoint, you get access to the page context which provides various key properties, such as: -Web title -Web absolute URL -Web server-relative URL -User login name
  • #49: The SharePoint workbench gives you the flexibility to test web parts in your local environment and from a SharePoint site. The EnvironmentType module is used to determine which environment your web part is running in.
  • #50: The SharePoint workbench gives you the flexibility to test web parts in your local environment and from a SharePoint site. The EnvironmentType module is used to determine which environment your web part is running in.
  • #51: Logging is a very convenient and easy way to keep track of events happening in the web part, instead of having breakpoints, or alerts in JavaScript. The SharePoint Framework has a built-in logging mechanism. Note:The Log class contains four static methods for logging: info: log information warn: log warnings error: log errors verbose: log everything In the SharePoint Framework all logging is done to the JavaScript console and you can see the logging using the developer tools in a web browser. All static methods have the same signature, except the error method - they take three arguments: source: the source of the logging information (max 20 characters), such as the method or the class name message: the actual message to log (max 100 characters) scope: an optional service scope Theerrormethod takes anErrorobject instead of themessagestring, otherwise they are the same.
  • #52: Logging is a very convenient and easy way to keep track of events happening in the web part, instead of having breakpoints, or alerts in JavaScript. The SharePoint Framework has a built-in logging mechanism. Note:The Log class contains four static methods for logging: info: log information warn: log warnings error: log errors verbose: log everything In the SharePoint Framework all logging is done to the JavaScript console and you can see the logging using the developer tools in a web browser. All static methods have the same signature, except the error method - they take three arguments: source: the source of the logging information (max 20 characters), such as the method or the class name message: the actual message to log (max 100 characters) scope: an optional service scope Theerrormethod takes anErrorobject instead of themessagestring, otherwise they are the same.
  • #53: Notice how the ModuleLoader is wrapped in theif (this.renderedOnce === false)clause. Therender function of Client-Side Web Parts is called initially whenever a web part is added to the page, but also every time a web part property is changed in the Property Pane. Because we only want to load the scripts with the ModuleLoader one time, we use therenderedOnceproperty to verify that the Web Part is rendering initially and then load the required modules. When loading jQuery using the ModuleLoader we load it as a global script associated with thejQueryvariable. Also, as we're loading the Simple Weather jQuery plugin we need the global variable which the plugin is using to add itself to jQuery. Because the plugin is not an AMD module, the jQuery variable must be available in the global scope. Also note, that after loading jQuery and before loading the Simple Weather plugin, we store the reference to jQuery in thethis.jQueryvariable. We we will need it in our customrenderContentsfunction to instantiate the Simple Weather plugin in the Web Part.
  • #60: The_getSharePointListDatamethod invokes the SharePoint REST API to return the SharePoint lists in the SharePoint site where the web part executes.
  • #61: The_getListDatamethod determines what environment the web part is running in. It returns mock data when running in the local environment or it returns data from the SharePoint REST API when not running in the local environment.
  • #62: Use Exercise 3: Use different JavaScript libraries (jQuery, Chartist, Moment) in a SPFx client-side web part in the lab manual.
  • #69: Open theSharePoint Online Management Shell. Connect to your Office 365 Developer Tenant within PowerShell session by executing the following commands: $creds = Get-Credential Connect-SPOService -Url https://<TENANCY>-admin.sharepoint.com/ -Credential $creds Enable the Public CDN in the tenant by executing the following command: Set-SPOTenant -PublicCdnEnabled $true Configure the allowed file extensions by executing the following command: Set-SPOTenant -PublicCdnAllowedFileTypes "CSS,EOT,GIF,ICO,JPEG,JPG,JS,MAP,PNG,SVG,TTF,WOFF,TXT Add the CDN Origin by executing the following command: New-SPOPublicCdnOrigin -Url "https://<TENANCY>.sharepoint.com/sites/dev/siteassets/cdn Get the CDN Origin Id by executing the following command: Get-SPOPublicCdnOrigins
  • #70: Your CDN base path should be:https://publiccdn.sharepointonline.com/<TENANCY>.sharepoint.com/<your-CDN-origin-Id>. Replace the<TENANCY>placeholder with the name of your Office 365 tenant, and the<your-CDN-origin-Id>placeholder with theCDN Origin Idyou created in the previous steps.
  • #76: Use Exercise 3: Use different JavaScript libraries (jQuery, Chartist, Moment) in a SPFx client-side web part in the lab manual.
  • #79: Themostimportant things in your package.json are the name and version fields. Those are actually required, and your package won't install without them. The name and version together form an identifier that is assumed to be completely unique. Changes to the package should come along with changes to the version. Version must be parseable bynode-semver, which is bundled with npm as a dependency. (npm install semverto use it yourself.) More on version numbers and ranges atsemver.
  • #84: Use Exercise 3: Use different JavaScript libraries (jQuery, Chartist, Moment) in a SPFx client-side web part in the lab manual.
  • #85: Pages: Separate pages in a single property pane. Pages contain a Header and Groups. Headers: The title of the property pane Groups: Sections in the property pane that group properties
  • #98: Use Exercise 3: Use different JavaScript libraries (jQuery, Chartist, Moment) in a SPFx client-side web part in the lab manual.
  • #99: Fabrics robust, up-to-date components are built with the React framework. Look through the component list to see the building blocks that are available using Fabric React. Reusable patterns Fabrics components help you get buttons, navigation, and more that look like Office quickly and easily. They also contain extra functionality that helps your app act like Office too. Used in Office products Many Fabric React components are used in our products. We make improvements and bug fixes frequently, ensuring they work as designed across all of thesupported browsers. https://github.com/OfficeDev/office-ui-fabric-react/blob/master/ghdocs/BROWSERSUPPORT.md After youve explored the components,get started. http://dev.office.com/fabric#/get-started
  • #103: Components are the building blocks, appropriately responsive.
  • #109: Use Exercise 3: Use different JavaScript libraries (jQuery, Chartist, Moment) in a SPFx client-side web part in the lab manual.