From 4440980baf9a7640b78bc50094bb04f73245f1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mads=20N=C3=B8rgaard?= Date: Wed, 14 Apr 2021 13:16:41 +0200 Subject: [PATCH 1/3] Adding WIP webforms and Maestro templates. --- ...ro.maestro_template.content_moderation.yml | 137 ++++++ ...tro.maestro_template.review_submission.yml | 220 ++++++++++ .../webform.webform.hk_grundskabelon.yml | 274 ++++++++++++ os2forms_forloeb.module | 81 ++++ .../EngineTasks/MaestroSelectContentTask.php | 407 ++++++++++++++++++ 5 files changed, 1119 insertions(+) create mode 100644 config/install/maestro.maestro_template.content_moderation.yml create mode 100644 config/install/maestro.maestro_template.review_submission.yml create mode 100644 config/install/webform.webform.hk_grundskabelon.yml create mode 100644 src/Plugin/EngineTasks/MaestroSelectContentTask.php diff --git a/config/install/maestro.maestro_template.content_moderation.yml b/config/install/maestro.maestro_template.content_moderation.yml new file mode 100644 index 0000000..b28f46a --- /dev/null +++ b/config/install/maestro.maestro_template.content_moderation.yml @@ -0,0 +1,137 @@ +status: true +dependencies: { } +id: content_moderation +label: 'Review webformular indsendelse' +app_group: 0 +canvas_height: 900 +canvas_width: 800 +default_workflow_timeline_stage_count: 1 +show_details: true +validated: true +views_attached: + maestro_entity_identifiers: + view_machine_name: maestro_entity_identifiers + view_weight: -10 + view_display: 'taskconsole_display;Task Console Display' + maestro_completed_tasks: + view_machine_name: maestro_completed_tasks + view_weight: -9 + view_display: default;Master +variables: + initiator: + variable_id: initiator + variable_value: '0' + workflow_timeline_stage_count: + variable_id: workflow_timeline_stage_count + variable_value: '' + workflow_current_stage: + variable_id: workflow_current_stage + variable_value: '' + workflow_current_stage_message: + variable_id: workflow_current_stage_message + variable_value: '' +initiator: null +workflow_timeline_stage_count: null +workflow_current_stage: null +workflow_current_stage_message: null +tasks: + start: + id: start + tasktype: MaestroStart + label: Start + nextstep: udfyld_webformular + nextfalsestep: '' + top: '30' + left: '30' + assignby: fixed + assignto: engine + end: + id: end + tasktype: MaestroEnd + label: End + nextstep: '' + nextfalsestep: '' + top: '290' + left: '40' + assignby: fixed + assignto: engine + if_approved: + id: if_approved + label: 'If approved' + tasktype: MaestroIf + nextstep: end + nextfalsestep: '' + top: '275' + left: '295' + assignby: fixed + assignto: '' + raphael: '' + to: '' + pointedfrom: '' + falsebranch: '' + lines: { } + data: + if: + method: bylasttaskstatus + variable: initiator + operator: '=' + variable_value: '' + status: '1' + assigned: '' + runonce: false + handler: '' + showindetail: true + participate_in_workflow_status_stage: false + workflow_status_stage_number: 0 + workflow_status_stage_message: '' + notifications: + notification_assignment_subject: null + notification_assignment: null + notification_reminder_subject: null + notification_reminder: null + notification_escalation_subject: null + notification_escalation: null + reminder_after: null + escalation_after: null + udfyld_webformular: + id: udfyld_webformular + label: 'Review indsendelse' + tasktype: MaestroWebform + nextstep: if_approved + nextfalsestep: '' + top: '40' + left: '300' + assignby: fixed + assignto: '' + raphael: '' + to: '' + pointedfrom: '' + falsebranch: '' + lines: { } + data: + unique_id: submission + webform_machine_name: test_af_hk_grundskabelon + modal: notmodal + skip_webform_handlers: 0 + webform_nodes_attached_to: node/10 + use_nodes_attached: 1 + webform_nodes_attached_variable: none + redirect_to: taskconsole + show_edit_form: 0 + assigned: 'role:fixed:sagsbehandler' + runonce: false + handler: '' + showindetail: true + participate_in_workflow_status_stage: true + workflow_status_stage_number: 1 + workflow_status_stage_message: 'Gennemgang af indsendelse' + notifications: + notification_assignment_subject: '' + notification_assignment: '' + notification_reminder_subject: '' + notification_reminder: '' + notification_escalation_subject: '' + notification_escalation: '' + reminder_after: 0 + escalation_after: 0 + notification_assignments: 'role:fixed:sagsbehandler:assignment' diff --git a/config/install/maestro.maestro_template.review_submission.yml b/config/install/maestro.maestro_template.review_submission.yml new file mode 100644 index 0000000..9d671b9 --- /dev/null +++ b/config/install/maestro.maestro_template.review_submission.yml @@ -0,0 +1,220 @@ +status: true +dependencies: { } +id: review_submission +label: 'Review submission' +app_group: 0 +canvas_height: 900 +canvas_width: 800 +default_workflow_timeline_stage_count: 3 +show_details: true +validated: true +views_attached: + maestro_entity_identifiers: + view_machine_name: maestro_entity_identifiers + view_weight: -10 + view_display: 'taskconsole_display;Task Console Display' + maestro_completed_tasks: + view_machine_name: maestro_completed_tasks + view_weight: -9 + view_display: default;Master +variables: + initiator: + variable_id: initiator + variable_value: '0' + workflow_timeline_stage_count: + variable_id: workflow_timeline_stage_count + variable_value: '' + workflow_current_stage: + variable_id: workflow_current_stage + variable_value: '' + workflow_current_stage_message: + variable_id: workflow_current_stage_message + variable_value: '' + assigned_to: + variable_id: assigned_to + variable_value: '' +initiator: null +workflow_timeline_stage_count: null +workflow_current_stage: null +workflow_current_stage_message: null +tasks: + start: + id: start + tasktype: MaestroStart + label: Start + nextstep: create_content + nextfalsestep: '' + top: '40' + left: '130' + assignby: fixed + assignto: engine + end: + id: end + tasktype: MaestroEnd + label: End + nextstep: '' + nextfalsestep: '' + top: '440' + left: '300' + assignby: fixed + assignto: engine + create_content: + id: create_content + label: 'Create content' + tasktype: MaestroContentType + nextstep: assign_sagsbehandler + nextfalsestep: '' + top: '142' + left: '122' + assignby: fixed + assignto: '' + raphael: '' + to: '' + pointedfrom: '' + falsebranch: '' + lines: { } + data: + unique_id: new_article + content_type: forloebsside + save_edit_later: 1 + link_to_edit: 1 + show_maestro_buttons_on_view: 0 + accept_label: '' + reject_label: '' + accept_redirect_to: '' + reject_redirect_to: '' + supply_maestro_ids_in_url: 0 + redirect_to: taskconsole + handler: '/node/add/forloebsside?maestro=1' + assigned: 'user:variable:initiator' + runonce: false + showindetail: true + participate_in_workflow_status_stage: true + workflow_status_stage_number: 1 + workflow_status_stage_message: 'Create content' + notifications: + notification_assignment_subject: '' + notification_assignment: '' + notification_reminder_subject: '' + notification_reminder: '' + notification_escalation_subject: '' + notification_escalation: '' + reminder_after: 0 + escalation_after: 0 + content_review: + id: content_review + label: 'Review content' + tasktype: MaestroContentType + nextstep: approve_status + nextfalsestep: '' + top: '157' + left: '457' + assignby: fixed + assignto: '' + raphael: '' + to: '' + pointedfrom: '' + falsebranch: '' + lines: { } + data: + unique_id: new_article + content_type: forloebsside + save_edit_later: 0 + link_to_edit: 0 + show_maestro_buttons_on_view: 1 + accept_label: Accept + reject_label: Reject + accept_redirect_to: /taskconsole + reject_redirect_to: /taskconsole + supply_maestro_ids_in_url: 0 + redirect_to: taskconsole + handler: '/node/add/forloebsside?maestro=1' + assigned: 'user:variable:assigned_to' + runonce: false + showindetail: true + participate_in_workflow_status_stage: true + workflow_status_stage_number: 3 + workflow_status_stage_message: 'Review content' + notifications: + notification_assignment_subject: '' + notification_assignment: '' + notification_reminder_subject: '' + notification_reminder: '' + notification_escalation_subject: '' + notification_escalation: '' + reminder_after: 0 + escalation_after: 0 + notification_assignments: 'role:fixed:flow_designer:assignment,user:variable:assigned_to:assignment' + approve_status: + id: approve_status + label: 'If approved' + tasktype: MaestroIf + nextstep: end + nextfalsestep: create_content + top: '295' + left: '295' + assignby: fixed + assignto: '' + raphael: '' + to: '' + pointedfrom: '' + falsebranch: '' + lines: { } + data: + if: + method: bylasttaskstatus + variable: initiator + operator: '=' + variable_value: '' + status: '1' + assigned: '' + runonce: false + handler: '' + showindetail: true + participate_in_workflow_status_stage: false + workflow_status_stage_number: null + workflow_status_stage_message: 'Task status' + notifications: + notification_assignment_subject: null + notification_assignment: null + notification_reminder_subject: null + notification_reminder: null + notification_escalation_subject: null + notification_escalation: null + reminder_after: null + escalation_after: null + assign_sagsbehandler: + id: assign_sagsbehandler + label: 'Assign to sagsbehandler' + tasktype: MaestroInteractive + nextstep: content_review + nextfalsestep: '' + top: '40' + left: '300' + assignby: fixed + assignto: '' + raphael: '' + to: '' + pointedfrom: '' + falsebranch: '' + lines: { } + handler: os2forms_forloeb_workflow_maestro_reassign_form + data: + modal: modal + redirect_to: taskconsole + assigned: 'user:variable:initiator' + runonce: false + showindetail: true + participate_in_workflow_status_stage: true + workflow_status_stage_number: 2 + workflow_status_stage_message: '' + notifications: + notification_assignments: 'user:variable:initiator:assignment' + notification_assignment_subject: '' + notification_assignment: '' + notification_reminder_subject: '' + notification_reminder: '' + notification_escalation_subject: '' + notification_escalation: '' + reminder_after: 0 + escalation_after: 0 diff --git a/config/install/webform.webform.hk_grundskabelon.yml b/config/install/webform.webform.hk_grundskabelon.yml new file mode 100644 index 0000000..82f4575 --- /dev/null +++ b/config/install/webform.webform.hk_grundskabelon.yml @@ -0,0 +1,274 @@ +langcode: da +status: open +dependencies: + module: + - maestro_webform + - os2forms + - webform_entity_print + - webform_revisions +third_party_settings: + os2forms: + os2forms_nemid: + webform_type: '' + nemlogin_auto_redirect: 0 + webform_entity_print: + template: + header: '' + footer: '' + css: '' + export_types: + pdf: + enabled: true + link_text: '' + link_attributes: { } + word_docx: + enabled: false + link_text: '' + link_attributes: { } + webform_revisions: + contentEntity_id: '1' +open: null +close: null +weight: 0 +uid: 4 +template: false +archive: false +id: hk_grundskabelon +title: 'HK grundskabelon' +description: 'Denne webform er oprettet ud fra HK's grundskabelon' +category: '' +elements: "forlob_type:\n '#type': hidden\n '#title': 'Forløb type'\n '#default_value': barsel\nsbsip_rules_flow:\n '#type': value\n '#title': 'A SBSIP Afleveringsregel'\n '#value': |\n //Her skal slette de regler som ikke gælder for denne formular.\n //Hvis der skal afleveres til SBSYS skal du også redigere sbsip_xml elementet\n sbsys_standard //Hvis sag eksisterer bliver dokument tilføjet eller ny sag\n sbsys_ny //Opret altid en ny SBSYS sag\n sbsys_direkte_sag_2 //aflever direkte til en sag, husk at udfylde sbsys_sags_nr\n digital_post //Aflever kvittering til digital post\n \n '#default_value': digital_post\nsbsys_sags_nr:\n '#type': value\n '#title': 'B sbsys_sags_nr // bruges ved sbsys_direkte_sag_2 ellers tom'\nsbsip_xml:\n '#type': webform_attachment_os2forms_sbsys_xml\n '#os2formsId': _custom_\n '#os2formsId_custom': angiv_uuid_her\n '#sagSkabelonId': _custom_\n '#sagSkabelonId_custom': 'angiv SBSYS sagsskabelon id'\n '#nemid_cpr': default_nemid_value\n '#nemid_name': default_nemid_value\n '#nemid_address': default_nemid_value\n '#nemid_zipcode': default_nemid_value\n '#nemid_city': default_nemid_value\n '#bodyText': _custom_\n '#bodyText_custom': |\n Tak - vi har nu modtaget de indtastede oplysninger. Du kan se dem i den vedhæftede kvittering.\n \n Venlig hilsen\n Holstebro Kommune\n \n '#MaaSendesTilDFF': ja\n '#title': 'C SBSIP XML // 1 ) Angiv altid UUID, 2) Angiv SBSYS skabelon id ved sbsip_rules_flow(sbsys_standard eller sbsys_ny)'\n '#filename': os2forms.xml\nlogind_oplysninger:\n '#type': webform_wizard_page\n '#title': Start\n cpr:\n '#type': os2forms_nemid_cpr\n '#title': Cpr\n '#multiple': false\n '#title_display': none\n '#readonly': true\n '#wrapper_attributes':\n style: 'display:none'\n navn:\n '#type': os2forms_nemid_name\n '#title': Navn\n '#multiple': false\n '#title_display': none\n '#readonly': true\n '#wrapper_attributes':\n style: 'display:none'\n privat_adresse:\n '#type': os2forms_nemid_address\n '#title': Adresse\n '#multiple': false\n '#title_display': none\n '#readonly': true\n '#wrapper_attributes':\n style: 'display:none'\n cvr:\n '#type': os2forms_nemid_company_cvr\n '#title': CVR\n '#multiple': false\n '#title_display': none\n '#readonly': true\n '#wrapper_attributes':\n style: 'display:none'\n firmanavn:\n '#type': os2forms_nemid_company_name\n '#title': Firmanavn\n '#multiple': false\n '#title_display': none\n '#readonly': true\n '#wrapper_attributes':\n style: 'display:none'\n adresse:\n '#type': os2forms_nemid_company_address\n '#title': Adresse\n '#multiple': false\n '#title_display': none\n '#readonly': true\n '#wrapper_attributes':\n style: 'display:none'\n firma_by:\n '#type': os2forms_nemid_company_city\n '#title': 'Postnummer og By'\n '#multiple': false\n '#title_display': none\n '#readonly': true\n '#wrapper_attributes':\n style: 'display:none'\n flexboxlogind:\n '#type': webform_flexbox\n introtekstfeltgruppe:\n '#type': fieldset\n '#title': Kontaktoplysninger\n '#title_display': invisible\n '#flex': 3\n introtekst:\n '#type': processed_text\n '#text': |\n

(Evt. beskriv hvad brugeren skal have klar på forhånd, eller anden vigtig information) 

\n \n

Du er allerede logget ind. Du kan logge ud igen med linket i højre kolonne under dine personoplysninger.

\n \n

 

\n \n '#format': full_html\n flexbox_01:\n '#type': webform_flexbox\n oplysninger:\n '#type': container\n '#flex': 3\n e_mail_:\n '#type': email\n '#title': E-mail\n '#states_clear': false\n telefon:\n '#type': tel\n '#title': Telefon\n '#states_clear': false\n '#telephone_validation_format': '2'\n '#telephone_validation_country': DK\n tom:\n '#type': container\n '#flex': 3\n du_er_logget_ind_som:\n '#type': fieldset\n '#title': 'Du er logget ind som'\n brugerinformation_1:\n '#type': webform_computed_token\n '#title': 'Du er logget ind som:'\n '#title_display': invisible\n '#display_on': form\n '#template': |\n [webform_submission:values:navn][current-user:display-name][webform_submission:values:firmanavn]
\n [webform_submission:values:e_mail_]
\n [webform_submission:values:telefon]\n \n '#hide_empty': true\n '#ajax': true\n nemidlogin:\n '#type': os2forms_nemid_nemlogin_link\n '#nemlogin_link_login_text': 'Log på'\n '#nemlogin_link_logout_text': 'Log af'\n samtykkeerklaering:\n '#type': fieldset\n '#title': 'Samtykke eller oplysningspligt'\n '#flex': 3\n databeskyttelse:\n '#type': checkboxes\n '#title': Databeskyttelse\n '#title_display': none\n '#options':\n 'Ja, jeg accepterer kommunens registrering og eventuelle videregivelse af oplysninger.': 'Jeg accepterer kommunens registrering og eventuelle videregivelse af oplysninger.'\n '#options_all_value': ''\n '#options_all_text': ''\n '#options_none_value': ''\n '#options_none_text': ''\n databeskyttelsestekst:\n '#type': webform_more\n '#more_title': 'Læs mere om samtykke'\n '#more': |\n


\n Holstebro Kommune registrerer dine oplysninger og kan videregive disse til andre offentlige myndigheder, private virksomheder m.fl., der har lovmæssigt krav på oplysningerne eller samarbejder med kommunen. Du har ret til at kende de oplysninger, kommunen har registreret om dig lige som du kan kræve forkerte oplysninger rettet eller slettet.

\n \n

Du kan kontakte Holstebro Kommunes databeskyttelsesrådgiveren om de rettigheder, du har i henhold til databeskyttelseslovgivningen. Du har ret til at klage til Datatilsynet over kommunens behandling af dine personlige oplysninger. På www.holstebro.dk/databeskyttelse kan du læse mere og finde kontaktoplysninger.
\n  

\n \n oplysningspligt:\n '#type': webform_more\n '#more_title': 'Læs mere om oplysningspligt'\n '#more': |\n


\n Holstebro Kommune er dataansvarlig for behandlingen af de personoplysninger, som vi har modtaget om dig.

\n \n

Kontaktoplysninger:
\n Mail: 
\n Evt. Tlf:

\n \n

Vi behandler dine personoplysninger til følgende formål

\n \n

(skriv kort og forståeligt, hvad formålene er med at behandle personoplysningerne)

\n \n

Retsgrundlaget for vores behandling af dine personoplysninger følger af

