Benutzer-Werkzeuge

Webseiten-Werkzeuge


extensibility:assessments:confirmation:example

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
extensibility:assessments:confirmation:example [2025/07/17 13:06] agoldmanextensibility:assessments:confirmation:example [Unbekanntes Datum] (aktuell) – gelöscht - Externe Bearbeitung (Unbekanntes Datum) 127.0.0.1
Zeile 1: Zeile 1:
-==== Beispielcode für ein Plugin vom Typ "Erweiterung" um einen Bestätigungsdialog zu einem Formular anzuzeigen ==== 
- 
-<file> 
-using Grpc.Core; 
-using System; 
-using System.Threading.Tasks; 
-using Caats.Infrastructure.Authorization; 
-using Caats.Infrastructure.Helper; 
-using Caats.Infrastructure.Extensions; 
-using Caats.Proto; 
- 
-namespace Caats.Service.Infrastructure.Extensibility; 
- 
-[PluginServiceDto(typeof(ChecklistInstanceDto))] 
-public class ChkValidationPoC : PluginBase 
-{ 
-    public override PluginDto Ident() => new() { }; 
- 
-    public async override Task<(RequestMsg, ResponseMsg?)> OnBeforeUpdate(RequestMsg request, Lazy<IdentityBase> identity, ServerCallContext context) 
-    { 
-        var candidate = RequestMsgHelper.GetSingleOrDefault<ChecklistInstanceDto>(request); 
-        ResponseMsg? response = null; 
- 
-        if (candidate == null) 
-        { 
-            return (request, null); 
-        } 
- 
-        // evaluate conditions to decide whether confirmation is needed 
-        // set to "true" for brevity (because this is not the subject of the tutorial) 
-        var confirmationNeeded = true; 
- 
-        if (request.IsConfirmationPromptAnswered()) 
-        { 
-            // user has already answered the confirmation prompt 
-        } 
-        else if (confirmationNeeded) 
-        { 
-            // this will result in the user being asked for confirmation 
-            // (and the update call will not immediately go ahead in the backend) 
-            // the prompt supports html (no script) for formatting: 
- 
-            var prompt = @"Die eingegebene Leistungszeit liegt mehr als 7 Tage in der Vergangenheit  
-            <ul> 
-              <li>Leistungen eines Einsatzes sollten <strong>aufeinanderfolgen</strong></li> 
-              <li>Anfahrt und Abfahrt sollten an die Leistungszeit <strong>angrenzen</strong></li> 
-            </ul> 
-            Bitte bestätigen: Trotzdem buchen?"; 
- 
-            response = ResponseMsg.PromptForConfirmation( 
-                dialogTitle: "Bestätigung erforderlich", 
-                dialogPrompt: prompt, 
-                [ 
-                    (choiceDialogResult: ResponseMsg.DialogResult.Save, choiceKey: "indeed", choiceLabel: "COMMON.YES"), 
-                    (choiceDialogResult: ResponseMsg.DialogResult.Cancel, choiceKey: "nope", choiceLabel: "COMMON.DIALOG_ACTION_CANCEL") 
-                ] 
-            ); 
-        } 
- 
-        return await Task.FromResult((request, response)); 
-    } 
-} 
-</file> 
  
extensibility/assessments/confirmation/example.1752757577.txt.gz · Zuletzt geändert: von agoldman

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki