React SPFx and viva extension holidays calendar first checkin

This commit is contained in:
Harminder Singh 2023-01-03 11:03:06 +05:30
parent 27d74757a2
commit 19a9bf733f
55 changed files with 83984 additions and 0 deletions

View File

@ -0,0 +1,352 @@
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
extends: ['@microsoft/eslint-config-spfx/lib/profiles/default'],
parserOptions: { tsconfigRootDir: __dirname },
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
'parserOptions': {
'project': './tsconfig.json',
'ecmaVersion': 2018,
'sourceType': 'module'
},
rules: {
// Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin
'@rushstack/no-new-null': 1,
// Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin
'@rushstack/hoist-jest-mock': 1,
// Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security
'@rushstack/security/no-unsafe-regexp': 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/adjacent-overload-signatures': 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
//
// CONFIGURATION: By default, these are banned: String, Boolean, Number, Object, Symbol
'@typescript-eslint/ban-types': [
1,
{
'extendDefaults': false,
'types': {
'String': {
'message': 'Use \'string\' instead',
'fixWith': 'string'
},
'Boolean': {
'message': 'Use \'boolean\' instead',
'fixWith': 'boolean'
},
'Number': {
'message': 'Use \'number\' instead',
'fixWith': 'number'
},
'Object': {
'message': 'Use \'object\' instead, or else define a proper TypeScript type:'
},
'Symbol': {
'message': 'Use \'symbol\' instead',
'fixWith': 'symbol'
},
'Function': {
'message': 'The \'Function\' type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with \'new\'.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.'
}
}
}
],
// RATIONALE: Code is more readable when the type of every variable is immediately obvious.
// Even if the compiler may be able to infer a type, this inference will be unavailable
// to a person who is reviewing a GitHub diff. This rule makes writing code harder,
// but writing code is a much less important activity than reading it.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/explicit-function-return-type': [
1,
{
'allowExpressions': true,
'allowTypedFunctionExpressions': true,
'allowHigherOrderFunctions': false
}
],
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Rationale to disable: although this is a recommended rule, it is up to dev to select coding style.
// Set to 1 (warning) or 2 (error) to enable.
'@typescript-eslint/explicit-member-accessibility': 0,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-array-constructor': 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
//
// RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript.
// This rule should be suppressed only in very special cases such as JSON.stringify()
// where the type really can be anything. Even if the type is flexible, another type
// may be more appropriate such as "unknown", "{}", or "Record<k,V>".
'@typescript-eslint/no-explicit-any': 1,
// RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch()
// handler. Thus wherever a Promise arises, the code must either append a catch handler,
// or else return the object to a caller (who assumes this responsibility). Unterminated
// promise chains are a serious issue. Besides causing errors to be silently ignored,
// they can also cause a NodeJS process to terminate unexpectedly.
'@typescript-eslint/no-floating-promises': 2,
// RATIONALE: Catches a common coding mistake.
'@typescript-eslint/no-for-in-array': 2,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-misused-new': 2,
// RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks
// a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler
// optimizations. If you are declaring loose functions/variables, it's better to make them
// static members of a class, since classes support property getters and their private
// members are accessible by unit tests. Also, the exercise of choosing a meaningful
// class name tends to produce more discoverable APIs: for example, search+replacing
// the function "reverse()" is likely to return many false matches, whereas if we always
// write "Text.reverse()" is more unique. For large scale organization, it's recommended
// to decompose your code into separate NPM packages, which ensures that component
// dependencies are tracked more conscientiously.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-namespace': [
1,
{
'allowDeclarations': false,
'allowDefinitionFiles': false
}
],
// RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)"
// that avoids the effort of declaring "title" as a field. This TypeScript feature makes
// code easier to write, but arguably sacrifices readability: In the notes for
// "@typescript-eslint/member-ordering" we pointed out that fields are central to
// a class's design, so we wouldn't want to bury them in a constructor signature
// just to save some typing.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Set to 1 (warning) or 2 (error) to enable the rule
'@typescript-eslint/no-parameter-properties': 0,
// RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code
// may impact performance.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-unused-vars': [
1,
{
'vars': 'all',
// Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code,
// the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures
// that are overriding a base class method or implementing an interface.
'args': 'none'
}
],
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-use-before-define': [
2,
{
'functions': false,
'classes': true,
'variables': true,
'enums': true,
'typedefs': true
}
],
// Disallows require statements except in import statements.
// In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports.
'@typescript-eslint/no-var-requires': 'error',
// RATIONALE: The "module" keyword is deprecated except when describing legacy libraries.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/prefer-namespace-keyword': 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Rationale to disable: it's up to developer to decide if he wants to add type annotations
// Set to 1 (warning) or 2 (error) to enable the rule
'@typescript-eslint/no-inferrable-types': 0,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios
'@typescript-eslint/no-empty-interface': 0,
// RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake.
'accessor-pairs': 1,
// RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking.
'dot-notation': [
1,
{
'allowPattern': '^_'
}
],
// RATIONALE: Catches code that is likely to be incorrect
'eqeqeq': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'for-direction': 1,
// RATIONALE: Catches a common coding mistake.
'guard-for-in': 2,
// RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time
// to split up your code.
'max-lines': ['warn', { max: 2000 }],
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-async-promise-executor': 2,
// RATIONALE: Deprecated language feature.
'no-caller': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-compare-neg-zero': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-cond-assign': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-constant-condition': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-control-regex': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-debugger': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-delete-var': 2,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-duplicate-case': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-empty': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-empty-character-class': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-empty-pattern': 1,
// RATIONALE: Eval is a security concern and a performance concern.
'no-eval': 1,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-ex-assign': 2,
// RATIONALE: System types are global and should not be tampered with in a scalable code base.
// If two different libraries (or two versions of the same library) both try to modify
// a type, only one of them can win. Polyfills are acceptable because they implement
// a standardized interoperable contract, but polyfills are generally coded in plain
// JavaScript.
'no-extend-native': 1,
// Disallow unnecessary labels
'no-extra-label': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-fallthrough': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-func-assign': 1,
// RATIONALE: Catches a common coding mistake.
'no-implied-eval': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-invalid-regexp': 2,
// RATIONALE: Catches a common coding mistake.
'no-label-var': 2,
// RATIONALE: Eliminates redundant code.
'no-lone-blocks': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-misleading-character-class': 2,
// RATIONALE: Catches a common coding mistake.
'no-multi-str': 2,
// RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to
// a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()",
// or else implies that the constructor is doing nontrivial computations, which is often
// a poor class design.
'no-new': 1,
// RATIONALE: Obsolete language feature that is deprecated.
'no-new-func': 2,
// RATIONALE: Obsolete language feature that is deprecated.
'no-new-object': 2,
// RATIONALE: Obsolete notation.
'no-new-wrappers': 1,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-octal': 2,
// RATIONALE: Catches code that is likely to be incorrect
'no-octal-escape': 2,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-regex-spaces': 2,
// RATIONALE: Catches a common coding mistake.
'no-return-assign': 2,
// RATIONALE: Security risk.
'no-script-url': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-self-assign': 2,
// RATIONALE: Catches a common coding mistake.
'no-self-compare': 2,
// RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use
// commas to create compound expressions. In general code is more readable if each
// step is split onto a separate line. This also makes it easier to set breakpoints
// in the debugger.
'no-sequences': 1,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-shadow-restricted-names': 2,
// RATIONALE: Obsolete language feature that is deprecated.
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-sparse-arrays': 2,
// RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception,
// such flexibility adds pointless complexity, by requiring every catch block to test
// the type of the object that it receives. Whereas if catch blocks can always assume
// that their object implements the "Error" contract, then the code is simpler, and
// we generally get useful additional information like a call stack.
'no-throw-literal': 2,
// RATIONALE: Catches a common coding mistake.
'no-unmodified-loop-condition': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-unsafe-finally': 2,
// RATIONALE: Catches a common coding mistake.
'no-unused-expressions': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-unused-labels': 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-useless-catch': 1,
// RATIONALE: Avoids a potential performance problem.
'no-useless-concat': 1,
// RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior.
// Always use "let" or "const" instead.
//
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'no-var': 2,
// RATIONALE: Generally not needed in modern code.
'no-void': 1,
// RATIONALE: Obsolete language feature that is deprecated.
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-with': 2,
// RATIONALE: Makes logic easier to understand, since constants always have a known value
// @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js
'prefer-const': 1,
// RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused.
'promise/param-names': 2,
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'require-atomic-updates': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'require-yield': 1,
// "Use strict" is redundant when using the TypeScript compiler.
'strict': [
2,
'never'
],
// RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
'use-isnan': 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
// Set to 1 (warning) or 2 (error) to enable.
// Rationale to disable: !!{}
'no-extra-boolean-cast': 0,
// ====================================================================
// @microsoft/eslint-plugin-spfx
// ====================================================================
'@microsoft/spfx/import-requires-chunk-name': 1,
'@microsoft/spfx/no-require-ensure': 2,
'@microsoft/spfx/pair-react-dom-render-unmount': 1
}
},
{
// For unit tests, we can be a little bit less strict. The settings below revise the
// defaults specified in the extended configurations, as well as above.
files: [
// Test files
'*.test.ts',
'*.test.tsx',
'*.spec.ts',
'*.spec.tsx',
// Facebook convention
'**/__mocks__/*.ts',
'**/__mocks__/*.tsx',
'**/__tests__/*.ts',
'**/__tests__/*.tsx',
// Microsoft convention
'**/test/*.ts',
'**/test/*.tsx'
],
rules: {}
}
]
};