\n \n

(Beskriv retsgrundlaget/retsgrundlagene for behandlingen, herunder f.eks. kapitlet i den lov eller bekendtgørelse, der pålægger jer at indsamle personoplysningerne. Hvis behandlingen er baseret på databeskyttelsesforordningens eller databeskyttelseslovens behandlingsbestemmelser, skal du henvise til den relevante bestemmelse.)

\n \n

Vi behandler følgende kategorier af personoplysninger om dig

\n \n

 (Skriv hvilken slags oplysninger der behandles fx kontaktoplysninger og cpr, økonomiske forhold, uddannelse. Hvis nogle af følgende kategorier behandles, skal det fremgå: Oplysninger om straffedomme eller lovovertrædelser, helbred, religion, fagforening, politisk eller filosofisk overbevisning, race eller etnicitet, seksuel orientering, biometrisk data til identifikation.)

\n \n

Vi videregiver eller overlader dine personoplysninger til

\n \n

(Skriv hvem der modtager oplysningerne fx SKAT, UDK, politiet, samarbejdspartnere eller virksomheder)

\n \n

Vi henter personoplysninger om dig fra (HVIS RELEVANT)

\n \n

(skriv hvor oplysninger hentes, fx fra SKAT, Folkeregistret, BBR , andre offentlige myndigheder.)

\n \n

Vi gemmer dine personoplysninger i (HVIS RELEVANT)

\n \n

(angiv tidsrum fx 5 år efter sagen er afsluttet, 6 måneder efter vi har afsluttet ansættelsen etc. Hvis ikke det er muligt at angive præcis tidsrum, skriv i stedet hvilke kriterier der lægger til grund for opbevaringstiden) Vi foretager en automatisk afgørelse ud fra (beskriv hvilken afgørelse der træffes og ud fra hvilke kriterier det sker. Skriv hvilken konsekvens det kan få for den registrerede)

\n \n

Du har mulighed for at trække dit samtykke tilbage

\n \n

Det gør du ved at kontakte os på ovenstående kontaktoplysninger. Hvis du trækker dit samtykke tilbage, påvirker det kun den fremadrettede behandling af dine personoplysninger.

\n \n

Du har følgende rettigheder jf. databeskyttelsesforordningen

\n \n \n \n

Du har ret til at klage til Datatilsynet, hvis du er utilfreds med vores behandling af dine personoplysninger. Se mere på datatilsynet.dk

\n \nudfyld:\n '#type': webform_wizard_page\n '#title': Udfyld\n flexbox_kontaktopl:\n '#type': webform_flexbox\n tekst_side2:\n '#type': fieldset\n '#title': 'Skriv forklarende overskrift'\n '#flex': 3\n tekst:\n '#type': textarea\n '#title': tekst\n '#title_display': none\n '#flex': 3\n du_er_logget_ind_som_3:\n '#type': fieldset\n '#title': 'Du er logget ind som:'\n brugerinformation_2:\n '#type': webform_computed_token\n '#title': 'Du er logget ind som:'\n '#title_display': invisible\n '#display_on': form\n '#template': |\n [webform_submission:values:navn][current-user:display-name][webform_submission:values:firmanavn]
\n [webform_submission:values:e_mail_]
\n [webform_submission:values:telefon]\n \n '#hide_empty': true\n '#ajax': true\nudfyld_2:\n '#type': webform_wizard_page\n '#title': 'Udfyld 2'\n flexbox_02:\n '#type': webform_flexbox\n skriv_forklarende_overskrift:\n '#type': fieldset\n '#title': 'Skriv forklarende overskrift'\n '#flex': 3\n tekst2:\n '#type': textarea\n '#title': tekst\n '#title_display': none\n '#flex': 3\n du_er_logget_ind_som_4:\n '#type': fieldset\n '#title': 'Du er logget ind som'\n brugerinformation_3:\n '#type': webform_computed_token\n '#title': 'Du er logget ind som:'\n '#title_display': invisible\n '#display_on': form\n '#template': |\n [webform_submission:values:navn][current-user:display-name][webform_submission:values:firmanavn]
\n [webform_submission:values:e_mail_]
\n [webform_submission:values:telefon]\n \n '#hide_empty': true\n '#ajax': true\nudfyld_3:\n '#type': webform_wizard_page\n '#title': 'Udfyld 3'\n flexbox_03:\n '#type': webform_flexbox\n skriv_forklarende_overskrift_6:\n '#type': fieldset\n '#title': 'Skriv forklarende overskrift'\n '#flex': 3\n tekst10:\n '#type': textarea\n '#title': tekst\n '#title_display': none\n '#flex': 3\n du_er_logget_ind_som_7:\n '#type': fieldset\n '#title': 'Du er logget ind som'\n brugerinformation_4:\n '#type': webform_computed_token\n '#title': 'Du er logget ind som:'\n '#title_display': invisible\n '#display_on': form\n '#template': |\n [webform_submission:values:navn][current-user:display-name][webform_submission:values:firmanavn]
\n [webform_submission:values:e_mail_]
\n [webform_submission:values:telefon]\n \n '#hide_empty': true\n '#ajax': true\nafslut_det_videre_forloeb:\n '#type': webform_wizard_page\n '#title': Afslut\n afslutning:\n '#type': processed_text\n '#text': |\n

(Beskriv efterfølgende forløb - Hvad kan borgeren forvente nu?

\n \n

Eksempelvis: Din ansøgning vil blive behandlet snarest og du vil modtage en afgørelse inden for 14 dage.)

