473 lines
27 KiB
Plaintext
473 lines
27 KiB
Plaintext
[% USE raw %]
|
|
[% USE Koha %]
|
|
[% USE JSON.Escape %]
|
|
[% USE Asset %]
|
|
[% USE TablesSettings %]
|
|
[% PROCESS 'i18n.inc' %]
|
|
[% SET footerjs = 1 %]
|
|
[% INCLUDE 'doc-head-open.inc' %]
|
|
[% IF ( TemplatesLoop ) %]
|
|
[% FOREACH TemplatesLoo IN TemplatesLoop %]
|
|
[% IF ( TemplatesLoo.selected ) %]
|
|
[% SET template_name = TemplatesLoo.name %]
|
|
[% END %]
|
|
[% END %]
|
|
[% END %]
|
|
<title
|
|
>[% FILTER collapse %]
|
|
[% IF ( template_name ) %]
|
|
[% tx("Actions for template '{template_name}'", template_name = template_name ) | html %]
|
|
›
|
|
[% END %]
|
|
[% t("MARC modification templates") | html %]
|
|
› [% t("Cataloging") | html %] › [% t("Koha") | html %]
|
|
[% END %]</title
|
|
>
|
|
[% INCLUDE 'doc-head-close.inc' %]
|
|
[% FILTER collapse %]
|
|
<style nonce="[% Koha.CSPNonce | $raw %]">
|
|
#add_action {
|
|
display: none;
|
|
}
|
|
|
|
.action_line {
|
|
margin-bottom: 1em;
|
|
}
|
|
</style>
|
|
[% END %]
|
|
</head>
|
|
|
|
<body id="tools_marc_modification_templates" class="tools">
|
|
[% WRAPPER 'header.inc' %]
|
|
[% INCLUDE 'cat-search.inc' %]
|
|
[% END %]
|
|
|
|
[% WRAPPER 'sub-header.inc' %]
|
|
[% WRAPPER breadcrumbs %]
|
|
[% WRAPPER breadcrumb_item %]
|
|
<a href="/cgi-bin/koha/cataloguing/cataloging-home.pl">Cataloging</a>
|
|
[% END %]
|
|
|
|
[% IF ( template_name ) %]
|
|
[% WRAPPER breadcrumb_item %]
|
|
<a href="/cgi-bin/koha/tools/marc_modification_templates.pl">MARC modification templates</a>
|
|
[% END %]
|
|
[% WRAPPER breadcrumb_item bc_active= 1 %]
|
|
[% tx("Actions for template '{template_name}'", template_name = template_name ) | html %]
|
|
[% END %]
|
|
[% ELSE %]
|
|
[% WRAPPER breadcrumb_item bc_active= 1 %]
|
|
<span>MARC modification templates</span>
|
|
[% END %]
|
|
[% END %]
|
|
[% END #/ WRAPPER breadcrumbs %]
|
|
[% END #/ WRAPPER sub-header.inc %]
|
|
|
|
[% WRAPPER 'main-container.inc' aside='cat-menu' %]
|
|
<div id="toolbar" class="btn-toolbar">
|
|
<a href="#" data-bs-toggle="modal" data-template_id="" data-bs-target="#createTemplate" id="new_template" class="btn btn-default duplicate_template"><i class="fa fa-plus"></i> New template</a>
|
|
[% IF ( template_id != '' ) %]
|
|
<a href="#" class="btn btn-default new_action"><i class="fa fa-plus"></i> New action</a>
|
|
<form action="/cgi-bin/koha/tools/marc_modification_templates.pl" method="post">
|
|
[% INCLUDE 'csrf-token.inc' %]
|
|
<input type="hidden" name="template_id" value="[% template_id | html %]" />
|
|
<input type="hidden" name="op" value="cud-delete_template" />
|
|
<button type="submit" class="btn btn-default confirm-delete-template"><i class="fa fa-fw fa-trash-can"></i> Delete template</button>
|
|
</form>
|
|
[% ELSE %]
|
|
<div class="btn-group">
|
|
<a href="#" class="btn btn-default" data-bs-toggle="dropdown"><i class="fa fa-download"></i> Export</a>
|
|
<div class="dropdown-menu">
|
|
<a class="dropdown-item" href="/cgi-bin/koha/tools/marc_modification_templates.pl?op=export&export_all=1">Export all templates</a>
|
|
[% FOREACH TemplatesLoo IN TemplatesLoop %]
|
|
<a class="dropdown-item" href="/cgi-bin/koha/tools/marc_modification_templates.pl?op=export&template_ids=[% TemplatesLoo.template_id | html %]">Export [% TemplatesLoo.name | html %]</a>
|
|
[% END %]
|
|
</div>
|
|
</div>
|
|
<a href="#" class="btn btn-default" data-bs-toggle="modal" data-bs-target="#importTemplate"><i class="fa fa-upload"></i> Import</a>
|
|
[% END %]
|
|
</div>
|
|
|
|
[% IF error %]
|
|
[% IF error == 'no_from_field' %]
|
|
<div class="alert alert-info">Error: no field value specified.</div>
|
|
[% END %]
|
|
[% END %]
|
|
|
|
[% IF ( TemplatesLoop ) %]
|
|
|
|
[% IF ( template_id == '' ) %]
|
|
<h1>MARC modification templates [% template_id | html %]</h1>
|
|
|
|
<div class="page-section">
|
|
<table id="templatest">
|
|
<thead>
|
|
<tr>
|
|
<th>Id</th>
|
|
<th>Template</th>
|
|
<th class="no-sort no-export">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
[% FOREACH TemplatesLoo IN TemplatesLoop %]
|
|
<tr>
|
|
<td>[% TemplatesLoo.template_id | html %]</td>
|
|
<td>[% TemplatesLoo.name | html %]</td>
|
|
<td class="actions">
|
|
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/marc_modification_templates.pl?template_id=[% TemplatesLoo.template_id | html %]&op=select_template"
|
|
><i class="fa-fw fa-solid fa-pencil" aria-hidden="true"></i> Edit actions</a
|
|
>
|
|
<a class="btn btn-default btn-xs duplicate_template" href="#" data-bs-toggle="modal" data-template_id="[% TemplatesLoo.template_id | html %]" data-bs-target="#createTemplate"
|
|
><i class="fa fa-fw fa-copy"></i> Duplicate</a
|
|
>
|
|
|
|
<form action="/cgi-bin/koha/tools/marc_modification_templates.pl" method="post">
|
|
[% INCLUDE 'csrf-token.inc' %]
|
|
<input type="hidden" name="op" value="cud-delete_template" />
|
|
<input type="hidden" name="template_id" value="[% TemplatesLoo.template_id | html %]" />
|
|
<button type="submit" class="btn btn-default btn-xs confirm-delete-template"><i class="fa fa-fw fa-trash-can"></i> Delete</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
[% END %]
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- /.page-section -->
|
|
[% ELSE %]
|
|
<h1>[% tx("Actions for template '{template_name}'", template_name = template_name ) | html %]</h1>
|
|
|
|
[% IF ( ActionsLoop ) %]
|
|
<div class="page-section">
|
|
<table id="template_actions" class="template_actions">
|
|
<thead>
|
|
<tr>
|
|
<th>Change order</th>
|
|
<th>Rank</th>
|
|
<th>Action</th>
|
|
<th>Description</th>
|
|
<th> </th>
|
|
<th> </th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
[% FOREACH ActionsLoo IN ActionsLoop %]
|
|
<tr>
|
|
<td class="actions">
|
|
<a title="Move action up" href="marc_modification_templates.pl?op=move_action&where=up&template_id=[% ActionsLoo.template_id | html %]&mmta_id=[% ActionsLoo.mmta_id | html %]">
|
|
<i class="fa fa-arrow-up fa-lg order-control"></i>
|
|
</a>
|
|
|
|
<a title="Move action to top" href="marc_modification_templates.pl?op=move_action&where=top&template_id=[% ActionsLoo.template_id | html %]&mmta_id=[% ActionsLoo.mmta_id | html %]">
|
|
<i class="fa fa-arrow-up fa-lg overline order-control"></i>
|
|
</a>
|
|
|
|
<a title="Move action to bottom" href="marc_modification_templates.pl?op=move_action&where=bottom&template_id=[% ActionsLoo.template_id | html %]&mmta_id=[% ActionsLoo.mmta_id | html %]">
|
|
<i class="fa fa-arrow-down fa-lg underline order-control"></i>
|
|
</a>
|
|
|
|
<a title="Move action down" href="marc_modification_templates.pl?op=move_action&where=down&template_id=[% ActionsLoo.template_id | html %]&mmta_id=[% ActionsLoo.mmta_id | html %]">
|
|
<i class="fa fa-arrow-down fa-lg order-control"></i>
|
|
</a>
|
|
</td>
|
|
|
|
<td>[% ActionsLoo.ordering | html %]</td>
|
|
<td>
|
|
[% IF ( ActionsLoo.action_delete_field ) %]<span>Delete</span>[% END %]
|
|
[% IF ( ActionsLoo.action_add_field ) %]<span>Add new</span>[% END %]
|
|
[% IF ( ActionsLoo.action_update_field ) %]<span>Update existing or add new</span>[% END %]
|
|
[% IF ( ActionsLoo.action_move_field ) %]<span>Move</span>[% END %]
|
|
[% IF ( ActionsLoo.action_copy_field ) %]<span>Copy</span>[% END %]
|
|
[% IF ( ActionsLoo.action_copy_and_replace_field ) %]<span>Copy and replace</span>[% END %]
|
|
|
|
[% UNLESS ( ActionsLoo.action_update_field ) %]
|
|
[% IF ( ActionsLoo.field_number ) %]
|
|
<span>1st</span>
|
|
[% END %]
|
|
[% END %]
|
|
|
|
<span>field</span>
|
|
|
|
[% ActionsLoo.from_field | html %][% IF ( ActionsLoo.from_subfield.length ) %]$[% ActionsLoo.from_subfield | html %][% END %]
|
|
|
|
[% IF ( ActionsLoo.field_value ) %]
|
|
<span>with value</span> <em>[% ActionsLoo.field_value | html %]</em>
|
|
[% END %]
|
|
|
|
[% IF ( ActionsLoo.to_field ) %]
|
|
<span>to</span> [% ActionsLoo.to_field | html %][% IF ( ActionsLoo.to_subfield.length ) %]$[% ActionsLoo.to_subfield | html %][% END %]
|
|
|
|
[% IF ( ActionsLoo.to_regex_search ) %]
|
|
<span>using RegEx</span> s<strong>/[% ActionsLoo.to_regex_search | html %]/[% ActionsLoo.to_regex_replace | html %]/[% ActionsLoo.to_regex_modifiers | html %]</strong>
|
|
[% END %]
|
|
[% END %]
|
|
|
|
[% IF ( ActionsLoo.conditional ) %]
|
|
[% IF ( ActionsLoo.conditional_if ) %]<span>if</span>[% END %]
|
|
[% IF ( ActionsLoo.conditional_unless ) %]<span>unless</span>[% END %]
|
|
|
|
[% ActionsLoo.conditional_field | html %][% IF ( ActionsLoo.conditional_subfield.length ) %]$[% ActionsLoo.conditional_subfield | html %][% END %]
|
|
|
|
[% IF ( ActionsLoo.conditional_comparison_exists ) %]<span>exists</span>[% END %]
|
|
[% IF ( ActionsLoo.conditional_comparison_not_exists ) %]<span>does not exist</span>[% END %]
|
|
[% IF ( ActionsLoo.conditional_comparison_equals ) %]<span>matches</span>[% END %]
|
|
[% IF ( ActionsLoo.conditional_comparison_not_equals ) %]<span>does not match</span>[% END %]
|
|
|
|
[% IF ( ActionsLoo.conditional_regex ) %]<span>RegEx</span> m/[% END %]<strong>[% ActionsLoo.conditional_value | html %]</strong>[% IF ( ActionsLoo.conditional_regex ) %]/[% END %]
|
|
[% END %]
|
|
</td>
|
|
<td>[% ActionsLoo.description | html %]</td>
|
|
<td>
|
|
<a class="btn btn-default btn-xs edit_action" href="#modaction" data-mmta_id="[% ActionsLoo.mmta_id | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
|
|
</td>
|
|
<td>
|
|
<form action="marc_modification_templates.pl" method="post">
|
|
[% INCLUDE 'csrf-token.inc' %]
|
|
<input type="hidden" name="template_id" value="[% ActionsLoo.template_id | html %]" />
|
|
<input type="hidden" name="op" value="cud-delete_action" />
|
|
<input type="hidden" name="mmta_id" value="[% ActionsLoo.mmta_id | html %]" />
|
|
<button type="submit" class="btn btn-default btn-xs confirm-delete-action"><i class="fa fa-trash-can"></i> Delete</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
[% END # /FOREACH ActionsLoo %]
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- /.page-section -->
|
|
[% ELSE %]
|
|
<div class="alert alert-info" id="no_defined_actions">
|
|
<p>There are no defined actions for this template.</p>
|
|
<p
|
|
><a href="#" class="btn btn-default approve new_action"><i class="fa fa-plus" aria-hidden="true"></i> New action</a></p
|
|
>
|
|
</div>
|
|
[% END # /IF ActionsLoop %]
|
|
|
|
<form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action">
|
|
[% INCLUDE 'csrf-token.inc' %]
|
|
<fieldset>
|
|
<legend id="modaction_legend">Add a new action</legend>
|
|
<div id="warning_multivalued" style="color:red; display:none;"
|
|
>You have chosen a condition on the same field as the original field. If your records contain multivalued fields it is highly recommended not to do that.</div
|
|
>
|
|
|
|
<div class="action_line">
|
|
<select name="action" id="action" onchange="onActionChange(this);">
|
|
<option value="delete_field">Delete</option>
|
|
<option value="add_field">Add new</option>
|
|
<option value="update_field">Update existing or add new</option>
|
|
<option value="move_field">Move</option>
|
|
<option value="copy_field">Copy</option>
|
|
<option value="copy_and_replace_field">Copy and replace</option>
|
|
</select>
|
|
|
|
<span id="field_number_block">
|
|
<select name="field_number" id="field_number">
|
|
<option value="0">All</option>
|
|
<option value="1">1st</option>
|
|
</select>
|
|
</span>
|
|
|
|
field(s) <input type="text" name="from_field" id="from_field" size="3" maxlength="3" /> <input type="text" name="from_subfield" id="from_subfield" size="1" maxlength="1" title="let blank for the entire field" />
|
|
|
|
<span name="with_value_block" id="with_value_block" style="display:none;"> with value <input type="text" name="field_value" id="field_value" /> </span>
|
|
|
|
<span name="to_field_block" id="to_field_block" style="display:none;">
|
|
to field <input type="text" name="to_field" id="to_field" size="3" maxlength="3" /> <input type="text" name="to_subfield" id="to_subfield" size="1" maxlength="1" title="let blank for the entire field" />
|
|
|
|
<span name="to_field_regex_block" id="to_field_regex_block">
|
|
<sup>
|
|
<label for="to_field_regex">RegEx</label>
|
|
<input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
|
|
|
|
<span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
|
|
s/<input type="text" name="to_regex_search" id="to_regex_search" placeholder="regex pattern" />/<input
|
|
type="text"
|
|
name="to_regex_replace"
|
|
id="to_regex_replace"
|
|
placeholder="regex replacement"
|
|
/>/<input type="text" name="to_regex_modifiers" id="to_regex_modifiers" placeholder="ig" size="3" />
|
|
</span>
|
|
</sup>
|
|
</span>
|
|
</span>
|
|
</div>
|
|
|
|
<div class="action_line">
|
|
<select name="conditional" id="conditional" onchange="onConditionalChange(this);">
|
|
<option value="" selected="selected" />
|
|
<option value="if">if</option>
|
|
<option value="unless">unless</option>
|
|
</select>
|
|
|
|
<span name="conditional_block" id="conditional_block" style="display:none;">
|
|
field <input type="text" name="conditional_field" id="conditional_field" size="3" maxlength="3" /> <input type="text" name="conditional_subfield" id="conditional_subfield" size="1" maxlength="1" />
|
|
|
|
<select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
|
|
<option value="" />
|
|
<option value="exists">exists</option>
|
|
<option value="not_exists">doesn't exist</option>
|
|
<option value="equals">matches</option>
|
|
<option value="not_equals">doesn't match</option>
|
|
</select>
|
|
|
|
<span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
|
|
<span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
|
|
|
|
<sup>
|
|
<label for="conditional_regex">RegEx</label>
|
|
<input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
|
|
</sup>
|
|
</span>
|
|
</span>
|
|
</div>
|
|
|
|
<div class="action_line">
|
|
<label for="description">Description:</label>
|
|
<input type="text" name="description" id="description" size="60" />
|
|
</div>
|
|
|
|
<fieldset class="action">
|
|
<input type="hidden" name="template_id" value="[% template_id | html %]" />
|
|
<input type="hidden" name="mmta_id" id="mmta_id" />
|
|
<input type="hidden" name="op" value="cud-add_action" />
|
|
<input type="submit" id="action_submit" class="btn btn-primary" value="Add action" />
|
|
<a href="#modaction" class="cancel" id="cancel_edit" onclick="cancelEditAction();">Cancel</a>
|
|
</fieldset>
|
|
</fieldset>
|
|
</form>
|
|
[% END %]
|
|
[% ELSE %]
|
|
<h1>MARC modification templates</h1>
|
|
<div class="alert alert-info">
|
|
<p>There are no defined templates. Please create a template first.</p>
|
|
<a href="#" data-bs-toggle="modal" data-bs-target="#createTemplate" class="btn btn-default"><i class="fa fa-plus" aria-hidden="true"></i> Create a new template</a>
|
|
</div>
|
|
[% END # /IF TemplatesLoop %]
|
|
|
|
<!-- Modal to create new template -->
|
|
<div class="modal" id="createTemplate" tabindex="-1" role="dialog" aria-labelledby="LabelcreateTemplate" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h1 class="modal-title" id="LabelcreateTemplate">Create a new template</h1>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" class="validated">
|
|
[% INCLUDE 'csrf-token.inc' %]
|
|
<div class="modal-body">
|
|
<fieldset>
|
|
<p>
|
|
<label for="template_name" class="required">Name: </label>
|
|
<input name="template_name" id="template_name" type="text" size="30" required="required" class="required" />
|
|
<span class="required">Required</span>
|
|
</p>
|
|
|
|
<input type="hidden" name="op" value="cud-create_template" />
|
|
|
|
<p>
|
|
<label for="duplicate_a_template">Duplicate a template:</label>
|
|
<select name="template_id" id="duplicate_a_template">
|
|
<option value=""> -- None --</option>
|
|
[% FOREACH TemplatesLoo IN TemplatesLoop %]
|
|
<option value="[% TemplatesLoo.template_id | html %]"> [% TemplatesLoo.name | html %]</option>
|
|
[% END %]
|
|
</select>
|
|
<input type="hidden" name="duplicate_current_template" id="duplicate_current_template" />
|
|
</p>
|
|
</fieldset>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="submit" class="btn btn-primary">Submit</button>
|
|
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Modal to import templates -->
|
|
<div class="modal" id="importTemplate" tabindex="-1" role="dialog" aria-labelledby="LabelimportTemplate" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h1 class="modal-title" id="LabelimportTemplate">Import MARC modification templates</h1>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" enctype="multipart/form-data" id="import_template" class="validated">
|
|
[% INCLUDE 'csrf-token.inc' %]
|
|
<div class="modal-body">
|
|
<fieldset>
|
|
<p>
|
|
<label for="import_file" class="required">JSON file:</label>
|
|
<input type="file" name="import_file" id="import_file" required="required" class="required" />
|
|
<span class="required">Required</span>
|
|
</p>
|
|
|
|
<p>
|
|
<label>
|
|
<input type="checkbox" name="skip_existing" id="skip_existing" value="1" checked />
|
|
Skip existing templates (do not overwrite)
|
|
</label>
|
|
</p>
|
|
|
|
<input type="hidden" name="op" value="cud-import" />
|
|
|
|
[% IF import_error %]
|
|
[% IF import_error == 'no_file_uploaded' %]
|
|
<div class="alert alert-danger">Error: No file was uploaded.</div>
|
|
[% END %]
|
|
[% END %]
|
|
|
|
[% IF import_success || import_skipped || import_overwrite %]
|
|
<div class="alert alert-success">
|
|
[% IF import_success %]
|
|
<p>Successfully imported [% import_success | html %] template(s).</p>
|
|
[% END %]
|
|
[% IF import_skipped %]
|
|
<p>Skipped [% import_skipped | html %] template(s) that already exist.</p>
|
|
[% END %]
|
|
[% IF import_overwrote %]
|
|
<p>Overwrote [% import_overwrote | html %] template(s) that already exist.</p>
|
|
[% END %]
|
|
</div>
|
|
[% END %]
|
|
|
|
[% IF import_errors %]
|
|
[% FOREACH error IN import_errors %]
|
|
<div class="alert alert-danger">Error: [% error | html %]</div>
|
|
[% END %]
|
|
[% END %]
|
|
</fieldset>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="submit" class="btn btn-primary">Import</button>
|
|
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Close</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
[% END %]
|
|
|
|
[% MACRO jsinclude BLOCK %]
|
|
[% INCLUDE 'datatables.inc' %]
|
|
<script nonce="[% Koha.CSPNonce | $raw %]">
|
|
table_settings = [% TablesSettings.GetTableSettings('tools', 'marc-modification-templates', 'templatest', 'json') | $raw %];
|
|
[% IF ActionsLoop %]
|
|
var mmtas = [% ActionsLoop.json | $raw %]
|
|
[% END %]
|
|
|
|
// Show import modal if there are import results
|
|
[% IF show_import_modal %]
|
|
$(document).ready(function() {
|
|
$('#importTemplate').modal('show');
|
|
});
|
|
[% END %]
|
|
</script>
|
|
[% Asset.js("js/marc_modification_templates.js") | $raw %]
|
|
[% END %]
|
|
|
|
[% INCLUDE 'intranet-bottom.inc' %]
|