View File

@ -0,0 +1,35 @@
# Logs
logs
*.log
npm-debug.log*
# Dependency directories
node_modules
# Build generated files
dist
lib
release
solution
temp
*.sppkg
.heft
# Coverage directory used by tools like istanbul
coverage
# OSX
.DS_Store
# Visual Studio files
.ntvs_analysis.dat
.vs
bin
obj
# Resx Generated Code
*.resx.ts
# Styles Generated Code
*.scss.ts
*.scss.d.ts

View File

@ -0,0 +1,16 @@
!dist
config
gulpfile.js
release
src
temp
tsconfig.json
tslint.json
*.log
.yo-rc.json
.vscode

View File

@ -0,0 +1,22 @@
{
"@microsoft/generator-sharepoint": {
"plusBeta": false,
"isCreatingSolution": false,
"nodeVersion": "16.16.0",
"sdksVersions": {
"@microsoft/microsoft-graph-client": "3.0.2",
"@microsoft/teams-js": "2.4.1"
},
"version": "1.16.1",
"libraryName": "holidays-calendar",
"libraryId": "c85f1137-142e-4570-b3c9-3cdc47580452",
"environment": "spo",
"packageManager": "npm",
"solutionName": "holidays-calendar",
"solutionShortDescription": "holidays-calendar description",
"skipFeatureDeployment": true,
"isDomainIsolated": false,
"componentType": "adaptiveCardExtension",
"aceTemplateType": "PrimaryText"
}
}

View File

@ -0,0 +1,49 @@
<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2022/09/ProvisioningSchema">
<pnp:Preferences Generator="PnP.Framework, Version=1.11.2.0, Culture=neutral, PublicKeyToken=0d501f89f11b748c" />
<pnp:Templates ID="CONTAINER-TEMPLATE-47E7C23DA1134744BED17D1CD2BE6A4E">
<pnp:ProvisioningTemplate ID="TEMPLATE-47E7C23DA1134744BED17D1CD2BE6A4E" Version="1" BaseSiteTemplate="GROUP#0" Scope="RootSite">
<pnp:Lists>
<pnp:ListInstance Title="Holidays" Description="" DocumentTemplate="" OnQuickLaunch="true" TemplateType="100" Url="Lists/Holidays" EnableVersioning="true" MinorVersionLimit="0" MaxVersionLimit="50" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-de22-43b2-a848-c05709900100" EnableFolderCreation="false" DefaultDisplayFormUrl="{site}/Lists/Holidays/DispForm.aspx" DefaultEditFormUrl="{site}/Lists/Holidays/EditForm.aspx" DefaultNewFormUrl="{site}/Lists/Holidays/NewForm.aspx" ImageUrl="/_layouts/15/images/itgen.png?rev=47" IrmExpire="false" IrmReject="false" IsApplicationList="false" ValidationFormula="" ValidationMessage="">
<pnp:ContentTypeBindings>
<pnp:ContentTypeBinding ContentTypeID="0x01" Default="true" />
<pnp:ContentTypeBinding ContentTypeID="0x0120" />
</pnp:ContentTypeBindings>
<pnp:Views>
<View Name="{64388604-296F-4F45-94FE-92AE6E1DD759}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="All Items" Url="{site}/Lists/Holidays/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/generic.png?rev=47">
<Query />
<ViewFields>
<FieldRef Name="LinkTitle" />
<FieldRef Name="Date" />
<FieldRef Name="Location" />
<FieldRef Name="Optional" />
</ViewFields>
<RowLimit Paged="TRUE">30</RowLimit>
<JSLink>clienttemplates.js</JSLink>
<CustomFormatter />
</View>
</pnp:Views>
<pnp:Fields>
<Field DisplayName="Date" FriendlyDisplayFormat="Disabled" Format="DateOnly" IsModern="TRUE" Name="Date" Title="Date" Type="DateTime" ID="{2cf76e70-f12c-46ec-888b-c65da9dd01bb}" SourceID="{{listid:Holidays}}" StaticName="Date" ColName="datetime1" RowOrdinal="0" />
<Field ClientSideComponentId="00000000-0000-0000-0000-000000000000" CustomFormatter="{&quot;elmType&quot;:&quot;div&quot;,&quot;style&quot;:{&quot;flex-wrap&quot;:&quot;wrap&quot;,&quot;display&quot;:&quot;flex&quot;},&quot;children&quot;:[{&quot;forEach&quot;:&quot;__INTERNAL__ in @currentField&quot;,&quot;elmType&quot;:&quot;div&quot;,&quot;style&quot;:{&quot;box-sizing&quot;:&quot;border-box&quot;,&quot;padding&quot;:&quot;4px 8px 5px 8px&quot;,&quot;overflow&quot;:&quot;hidden&quot;,&quot;text-overflow&quot;:&quot;ellipsis&quot;,&quot;display&quot;:&quot;flex&quot;,&quot;border-radius&quot;:&quot;16px&quot;,&quot;height&quot;:&quot;24px&quot;,&quot;align-items&quot;:&quot;center&quot;,&quot;white-space&quot;:&quot;nowrap&quot;,&quot;margin&quot;:&quot;4px 4px 4px 4px&quot;},&quot;attributes&quot;:{&quot;class&quot;:{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;[$__INTERNAL__]&quot;,&quot;India&quot;]},&quot;sp-css-backgroundColor-BgCornflowerBlue sp-css-color-CornflowerBlueFont&quot;,{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;[$__INTERNAL__]&quot;,&quot;United States&quot;]},&quot;sp-css-backgroundColor-BgMintGreen sp-css-color-MintGreenFont&quot;,{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;[$__INTERNAL__]&quot;,&quot;Canada&quot;]},&quot;sp-css-backgroundColor-BgGold sp-css-color-GoldFont&quot;,{&quot;operator&quot;:&quot;:&quot;,&quot;operands&quot;:[{&quot;operator&quot;:&quot;==&quot;,&quot;operands&quot;:[&quot;[$__INTERNAL__]&quot;,&quot;All&quot;]},&quot;sp-css-backgroundColor-BgCoral sp-css-color-CoralFont&quot;,&quot;sp-field-borderAllRegular sp-field-borderAllSolid sp-css-borderColor-neutralSecondary&quot;]}]}]}]}},&quot;txtContent&quot;:&quot;[$__INTERNAL__]&quot;}],&quot;templateId&quot;:&quot;BgColorChoicePill&quot;}" DisplayName="Location" FillInChoice="FALSE" Format="Dropdown" Name="Location" Title="Location" Type="MultiChoice" ID="{c10a22de-e1a3-4cf7-b9bd-69d4b9516ff6}" Version="4" StaticName="Location" SourceID="{{listid:Holidays}}" ColName="ntext2" RowOrdinal="0">
<CHOICES>
<CHOICE>India</CHOICE>
<CHOICE>United States</CHOICE>
<CHOICE>Canada</CHOICE>
</CHOICES>
</Field>
<Field DisplayName="Optional" Format="Dropdown" IsModern="TRUE" Name="Optional" Title="Optional" Type="Boolean" ID="{f7e35a2f-0483-4939-82a5-473928d5db93}" SourceID="{{listid:Holidays}}" StaticName="Optional" ColName="bit1" RowOrdinal="0">
<Default>0</Default>
</Field>
</pnp:Fields>
<pnp:FieldRefs>
<pnp:FieldRef ID="fa564e0f-0c70-4ab9-b863-0177e6ddd247" Name="Title" Required="true" DisplayName="Title" />
</pnp:FieldRefs>
<pnp:Webhooks>
<pnp:Webhook ServerNotificationUrl="https://southindia1-0.pushnp.svc.ms/notifications?token=cbeca6d3-9742-4e3a-add6-4b18c8256703" ExpiresInDays="1" />
</pnp:Webhooks>
</pnp:ListInstance>
</pnp:Lists>
</pnp:ProvisioningTemplate>
</pnp:Templates>
</pnp:Provisioning>