\n \n '#format': full_html\nactions:\n '#type': webform_actions\n '#title': 'Submit button(s)'\n '#submit__label': 'Send XXX'\nvedhaeftet_pdf:\n '#type': 'webform_entity_print_attachment:pdf'\n '#title': 'D Vedhæftet PDF'\n '#filename': HK-Kvittering.pdf\n '#link_title': Kvittering\n '#view_mode': twig\n '#template': |\n

Kvittering

\n

[webform:title]

\n

Indsendt den [webform_submission:created:custom:d-m-Y - H:i]

\n \n [webform_submission:values:logind_oplysninger:html]\n \n [webform_submission:values:udfyld:format:html]\n \n [webform_submission:values:udfyld_2:format:html]\n \n [webform_submission:values:udfyld_3:format:html]" +css: '' +javascript: '' +settings: + ajax: true + ajax_scroll_top: form + ajax_progress_type: '' + ajax_effect: '' + ajax_speed: null + page: true + page_submit_path: '' + page_confirm_path: '' + page_theme_name: '' + form_title: source_entity_webform + form_submit_once: false + form_exception_message: '' + form_open_message: '' + form_close_message: '' + form_previous_submissions: true + form_confidential: false + form_confidential_message: '' + form_remote_addr: true + form_convert_anonymous: false + form_prepopulate: false + form_prepopulate_source_entity: false + form_prepopulate_source_entity_required: false + form_prepopulate_source_entity_type: '' + form_reset: false + form_disable_autocomplete: false + form_novalidate: false + form_disable_inline_errors: false + form_required: false + form_unsaved: false + form_disable_back: false + form_submit_back: false + form_autofocus: false + form_details_toggle: false + form_access_denied: default + form_access_denied_title: '' + form_access_denied_message: '' + form_access_denied_attributes: { } + form_file_limit: '' + share: true + share_node: true + share_theme_name: '' + share_title: true + share_page_body_attributes: { } + submission_label: '' + submission_log: false + submission_views: { } + submission_views_replace: { } + submission_user_columns: { } + submission_user_duplicate: false + submission_access_denied: default + submission_access_denied_title: '' + submission_access_denied_message: '' + submission_access_denied_attributes: { } + submission_exception_message: '' + submission_locked_message: '' + submission_excluded_elements: { } + submission_exclude_empty: false + submission_exclude_empty_checkbox: false + previous_submission_message: '' + previous_submissions_message: '' + autofill: false + autofill_message: '' + autofill_excluded_elements: { } + wizard_progress_bar: true + wizard_progress_pages: false + wizard_progress_percentage: false + wizard_progress_link: false + wizard_progress_states: true + wizard_auto_forward: true + wizard_start_label: '' + wizard_preview_link: false + wizard_confirmation: false + wizard_confirmation_label: '' + wizard_track: '' + wizard_prev_button_label: '' + wizard_next_button_label: '' + wizard_toggle: false + wizard_toggle_show_label: '' + wizard_toggle_hide_label: '' + preview: 0 + preview_label: Gennemse + preview_title: 'Gennemse dine oplysninger' + preview_message: '' + preview_attributes: { } + preview_excluded_elements: + sbsip_rules_flow: sbsip_rules_flow + sbsys_sags_nr: sbsys_sags_nr + vedhaeftet_pdf: vedhaeftet_pdf + sbsip_xml: sbsip_xml + preview_exclude_empty: true + preview_exclude_empty_checkbox: false + draft: none + draft_multiple: false + draft_auto_save: false + draft_saved_message: '' + draft_loaded_message: '' + draft_pending_single_message: '' + draft_pending_multiple_message: '' + confirmation_type: page + confirmation_title: '' + confirmation_message: "

Tak - vi har nu modtaget de indtastede oplysninger

\n\n

Du vil modtage en kvittering med de indtastede oplysninger i din digitale postkasse på post.borger.dk eller post.virk.dk. Her kan du også skrive til os hvis du har spørgsmål. 
\n
\nKvitteringen kommer inden for 24 timer.
\n
\nVenlig hilsen
\nAfdeling
\nTelefon 9611 xxxx

