Skip to content

Instantly share code, notes, and snippets.

var PageContextClassic = _spPageContextInfo;

Start SPFx Development Server:

gulp serve --nobrowser

Bundle & Pack SPFx Package for Production:

gulp bundle --ship

@precyx
precyx / complexIf.ts
Last active December 18, 2019 20:53
Complex Ifs/Conditions - 2 different approaches in handling them.
/**
* Complex If split up into multiple single compares
* Early returns help reduce nesting and complexity
* ES6 Includes helps readability of multi checks
* Pros: More readable, better debuggable, enables commenting of logic
* Cons: More verbose
* @fnDescription - Checks if a NavigationItem can render Children
*/
private canRenderChildren(process:NavigationItemModel, nodeType:NodeType, toggled:boolean, preventChildRendering:boolean){
let nodeTypesThatRenderChildren:any = [NodeType.HIDDEN, NodeType.TITLE];
@precyx
precyx / SearchService_NEW.ts
Last active December 18, 2019 20:55
SearchService Commit Compare old vs new. **Commit Message:** increase max search results limit to 499 items
import * as Handlebars from 'handlebars';
import ISearchService from './ISearchService';
import { ISearchResults, ISearchResult, IRefinementResult, IRefinementValue, IRefinementFilter, IPromotedResult, ISearchVerticalInformation } from '../../models/ISearchResult';
import { sp, SearchQuery, SearchResults, SPRest, Sort, SearchSuggestQuery, SortDirection } from '@pnp/sp';
import { Logger, LogLevel, ConsoleListener } from '@pnp/logging';
import { Text, Guid } from '@microsoft/sp-core-library';
import { sortBy, isEmpty, escape, chunk } from '@microsoft/sp-lodash-subset';
import LocalizationHelper from '../../helpers/LocalizationHelper';
import "@pnp/polyfill-ie11";
import IRefinerConfiguration from '../../models/IRefinerConfiguration';
@precyx
precyx / DetailsListComponent_NEW.ts
Last active December 18, 2019 20:56
Git Commit Compare: **Changed Files:** DetailsListComponent.ts details-list.html TemplateService.ts en-us.js mystrings.d.ts **Commit Message:** Add grouping options to details list layout
import * as React from 'react';
import { TextField } from 'office-ui-fabric-react/lib/TextField';
import { Fabric } from 'office-ui-fabric-react/lib/Fabric';
import { DetailsListLayoutMode, SelectionMode, IColumn } from 'office-ui-fabric-react/lib/DetailsList';
import { mergeStyleSets } from 'office-ui-fabric-react/lib/Styling';
import { ISearchResult } from '../../../models/ISearchResult';
import { IGroup, IGroupRenderProps, IGroupDividerProps, IGroupedListProps } from 'office-ui-fabric-react';
import * as Handlebars from 'handlebars';
import { ShimmeredDetailsList } from 'office-ui-fabric-react/lib/ShimmeredDetailsList';
import { IReadonlyTheme } from '@microsoft/sp-component-base';

ProductID: {110AFFEF-33E0-4D72-BD72-36399E02154C}

@precyx
precyx / NavigationItem.ts
Created December 18, 2019 15:32
# Extension of VMN Webpart: Add customizable fontSize of Titles and Elements with 2 new Select Controls: [titleTextsize] **Titel Textgrösse:** - "100%" - "90%" - "80%" - "70%" [elementTextsize] **Element Textgrösse:** - "12" - "13" - "14" [defaul
// @todo handle dynamic fontsize
// font size
let fontSize = 12;
let ___elementFontSize = 12;
let ___titleFontSize = { //titleSize: 90%
title1: 19,
title2: 16,
title3: 14,
elementTitle: 17,
};
<a
href='javascript:'
onclick="check_file('http://www.sharepointserver.eu/site/_vti_history/{X*512}/Documents/Specifications.pdf')">
</a>
http://srodev.dev.advis.ch/sites/00185/DisplayTemplateDokumente/Mein Dokument B.docx
http://srodev.dev.advis.ch/sites/00185/_vti_history/512/DisplayTemplateDokumente/Mein Dokument B.docx
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "PnP - Search Web Parts",
"id": "890affef-33e0-4d72-bd72-36399e02143b",
"version": "3.6.3.1",
"includeClientSideAssets": true,
"skipFeatureDeployment": false,
"isDomainIsolated": false
},
@precyx
precyx / react-hooks.js
Last active December 18, 2019 20:50
# UI Framework API Comparison: React, Vue, Svelte 3 - side effects - state changes - lifecycle
/**
React Hooks
*/
const [count, setCount] = useState(0)
// memoized derived state
const plusOne = useMemo(() => count + 1, [count])
// side effects in lifecycle hooks