View File

@ -0,0 +1,12 @@
$siteurl = "<Site URL>"
Connect-PnPOnline -Url $siteurl -Interactive
Write-Host "...Connected successfully"
$continue = Read-Host "Click C to continue"
if ($continue -ne "C") {
exit
}
$inputTemplateFile = "Metadata.xml"
Invoke-PnPSiteTemplate -Path $inputTemplateFile -Handlers Lists

View File

@ -0,0 +1,77 @@
# holidays-calendar
## Summary
Holiday calendar solution contains SPFx webpart and Adaptive card extenstion for Viva connections. SPFx webpart provides below functionalities
1. Provides the functionality to add the holiday as an event in the calendar
2. Allows download all the holidays as CSV
3. Icon to show Fixed and optional holiday
4. Webpart properties to set the webpart title, hide/show download option, hide/show optional fixed holiday icons
ACE card extension provides below functionalities
1. Show the next Holiday
2. Allows to add holiday as an event in the calendar.
![image](https://user-images.githubusercontent.com/17841313/209691123-03ac3c5d-cc8e-490e-8cb2-837539914db8.png)
![image](https://user-images.githubusercontent.com/17841313/209691198-4d0cbc31-f0d4-49c8-a1b5-ae8701406221.png)
## Used SharePoint Framework Version
![version](https://img.shields.io/badge/version-1.16.1-green.svg)
## Applies to
- [SharePoint Framework](https://aka.ms/spfx)
- [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
> Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram)
## Prerequisites
> Run \_applyTemplates powershell to create the Holidays list officelocation property of user profile should have a valid value and holiday item for that
> location should be avilable in the Holidays list(created as part of previous step)
## Solution
| Solution | Author(s) |
| ----------------------- | ------------------------------------------------------------------- |
| react-holidays-calendar | [Harminder Singh](https://www.linkedin.com/in/harmindersinghsethi/) |
## Version history
| Version | Date | Comments |
| ------- | ---------------- | --------------- |
| 1.0 | January 29, 2021 | Initial release |
## Disclaimer
**THIS CODE IS PROVIDED _AS IS_ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABILITY, OR NON-INFRINGEMENT.**
---
## Minimal Path to Awesome
- Clone this repository
- Ensure that you are at the solution folder
- in the command-line run:
- **npm install**
- **gulp serve**
> Include any additional steps as needed.
## Features
1. Provides the functionality to add the holiday as an event in the calendar
2. Allows download all the holidays as CSV
3. Icon to show Fixed and optional holiday
## References
- [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
- [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
- [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
- [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
- [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development

View File

@ -0,0 +1,27 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"holidays-calendar-web-part": {
"components": [
{
"entrypoint": "./lib/webparts/holidaysCalendar/HolidaysCalendarWebPart.js",
"manifest": "./src/webparts/holidaysCalendar/HolidaysCalendarWebPart.manifest.json"
}
]
},
"holiday-view-adaptive-card-extension": {
"components": [
{
"entrypoint": "./lib/adaptiveCardExtensions/holidayView/HolidayViewAdaptiveCardExtension.js",
"manifest": "./src/adaptiveCardExtensions/holidayView/HolidayViewAdaptiveCardExtension.manifest.json"
}
]
}
},
"externals": {},
"localizedResources": {
"HolidaysCalendarWebPartStrings": "lib/webparts/holidaysCalendar/loc/{locale}.js",
"HolidayViewAdaptiveCardExtensionStrings": "lib/adaptiveCardExtensions/holidayView/loc/{locale}.js"
}
}

View File

@ -0,0 +1,7 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"workingDir": "./release/assets/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "holidays-calendar",
"accessKey": "<!-- ACCESS KEY -->"
}

View File

@ -0,0 +1,56 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "holidays-calendar",
"id": "c85f1137-142e-4570-b3c9-3cdc47580452",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"skipFeatureDeployment": true,
"webApiPermissionRequests": [
{
"resource": "Microsoft Graph",
"scope": "Calendars.ReadWrite"
},
{
"resource": "Microsoft Graph",
"scope": "User.Read"
},
{
"resource": "Microsoft Graph",
"scope": "MailboxSettings.Read"
}
],
"isDomainIsolated": false,
"developer": {
"name": "Harminder Singh",
"websiteUrl": "https://github.com/HarminderSethi",
"privacyUrl": "",
"termsOfUseUrl": "",
"mpnId": "Undefined-1.16.1"
},
"metadata": {
"shortDescription": {
"default": "holidays-calendar description"
},
"longDescription": {
"default": "holidays-calendar description"
},
"screenshotPaths": [],
"videoUrl": "",
"categories": []
},
"features": [
{
"title": "holidays-calendar Feature",
"description": "The feature that activates elements of the holidays-calendar solution.",
"id": "182f7879-26d6-4fb6-b5ad-9f34a54ba79d",
"version": "1.0.0.0"
}
]
},
"paths": {
"zippedPackage": "solution/holidays-calendar.sppkg"
}
}

View File

@ -0,0 +1,3 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
}

View File

@ -0,0 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
"port": 4321,
"https": true,
"initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"
}

View File

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

View File

@ -0,0 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/s-KaiNet/spfx-fast-serve/master/schema/config.latest.schema.json",
"cli": {
"isLibraryComponent": false
}
}

View File

@ -0,0 +1,24 @@
/*
* User webpack settings file. You can add your own settings here.
* Changes from this file will be merged into the base webpack configuration file.
* This file will not be overwritten by the subsequent spfx-fast-serve calls.
*/
// you can add your project related webpack configuration here, it will be merged using webpack-merge module
// i.e. plugins: [new webpack.Plugin()]
const webpackConfig = {
}
// for even more fine-grained control, you can apply custom webpack settings using below function
const transformConfig = function (initialWebpackConfig) {
// transform the initial webpack config here, i.e.
// initialWebpackConfig.plugins.push(new webpack.Plugin()); etc.
return initialWebpackConfig;
}
module.exports = {
webpackConfig,
transformConfig
}

View File

@ -0,0 +1,22 @@
'use strict';
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.`);
var getTasks = build.rig.getTasks;
build.rig.getTasks = function () {
var result = getTasks.call(build.rig);
result.set('serve', result.get('serve-deprecated'));
return result;
};
/* fast-serve */
const { addFastServe } = require("spfx-fast-serve-helpers");
addFastServe(build);
/* end of fast-serve */
build.initialize(require('gulp'));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,53 @@
{
"name": "holidays-calendar",
"version": "0.0.1",
"private": true,
"engines": {
"node": ">=16.13.0 <17.0.0"
},
"main": "lib/index.js",
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test",
"serve": "gulp bundle --custom-serve --max_old_space_size=4096 && fast-serve"
},
"dependencies": {
"@fluentui/react-components": "^9.7.4",
"@microsoft/generator-sharepoint": "^1.16.1",
"@microsoft/sp-core-library": "1.16.1",
"@microsoft/sp-lodash-subset": "1.16.1",
"@microsoft/sp-office-ui-fabric-core": "1.16.1",
"@microsoft/sp-property-pane": "1.16.1",
"@microsoft/sp-webpart-base": "1.16.1",
"@pnp/core": "^3.10.0",
"@pnp/graph": "^3.10.0",
"@pnp/logging": "^3.10.0",
"@pnp/queryable": "^3.10.0",
"@pnp/sp": "^3.10.0",
"json-to-csv-export": "^2.1.1",
"moment": "^2.29.4",
"office-ui-fabric-react": "^7.199.1",
"react": "17.0.1",
"react-dom": "17.0.1",
"tslib": "2.3.1",
"@microsoft/sp-adaptive-card-extension-base": "1.16.1"
},
"devDependencies": {
"@microsoft/eslint-config-spfx": "1.16.1",
"@microsoft/eslint-plugin-spfx": "1.16.1",
"@microsoft/microsoft-graph-types": "^2.25.0",
"@microsoft/rush-stack-compiler-4.5": "0.2.2",
"@microsoft/sp-build-web": "1.16.1",
"@microsoft/sp-module-interfaces": "1.16.1",
"@rushstack/eslint-config": "2.5.1",
"@types/react": "17.0.45",
"@types/react-dom": "17.0.17",
"@types/webpack-env": "~1.15.2",
"ajv": "^6.12.5",
"eslint-plugin-react-hooks": "4.3.0",
"gulp": "4.0.2",
"spfx-fast-serve-helpers": "~1.16.0",
"typescript": "4.5.5"
}
}

View File

@ -0,0 +1,27 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx/adaptive-card-extension-manifest.schema.json",
"id": "6cef4b24-5fab-425a-8dec-1e8f5f4a9dfe",
"alias": "HolidayViewAdaptiveCardExtension",
"componentType": "AdaptiveCardExtension",
// The "*" signifies that the version should be taken from the package.json
"version": "*",
"manifestVersion": 2,
// If true, the component can only be installed on sites where Custom Script is allowed.
// Components that allow authors to embed arbitrary script code should set this to true.
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
"requiresCustomScript": false,
"supportedHosts": ["Dashboard"],
"preconfiguredEntries": [{
"groupId": "bd067b1e-3ad5-4d5d-a5fe-505f07d7f59c", // Dashboard
"group": { "default": "Dashboard" },
"title": { "default": "HolidayView" },
"description": { "default": "HolidayView description" },
"officeFabricIconFontName": "SharePointLogo",
"properties": {
"title": "HolidayView"
},
"cardSize": "Large"
}]
}

View File

@ -0,0 +1,82 @@
import { ItemSuccessQuickView } from "./quickView/ItemSuccessQuickView";
import { IPropertyPaneConfiguration } from "@microsoft/sp-property-pane";
import { BaseAdaptiveCardExtension } from "@microsoft/sp-adaptive-card-extension-base";
import { CardView } from "./cardView/CardView";
import { QuickView } from "./quickView/QuickView";
import { HolidayViewPropertyPane } from "./HolidayViewPropertyPane";
import { SPService } from "../../common/services/SPService";
import { GraphService } from "../../common/services/GraphService";
import { HolidaysCalendarService } from "../../common/services/HolidaysCalendarService";
import { IHoliday, IHolidayItem } from "../../common/interfaces/HolidaysCalendar";
import * as moment from "moment";
import { IEmployeeInfo } from "../../webparts/holidaysCalendar/interfaces/IHolidaysCalendarState";
import { ItemFailureQuickView } from "./quickView/ItemFailureQuickView";
export interface IHolidayViewAdaptiveCardExtensionProps {
title: string;
}
export interface IHolidayViewAdaptiveCardExtensionState {
holidayItems: IHolidayItem[];
listItems: IHoliday[];
currentIndex: number;
holidayService: HolidaysCalendarService;
employeeInfo: IEmployeeInfo;
}
const CARD_VIEW_REGISTRY_ID: string = "HolidayView_CARD_VIEW";
export const QUICK_VIEW_REGISTRY_ID: string = "HolidayView_QUICK_VIEW";
export const ITEMSUCCESS_QUICK_VIEW_REGISTRY_ID: string = "ItemSuccess_Quick_VIEW";
export const ITEMFAILURE_QUICK_VIEW_REGISTRY_ID: string = "ItemFailure_Quick_VIEW";
export default class HolidayViewAdaptiveCardExtension extends BaseAdaptiveCardExtension<
IHolidayViewAdaptiveCardExtensionProps,
IHolidayViewAdaptiveCardExtensionState
> {
private _deferredPropertyPane: HolidayViewPropertyPane | undefined;
private spService: SPService;
private graphService: GraphService;
private holidayService: HolidaysCalendarService;
public async onInit(): Promise<void> {
this.spService = new SPService(this.context);
this.graphService = new GraphService(this.context);
this.holidayService = new HolidaysCalendarService(this.spService, this.graphService);
const employeeInfo = await this.holidayService.getEmployeeInfo();
const listItems = await this.holidayService.getHolidaysByLocation(employeeInfo.officeLocation);
const holidayItems = this.holidayService.getHolidayItemsToRender(listItems);
const upcomingHoliday = holidayItems.filter((item) => moment().isBefore(item.holidayDate.value, "days"));
const upcomingHolidayIndex = upcomingHoliday.length > 0 ? holidayItems.findIndex((item) => item.Id == upcomingHoliday[0].Id) : 0;
this.state = {
holidayItems: holidayItems,
listItems: listItems,
currentIndex: upcomingHolidayIndex,
holidayService: this.holidayService,
employeeInfo: employeeInfo,
};
this.cardNavigator.register(CARD_VIEW_REGISTRY_ID, () => new CardView());
this.quickViewNavigator.register(QUICK_VIEW_REGISTRY_ID, () => new QuickView());
this.quickViewNavigator.register(ITEMSUCCESS_QUICK_VIEW_REGISTRY_ID, () => new ItemSuccessQuickView());
this.quickViewNavigator.register(ITEMFAILURE_QUICK_VIEW_REGISTRY_ID, () => new ItemFailureQuickView());
return Promise.resolve();
}
protected loadPropertyPaneResources(): Promise<void> {
return import(
/* webpackChunkName: 'HolidayView-property-pane'*/
"./HolidayViewPropertyPane"
).then((component) => {
this._deferredPropertyPane = new component.HolidayViewPropertyPane();
});
}
protected renderCard(): string | undefined {
return CARD_VIEW_REGISTRY_ID;
}
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return this._deferredPropertyPane?.getPropertyPaneConfiguration();
}
}

View File

@ -0,0 +1,23 @@
import { IPropertyPaneConfiguration, PropertyPaneTextField } from '@microsoft/sp-property-pane';
import * as strings from 'HolidayViewAdaptiveCardExtensionStrings';
export class HolidayViewPropertyPane {
public getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [
{
header: { description: strings.PropertyPaneDescription },
groups: [
{
groupFields: [
PropertyPaneTextField('title', {
label: strings.TitleFieldLabel
})
]
}
]
}
]
};
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -0,0 +1,8 @@
<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10.3125 13.0625C13.9196 13.0625 16.8438 10.1384 16.8438 6.53125C16.8438 2.92414 13.9196 0 10.3125 0C6.70539 0 3.78125 2.92414 3.78125 6.53125C3.78125 10.1384 6.70539 13.0625 10.3125 13.0625Z" fill="#036C70"/>
<path d="M16.5 17.875C19.5376 17.875 22 15.4126 22 12.375C22 9.33743 19.5376 6.875 16.5 6.875C13.4624 6.875 11 9.33743 11 12.375C11 15.4126 13.4624 17.875 16.5 17.875Z" fill="#1A9BA1"/>
<path d="M11 22C13.468 22 15.4688 19.9993 15.4688 17.5312C15.4688 15.0632 13.468 13.0625 11 13.0625C8.53198 13.0625 6.53125 15.0632 6.53125 17.5312C6.53125 19.9993 8.53198 22 11 22Z" fill="#37C6D0"/>
<path opacity="0.5" d="M13.75 5.50464H3.88472C3.82303 5.84353 3.78843 6.1868 3.78125 6.53119C3.78125 8.26338 4.46936 9.92463 5.69421 11.1495C6.91906 12.3743 8.5803 13.0624 10.3125 13.0624C10.5137 13.0624 10.7035 13.021 10.9001 13.0032C10.9031 13.0259 10.9038 13.0493 10.907 13.0718C10.1797 13.0855 9.46672 13.2769 8.83032 13.6293C8.19392 13.9817 7.6534 14.4844 7.25589 15.0937C6.85838 15.703 6.61595 16.4002 6.54975 17.1246C6.48355 17.8491 6.59559 18.5787 6.87609 19.2499H12.3743C12.7356 19.2499 13.0932 19.1788 13.427 19.0406C13.7607 18.9023 14.0639 18.6997 14.3194 18.4443C14.5748 18.1889 14.7774 17.8856 14.9156 17.5519C15.0539 17.2182 15.125 16.8605 15.125 16.4993V6.87964C15.125 6.51497 14.9801 6.16523 14.7223 5.90737C14.4644 5.6495 14.1147 5.50464 13.75 5.50464Z" fill="black"/>
<path d="M12.375 4.125H1.375C0.615608 4.125 0 4.74061 0 5.5V16.5C0 17.2594 0.615608 17.875 1.375 17.875H12.375C13.1344 17.875 13.75 17.2594 13.75 16.5V5.5C13.75 4.74061 13.1344 4.125 12.375 4.125Z" fill="#038387"/>
<path d="M5.07712 10.8554C4.80603 10.6695 4.58101 10.4241 4.41928 10.138C4.26016 9.83564 4.18125 9.49752 4.19007 9.15597C4.17534 8.6949 4.32648 8.24384 4.61603 7.88472C4.91574 7.53092 5.3077 7.26716 5.74833 7.12277C6.24641 6.95324 6.76967 6.8695 7.29578 6.87512C7.98742 6.84915 8.67801 6.94905 9.33393 7.16996V8.65529C9.04944 8.47693 8.73813 8.34545 8.41191 8.26587C8.05945 8.17641 7.69716 8.13156 7.33353 8.13236C6.94967 8.11836 6.5685 8.20157 6.2254 8.37427C6.0939 8.43448 5.98253 8.53131 5.90461 8.65316C5.82669 8.77501 5.78552 8.91673 5.78603 9.06137C5.78391 9.24141 5.85046 9.4155 5.97214 9.54823C6.11501 9.70135 6.28496 9.82675 6.47341 9.9181C6.68388 10.0258 6.99754 10.1686 7.41439 10.3465C7.46064 10.3616 7.50568 10.3802 7.54914 10.4021C7.96131 10.5685 8.35821 10.7705 8.73535 11.0057C9.04484 11.1955 9.29704 11.4657 9.46511 11.7875C9.63317 12.1093 9.7108 12.4707 9.68973 12.8331C9.71074 13.3069 9.57003 13.7738 9.29071 14.1571C9.01622 14.5043 8.64457 14.7618 8.22312 14.897C7.73228 15.056 7.2186 15.133 6.7027 15.1251C6.24096 15.1271 5.77996 15.088 5.32516 15.0082C4.93957 14.9448 4.56359 14.8326 4.20624 14.6745V13.1057C4.54746 13.3572 4.93095 13.5456 5.33855 13.662C5.74129 13.7918 6.16102 13.8611 6.58408 13.8679C6.97637 13.8933 7.36787 13.8075 7.71359 13.6204C7.83325 13.5482 7.93154 13.4455 7.99837 13.3228C8.06519 13.2001 8.09814 13.0618 8.09382 12.9221C8.09573 12.7231 8.01926 12.5312 7.88091 12.3881C7.71009 12.2151 7.51135 12.0722 7.29303 11.9654C7.04326 11.8356 6.67394 11.665 6.18507 11.4536C5.79647 11.2922 5.42526 11.0917 5.07712 10.8554Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -0,0 +1,73 @@
import {
BasePrimaryTextCardView,
IPrimaryTextCardParameters,
IExternalLinkCardAction,
IQuickViewCardAction,
ICardButton,
IActionArguments,
} from "@microsoft/sp-adaptive-card-extension-base";
import { IHolidayViewAdaptiveCardExtensionProps, IHolidayViewAdaptiveCardExtensionState, QUICK_VIEW_REGISTRY_ID } from "../HolidayViewAdaptiveCardExtension";
export class CardView extends BasePrimaryTextCardView<IHolidayViewAdaptiveCardExtensionProps, IHolidayViewAdaptiveCardExtensionState> {
public get cardButtons(): [ICardButton] | [ICardButton, ICardButton] | undefined {
const buttons: ICardButton[] = [];
if (this.state.currentIndex > 0) {
buttons.push({
title: "Previous",
action: {
type: "Submit",
parameters: {
id: "previous",
op: -1,
},
},
});
}
if (this.state.currentIndex < this.state.holidayItems.length - 1) {
buttons.push({
title: "Next",
action: {
type: "Submit",
parameters: {
id: "next",
op: 1, // Increment the index
},
},
});
}
return buttons as [ICardButton] | [ICardButton, ICardButton];
}
public onAction(action: IActionArguments): void {
if (action.type === "Submit") {
const { id, op } = action.data;
switch (id) {
case "previous":
case "next":
this.setState({ currentIndex: this.state.currentIndex + op });
break;
}
}
}
public get data(): IPrimaryTextCardParameters {
const item = this.state.holidayItems[this.state.currentIndex];
return {
primaryText: item.holidayTitle.label,
description: item.holidayDay.label + " " + item.holidayDate.label,
title: "Holidays",
iconProperty: "Calendar",
};
}
public get onCardSelection(): IQuickViewCardAction | IExternalLinkCardAction | undefined {
return {
type: "QuickView",
parameters: {
view: QUICK_VIEW_REGISTRY_ID,
},
};
}
}

View File

@ -0,0 +1,11 @@
define([], function() {
return {
"PropertyPaneDescription": "Write 1-3 sentences describing the functionality of this component.",
"TitleFieldLabel": "Card title",
"Title": "Adaptive Card Extension",
"SubTitle": "Quick view",
"PrimaryText": "SPFx Adaptive Card Extension",
"Description": "Create your SPFx Adaptive Card Extension solution!",
"QuickViewButton": "Quick view"
}
});

View File

@ -0,0 +1,14 @@
declare interface IHolidayViewAdaptiveCardExtensionStrings {
PropertyPaneDescription: string;
TitleFieldLabel: string;
Title: string;
SubTitle: string;
PrimaryText: string;
Description: string;
QuickViewButton: string;
}
declare module 'HolidayViewAdaptiveCardExtensionStrings' {
const strings: IHolidayViewAdaptiveCardExtensionStrings;
export = strings;
}

View File

@ -0,0 +1,28 @@
import { ISPFxAdaptiveCard, BaseAdaptiveCardView, IActionArguments } from "@microsoft/sp-adaptive-card-extension-base";
import { IHolidayViewAdaptiveCardExtensionProps, IHolidayViewAdaptiveCardExtensionState } from "../HolidayViewAdaptiveCardExtension";
export interface IQuickViewData {
holidayTitle: string;
detail: string;
}
export class ItemFailureQuickView extends BaseAdaptiveCardView<IHolidayViewAdaptiveCardExtensionProps, IHolidayViewAdaptiveCardExtensionState, IQuickViewData> {
public get data(): IQuickViewData {
return {
holidayTitle: this.state.holidayItems[this.state.currentIndex].holidayTitle.label,
detail: this.state.holidayItems[this.state.currentIndex].holidayDay.label + " " + this.state.holidayItems[this.state.currentIndex].holidayDate.label,
};
}
public onAction(action: IActionArguments): void {
if (action.type === "Submit") {
const { id } = action.data;
if (id === "back") {
this.quickViewNavigator.pop();
}
}
}
public get template(): ISPFxAdaptiveCard {
return require("./template/ItemFailureTemplate.json");
}
}

View File

@ -0,0 +1,28 @@
import { ISPFxAdaptiveCard, BaseAdaptiveCardView, IActionArguments } from "@microsoft/sp-adaptive-card-extension-base";
import { IHolidayViewAdaptiveCardExtensionProps, IHolidayViewAdaptiveCardExtensionState } from "../HolidayViewAdaptiveCardExtension";
export interface IQuickViewData {
holidayTitle: string;
detail: string;
}
export class ItemSuccessQuickView extends BaseAdaptiveCardView<IHolidayViewAdaptiveCardExtensionProps, IHolidayViewAdaptiveCardExtensionState, IQuickViewData> {
public get data(): IQuickViewData {
return {
holidayTitle: this.state.holidayItems[this.state.currentIndex].holidayTitle.label,
detail: this.state.holidayItems[this.state.currentIndex].holidayDay.label + " " + this.state.holidayItems[this.state.currentIndex].holidayDate.label,
};
}
public onAction(action: IActionArguments): void {
if (action.type === "Submit") {
const { id } = action.data;
if (id === "back") {
this.quickViewNavigator.pop();
}
}
}
public get template(): ISPFxAdaptiveCard {
return require("./template/ItemSuccessTemplate.json");
}
}

View File

@ -0,0 +1,34 @@
import { ISPFxAdaptiveCard, BaseAdaptiveCardView, IActionArguments } from "@microsoft/sp-adaptive-card-extension-base";
import { IHolidayViewAdaptiveCardExtensionProps, IHolidayViewAdaptiveCardExtensionState } from "../HolidayViewAdaptiveCardExtension";
import { ITEMSUCCESS_QUICK_VIEW_REGISTRY_ID, ITEMFAILURE_QUICK_VIEW_REGISTRY_ID } from "../HolidayViewAdaptiveCardExtension";
export interface IQuickViewData {
holidayTitle: string;
detail: string;
}
export class QuickView extends BaseAdaptiveCardView<IHolidayViewAdaptiveCardExtensionProps, IHolidayViewAdaptiveCardExtensionState, IQuickViewData> {
public get data(): IQuickViewData {
return {
holidayTitle: this.state.holidayItems[this.state.currentIndex].holidayTitle.label,
detail: this.state.holidayItems[this.state.currentIndex].holidayDay.label + " " + this.state.holidayItems[this.state.currentIndex].holidayDate.label,
};
}
public onAction(action: IActionArguments): void {
if (action.type === "Submit") {
const { id } = action.data;
if (id === "addInCalendar") {
this.state.holidayService
.addLeaveInCalendar(this.state.employeeInfo, this.state.holidayItems[this.state.currentIndex])
.then((value) => this.quickViewNavigator.push(ITEMSUCCESS_QUICK_VIEW_REGISTRY_ID))
.catch((ex) => {
console.log(ex);
this.quickViewNavigator.push(ITEMFAILURE_QUICK_VIEW_REGISTRY_ID);
});
}
}
}
public get template(): ISPFxAdaptiveCard {
return require("./template/QuickViewTemplate.json");
}
}

View File

@ -0,0 +1,43 @@
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"text": "${holidayTitle}",
"size": "large",
"style": "default"
},
{
"type": "TextBlock",
"text": "Some issue occurred",
"size": "Medium"
}
]
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.Submit",
"title": "Back",
"data": {
"id": "back"
}
}
]
}
]
}

View File

@ -0,0 +1,37 @@
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"text": "Holiday added in calendar",
"size": "Medium"
}
]
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.Submit",
"title": "Back",
"data": {
"id": "back"
}
}
]
}
]
}

View File

@ -0,0 +1,43 @@
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"text": "${holidayTitle}",
"size": "medium",
"style": "default"
},
{
"type": "TextBlock",
"text": "${detail}",
"size": "small"
}
]
}
]
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.Submit",
"title": "Add in calendar",
"data": {
"id": "addInCalendar"
}
}
]
}
]
}

View File

@ -0,0 +1,19 @@
export const ListName = {
Holidays: "Holidays",
};
export const HolidaysListColumns = {
Id: "Id",
Title: "Title",
Date: "Date",
Location: "Location",
Optional: "Optional",
};
export const HolidaysListSelectColumns = [
HolidaysListColumns.Id,
HolidaysListColumns.Title,
HolidaysListColumns.Date,
HolidaysListColumns.Location,
HolidaysListColumns.Optional,
].join(",");

View File

@ -0,0 +1,43 @@
export interface IHolidaysListProps {
items: IHolidayItem[];
onCalendarAddClick: (itemId: number) => void;
onDownloadItems: () => void;
showDownload: boolean;
showFixedOptional: boolean;
title: string;
}
type HolidayTitleCell = {
label: string;
};
type HolidayDateCell = {
value: Date;
label: string;
};
type HolidayDayCell = {
label: string;
};
type HolidayTypeCell = {
optional: boolean;
};
// type HolidayActionCell = {
// icon: JSX.Element;
// };
export type IHolidayItem = {
holidayTitle: HolidayTitleCell;
holidayDate: HolidayDateCell;
holidayDay: HolidayDayCell;
holidayType: HolidayTypeCell;
Id: number;
};
export interface IHoliday {
Id: number;
Title: string;
Date: Date;
Location: string;
Optional: boolean;
}

View File

@ -0,0 +1,38 @@
/* eslint-disable */
import { Event as IEventType, User } from "@microsoft/microsoft-graph-types";
import { MSGraphClientV3, GraphRequest } from "@microsoft/sp-http-msgraph";
export class GraphService {
private context: any;
constructor(context: any) {
this.context = context;
}
private getClient = async (): Promise<MSGraphClientV3> => {
return await this.context.msGraphClientFactory.getClient("3");
};
public getMyInformation = async () => {
const client = await this.getClient();
const request: GraphRequest = client.api("/me");
const employeeInfo: User = await request.get();
return Promise.resolve(employeeInfo);
};
public getMyTimeZone = async (): Promise<string> => {
const client = await this.getClient();
const request: GraphRequest = client.api("/me/mailboxSettings");
const response = await request.get();
return Promise.resolve(response.timeZone);
};
public createEvent = async (detail: IEventType): Promise<any> => {
const client = await this.getClient();
const request: GraphRequest = client.api("/me/events");
const response = await request.post(detail);
return Promise.resolve(response);
};
}

View File

@ -0,0 +1,148 @@
import { HolidaysListColumns, HolidaysListSelectColumns } from "../constants/constant";
import { ListName } from "../constants/constant";
import { GraphService } from "./GraphService";
import { SPService } from "./SPService";
import { Event as IEventType } from "@microsoft/microsoft-graph-types";
import * as moment from "moment";
import { IEmployeeInfo } from "../../webparts/holidaysCalendar/interfaces/IHolidaysCalendarState";
import { IHolidayItem, IHoliday } from "../interfaces/HolidaysCalendar";
export class HolidaysCalendarService {
private spService: SPService;
private graphService: GraphService;
constructor(spService: SPService, graphService: GraphService) {
this.spService = spService;
this.graphService = graphService;
}
public getHolidayItemsToRender = (items: any[]): IHolidayItem[] => {
const holidayItems: IHolidayItem[] = [];
items.forEach((item) => {
holidayItems.push({
holidayTitle: {
label: item.Title,
},
holidayDate: {
value: item.Date,
label: moment(item.Date).format("MMMM Do"),
},
holidayDay: {
label: moment(item.Date).format("dddd"),
},
holidayType: {
optional: item.Optional,
},
Id: item.Id,
});
});
return holidayItems;
};
public getHolidayItemsToRender_ACE = (items: IHoliday[]): IHolidayItem[] => {
const holidayItems: IHolidayItem[] = [];
items.forEach((item) => {
if (moment().isBefore(item.Date, "days")) {
holidayItems.push({
holidayTitle: {
label: item.Title,
},
holidayDate: {
value: item.Date,
label: moment(item.Date).format("MMMM Do"),
},
holidayDay: {
label: moment(item.Date).format("dddd"),
},
holidayType: {
optional: item.Optional,
},
Id: item.Id,
});
}
});
return holidayItems;
};
public getHolidaysByLocation = async (location: string): Promise<IHoliday[]> => {
const holidays: IHoliday[] = [];
const filter = `${HolidaysListColumns.Location} eq '${location}'`;
try {
const listItems: any[] = await this.spService.getListItems(ListName.Holidays, filter, HolidaysListSelectColumns);
listItems.forEach((listItem: any) => {
const holiday: IHoliday = {
Id: listItem.Id,
Title: listItem.Title ?? null,
Date: Boolean(listItem.Date) ? new Date(listItem.Date) : null,
Location: listItem.Location ?? null,
Optional: listItem.Optional,
};
holidays.push(holiday);
});
return Promise.resolve(holidays);
} catch (ex) {
return Promise.reject(holidays);
}
};
public getEmployeeInfo = async (): Promise<IEmployeeInfo> => {
const [myInformation, myTimeZone] = await Promise.all([this.graphService.getMyInformation(), this.graphService.getMyTimeZone()]);
const employeeInformation = {} as IEmployeeInfo;
employeeInformation.eMail = myInformation.mail;
employeeInformation.id = myInformation.id;
employeeInformation.officeLocation = myInformation.officeLocation;
employeeInformation.displayName = myInformation.displayName;
employeeInformation.timezone = myTimeZone;
return Promise.resolve(employeeInformation);
};
public addLeaveInCalendar = async (employeeInfo: IEmployeeInfo, item: IHolidayItem): Promise<boolean> => {
try {
const eventDetail: IEventType = {};
eventDetail.subject = item.holidayTitle.label ?? null;
eventDetail.start = {
dateTime: moment(item.holidayDate.value).format("YYYY-MM-DD") + "T00:00:00",
timeZone: employeeInfo.timezone,
};
eventDetail.end = {
dateTime: moment(item.holidayDate.value).format("YYYY-MM-DD") + "T23:59:59",
timeZone: employeeInfo.timezone,
};
eventDetail.showAs = "oof";
eventDetail.attendees = [
{
emailAddress: {
address: employeeInfo.eMail,
name: employeeInfo.displayName,
},
},
];
await this.graphService.createEvent(eventDetail);
return Promise.resolve(true);
} catch (ex) {
return Promise.reject(false);
}
};
public getItemsToDownloadAsCSV = (items: IHolidayItem[]) => {
const itemsToExport: any[] = [];
items.forEach((item) => {
itemsToExport.push({
Title: item.holidayTitle.label,
Date: item.holidayDate.label,
Day: item.holidayDay.label,
IsOptional: item.holidayType.optional ? "Yes" : "No",
});
});
const dataToDownload = {
data: itemsToExport,
filename: "HolidayCalendar",
delimiter: ",",
headers: ["Title", "Date", "Day", "IsOptional"],
};
return dataToDownload;
};
}

View File

@ -0,0 +1,67 @@
import { SPFI, spfi, SPFx as spSPFx } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists/web";
import "@pnp/sp/site-groups";
import "@pnp/sp/items";
import "@pnp/sp/items/get-all";
import "@pnp/sp/site-users/web";
export class SPService {
private sp: SPFI;
constructor(context: any) {
this.sp = spfi().using(spSPFx(context));
}
public getListItems = async (
listTitle: string,
filter: string = "",
columns: string = "*",
expand: string = "",
orderby?: string,
orderSequence?: boolean
): Promise<any> => {
let items: any = [];
try {
if (!orderby) {
items = await this.sp.web.lists.getByTitle(listTitle).items.select(columns).filter(filter).expand(expand).top(5000)();
} else {
return await this.sp.web.lists.getByTitle(listTitle).items.select(columns).orderBy(orderby, orderSequence).filter(filter).expand(expand).top(5000)();
}
return Promise.resolve(items);
} catch (ex) {
return Promise.reject(ex);
}
};
public getSharePointGroupDetails = async (groupTitle: string): Promise<any> => {
try {
const response = await this.sp.web.siteGroups.getByName(groupTitle)();
return Promise.resolve(response);
} catch (ex) {
return Promise.reject(ex);
}
};
public getUserDetails = async (userId: number): Promise<any> => {
try {
const response = await this.sp.web.getUserById(userId)();
return Promise.resolve(response);
} catch (ex) {
return Promise.reject(ex);
}
};
public ensureUser = async (loginName: string): Promise<any> => {
if (loginName.indexOf("i:0#.f|membership|") === -1) {
loginName = "i:0#.f|membership|" + loginName;
}
try {
const response = await (await this.sp.web.ensureUser(loginName)).user();
return Promise.resolve(response);
} catch (ex) {
return Promise.reject(ex);
}
};
}

View File

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

View File

@ -0,0 +1,28 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "b12773f8-a394-45e9-847e-7845995bf0c0",
"alias": "HolidaysCalendarWebPart",
"componentType": "WebPart",
// The "*" signifies that the version should be taken from the package.json
"version": "*",
"manifestVersion": 2,
// If true, the component can only be installed on sites where Custom Script is allowed.
// Components that allow authors to embed arbitrary script code should set this to true.
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
"requiresCustomScript": false,
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"],
"supportsThemeVariants": true,
"preconfiguredEntries": [{
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced
"group": { "default": "Advanced" },
"title": { "default": "HolidaysCalendar" },
"description": { "default": "HolidaysCalendar description" },
"officeFabricIconFontName": "Page",
"properties": {
"description": "HolidaysCalendar"
}
}]
}

View File

@ -0,0 +1,142 @@
import { GraphService } from "./../../common/services/GraphService";
import * as React from "react";
import * as ReactDom from "react-dom";
import { Version } from "@microsoft/sp-core-library";
import { IPropertyPaneConfiguration, PropertyPaneTextField, PropertyPaneToggle } from "@microsoft/sp-property-pane";
import { BaseClientSideWebPart } from "@microsoft/sp-webpart-base";
import { IReadonlyTheme } from "@microsoft/sp-component-base";
import * as strings from "HolidaysCalendarWebPartStrings";
import HolidaysCalendar from "./components/HolidaysCalendar";
import { IHolidaysCalendarProps } from "./components/IHolidaysCalendarProps";
import { SPService } from "../../common/services/SPService";
export interface IHolidaysCalendarWebPartProps {
enableDownload: boolean;
title: string;
showFixedOptional: boolean;
}
export default class HolidaysCalendarWebPart extends BaseClientSideWebPart<IHolidaysCalendarWebPartProps> {
private _isDarkTheme: boolean = false;
private _environmentMessage: string = "";
private spService: SPService;
private graphService: GraphService;
public render(): void {
const element: React.ReactElement<IHolidaysCalendarProps> = React.createElement(HolidaysCalendar, {
isDarkTheme: this._isDarkTheme,
environmentMessage: this._environmentMessage,
hasTeamsContext: !!this.context.sdks.microsoftTeams,
userDisplayName: this.context.pageContext.user.displayName,
spService: this.spService,
graphService: this.graphService,
context: this.context,
showDownload: this.properties.enableDownload ?? false,
title: this.properties.title,
showFixedOptional: this.properties.showFixedOptional,
});
ReactDom.render(element, this.domElement);
}
protected onInit(): Promise<void> {
return this._getEnvironmentMessage().then((message) => {
this.spService = new SPService(this.context);
this.graphService = new GraphService(this.context);
this._environmentMessage = message;
});
}
private _getEnvironmentMessage(): Promise<string> {
if (!!this.context.sdks.microsoftTeams) {
// running in Teams, office.com or Outlook
return this.context.sdks.microsoftTeams.teamsJs.app.getContext().then((context) => {
let environmentMessage: string = "";
switch (context.app.host.name) {
case "Office": // running in Office
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment;
break;
case "Outlook": // running in Outlook
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOutlook : strings.AppOutlookEnvironment;
break;
case "Teams": // running in Teams
environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
break;
default:
throw new Error("Unknown host");
}
return environmentMessage;
});
}
return Promise.resolve(this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment);
}
protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void {
if (!currentTheme) {
return;
}
this._isDarkTheme = !!currentTheme.isInverted;
const { semanticColors } = currentTheme;
if (semanticColors) {
this.domElement.style.setProperty("--bodyText", semanticColors.bodyText || null);
this.domElement.style.setProperty("--link", semanticColors.link || null);
this.domElement.style.setProperty("--linkHovered", semanticColors.linkHovered || null);
}
}
protected onDispose(): void {
ReactDom.unmountComponentAtNode(this.domElement);
}
protected get dataVersion(): Version {
return Version.parse("1.0");
}
protected onPropertyPaneFieldChanged = (propertyPath: string, oldValue: any, newValue: any): void => {
if (propertyPath === "enableDownload" && oldValue !== newValue) {
this.properties.enableDownload = newValue;
}
if (propertyPath === "title" && oldValue !== newValue) {
this.properties.title = newValue;
}
if (propertyPath === "showFixedOptional" && oldValue !== newValue) {
this.properties.showFixedOptional = newValue;
}
};
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription,
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
PropertyPaneTextField("title", {
label: "Title",
}),
PropertyPaneToggle("enableDownload", {
key: "enableDownload",
label: "Show Download Option",
checked: false,
}),
PropertyPaneToggle("showFixedOptional", {
key: "showFixedOptional",
label: "Show Fixed Optional Icons",
checked: false,
}),
],
},
],
},
],
};
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,77 @@
import * as React from "react";
import { IHolidaysCalendarState } from "../interfaces/IHolidaysCalendarState";
import { HolidaysCalendarService } from "../../../common/services/HolidaysCalendarService";
import HolidaysList from "./HolidaysList/HolidaysList";
import { Alert } from "@fluentui/react-components/unstable";
import { IHolidaysCalendarProps } from "./IHolidaysCalendarProps";
import { FluentProvider, webLightTheme } from "@fluentui/react-components";
import { DismissCircleRegular } from "@fluentui/react-icons";
import csvDownload from "json-to-csv-export";
const HolidaysCalendar = (props: IHolidaysCalendarProps) => {
const [service] = React.useState<HolidaysCalendarService>(new HolidaysCalendarService(props.spService, props.graphService));
const [state, setState] = React.useState<IHolidaysCalendarState>({
listItems: [],
holidayListItems: [],
message: {
show: false,
intent: "success",
},
employeeInfo: null,
columns: [],
});
const handleCalenderAddClick = async (itemId: number) => {
try {
const selectedItem = state.holidayListItems.filter((item) => item.Id === itemId);
await service.addLeaveInCalendar(state.employeeInfo, selectedItem[0]);
setState((prevState: IHolidaysCalendarState) => ({ ...prevState, message: { show: true, intent: "success" } }));
} catch (ex) {
setState((prevState: IHolidaysCalendarState) => ({ ...prevState, message: { show: true, intent: "error" } }));
}
};
const handleDismissClick = () => {
setState((prevState: IHolidaysCalendarState) => ({ ...prevState, message: { show: false, intent: "success" } }));
};
const handleDownload = () => {
const itemsToDownload = service.getItemsToDownloadAsCSV(state.holidayListItems);
csvDownload(itemsToDownload);
};
/* eslint-disable */
React.useEffect(() => {
(async () => {
const employeeInfo = await service.getEmployeeInfo();
const listItems = await service.getHolidaysByLocation(employeeInfo.officeLocation);
const holidayItems = service.getHolidayItemsToRender(listItems);
setState((prevState: IHolidaysCalendarState) => ({ ...prevState, listItems: listItems, holidayListItems: holidayItems, employeeInfo: employeeInfo }));
})();
}, []);
return (
<>
<FluentProvider theme={webLightTheme}>
{state.message.show && (
<Alert intent={state.message.intent} action={{ icon: <DismissCircleRegular aria-label="dismiss message" onClick={handleDismissClick} /> }}>
{state.message.intent === "success" ? "Holiday added in calendar" : "Some error occurred"}
</Alert>
)}
{state.holidayListItems.length > 0 && (
<HolidaysList
items={state.holidayListItems}
onCalendarAddClick={handleCalenderAddClick}
onDownloadItems={handleDownload}
showDownload={props.showDownload}
title={props.title}
showFixedOptional={props.showFixedOptional}
/>
)}
</FluentProvider>
</>
);
};
export default HolidaysCalendar;

View File

@ -0,0 +1,130 @@
import * as React from "react";
import { IHolidaysListProps } from "../../../../common/interfaces/HolidaysCalendar";
import {
ColumnDefinition,
createColumn,
DataGrid,
DataGridBody,
DataGridCell,
DataGridHeader,
DataGridHeaderCell,
DataGridRow,
RowState,
TableCell,
TableCellActions,
TableCellLayout,
} from "@fluentui/react-components/unstable";
import { IHolidayItem } from "../../../../common/interfaces/HolidaysCalendar";
import { Button, Label, makeStyles, Title2 } from "@fluentui/react-components";
import { CalendarAdd20Regular, Diamond24Regular, ArrowDownload24Regular } from "@fluentui/react-icons";
const useStyles = makeStyles({
root: {
marginTop: "25px",
},
});
export default function HolidaysList(props: IHolidaysListProps) {
const classes = useStyles();
const [showOptionalIcon, setShowOptionalIcon] = React.useState<boolean>(false);
React.useEffect(() => {
if (props.items.length > 0) {
props.items.filter((item) => item.holidayType.optional).length > 0;
setShowOptionalIcon(true);
}
}, [props.items]);
const columns: ColumnDefinition<IHolidayItem>[] = React.useMemo(
() => [
createColumn<IHolidayItem>({
columnId: "HolidayTitle",
renderHeaderCell: () => {
return "";
},
renderCell: (item) => {
return (
<TableCell>
<TableCellLayout>{item.holidayTitle.label}</TableCellLayout>
<TableCellActions>
<Button icon={<CalendarAdd20Regular />} appearance="subtle" onClick={() => props.onCalendarAddClick(item.Id)} />
</TableCellActions>
</TableCell>
);
},
}),
createColumn<IHolidayItem>({
columnId: "HolidayDate",
renderHeaderCell: () => {
return "";
},
renderCell: (item) => {
return <TableCellLayout>{item.holidayDate.label}</TableCellLayout>;
},
}),
createColumn<IHolidayItem>({
columnId: "HolidayDay",
renderHeaderCell: () => {
return "";
},
renderCell: (item) => {
return <TableCellLayout>{item.holidayDay.label}</TableCellLayout>;
},
}),
createColumn<IHolidayItem>({
columnId: "HolidayType",
renderHeaderCell: () => {
return "";
},
renderCell: (item) => {
return (
<TableCellLayout>
{props.showFixedOptional ? (
item.holidayType.optional ? (
<Diamond24Regular primaryFill="Orange" />
) : (
<Diamond24Regular primaryFill="Green" />
)
) : null}
</TableCellLayout>
);
},
}),
],
[props.items, props.showFixedOptional]
);
return (
<>
<Title2 align="center" style={{ fontFamily: "fontFamilyBase" }}>
{props.title}
</Title2>
<DataGrid items={props.items} columns={columns} sortable={false} getRowId={(item: IHolidayItem) => item.Id}>
<DataGridHeader>
<DataGridRow>{({ renderHeaderCell }: ColumnDefinition<IHolidayItem>) => <DataGridHeaderCell>{renderHeaderCell()}</DataGridHeaderCell>}</DataGridRow>
</DataGridHeader>
<DataGridBody>
{({ item, rowId }: RowState<IHolidayItem>) => (
<DataGridRow key={rowId}>{({ renderCell }: ColumnDefinition<IHolidayItem>) => <DataGridCell>{renderCell(item)}</DataGridCell>}</DataGridRow>
)}
</DataGridBody>
</DataGrid>
{props.showDownload && (
<Button icon={<ArrowDownload24Regular />} appearance="subtle" onClick={props.onDownloadItems} className={classes.root}>
Download
</Button>
)}
{props.showFixedOptional && (
<div className={classes.root}>
<Diamond24Regular primaryFill="Green" />
<Label>Fixed Holiday</Label>
{showOptionalIcon && (
<>
<Diamond24Regular primaryFill="Orange" />
<Label>Optional/Flexible holiday</Label>
</>
)}
</div>
)}
</>
);
}

View File

@ -0,0 +1,16 @@
import { GraphService } from "./../../../common/services/GraphService";
import { SPService } from "../../../common/services/SPService";
import { WebPartContext } from "@microsoft/sp-webpart-base";
export interface IHolidaysCalendarProps {
isDarkTheme: boolean;
environmentMessage: string;
hasTeamsContext: boolean;
userDisplayName: string;
spService: SPService;
graphService: GraphService;
context: WebPartContext;
showDownload: boolean;
showFixedOptional: boolean;
title: string;
}

View File

@ -0,0 +1,20 @@
import { ColumnDefinition } from "@fluentui/react-components/unstable";
import { IHolidayItem, IHoliday } from "../../../common/interfaces/HolidaysCalendar";
export interface IEmployeeInfo {
eMail: string;
id: string;
officeLocation: string;
timezone: string;
displayName: string;
}
export interface IHolidaysCalendarState {
listItems: IHoliday[];
holidayListItems: IHolidayItem[];
message: {
show: boolean;
intent: "success" | "error";
};
employeeInfo: IEmployeeInfo;
columns: ColumnDefinition<IHolidayItem>[];
}

View File

@ -0,0 +1,15 @@
define([], function() {
return {
"PropertyPaneDescription": "Description",
"BasicGroupName": "Group Name",
"DescriptionFieldLabel": "Description Field",
"AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part",
"AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app",
"AppLocalEnvironmentOffice": "The app is running on your local environment in office.com",
"AppLocalEnvironmentOutlook": "The app is running on your local environment in Outlook",
"AppSharePointEnvironment": "The app is running on SharePoint page",
"AppTeamsTabEnvironment": "The app is running in Microsoft Teams",
"AppOfficeEnvironment": "The app is running in office.com",
"AppOutlookEnvironment": "The app is running in Outlook"
}
});

View File

@ -0,0 +1,18 @@
declare interface IHolidaysCalendarWebPartStrings {
PropertyPaneDescription: string;
BasicGroupName: string;
DescriptionFieldLabel: string;
AppLocalEnvironmentSharePoint: string;
AppLocalEnvironmentTeams: string;
AppLocalEnvironmentOffice: string;
AppLocalEnvironmentOutlook: string;
AppSharePointEnvironment: string;
AppTeamsTabEnvironment: string;
AppOfficeEnvironment: string;
AppOutlookEnvironment: string;
}
declare module 'HolidaysCalendarWebPartStrings' {
const strings: IHolidaysCalendarWebPartStrings;
export = strings;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

View File

@ -0,0 +1,23 @@
{
"extends": "./node_modules/@microsoft/rush-stack-compiler-4.5/includes/tsconfig-web.json",
"compilerOptions": {
"target": "es5",
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"jsx": "react",
"declaration": true,
"sourceMap": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"outDir": "lib",
"inlineSources": false,
"strictNullChecks": false,
"noImplicitAny": true,
"typeRoots": ["./node_modules/@types", "./node_modules/@microsoft"],
"types": ["webpack-env"],
"lib": ["es2017", "es5", "dom", "es2015.collection", "es2015.promise"]
},
"include": ["src/**/*.ts", "src/**/*.tsx"]
}

File diff suppressed because it is too large Load Diff