Working with a super model for SharePoint Tuga IT 2016

57
TUGA IT 2016 LISBON, PORTUGAL

Transcript of Working with a super model for SharePoint Tuga IT 2016

Page 1: Working with a super model for SharePoint Tuga IT 2016

TUGA IT 2016LISBON, PORTUGAL

Page 2: Working with a super model for SharePoint Tuga IT 2016

THANK YOU TO OUR SPONSORS

Page 3: Working with a super model for SharePoint Tuga IT 2016

THANK YOU TO OUR TEAM

ANDRÉ BATISTA ANDRÉ MELANCIA ANDRÉ VALA ANTÓNIO LOURENÇO BRUNO LOPES

CLÁUDIO SILVA

RUI BASTOS

NIKO NEUGEBAUER

RUI REISRICARDO CABRAL

NUNO CANCELO PAULO MATOS PEDRO SIMÕES

SANDRA MORGADO SANDRO PEREIRA

Page 4: Working with a super model for SharePoint Tuga IT 2016

Working with a Super model for SharePoint

Sonja Madsen

Page 5: Working with a super model for SharePoint Tuga IT 2016

Sonja Madsen

sp2013.blogspot.com@sonjamadsen

[email protected]

Sonja Madsen

Microsoft MVP, SONJAsAPPSBest International Developer

Page 6: Working with a super model for SharePoint Tuga IT 2016

Super model projecthttps://code.msdn.microsoft.com/officeapps/SharePoint-Super-Model-7855df3a

Read from Web API

Page 7: Working with a super model for SharePoint Tuga IT 2016

Building views and pages

• SharePoint add-in• Single Page Add-in• App Part – web part• SharePoint List View• Multiple languages• Design• Modules

Page 8: Working with a super model for SharePoint Tuga IT 2016

SharePoint add-in system view.aspx page.js files.css files.xml files

app manifestlist definitioncontent typessite columnsapp partmodulesfeature

aspx

Page 9: Working with a super model for SharePoint Tuga IT 2016

Landing page HTML similar to a page layout- Placeholders: PlaceHolderAdditionalPageHead,

PlaceHolderPageTitleInTitleArea, PlaceHolderMain- SharePoint namespaces- Inherits from

Microsoft.SharePoint.WebPartPages.WebPartPage- Allows web part zones- Allows web parts- Parameters – properties in the URL: SPHostUrl, SPLanguage,

SPClientTag, SPProductNumber, SPAppWebUrl

Page 10: Working with a super model for SharePoint Tuga IT 2016

App Part pageHTMLInherits from Microsoft.SharePoint.WebPartPages.WebPartPageNo placeholdersNo web part zonesNo web partsParameters – properties in the URL: SPHostUrl, SPLanguage, SPClientTag, SPProductNumber, SPAppWebUrlAdvanced IframeAdvanced IFRAMEEdit web part: Title, layout, custom category and custom propertiesResize No data from the pageNo data from parent page URL

Page 11: Working with a super model for SharePoint Tuga IT 2016

Using SharePoint lists, libraries, and controls• Controls such as

• List View, • SharePoint:ScriptLink, • SharePoint:EncodedLiteral, • WebPartPages:XsltListViewWebPart

• Lists and libraries that are part of the add-in or part of a SharePoint site• Lists and libraries that are part of the add-in do not have all the features

like the ones created on SharePoint• No Site Contents• No List Settings

Page 12: Working with a super model for SharePoint Tuga IT 2016

Client-Side Object Model

Lists and Libraries

ManagedMetadata

User Profiles

Workflows

SearchSite

Publishing

Analytics

BISocial

Add-ins, apps, farm solutions

_API

SharePoint 2013 - Office 365 - 2016

Page 13: Working with a super model for SharePoint Tuga IT 2016

DEMO

Page 14: Working with a super model for SharePoint Tuga IT 2016

REST and JSOM API

• JSOM - JavaScript Client Object Model• REST - stateless, client-server, cacheable communications protocol• What is better?• Can we mix?

Page 15: Working with a super model for SharePoint Tuga IT 2016

JavaScript

