#include "macro_workflows.html" />
<#assign actionUrl = 'jsp/admin/plugins/workflow/ModifyAction.jsp?id_action=${action.id}' />
<#assign stateBeforeNames = [] />
<#assign stateAfterName = '' />
<#list state_list as state>
<#if action.listIdStateBefore?seq_contains( state.code?number )><#assign stateBeforeNames = stateBeforeNames + [ state.name ] />#if>
<#if state.code == action.stateAfter.id?c><#assign stateAfterName = state.name />#if>
#list>
<#assign headerDescription><@span class='text-secondary'>${stateBeforeNames?join( ', ' )}<@icon style='arrow-right' class='mx-1' />${stateAfterName}@span><#if action.automaticState><@tag color='info' class='ms-2' tagIcon='bolt'>#i18n{workflow.create_action.label_automatic}@tag>#if><#if action.massAction><@tag color='secondary' class='ms-1' tagIcon='stack-2'>#i18n{workflow.create_action.label_mass_action}@tag>#if>#assign>
<#assign pageBreadcrumb><@workflowBreadcrumb workflow=workflow><@workflowBreadcrumbLink href='jsp/admin/plugins/workflow/ModifyWorkflow.jsp?id_workflow=${workflow.id}&pane=pane-actions' label='#i18n{workflow.modify_workflow.manage_action.title}' /><@workflowBreadcrumbCurrent label=action.name />@workflowBreadcrumb>#assign>
<@pageContainer>
<@pageColumn>
<@pageHeader breadcrumb=pageBreadcrumb title='#i18n{workflow.modify_action.title} : ${action.name}' description=headerDescription>
<@aButton href='jsp/admin/plugins/workflow/ModifyWorkflow.jsp?id_workflow=${action.workflow.id}&pane=pane-actions' buttonIcon='arrow-left' color='light' title='#i18n{portal.util.labelBack}' hideTitle=['xs','sm','md'] />
@pageHeader>
<@tabs>
<@tabList>
<@tabLink href='${actionUrl}&pane=pane-general' active=( pane == 'pane-general' ) title='#i18n{workflow.modify_action.tab_general}' />
<@tabLink href='${actionUrl}&pane=pane-tasks' active=( pane == 'pane-tasks' ) title='#i18n{workflow.modify_action.manage_task.title}'><@tag color='secondary' class='ms-2'>${number_task}@tag>@tabLink>
<@tabLink href='${actionUrl}&pane=pane-prerequisites' active=( pane == 'pane-prerequisites' ) title='#i18n{workflow.modify_action.manage_prerequisite.columnTitle}'><@tag color='secondary' class='ms-2'>${(listPrerequisite?size)!0}@tag>@tabLink>
<@tabLink href='${actionUrl}&pane=pane-linked-actions' active=( pane == 'pane-linked-actions' ) title='#i18n{workflow.create_action.label_link_actions}' />
<@tabLink tabClass='ms-auto d-flex align-items-center pe-2'>
<#if pane == 'pane-tasks'>
<@aButton href='jsp/admin/plugins/workflow/DoUpdateTaskOrder.jsp?id_action=${action.id}&token=${token_update_task_order}' color='light' size='sm' class='me-1' buttonIcon='arrows-sort' title='#i18n{workflow.modify_workflow.init_order}' hideTitle=['all'] />
<@button type='button' color='primary' size='sm' buttonIcon='plus' title='#i18n{workflow.create_action.button_insert_new_task}' hideTitle=['xs','sm'] params='data-bs-toggle="modal" data-bs-target="#add-task"' />
<#elseif pane == 'pane-prerequisites'>
<@button type='button' color='primary' size='sm' buttonIcon='plus' title='#i18n{workflow.modify_action.manage_prerequisite.createPrerequisite}' hideTitle=['xs','sm'] params='data-bs-toggle="modal" data-bs-target="#add-prerequisite"' />
#if>
@tabLink>
@tabList>
<@tabContent>
<@tabPanel id='pane-general' active=( pane == 'pane-general' )>
<#if pane == 'pane-general'>
<@tform action='jsp/admin/plugins/workflow/DoModifyAction.jsp?plugin_name=workflow'>
<@input type='hidden' name='id_action' value='${action.id}' />
<@input type='hidden' name='token' value='${token}' />
<@row>
<@columns lg=6>
<@formGroup rows=2 labelFor='name' labelKey='#i18n{workflow.create_action.label_name}' mandatory=true helpKey='#i18n{workflow.create_action.label_name_comment}'>
<@input type='text' name='name' id='name' value=action.name maxlength=255 mandatory=true />
@formGroup>
<@formGroup rows=2 labelFor='uid' labelKey='#i18n{workflow.create_action.label_uid}' helpKey='#i18n{workflow.create_action.label_uid_comment}'>
<@input type='text' name='uid' id='uid' value=action.uid readonly=true />
@formGroup>
<@formGroup rows=2 labelFor='description' labelKey='#i18n{workflow.create_action.label_description}' mandatory=true helpKey='#i18n{workflow.create_action.label_description_comment}'>
<@input type='textarea' name='description' id='description' rows=3 mandatory=true>${action.description!}@input>
@formGroup>
<@formGroup rows=2 labelFor='id_icon' labelKey='#i18n{workflow.create_action.label_icon}' mandatory=true helpKey='#i18n{workflow.create_action.label_icon_comment}'>
<@radioIconList name='id_icon' default_value=action.icon.id icons=icon_list />
@formGroup>
@columns>
<@columns lg=6>
<@formGroup rows=2 labelKey='#i18n{workflow.create_action.label_state_before}' mandatory=true helpKey='#i18n{workflow.create_action.label_state_before_comment}'>
<#list state_list as state>
<@checkBox orientation='switch' name='id_state_before' id='id_state_before${state.code}' value='${state.code}' labelKey='${state.name}' checked=action.listIdStateBefore?seq_contains( state.code?number ) />
#list>
@formGroup>
<@formGroup rows=2 labelFor='id_state_after' labelKey='#i18n{workflow.create_action.label_state_after}' mandatory=true helpKey='#i18n{workflow.create_action.label_state_after_comment}'>
<@select name='id_state_after' id='id_state_after' items=state_list default_value=action.stateAfter.id?string />
@formGroup>
<@formGroup rows=2 labelFor='id_alternative_state_after' labelKey='#i18n{workflow.create_action.label_alternative_state_after}' helpKey='#i18n{workflow.create_action.label_alternative_state_after_comment}'>
<@select name='id_alternative_state_after' id='id_alternative_state_after' items=alternative_state_list default_value=action.alternativeStateAfter.id?string />
@formGroup>
<@fieldSet legend='#i18n{workflow.modify_action.legend_behaviour}'>
<@formGroup rows=2 helpKey='#i18n{workflow.create_action.label_automatic_comment}'>
<@checkBox orientation='switch' name='automatic' id='automatic' value='1' labelKey='#i18n{workflow.create_action.label_automatic}' checked=action.automaticState />
@formGroup>
<@formGroup rows=2 helpKey='#i18n{workflow.create_action.label_mass_action_comment}'>
<@checkBox orientation='switch' name='is_mass_action' id='is_mass_action' value='1' labelKey='#i18n{workflow.create_action.label_mass_action}' checked=action.massAction />
@formGroup>
@fieldSet>
@columns>
@row>
<@formGroup rows=2>
<@button type='submit' name='save' color='primary' buttonIcon='device-floppy' title='#i18n{workflow.create_action.button_save}' />
<@button type='submit' name='apply' color='light' buttonIcon='circle-check' title='#i18n{workflow.modify_action.button_apply}' />
<@button type='submit' name='cancel' color='light' buttonIcon='x' title='#i18n{workflow.create_action.button_cancel}' params='formnovalidate' />
@formGroup>
@tform>
#if>
@tabPanel>
<@tabPanel id='pane-tasks' active=( pane == 'pane-tasks' )>
<#if pane == 'pane-tasks'>
<@callOut color='info' callOutIcon='info-circle' title='#i18n{workflow.modify_action.manage_task.warning_assignment}' />
<#if task_list?has_content>
<@manageFeature>
<#list task_list as task>
<@manageFeatureItem>
<@manageFeatureItemColumn auto=true>
<@tag color='secondary'>${task.order}@tag>
@manageFeatureItemColumn>
<@manageFeatureItemColumn auto=true flex=false class='text-truncate'>
<#assign taskTitle = task.getTitle( locale )!'' />
<@span class='fw-bold'>${task.taskType.title!}@span>
<#if taskTitle?has_content && taskTitle != task.taskType.title!''><@p class='text-secondary small mb-0 text-truncate'><#outputformat 'HTML'>${taskTitle}#outputformat>@p>#if>
@manageFeatureItemColumn>
<@manageFeatureItemColumn align='end'>
<@orderButtons url='jsp/admin/plugins/workflow/DoChangeOrderTask.jsp?id_task=${task.id}' orderParam='order_task_id' order=task.order max=number_task token=token_change_order_task />
<#if task.taskType.configRequired>
<@aButton href='jsp/admin/plugins/workflow/ModifyTask.jsp?id_task=${task.id}' color='' class='ms-1' buttonIcon='pencil' title='#i18n{workflow.modify_action.manage_task.title_modify}' hideTitle=['all'] />
#if>
<@actionsMenu id='task-actions-${task.id}'>
<@actionsMenuItem href='jsp/admin/plugins/workflow/ConfirmCopyTask.jsp?id_task=${task.id}' iconName='copy' label='#i18n{workflow.modify_action.manage_task.title_copy}' />
<@actionsMenuItem href='jsp/admin/plugins/workflow/ConfirmRemoveTask.jsp?id_task=${task.id}' iconName='trash' label='#i18n{workflow.modify_action.manage_task.title_delete}' danger=true />
@actionsMenu>
@manageFeatureItemColumn>
@manageFeatureItem>
#list>
@manageFeature>
<#else>
<@empty title='#i18n{workflow.modify_action.manage_task.no_task}' subtitle='#i18n{workflow.modify_action.manage_task.no_task_help}' iconName='list-check'>
<@div class='empty-action'><@button type='button' color='primary' buttonIcon='plus' title='#i18n{workflow.create_action.button_insert_new_task}' params='data-bs-toggle="modal" data-bs-target="#add-task"' />@div>
@empty>
#if>
<@modal id='add-task'>
<@modalHeader modalTitle='#i18n{workflow.create_action.button_insert_new_task}' />
<@modalBody>
<@tform id='form-add-task' action='jsp/admin/plugins/workflow/DoInsertTask.jsp?plugin_name=workflow'>
<@input type='hidden' name='id_action' value='${action.id}' />
<@input type='hidden' name='token' value='${token}' />
<@formGroup rows=2 labelFor='task_type_key' labelKey='#i18n{workflow.modify_action.manage_task.insert_new_task}' mandatory=true>
<@select name='task_type_key' id='task_type_key' default_value='-1' items=task_type_list sort=true />
@formGroup>
@tform>
@modalBody>
<@modalFooter>
<@button type='button' color='light' buttonIcon='x' title='#i18n{portal.util.labelCancel}' params='data-bs-dismiss="modal"' />
<@button type='submit' formId='form-add-task' color='primary' buttonIcon='plus' title='#i18n{workflow.create_action.button_insert_new_task}' />
@modalFooter>
@modal>
#if>
@tabPanel>
<@tabPanel id='pane-prerequisites' active=( pane == 'pane-prerequisites' )>
<#if pane == 'pane-prerequisites'>
<@callOut color='info' callOutIcon='info-circle' title='#i18n{workflow.modify_action.manage_prerequisite.help}' />
<#if listPrerequisite?has_content>
<@manageFeature>
<#list listPrerequisite as prerequisite>
<@manageFeatureItem>
<@manageFeatureItemColumn auto=true flex=false><@span class='fw-bold'>#i18n{${prerequisite.title}}@span>@manageFeatureItemColumn>
<@manageFeatureItemColumn align='end'>
<#if prerequisite.hasConfiguration>
<@aButton href='jsp/admin/plugins/workflow/prerequisite/GetModifyPrerequisite.jsp?id_prerequisite=${prerequisite.idPrerequisite}&id_action=${action.id}' color='' buttonIcon='pencil' title='#i18n{workflow.manage_workflow.title_modify}' hideTitle=['all'] />
#if>
<@aButton href='jsp/admin/plugins/workflow/prerequisite/ConfirmRemovePrerequisite.jsp?id_prerequisite=${prerequisite.idPrerequisite}&id_action=${action.id}' color='danger' class='ms-1' buttonIcon='trash' title='#i18n{workflow.modify_action.manage_task.title_delete}' hideTitle=['all'] />
@manageFeatureItemColumn>
@manageFeatureItem>
#list>
@manageFeature>
<#else>
<@empty title='#i18n{workflow.modify_action.manage_prerequisite.noItem}' subtitle=' ' iconName='lock-open'>
<@div class='empty-action'><@button type='button' color='primary' buttonIcon='plus' title='#i18n{workflow.modify_action.manage_prerequisite.createPrerequisite}' params='data-bs-toggle="modal" data-bs-target="#add-prerequisite"' />@div>
@empty>
#if>
<@modal id='add-prerequisite'>
<@modalHeader modalTitle='#i18n{workflow.modify_action.manage_prerequisite.createPrerequisite}' />
<@modalBody>
<@tform id='form-add-prerequisite' action='jsp/admin/plugins/workflow/prerequisite/GetCreatePrerequisite.jsp'>
<@input type='hidden' name='id_action' value='${action.id}' />
<@formGroup rows=2 labelFor='prerequisite_type' labelKey='#i18n{workflow.modify_action.manage_prerequisite.columnTitle}' mandatory=true>
<@select name='prerequisite_type' id='prerequisite_type' items=list_prerequisite_type default_value='' />
@formGroup>
@tform>
@modalBody>
<@modalFooter>
<@button type='button' color='light' buttonIcon='x' title='#i18n{portal.util.labelCancel}' params='data-bs-dismiss="modal"' />
<@button type='submit' formId='form-add-prerequisite' color='primary' buttonIcon='plus' title='#i18n{workflow.modify_action.manage_prerequisite.createPrerequisite}' />
@modalFooter>
@modal>
#if>
@tabPanel>
<@tabPanel id='pane-linked-actions' active=( pane == 'pane-linked-actions' )>
<#if pane == 'pane-linked-actions'>
<@callOut color='info' callOutIcon='info-circle' title='#i18n{workflow.create_action.label_link_actions_comment}'>
<@p class='mb-0'>#i18n{workflow.create_action.label_link_actions_example}@p>
@callOut>
<#if display_tasks_form>
<@alert color='warning' iconTitle='alert-triangle' title='#i18n{workflow.create_action.label_link_actions_comment_display_task_forms}' />
<#elseif selected_linked_actions?has_content || available_linked_actions?has_content>
<@tform action='jsp/admin/plugins/workflow/DoModifyLinkedActions.jsp?plugin_name=workflow'>
<@input type='hidden' name='id_action' value='${action.id}' />
<@input type='hidden' name='token' value='${token}' />
<@formGroup rows=2 labelKey='#i18n{workflow.create_action.label_available_linked_actions}'>
<#list selected_linked_actions as linkedAction>
<@checkBox orientation='switch' name='id_linked_action' id='id_linked_action_${linkedAction.code}' value='${linkedAction.code}' labelKey='${linkedAction.name}' checked=true />
#list>
<#list available_linked_actions as linkedAction>
<@checkBox orientation='switch' name='id_linked_action' id='id_linked_action_${linkedAction.code}' value='${linkedAction.code}' labelKey='${linkedAction.name}' />
#list>
@formGroup>
<@formGroup rows=2>
<@button type='submit' color='primary' buttonIcon='device-floppy' title='#i18n{workflow.create_action.button_save}' />
@formGroup>
@tform>
<#else>
<@empty title='#i18n{workflow.modify_action.no_linkable_action}' subtitle=' ' iconName='link-off' />
#if>
#if>
@tabPanel>
@tabContent>
@tabs>
@pageColumn>
@pageContainer>