diff --git a/samples/react-application-quick-register-to-appointment/.eslintrc.js b/samples/react-application-quick-register-to-appointment/.eslintrc.js new file mode 100644 index 000000000..84eb5c94c --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/.eslintrc.js @@ -0,0 +1,320 @@ +require('@rushstack/eslint-config/patch/modern-module-resolution'); +module.exports = { + extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'], + parserOptions: { tsconfigRootDir: __dirname }, + overrides: [ + { + files: ['*.ts', '*.tsx'], + parser: '@typescript-eslint/parser', + 'parserOptions': { + 'project': './tsconfig.json', + 'ecmaVersion': 2018, + 'sourceType': 'module' + }, + "plugins": ["react-hooks"], + 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, + // 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". + '@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/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: {} + } + ] +}; \ No newline at end of file diff --git a/samples/react-application-quick-register-to-appointment/.gitignore b/samples/react-application-quick-register-to-appointment/.gitignore new file mode 100644 index 000000000..51ca7b9e7 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/.gitignore @@ -0,0 +1,34 @@ +# 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 diff --git a/samples/react-application-quick-register-to-appointment/.npmignore b/samples/react-application-quick-register-to-appointment/.npmignore new file mode 100644 index 000000000..ae0b487c0 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/.npmignore @@ -0,0 +1,16 @@ +!dist +config + +gulpfile.js + +release +src +temp + +tsconfig.json +tslint.json + +*.log + +.yo-rc.json +.vscode diff --git a/samples/react-application-quick-register-to-appointment/.nvmrc b/samples/react-application-quick-register-to-appointment/.nvmrc new file mode 100644 index 000000000..aebd91c52 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/.nvmrc @@ -0,0 +1 @@ +v22.16.0 diff --git a/samples/react-application-quick-register-to-appointment/.yo-rc.json b/samples/react-application-quick-register-to-appointment/.yo-rc.json new file mode 100644 index 000000000..e71205700 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/.yo-rc.json @@ -0,0 +1,22 @@ +{ + "@microsoft/generator-sharepoint": { + "plusBeta": false, + "isCreatingSolution": true, + "nodeVersion": "16.20.0", + "sdksVersions": { + "@microsoft/microsoft-graph-client": "3.0.2", + "@microsoft/teams-js": "2.24.0" + }, + "version": "1.21.1", + "libraryName": "fast-register-to-appointment", + "libraryId": "8840a13c-f490-41e6-9c2a-e5cba8dfba1f", + "environment": "spo", + "packageManager": "npm", + "solutionName": "Fast Register to Appointment", + "solutionShortDescription": "Fast Register to Appointment description", + "skipFeatureDeployment": true, + "isDomainIsolated": false, + "componentType": "extension", + "extensionType": "ApplicationCustomizer" + } +} \ No newline at end of file diff --git a/samples/react-application-quick-register-to-appointment/README.md b/samples/react-application-quick-register-to-appointment/README.md new file mode 100644 index 000000000..a7cd664b2 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/README.md @@ -0,0 +1,88 @@ +# Quick Register to Appointment (SharePoint Event page) + +Add a function to register directly to an event/appointment. User will be added to the attendees list. + +## Summary + +SharePoint Online provides a list of appointments (events) on a site. The "Events" web part can be used to display them on a page. Users can access the appointment details via the web part and view all the details. The detailed view provides a link that allows them to add the appointment to their personal calendar. An appointment entry also allows them to maintain an attendee list. The "Events" list provides the "Attendees" column, where multiple people can be added. However, there is no automatic function for this; the list must be edited manually. +The special app extension adds a registration and deregistration function to the detailed view. Users can register for a specific appointment and later deregister with a simple click. Attendees are automatically managed in the attendee column of the list. + +![UI of the generated form](./assets/fastregisterappointment.png) + +*Extended interface of an appointment* + +### Video + +[![SharePoint Online: Fast & easy appointment booking](https://img.youtube.com/vi/_-aTpJPXRdA/hqdefault.jpg)](https://youtu.be/_-aTpJPXRdA) + +## Compatibility + +| :warning: Important | +|:---------------------------| +| Every SPFx version is optimally compatible with specific versions of Node.js. In order to be able to Toolchain this sample, you need to ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.| +|Refer to for more information on SPFx compatibility. | + +This sample is optimally compatible with the following environment configuration: + +![SPFx 1.21.1](https://img.shields.io/badge/SPFx-1.21.1-green.svg) +![Node.js v22](https://img.shields.io/badge/Node.js-v22-green.svg) +![Toolchain: Heft](https://img.shields.io/badge/Toolchain-Heft-green.svg) +![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg) +![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower") +![Does not work with SharePoint 2016 (Feature Pack 2)](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202)-Incompatible-red.svg "SharePoint Server 2016 Feature Pack 2 requires SPFx 1.1") +![Local Workbench Unsupported](https://img.shields.io/badge/Local%20Workbench-Unsupported-red.svg "Local workbench is no longer available as of SPFx 1.13 and above") +![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg) +![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-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) + +## Contributors + +- [Marc André Schröder-Zhou](https://github.com/maschroeder-z) + +## Version history + +| Version | Date | Comments | +| ------- | ---------------- | ----------------------- | +| 1.2 | 19.09.2025 | Upgrade to SPFx 1.21.1 | +| 1.1 | 24.07.2024 | Upgrade to SPFx 1.18 | +| 1.0 | 30.09.2023 | Initial Release | + + + +## Minimal Path to Awesome + +- Clone this repository +- Ensure that you are at the solution folder +- in the command-line run: + - `npm install` + - `gulp serve` + +> Check your current Node version and installed SPFx-Framework version. + +## Features + +Allows quick and easy registration for an event. + +## Help + +Please contact me for further help or information about the sample. + +## 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 + +## 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.** + + diff --git a/samples/react-application-quick-register-to-appointment/assets/fastregisterappointment.png b/samples/react-application-quick-register-to-appointment/assets/fastregisterappointment.png new file mode 100644 index 000000000..b76246a71 Binary files /dev/null and b/samples/react-application-quick-register-to-appointment/assets/fastregisterappointment.png differ diff --git a/samples/react-application-quick-register-to-appointment/assets/sample.json b/samples/react-application-quick-register-to-appointment/assets/sample.json new file mode 100644 index 000000000..3eb00a8b2 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/assets/sample.json @@ -0,0 +1,59 @@ +[ + { + "name": "pnp-sp-dev-spfx-extensions-react-application-quick-register-to-appointment", + "source": "pnp", + "title": "Quick Register to Appointment (SharePoint Event page)", + "shortDescription": "SharePoint Online provides a list of appointments (events) on a site. The \"Events\" web part can be used to display them on a page. Users can access the appointment details via the web part and view all the details. The detailed view provides a link that allows them to add the appointment to their personal calendar. An appointment entry also allows them to maintain an attendee list. The \"Events\" list provides the \"Attendees\" column, where multiple people can be added. However, there is no automatic function for this; the list must be edited manually. The special app extension adds a registration and deregistration function to the detailed view. Users can register for a specific appointment and later deregister with a simple click. Attendees are automatically managed in the attendee column of the list.", + "url": "https://github.com/pnp/sp-dev-fx-extensions/tree/main/samples/react-application-quick-register-to-appointment", + "longDescription": [ + "SharePoint Online provides a list of appointments (events) on a site. The \"Events\" web part can be used to display them on a page. Users can access the appointment details via the web part and view all the details. The detailed view provides a link that allows them to add the appointment to their personal calendar. An appointment entry also allows them to maintain an attendee list. The \"Events\" list provides the \"Attendees\" column, where multiple people can be added. However, there is no automatic function for this; the list must be edited manually. The special app extension adds a registration and deregistration function to the detailed view. Users can register for a specific appointment and later deregister with a simple click. Attendees are automatically managed in the attendee column of the list." + ], + "creationDateTime": "2025-10-17", + "updateDateTime": "2025-10-17", + "products": [ + "SharePoint" + ], + "metadata": [ + { + "key": "CLIENT-SIDE-DEV", + "value": "React" + }, + { + "key": "SPFX-VERSION", + "value": "1.21.1" + } + ], + "tags": [], + "categories": [ + "SPFX-APPLICATION-EXTENSION" + ], + "thumbnails": [ + { + "name": "fastregisterappointment.png", + "type": "image", + "order": 100, + "url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-application-quick-register-to-appointment/assets/fastregisterappointment.png", + "alt": "Web Part Preview" + } + ], + "authors": [ + { + "gitHubAccount": "https://github.com/maschroeder-z", + "pictureUrl": "https://github.com/maschroeder-z.png", + "name": "Marc André Schröder-Zhou" + } + ], + "references": [ + { + "name": "Overview of SharePoint Framework Extensions", + "description": "You can use SharePoint Framework (SPFx) Extensions to extend the SharePoint user experience. With SPFx Extensions, you can customize more facets of the SharePoint experience, including notification areas, toolbars, and list data views. SPFx Extensions are available in all Microsoft 365 subscriptions for production usage.", + "url": "https://docs.microsoft.com/sharepoint/dev/spfx/extensions/overview-extensions?WT.mc_id=m365-15741-cxa" + }, + { + "name": "Use page placeholders from Application Customizer", + "description": "Application Customizers provide access to well-known locations on SharePoint pages that you can modify based on your business and functional requirements. For example, you can create dynamic header and footer experiences that render across all the pages in SharePoint Online.", + "url": "https://docs.microsoft.com/sharepoint/dev/spfx/extensions/get-started/using-page-placeholder-with-extensions?WT.mc_id=m365-15741-cxa" + } + ] + } +] \ No newline at end of file diff --git a/samples/react-application-quick-register-to-appointment/config/config.json b/samples/react-application-quick-register-to-appointment/config/config.json new file mode 100644 index 000000000..2499ca974 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/config/config.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json", + "version": "2.0", + "bundles": { + "quick-appointment-register-application-customizer": { + "components": [ + { + "entrypoint": "./lib/extensions/quickAppointmentRegister/QuickAppointmentRegisterApplicationCustomizer.js", + "manifest": "./src/extensions/quickAppointmentRegister/QuickAppointmentRegisterApplicationCustomizer.manifest.json" + } + ] + } + }, + "externals": {}, + "localizedResources": { + "QuickAppointmentRegisterApplicationCustomizerStrings": "lib/extensions/quickAppointmentRegister/loc/{locale}.js" + } +} diff --git a/samples/react-application-quick-register-to-appointment/config/deploy-azure-storage.json b/samples/react-application-quick-register-to-appointment/config/deploy-azure-storage.json new file mode 100644 index 000000000..191831a34 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/config/deploy-azure-storage.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json", + "workingDir": "./release/assets/", + "account": "", + "container": "fast-register-to-appointment", + "accessKey": "" +} \ No newline at end of file diff --git a/samples/react-application-quick-register-to-appointment/config/package-solution.json b/samples/react-application-quick-register-to-appointment/config/package-solution.json new file mode 100644 index 000000000..69aff5ccb --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/config/package-solution.json @@ -0,0 +1,40 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json", + "solution": { + "name": "Fast Register to Appointment", + "id": "8840a13c-f490-41e6-9c2a-e5cba8dfba1f", + "version": "1.2.0.0", + "includeClientSideAssets": true, + "skipFeatureDeployment": true, + "isDomainIsolated": false, + "iconPath": "assets/96x96.png", + "metadata": { + "shortDescription": { + "default": "Fast Register to Appointment" + }, + "longDescription": { + "default": "Add a function to register directly to an event/appointment. User will be added to the attendees list." + }, + "screenshotPaths": [], + "videoUrl": "", + "categories": [] + }, + "features": [ + { + "title": "Fast Register to Appointment", + "description": "Add a function to register directly to an event/appointment. User will be added to the attendees list.", + "id": "53fd8073-f835-491f-866a-1532cead2475", + "version": "1.0.0.0", + "assets": { + "elementManifests": [ + "elements.xml", + "ClientSideInstance.xml" + ] + } + } + ] + }, + "paths": { + "zippedPackage": "solution/dev-sky-ac-quick-appointment-register.sppkg" + } +} \ No newline at end of file diff --git a/samples/react-application-quick-register-to-appointment/config/sass.json b/samples/react-application-quick-register-to-appointment/config/sass.json new file mode 100644 index 000000000..5e78c982d --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/config/sass.json @@ -0,0 +1,3 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json" +} \ No newline at end of file diff --git a/samples/react-application-quick-register-to-appointment/config/serve.json b/samples/react-application-quick-register-to-appointment/config/serve.json new file mode 100644 index 000000000..e20ebde37 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/config/serve.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json", + "port": 4321, + "https": true, + "serveConfigurations": { + "default": { + "pageUrl": "https://devskynet0.sharepoint.com", + "customActions": { + "f9fdc242-8072-4e2c-ab79-3159265522c9": { + "location": "ClientSideExtension.ApplicationCustomizer", + "properties": { + } + } + } + }, + "quickAppointmentRegister": { + "pageUrl": "https://devskynet0.sharepoint.com", + "customActions": { + "f9fdc242-8072-4e2c-ab79-3159265522c9": { + "location": "ClientSideExtension.ApplicationCustomizer", + "properties": { + } + } + } + } + } +} diff --git a/samples/react-application-quick-register-to-appointment/config/write-manifests.json b/samples/react-application-quick-register-to-appointment/config/write-manifests.json new file mode 100644 index 000000000..bad352605 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/config/write-manifests.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json", + "cdnBasePath": "" +} \ No newline at end of file diff --git a/samples/react-application-quick-register-to-appointment/gulpfile.js b/samples/react-application-quick-register-to-appointment/gulpfile.js new file mode 100644 index 000000000..be2918708 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/gulpfile.js @@ -0,0 +1,16 @@ +'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; +}; + +build.initialize(require('gulp')); diff --git a/samples/react-application-quick-register-to-appointment/package.json b/samples/react-application-quick-register-to-appointment/package.json new file mode 100644 index 000000000..3d95ad103 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/package.json @@ -0,0 +1,39 @@ +{ + "name": "fast-register-to-appointment", + "version": "1.0.1", + "private": true, + "engines": { + "node": ">=22.14.0 < 23.0.0" + }, + "main": "lib/index.js", + "scripts": { + "build": "gulp bundle", + "clean": "gulp clean", + "test": "gulp test" + }, + "dependencies": { + "@microsoft/decorators": "1.21.1", + "@microsoft/sp-adaptive-card-extension-base": "1.21.1", + "@microsoft/sp-application-base": "1.21.1", + "@microsoft/sp-core-library": "1.21.1", + "@microsoft/sp-dialog": "1.21.1", + "tslib": "2.3.1" + }, + "devDependencies": { + "@microsoft/eslint-config-spfx": "1.21.1", + "@microsoft/eslint-plugin-spfx": "1.21.1", + "@microsoft/rush-stack-compiler-5.3": "0.1.0", + "@microsoft/sp-build-web": "1.21.1", + "@microsoft/sp-module-interfaces": "1.21.1", + "@rushstack/eslint-config": "4.0.1", + "@rushstack/eslint-plugin": "0.19.0", + "@types/webpack-env": "~1.15.2", + "@typescript-eslint/parser": "8.44.0", + "ajv": "^6.12.6", + "baseline-browser-mapping": "^2.9.11", + "eslint": "8.57.0", + "eslint-plugin-react-hooks": "4.3.0", + "gulp": "4.0.2", + "typescript": "5.3.3" + } +} diff --git a/samples/react-application-quick-register-to-appointment/sharepoint/assets/96x96.png b/samples/react-application-quick-register-to-appointment/sharepoint/assets/96x96.png new file mode 100644 index 000000000..03ace28ec Binary files /dev/null and b/samples/react-application-quick-register-to-appointment/sharepoint/assets/96x96.png differ diff --git a/samples/react-application-quick-register-to-appointment/sharepoint/assets/ClientSideInstance.xml b/samples/react-application-quick-register-to-appointment/sharepoint/assets/ClientSideInstance.xml new file mode 100644 index 000000000..2cc9b4b04 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/sharepoint/assets/ClientSideInstance.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/samples/react-application-quick-register-to-appointment/sharepoint/assets/elements.xml b/samples/react-application-quick-register-to-appointment/sharepoint/assets/elements.xml new file mode 100644 index 000000000..abfae7baf --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/sharepoint/assets/elements.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/QuickAppointmentRegisterApplicationCustomizer.manifest.json b/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/QuickAppointmentRegisterApplicationCustomizer.manifest.json new file mode 100644 index 000000000..4f1537b1e --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/QuickAppointmentRegisterApplicationCustomizer.manifest.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-extension-manifest.schema.json", + + "id": "f9fdc242-8072-4e2c-ab79-3159265522c9", + "alias": "QuickAppointmentRegisterApplicationCusto", + "componentType": "Extension", + "extensionType": "ApplicationCustomizer", + + // 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 +} diff --git a/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/QuickAppointmentRegisterApplicationCustomizer.ts b/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/QuickAppointmentRegisterApplicationCustomizer.ts new file mode 100644 index 000000000..e663e2945 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/QuickAppointmentRegisterApplicationCustomizer.ts @@ -0,0 +1,132 @@ +import { + BaseApplicationCustomizer +} from '@microsoft/sp-application-base'; +import { Dialog } from '@microsoft/sp-dialog'; +import { Log } from '@microsoft/sp-core-library'; +import * as strings from 'QuickAppointmentRegisterApplicationCustomizerStrings'; +import { IEvent } from '../../models/IEvent'; +import { SPUser } from '@microsoft/sp-page-context'; +import { SPHttpClient, ISPHttpClientOptions, SPHttpClientResponse } from '@microsoft/sp-http'; + +const LOG_SOURCE: string = 'dev-sky-QuickAppointmentRegister'; + +export interface IQuickAppointmentRegisterApplicationCustomizerProperties { +} + +export default class QuickAppointmentRegisterApplicationCustomizer + extends BaseApplicationCustomizer { + + public onInit(): Promise { + Log.info(LOG_SOURCE, "Fast appointment register extension loaded."); + this.specialClientSideExtensions(); + return Promise.resolve(); + } + + private specialClientSideExtensions(): void { + this.context.application.navigatedEvent.add(this, () => { + setTimeout(() => { + void this.extendEventPage(); // eslint-disable-line + }, 800); + }); + } + private async extendEventPage(): Promise { + if (location.href.toLowerCase().indexOf("/_layouts/15/event.aspx") !== -1) { + Log.info(LOG_SOURCE, "We are on an event page!") + const container = document.querySelector("section[data-automation-id='seeAllEvents']"); + if (container !== undefined && container !== null) { + const allEvents = container.querySelector("a"); + Log.info(LOG_SOURCE, "Found container to add our new function!") + const params = new URLSearchParams(location.search); + const listGuid = params.get('ListGuid'); + const itemID = params.get('ItemId') !== null ? parseInt(params.get('ItemId') as string, 10) : 0; + const currentUser: SPUser = this.context.pageContext.user; + if (listGuid !== null && itemID > 0) { + const btnRegister: HTMLAnchorElement = document.createElement("a"); + if (allEvents !== undefined && allEvents !== null) + btnRegister.className = allEvents.className; + btnRegister.style.marginLeft = "10px"; + btnRegister.style.paddingTop = "5px"; + + const currentAppointmentEntry = await this.loadAppointment(listGuid, itemID); + if (currentAppointmentEntry.ParticipantsPickerId.filter(x => x.Title === currentUser.displayName).length > 0) { + const propertyContent = container.parentNode?.firstChild; + if (propertyContent !== undefined) { + const head3: HTMLHeadingElement = document.createElement("h3"); + head3.innerText = strings.HeadRegistered; + (propertyContent as any).before(head3);// eslint-disable-line + } + btnRegister.innerText = strings.BTNUnregister; + btnRegister.onclick = async (source: any) => { // eslint-disable-line + await this.manageUserToAppointment(listGuid, itemID, currentAppointmentEntry, currentUser, false); + void Dialog.alert(strings.MSGUnregistered).then(() => { // eslint-disable-line + location.reload(); + }); + } + } + else { + btnRegister.innerText = strings.BTNRegister; + btnRegister.onclick = async (source: any) => { // eslint-disable-line + await this.manageUserToAppointment(listGuid, itemID, currentAppointmentEntry, currentUser, true); + void Dialog.alert(strings.MSGRegistered).then(() => { // eslint-disable-line + location.reload(); + }); + } + } + container.appendChild(btnRegister); + } + else { + Log.warn(LOG_SOURCE, `Cannot apply register function due to missing data: ListID: ${listGuid}, ItemID: ${itemID}.`); + } + } + else { + Log.warn(LOG_SOURCE, "Cannot apply register function due to missing CONTAINER element!"); + } + } + } + + private loadAppointment(listGuid: string, id: number): Promise { + const endpoint = `${this.context.pageContext.web.absoluteUrl}/_api/web/lists/getById('${listGuid}')/items(${id})?$expand=ParticipantsPicker&$select=Id,Title,ParticipantsPicker/ID,ParticipantsPicker/Title`; + return this.context.spHttpClient.get( + endpoint, + SPHttpClient.configurations.v1) + .then(response => { + return response.json(); + }) + .then((jsonResponse: any) => { // eslint-disable-line + return { + Id: jsonResponse.Id, + ParticipantsPickerId: jsonResponse.ParticipantsPicker ? jsonResponse.ParticipantsPicker : [], + Title: jsonResponse.Title + }; + }) as Promise; + } + + private async manageUserToAppointment(listGuid: string, id: number, userList: IEvent, userToAdd: SPUser, addNew: boolean): Promise { + const clientconfig = SPHttpClient.configurations.v1; + const options: ISPHttpClientOptions = { + body: JSON.stringify({ 'logonName': userToAdd.loginName }) + }; + + const reqUser = await this.context.spHttpClient.post(`${this.context.pageContext.web.absoluteUrl}/_api/web/ensureuser`, clientconfig, options); + const userData = await reqUser.json(); + if (addNew) { + userList.ParticipantsPickerId = userList.ParticipantsPickerId.map((x) => x.ID); + userList.ParticipantsPickerId.push(userData.Id); + } + else { + userList.ParticipantsPickerId = userList.ParticipantsPickerId.filter(x => x.ID !== userData.Id).map((x) => x.ID); + } + const body = JSON.stringify(userList); + const updateoptions = { + headers: { + 'Accept': 'application/json;odata=nometadata', + 'Content-type': 'application/json;odata=nometadata', + 'odata-version': '', + 'IF-MATCH': '*', + 'X-HTTP-Method': 'MERGE' + }, + body: body + }; + return this.context.spHttpClient.post(`${this.context.pageContext.web.absoluteUrl}/_api/web/lists/getById('${listGuid}')/items(${id})`, clientconfig, updateoptions); + } +} diff --git a/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/loc/de-de.js b/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/loc/de-de.js new file mode 100644 index 000000000..4e0859cae --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/loc/de-de.js @@ -0,0 +1,9 @@ +define([], function() { + return { + "HeadRegistered": "Sie haben sich zu dem Termin bereits angemeldet.", + "BTNRegister":"Anmelden", + "BTNUnregister":"Abmelden", + "MSGRegistered":"Vielen Dank für die Anmeldung.", + "MSGUnregistered":"Sie haben sich wieder von dem Termin abgemeldet." + } +}); \ No newline at end of file diff --git a/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/loc/en-us.js b/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/loc/en-us.js new file mode 100644 index 000000000..e76c0389b --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/loc/en-us.js @@ -0,0 +1,9 @@ +define([], function() { + return { + "HeadRegistered": "You will attend to this appointment.", + "BTNRegister":"Register", + "BTNUnregister":"Unregister", + "MSGRegistered":"Thank you for your registration.", + "MSGUnregistered":"You have been removed from the participant list." + } +}); \ No newline at end of file diff --git a/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/loc/myStrings.d.ts b/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/loc/myStrings.d.ts new file mode 100644 index 000000000..a166e9afd --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/src/extensions/quickAppointmentRegister/loc/myStrings.d.ts @@ -0,0 +1,12 @@ +declare interface IQuickAppointmentRegisterApplicationCustomizerStrings { + HeadRegistered: string; + BTNRegister:string; + BTNUnregister:string; + MSGRegistered:string; + MSGUnregistered:string; +} + +declare module 'QuickAppointmentRegisterApplicationCustomizerStrings' { + const strings: IQuickAppointmentRegisterApplicationCustomizerStrings; + export = strings; +} diff --git a/samples/react-application-quick-register-to-appointment/src/index.ts b/samples/react-application-quick-register-to-appointment/src/index.ts new file mode 100644 index 000000000..fb81db1e2 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/src/index.ts @@ -0,0 +1 @@ +// A file is required to be in the root of the /src directory by the TypeScript compiler diff --git a/samples/react-application-quick-register-to-appointment/src/models/IEvent.ts b/samples/react-application-quick-register-to-appointment/src/models/IEvent.ts new file mode 100644 index 000000000..ce3b74247 --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/src/models/IEvent.ts @@ -0,0 +1,5 @@ +export interface IEvent { + ParticipantsPickerId: Array, // eslint-disable-line + Title: string; + Id: number; +} \ No newline at end of file diff --git a/samples/react-application-quick-register-to-appointment/tsconfig.json b/samples/react-application-quick-register-to-appointment/tsconfig.json new file mode 100644 index 000000000..216ab882f --- /dev/null +++ b/samples/react-application-quick-register-to-appointment/tsconfig.json @@ -0,0 +1,34 @@ +{ + "extends": "./node_modules/@microsoft/rush-stack-compiler-5.3/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, + "noImplicitAny": true, + "typeRoots": [ + "./node_modules/@types", + "./node_modules/@microsoft" + ], + "types": [ + "webpack-env" + ], + "lib": [ + "es5", + "dom", + "es2015.collection", + "es2015.promise" + ] + }, + "include": [ + "src/**/*.ts", + "src/**/*.tsx" + ] +} \ No newline at end of file