JSOMcontext = new SP.ClientContext.get_current();this.list = context.get_web().get_lists().getByTitle(newsList); var displayNewsQuery = '<View><Query><OrderBy><FieldRef Name="ID" Ascending="TRUE"/></OrderBy></Query></View>'; var query = new SP.CamlQuery(); query.set_viewXml(displayNewsQuery); news = this.list.getItems(query); context.load(news, 'Include(Title,ID)'); context.executeQueryAsync(onNewsSuccess, onFail);

RESTvar restUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('Links')/items";

$.ajax({ url: restUrl, method: "GET", headers: { "ACCEPT": "application/json;odata=verbose" }, success: onLinksSuccess, error: onError });

Page 16: Working with a super model for SharePoint Tuga IT 2016

Resembles SharePoint Server API, SSOMStrongly typedBatch requestsConnection authentication to the serverCovers more SharePoint API than REST

JSOM Advantages

Page 17: Working with a super model for SharePoint Tuga IT 2016

Add list and list columns with JSOMvar listCreationInfo = new SP.ListCreationInformation();listCreationInfo.set_title(listName); listCreationInfo.set_templateType(SP.ListTemplateType.genericList);var list = web.get_lists().add(listCreationInfo);var newCols = [ "<Field Type='DateTime' DisplayName='StartDate' />", "<Field Name='LinkURL' DisplayName='Link URL' Type='URL' />", true];var numberCols = newCols.length; for (var i = 0; i < numberCols; i++) { this.newColumns= list.get_fields().addFieldAsXml(newCols[i], true, SP.AddFieldOptions.defaultValue); }context.load(this.newColumns);

Page 18: Working with a super model for SharePoint Tuga IT 2016
Page 19: Working with a super model for SharePoint Tuga IT 2016

DEMO

Page 20: Working with a super model for SharePoint Tuga IT 2016

Office UI Fabric

Page 21: Working with a super model for SharePoint Tuga IT 2016

Office UI Fabric

• http://dev.office.com/fabric/styles• Fonts, colors, message colors• Grid• Icons• Controls

Page 22: Working with a super model for SharePoint Tuga IT 2016

<i class="ms-Icon ms-Icon--mail" aria-hidden="true"></i>

<a id="addLists" href="#"><i class="ms-Icon ms-Icon--circlePlus" style="font-size: xx-large" aria-hidden="true"></i>Add lists</a>

Page 23: Working with a super model for SharePoint Tuga IT 2016

<div> Add a Site <div> <input id="sitename" class="ms-TextField-field" type="text"> <span class="ms-TextField-description">This should be the name of the site</span> </div> </div>

Page 24: Working with a super model for SharePoint Tuga IT 2016

Responsive Grid

Page 25: Working with a super model for SharePoint Tuga IT 2016

<div class="ms-Grid"> <div class="ms-Grid-row"> <div class="ms-Grid-col ms-u-md12"> <h1>Super DEMO</h1> </div> </div></div><div class="ms-Grid-row"> <div class="ms-Grid-col ms-u-md2"> <a id="addLists" href="#"><i class="ms-Icon ms-Icon--circlePlus" style="font-size: xx-large" aria-hidden="true"></i>Add lists</a> </div>

Page 26: Working with a super model for SharePoint Tuga IT 2016

SharePoint FrameworkClient-side web parts, list-and page based applications

Page 27: Working with a super model for SharePoint Tuga IT 2016

No isolated app webNo app domain

Page 28: Working with a super model for SharePoint Tuga IT 2016

&

Visual Studio CodeOrVisual Studio

Workbench

SharePoint web part and Office 365

& LOCAL HOST

SharePoint 2016

Page 29: Working with a super model for SharePoint Tuga IT 2016

SharePoint Web Part .spapp package

.spapp

.xml

.js

.cssimages

Page 30: Working with a super model for SharePoint Tuga IT 2016

SharePoint web part .spapp

No .wsp, no .js, no .css, no images

Page 31: Working with a super model for SharePoint Tuga IT 2016

DevelopmentVisual Studio CodeTypeScriptReact is a suggested frameworkOffice UI Fabric

Page 32: Working with a super model for SharePoint Tuga IT 2016

List-based Applications

A list with custom list form pagesMain page

New item, Edit item, Display item

Any other page

Page 33: Working with a super model for SharePoint Tuga IT 2016

Page-based Applications

Site Pages Library

Pages