\n" + confirmation_url: '' + confirmation_attributes: { } + confirmation_back: true + confirmation_back_label: '' + confirmation_back_attributes: { } + confirmation_exclude_query: false + confirmation_exclude_token: false + confirmation_update: false + limit_total: null + limit_total_interval: null + limit_total_message: '' + limit_total_unique: false + limit_user: null + limit_user_interval: null + limit_user_message: '' + limit_user_unique: false + entity_limit_total: null + entity_limit_total_interval: null + entity_limit_user: null + entity_limit_user_interval: null + purge: completed + purge_days: 7 + results_disabled: false + results_disabled_ignore: false + results_customize: false + token_view: false + token_update: false + wizard_auto_forward_hide_next_button: false + wizard_keyboard: true + token_delete: false + serial_disabled: false +access: + create: + roles: + - anonymous + - authenticated + users: { } + permissions: { } + view_any: + roles: { } + users: { } + permissions: { } + update_any: + roles: { } + users: { } + permissions: { } + delete_any: + roles: { } + users: { } + permissions: { } + purge_any: + roles: { } + users: { } + permissions: { } + view_own: + roles: { } + users: { } + permissions: { } + update_own: + roles: { } + users: { } + permissions: { } + delete_own: + roles: { } + users: { } + permissions: { } + administer: + roles: { } + users: { } + permissions: { } + test: + roles: { } + users: { } + permissions: { } + configuration: + roles: { } + users: { } + permissions: { } +handlers: + e_mail: + id: email + label: 'SBSIP PROD' + notes: '' + handler_id: e_mail + status: false + conditions: { } + weight: 0 + settings: + states: + - completed + to_mail: formularinput@holstebro.dk + to_options: { } + cc_mail: '' + cc_options: { } + bcc_mail: '' + bcc_options: { } + from_mail: _default + from_options: { } + from_name: _default + subject: _default + body: _default + excluded_elements: + nemidlogin: nemidlogin + ignore_access: true + exclude_empty: true + exclude_empty_checkbox: false + exclude_attachments: false + html: true + attachments: true + twig: false + debug: false + reply_to: '' + return_path: '' + sender_mail: '' + sender_name: '' + theme_name: '' + parameters: { } + spawn_maestro_workflow: + id: maestro + label: 'Spawn Maestro Workflow' + notes: '' + handler_id: spawn_maestro_workflow + status: true + conditions: { } + weight: 0 + settings: + maestro_template: content_moderation + maestro_message_success: 'Din indsendelse er modtaget.' + maestro_message_failure: 'Der er sket en fejl med din indsendelse.' +variants: { } diff --git a/os2forms_forloeb.module b/os2forms_forloeb.module index acac3cc..0a9420d 100644 --- a/os2forms_forloeb.module +++ b/os2forms_forloeb.module @@ -28,3 +28,84 @@ function os2forms_forloeb_install() { ->set('admin', 'gin') ->save(); } + +use Drupal\maestro\Engine\MaestroEngine; + +/** + * Implements hook_maestro_interactive_handlers() for the return of an Array + * of function names and help text that will be displayed in the edit task + * form under the handler field. + */ +function os2forms_forloeb_maestro_interactive_handlers() { + return [ + 'os2forms_forloeb_workflow_maestro_reassign_form' => t('Tilføj sagsbehandler'), + ]; +} + +/** + * The Reassign for Approval form used in maestro workflows. + * + * @param array $form + * The array that contains the form. + * @param int $queueID + * The queueID from Maestro. + * @param object $obj + * References the calling object. + */ +function os2forms_forloeb_workflow_maestro_reassign_form(&$form, $queueID = 0, $obj) { + +// $form['approve_content'] = array( +// '#id' => 'approve_content', +// '#type' => 'radios', +// '#options' => array( +// 0 => t("Assign for Review"), +// 1 => t("Approve") +// ), +// '#default_value' => 0, +// '#title' => t('Review or Approve Content '), +// '#required' => true, +// ); + + $form['reviewer'] = array( + '#id' => 'select_assigned_user', + '#type' => 'entity_autocomplete', + '#target_type' => 'user', + '#default_value' => '', + '#selection_settings' => ['include_anonymous' => FALSE], + '#title' => t('Assign for Review to'), + ); + + $form['queueID'] = array( + '#type' => 'hidden', + '#title' => 'the queue ID in the event we need it in later processing', + '#default_value' => $queueID, + '#description' => ('queueID'), + ); + + //overriding the default label "complete" + $form['actions']['submit']['#value'] = t('Assign'); + + return $form; +} + + +/** + * This is the submit handler for the Reassign for Approval form use in maestro workflows. + */ +function os2forms_forloeb_workflow_maestro_reassign_form_submit(&$form, &$form_state) { + + $queueID = intval($form_state->getValue('queueID')); + $processID = MaestroEngine::getProcessIdFromQueueId($queueID); + + //Who was selected? Load their username, which is the user attribute that Maestro assigns tasks by. + $reviewer_uid = $form_state->getValue('reviewer'); + $reviewer = \Drupal\user\Entity\User::load($reviewer_uid); // pass your uid + $reviewer_username = $reviewer->getUsername(); + + //add that user to our maestro process variable. + MaestroEngine::setProcessVariable("assigned_to", $reviewer_username, $processID); + + //Provide some feedback + drupal_set_message("Content Reassigned"); + +} diff --git a/src/Plugin/EngineTasks/MaestroSelectContentTask.php b/src/Plugin/EngineTasks/MaestroSelectContentTask.php new file mode 100644 index 0000000..e2dd543 --- /dev/null +++ b/src/Plugin/EngineTasks/MaestroSelectContentTask.php @@ -0,0 +1,407 @@ +processID = $configuration[0]; + $this->queueID = $configuration[1]; + } + } + + /** + * {@inheritDoc} + */ + public function isInteractive() { + return TRUE; + } + + /** + * {@inheritDoc} + */ + public function shortDescription() { + return t('Create or Select a Content Item'); + } + + /** + * {@inheritDoc} + */ + public function description() { + return $this->t('Create or Select a Content Item'); + } + + /** + * + * {@inheritDoc} + * @see \Drupal\Component\Plugin\PluginBase::getPluginId() + */ + public function getPluginId() { + return 'MaestroSelectContent'; + } + + /** + * {@inheritDoc} + */ + public function getTaskColours() { + return '#e2743c'; + } + + + + /** + * {@inheritDoc} + */ + public function getTaskEditForm(array $task, $templateMachineName) { + $form = array( + '#markup' => t('Select a Content Item.'), + ); + + $content_type_options = array(""=>"All Content Types"); + $content_types_objs = $types = \Drupal::entityTypeManager() + ->getStorage('node_type') + ->loadMultiple(); + foreach($content_types_objs as $content_type_machine_name => $content_type) { + $content_type_options[$content_type_machine_name] = $content_type_machine_name; + } + + $form['content_type'] = array( + '#type' => 'select', + '#title' => $this->t('Select the Content Type'), + '#description' => $this->t('Limit the content that can be selected to this content type.'), + '#required' => TRUE, + '#options' => $content_type_options, + ); + if(isset($task['data']['content_type'])) { + $form['content_type']['#default_value'] = $task['data']['content_type']; + } + + $form['unique_id'] = [ + '#type' => 'textfield', + '#title' => $this->t('Give this piece of content a unique identifier'), + '#description' => $this->t('This identifier is stored along with its ID to allow you to recall it when filled in.'), + '#default_value' => isset($task['data']['unique_id']) ? $task['data']['unique_id'] : '', + '#required' => TRUE, + ]; + + $form['redirect_to'] = array( + '#type' => 'textfield', + '#title' => $this->t('Return Path'), + '#description' => $this->t('You can specify where your return path should go upon task completion.'), + '#default_value' => isset($task['data']['redirect_to']) ? $task['data']['redirect_to'] : '/taskconsole', + '#required' => TRUE, + ); + + $form['modal'] = array( + '#type' => 'select', + '#title' => $this->t('Task presentation'), + '#description' => $this->t('Should this task be shown as a modal or full screen task.'), + '#default_value' => isset($task['data']['modal']) ? $task['data']['modal'] : 'notmodal', + '#options' => array( + 'modal' => $this->t('Modal'), + 'notmodal' => $this->t('Full Page'), + ), + '#required' => TRUE, + ); + return $form; + } + + + /** + * {@inheritDoc} + */ + public function validateTaskEditForm(array &$form, FormStateInterface $form_state) { + + } + + /** + * {@inheritDoc} + */ + public function prepareTaskForSave(array &$form, FormStateInterface $form_state, array &$task) { + + $task['data']['modal'] = $form_state->getValue('modal'); + $redirect = $form_state->getValue('redirect_to'); + if(isset($redirect)) { + $task['data']['redirect_to'] = $redirect; + } + else { + $task['data']['redirect_to'] = ''; + } + + $content_type = $form_state->getValue('content_type'); + if(isset($content_type)) { + $task['data']['content_type'] = $content_type; + } + else { + $task['data']['content_type'] = ''; + } + + $task['data']['unique_id'] = $form_state->getValue('unique_id'); + + } + + /* + * Part of the ExecutableInterface + * Execution of the interactive task does nothing except for setting the run_once flag + * {@inheritdoc} + */ + public function execute() { + //need to set the run_once flag here + //as interactive tasks are executed and completed by the user using the Maestro API + $queueRecord = \Drupal::entityTypeManager()->getStorage('maestro_queue')->load($this->queueID); + $queueRecord->set('run_once', 1); + $queueRecord->save(); + + return TRUE; + } + + /** + * {@inheritDoc} + */ + public function getExecutableForm($modal, MaestroExecuteInteractive $parent) { + $form['new_article'] = array( + '#id' => 'new_article', + '#type' => 'radios', + '#options' => array ( + 0 => t('Choose an Existing Article'), + 1 => t('Create a New Article'), + ), + '#default_value' => 0, + '#title' => t('Create or Select an Article'), + '#required' => true, + ); + + //query for all articles. + $articles = array(); + $nids = \Drupal::entityQuery('node') + ->condition('type','article') + ->execute(); + $article_nodes = \Drupal\node\Entity\Node::loadMultiple($nids); + foreach($article_nodes as $nid => $article_node) { + $articles[$nid] = $article_node->getTitle(); + } + + $form['existing_article'] = array( + '#id' => 'existing_article', + '#type' => 'select', + '#options' => $articles, + '#title' => t('Choose an Existing Article'), + '#validated' => TRUE, + '#prefix' => '
', + '#suffix' => '
', + '#states' => array( + 'invisible' => array( + ':input[name="new_article"]' => array('value' => 1), + ), + 'required' => array( + ':input[name="new_article"]' => array('value' => 0), + ), + ), + ); + + $form['queueID'] = array( + '#type' => 'hidden', + '#title' => 'the queue ID in the event we need it in later processing', + '#default_value' => $this->queueID, + '#description' => ('queueID'), + ); + + //add all of the entity form's fields into a fieldset + //create a fieldset to hold all the entity form fields + #ToDo Rather than simply hiding the entity_form it should be loaded and + # unloaded via JS. Currently required fields in the entity form, can cause + # this form to not validate, even when the new entity option is not selected + # and the entity_form is hidden. + $form['entity_form'] = array( + '#type'=>'fieldset', + '#title'=>'Create a Article', + '#states' => array( + 'invisible' => array( + ':input[name="new_article"]' => array('value' => 0), + ), + 'required' => array( + ':input[name="new_article"]' => array('value' => 1), + ), + ), + ); + + //create a form_state for this step. + $form_state = new FormState(); + + //specify a #parents key on our form definition because that is something the widgets themselves expect. + $form['#parents'] = []; + + //load an entity and store on the form state. + $new_article = \Drupal::entityTypeManager()->getStorage('node')->create([ + 'type' => 'article' + ]); + $form_state->set('entity', $new_article); + + //Load the form display + $article_form_display = \Drupal::entityTypeManager()->getStorage('entity_form_display')->load('node.article.default'); + $form_state->set('form_display', $article_form_display); + //Loop over the form display and add fields to the maestro form + foreach ($article_form_display->getComponents() as $name => $component) { + //Load the component's configured widget + $widget = $article_form_display->getRenderer($name); + $items = $new_article->get($name); + $form['entity_form'][$name] = $widget->form($items, $form, $form_state); + $form['entity_form'][$name]['#weight'] = $component['weight']; + //make the title field required. + if($name == "title"){ + $form['entity_form'][$name]['#required'] = false; + $form['entity_form'][$name]['widget']['#required'] = false; + $form['entity_form'][$name]['widget'][0]['#required'] = false; + $form['entity_form'][$name]['widget'][0]['value']['#required'] = false; + $form['entity_form'][$name]['#states'] = array( + 'required' => array( + ':input[name="new_lineup"]' => array('value' => 1), + ), + ); + } + } + + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => $this->t('Go'), + '#weight' => 1000 + ); + + if($modal == 'modal') { //if this is a modal task, we use the ajax completion routines and tell the buttons to use our built in completeForm modal closer + $form['actions']['submit']['#ajax'] = array( + 'callback' => [$parent, 'completeForm'], + 'wrapper' => '', + ); + + } + return $form; + } + + /** + * {@inheritDoc} + */ + public function handleExecuteSubmit(array &$form, FormStateInterface $form_state) { + + + $queueID = intval($form_state->getValue('maestro_queue_id')); + $triggeringElement = $form_state->getTriggeringElement(); + $processID = MaestroEngine::getProcessIdFromQueueId($queueID); + + if(strstr($triggeringElement['#id'], 'edit-submit') !== FALSE && $queueID > 0) { + /** + * If existing article is chosen simply assign it to this process + * + * If a new artivle is chosen create that article and assign it to this process. + */ + if($form_state->getValue('new_article')) { + //Create the new article entity. + $new_article = \Drupal::entityTypeManager()->getStorage('node')->create([ + 'type' => 'article' + ]); + //Load te form display + $article_form_display = \Drupal::entityTypeManager()->getStorage('entity_form_display')->load('node.article.default'); + //extract all of the form display's fields that are in the form_state values and assign to the new article. + $article_form_display->extractFormValues($new_article, $form, $form_state); + //Save the article + $new_article->save(); + //Assign this article to the maestro variable. + MaestroEngine::setProcessVariable("new_article", $new_article->id(), $processID); + //Bound this entity to this maestro process + $templateTask = MaestroEngine::getTemplateTaskByQueueID($queueID); + MaestroEngine::createEntityIdentifier($processID, 'node', 'article', $templateTask['data']['unique_id'], $new_article->id()); + //Complete this task. + MaestroEngine::completeTask($queueID, \Drupal::currentUser()->id()); + } + else { + $article_nid = $form_state->getValue('existing_article'); + MaestroEngine::setProcessVariable("new_article", $article_nid, $processID); + //Bound this entity to this maestro process + $templateTask = MaestroEngine::getTemplateTaskByQueueID($queueID); + MaestroEngine::createEntityIdentifier($processID, 'node', 'article', $templateTask['data']['unique_id'], $article_nid); + + //Complete this task. + MaestroEngine::completeTask($queueID, \Drupal::currentUser()->id()); + } + } + else { + //we'll complete the task, but we'll also flag it as TASK_STATUS_CANCEL + MaestroEngine::completeTask($queueID, \Drupal::currentUser()->id()); + MaestroEngine::setTaskStatus($queueID, TASK_STATUS_CANCEL); + } + + $task = MaestroEngine::getTemplateTaskByQueueID($queueID); + if(isset($task['data']['redirect_to'])) { + $response = new TrustedRedirectResponse($task['data']['redirect_to']); + $form_state->setResponse($response); + } + + } + + /** + * {@inheritDoc} + */ + public function performValidityCheck(array &$validation_failure_tasks, array &$validation_information_tasks, array $task) { + if( (array_key_exists('modal', $task['data']) && $task['data']['modal'] == '') || !array_key_exists('modal', $task['data'])) { + $validation_failure_tasks[] = array( + 'taskID' => $task['id'], + 'taskLabel' => $task['label'], + 'reason' => t('The Interactive Task has not been set up properly. The "Task Presentation" option is missing and thus the engine will be unable to execute this task.'), + ); + } + + //This task should have assigned users + //$task['assigned'] should have data + if( (array_key_exists('assigned', $task) && $task['assigned'] == '') || !array_key_exists('assigned', $task)) { + $validation_failure_tasks[] = array( + 'taskID' => $task['id'], + 'taskLabel' => $task['label'], + 'reason' => t('The Interactive Task has not been set up properly. The Interactive Task requires assignments to actors, roles or other assignment options.'), + ); + } + + if ((array_key_exists('unique_id', $task['data']) && $task['data']['unique_id'] == '') || !array_key_exists('unique_id', $task['data'])) { + $validation_failure_tasks[] = [ + 'taskID' => $task['id'], + 'taskLabel' => $task['label'], + 'reason' => t('The Content Type Task has not been set up properly. The "unique identifier" option is missing and thus the engine will be unable to execute this task.'), + ]; + } + } + + /** + * {@inheritDoc} + */ + public function getTemplateBuilderCapabilities() { + + return array('edit', 'drawlineto', 'removelines', 'remove'); + + } + +} From 16e15e4a5b55222a8b03aa8638e4c6fb00b194b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mads=20N=C3=B8rgaard?= Date: Wed, 14 Apr 2021 13:26:37 +0200 Subject: [PATCH 2/3] Adjustment to Maestro template. --- config/install/maestro.maestro_template.content_moderation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/install/maestro.maestro_template.content_moderation.yml b/config/install/maestro.maestro_template.content_moderation.yml index b28f46a..1e06a28 100644 --- a/config/install/maestro.maestro_template.content_moderation.yml +++ b/config/install/maestro.maestro_template.content_moderation.yml @@ -110,7 +110,7 @@ tasks: lines: { } data: unique_id: submission - webform_machine_name: test_af_hk_grundskabelon + webform_machine_name: hk_grundskabelon modal: notmodal skip_webform_handlers: 0 webform_nodes_attached_to: node/10 From 0f5847a80085a66a234c0bf62887e7423d95cd62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mads=20N=C3=B8rgaard?= Date: Fri, 16 Apr 2021 12:24:59 +0200 Subject: [PATCH 3/3] Changes in response to comments om PR. --- os2forms_forloeb.module | 12 ------------ src/Plugin/EngineTasks/MaestroSelectContentTask.php | 4 +++- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/os2forms_forloeb.module b/os2forms_forloeb.module index 0a9420d..f3db24a 100644 --- a/os2forms_forloeb.module +++ b/os2forms_forloeb.module @@ -54,18 +54,6 @@ function os2forms_forloeb_maestro_interactive_handlers() { */ function os2forms_forloeb_workflow_maestro_reassign_form(&$form, $queueID = 0, $obj) { -// $form['approve_content'] = array( -// '#id' => 'approve_content', -// '#type' => 'radios', -// '#options' => array( -// 0 => t("Assign for Review"), -// 1 => t("Approve") -// ), -// '#default_value' => 0, -// '#title' => t('Review or Approve Content '), -// '#required' => true, -// ); - $form['reviewer'] = array( '#id' => 'select_assigned_user', '#type' => 'entity_autocomplete', diff --git a/src/Plugin/EngineTasks/MaestroSelectContentTask.php b/src/Plugin/EngineTasks/MaestroSelectContentTask.php index e2dd543..b300e1e 100644 --- a/src/Plugin/EngineTasks/MaestroSelectContentTask.php +++ b/src/Plugin/EngineTasks/MaestroSelectContentTask.php @@ -84,7 +84,9 @@ public function getTaskEditForm(array $task, $templateMachineName) { '#markup' => t('Select a Content Item.'), ); - $content_type_options = array(""=>"All Content Types"); + $content_type_options = array( + 'all' => t('All Content Types'), + ); $content_types_objs = $types = \Drupal::entityTypeManager() ->getStorage('node_type') ->loadMultiple();