Page 34: Working with a super model for SharePoint Tuga IT 2016

Webhooks• List item receivers• Add item, delete item, check-out, check-in

Page 35: Working with a super model for SharePoint Tuga IT 2016

DEMOWeb part, React web part

Page 36: Working with a super model for SharePoint Tuga IT 2016

What’s new• Namespace – JavaScript• Hosting of js and other files• No cross-domain• No .aspx page

Page 37: Working with a super model for SharePoint Tuga IT 2016

context = new SP.ClientContext.get_current();

var context var context

var context var context

Page 38: Working with a super model for SharePoint Tuga IT 2016

JavaScript Patterns

function getImages() { context = new SP.ClientContext.get_current(); var request = new SP.WebRequestInfo(); var url = rssurl; var account = getProperty("Account");}

var myApp = (function () { var getImages = function () { context = new SP.ClientContext.get_current(); var request = new SP.WebRequestInfo(); var url = rssurl; var account = getProperty("Account");};

Page 39: Working with a super model for SharePoint Tuga IT 2016

TypeScript• TypeScript is a typed superset of JavaScript that compiles to plain

JavaScript

Page 40: Working with a super model for SharePoint Tuga IT 2016

JavaScript Frameworks• Model-View-View Model (MVVM) is a design pattern for building user

interfaces• Model - stored data• View model - representation of the data and operations (add,

remove)• View - visible, interactive UI

Page 41: Working with a super model for SharePoint Tuga IT 2016

Reactjs• React is front end library developed by Facebook• Used for handling view layer for web and mobile apps• JSX − JSX is JavaScript syntax extension• Components − everything is a component• Unidirectional data flow and Flux − React implements one way data

flow• Virtual DOM which is JavaScript object• Inline templating and JSX

Page 42: Working with a super model for SharePoint Tuga IT 2016

SharePoint Add-ins - Advantages• You can hide the lists from end-user• Both pages and an app part• .aspx page – HTML• Images, scripts, stylesheets hosted on SharePoint• Isolated is not always a bad thing

Page 43: Working with a super model for SharePoint Tuga IT 2016

SharePoint Framework - Advantages• Responsive mobile friendly• No iframe• Dynamic properties• Webhooks• List-based and Page-based• No need for cross-domain library to access SharePoint resources

Page 44: Working with a super model for SharePoint Tuga IT 2016

•SharePoint Add-ins on Office 365•Azure Web APIand Core 1.0

Page 45: Working with a super model for SharePoint Tuga IT 2016

Front-end Back-end

SharePoint AzureCore 1.0

Page 46: Working with a super model for SharePoint Tuga IT 2016

Front-end

Back-end

Page 47: Working with a super model for SharePoint Tuga IT 2016

SharePoint Client Object Model

• Lists, libraries• Sites, permissions• Users, user profiles• Search• Content • Metadata• External sources

Page 48: Working with a super model for SharePoint Tuga IT 2016

C# is what JavaScript is not

• Send email• Connect to database• Secret sauce, code-behind

Page 49: Working with a super model for SharePoint Tuga IT 2016

Microsoft on Instagram

Page 50: Working with a super model for SharePoint Tuga IT 2016

Code-behind• Intelligent apps• Current user name, takes pictures description, language-country,

customer profile, purchase history, your product inventory• Secret sauce logic

Page 51: Working with a super model for SharePoint Tuga IT 2016

Core 1.0• Cross-platform • project.json• global.json• appsettings.json• Command line• Rebirth of MVC• Coexist with ASP.NET 4.6

Page 52: Working with a super model for SharePoint Tuga IT 2016

DEMO

• Code-behind

Page 53: Working with a super model for SharePoint Tuga IT 2016

InstagramRSS feed

SharePointAdd-inJavaScript

Code-behindLogic

REST∫∞

Page 54: Working with a super model for SharePoint Tuga IT 2016

Solution Architecture

SharePoint add-in Core 1.0

App manifestXML files

JavaScriptCSSC#

D E M O

Page 55: Working with a super model for SharePoint Tuga IT 2016

DEMO

• SQL Database

Page 56: Working with a super model for SharePoint Tuga IT 2016
Page 57: Working with a super model for SharePoint Tuga IT 2016

THANK YOU TO OUR SPONSORS