View | Details | Raw Unified | Return to bug 16148
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt (-213 / +271 lines)
Lines 18-36 Link Here
18
    //]]>
18
    //]]>
19
</script>
19
</script>
20
<script type="text/javascript" src="[% interface %]/[% theme %]/js/marc_modification_templates.js"></script>
20
<script type="text/javascript" src="[% interface %]/[% theme %]/js/marc_modification_templates.js"></script>
21
<style type="text/css">
22
    #add_action { display: none; }
23
</style>
21
</head>
24
</head>
22
25
23
<body id="tools_marc_modification_templates" class="tools">
26
<body id="tools_marc_modification_templates" class="tools">
24
[% INCLUDE 'header.inc' %]
27
[% INCLUDE 'header.inc' %]
25
[% INCLUDE 'cat-search.inc' %]
28
[% INCLUDE 'cat-search.inc' %]
26
29
27
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; MARC modification templates</div>
30
[% IF ( TemplatesLoop ) %]
31
    [% FOREACH TemplatesLoo IN TemplatesLoop %]
32
        [% IF ( TemplatesLoo.selected ) %]
33
            [% SET template_name = TemplatesLoo.name %]
34
        [% END %]
35
    [% END %]
36
[% END %]
37
38
<div id="breadcrumbs">
39
    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
40
    <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
41
    [% IF ( template_name ) %]
42
        <a href="/cgi-bin/koha/tools/marc_modification_templates.pl">MARC modification templates</a>
43
        &rsaquo; [% template_name %]
44
    [% ELSE %]
45
        MARC modification templates
46
    [% END %]
47
</div>
28
48
29
<div id="doc3" class="yui-t2">
49
<div id="doc3" class="yui-t2">
30
  <div id="bd">
50
  <div id="bd">
31
    <div id="yui-main">
51
    <div id="yui-main">
32
        <div class="yui-b">
52
        <div class="yui-b">
33
            <h2>MARC modification templates</h2>
53
54
            <div id="toolbar" class="btn-toolbar">
55
                <a href="#" data-toggle="modal" data-template_id="" data-target="#createTemplate" id="new_template" class="btn btn-small duplicate_template"><i class="fa fa-plus"></i> New template</a>
56
                [% IF ( template_id != '' ) %]
57
                    <a href="#" id="new_action" class="btn btn-small"><i class="fa fa-plus"></i> New action</a>
58
                [% END %]
59
            </div>
34
60
35
            [% IF error %]
61
            [% IF error %]
36
                [% IF error == 'no_from_field' %]
62
                [% IF error == 'no_from_field' %]
Lines 40-285 Link Here
40
66
41
            [% IF ( TemplatesLoop ) %]
67
            [% IF ( TemplatesLoop ) %]
42
68
43
                <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="select_template">
69
                [% IF ( template_id == '' ) %]
44
                    <label for="select_template">Template: </label>
45
                    <select name="template_id" id="select_template" style="width:20em;">
46
                        [% FOREACH TemplatesLoo IN TemplatesLoop %]
47
                                                    [% IF ( TemplatesLoo.selected ) %]
48
                            <option value="[% TemplatesLoo.template_id %]" selected="selected"> [% TemplatesLoo.name %]</option>
49
                                                    [% ELSE %]
50
                            <option value="[% TemplatesLoo.template_id %]"> [% TemplatesLoo.name %]</option>
51
                                                    [% END %]
52
                        [% END %]
53
                    </select>
54
                    <input type="hidden" name="op" value="select_template">
55
                    <input type="submit" value="Go" />
56
                </form>
57
58
                <form method="get" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="delete_template">
59
                    <input type="hidden" name="template_id" value="[% template_id %]" />
60
                    <input type="hidden" name="op" value="delete_template">
61
                    <input type="submit" value="Delete template" onClick="return confirmDelete()" />
62
                </form>
63
64
65
                [% IF ( ActionsLoop ) %]
66
                    <table>
67
                        <caption>Actions for this template</caption>
68
70
69
                        <tr>
71
                    <h2>MARC modification templates [% template_id %]</h2>
70
                            <th>Change order</th>
71
                            <th>Order</th>
72
                            <th>Action</th>
73
                            <th>Description</th>
74
                            <th>&nbsp;</th>
75
                            <th>&nbsp;</th>
76
                        </tr>
77
72
78
                        [% FOREACH ActionsLoo IN ActionsLoop %]
73
                    <table id="templatest">
74
                        <thead>
79
                            <tr>
75
                            <tr>
80
                                <td style="white-space:nowrap;">
76
                                <th>Template</th>
81
                                    <a title="Move action up" href="marc_modification_templates.pl?op=move_action&amp;where=up&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
77
                                <th>Actions</th>
82
                                    <img src="[% interface %]/[% theme %]/img/go-up.png" alt="Go up" />
83
                                        </a>
84
85
                                <a title="Move action to top" href="marc_modification_templates.pl?op=move_action&amp;where=top&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
86
                                    <img src="[% interface %]/[% theme %]/img/go-top.png" alt="Go top" />
87
                                        </a>
88
89
                                        <a title="Move action to bottom" href="marc_modification_templates.pl?op=move_action&amp;where=bottom&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
90
                                    <img src="[% interface %]/[% theme %]/img/go-bottom.png" alt="Go bottom" />
91
                                        </a>
92
93
                                        <a title="Move action down" href="marc_modification_templates.pl?op=move_action&amp;where=down&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
94
                                    <img src="[% interface %]/[% theme %]/img/go-down.png" alt="Go down" />
95
                                        </a>
96
                                </td>
97
98
                                <td>[% ActionsLoo.ordering %]</td>
99
                                <td>
100
                                    [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
101
                                    [% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
102
                                    [% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
103
                                    [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
104
                                    [% IF ( ActionsLoo.action_copy_and_replace_field ) %] Copy and replace [% END %]
105
106
                                    [% UNLESS ( ActionsLoo.action_update_field ) %]
107
                                        [% IF ( ActionsLoo.field_number ) %]
108
                                            1st
109
                                        [% END %]
110
                                    [% END %]
111
112
                                    field
113
114
                                    [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %]
115
116
                                    [% IF ( ActionsLoo.field_value ) %]
117
                                        with value <i>[% ActionsLoo.field_value %]</i>
118
                                    [% END %]
119
120
                                    [% IF ( ActionsLoo.to_field ) %]
121
                                        to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
122
123
                                        [% IF ( ActionsLoo.to_regex_search ) %]
124
                                             using RegEx s<strong>/[% ActionsLoo.to_regex_search %]/[% ActionsLoo.to_regex_replace %]/[% ActionsLoo.to_regex_modifiers %]</strong>
125
                                        [% END %]
126
                                    [% END %]
127
128
                                    [% IF ( ActionsLoo.conditional ) %]
129
                                        [% IF ( ActionsLoo.conditional_if ) %] if [% END %]
130
                                        [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
131
132
                                        [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %]
133
134
                                        [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
135
                                        [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
136
                                        [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
137
                                        [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
138
139
                                        [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %]
140
                                        <strong>[% ActionsLoo.conditional_value %]</strong>
141
                                        [% IF ( ActionsLoo.conditional_regex ) %]/[% END %]
142
                                    [% END %]
143
                                </td>
144
                                <td>[% ActionsLoo.description %]</td>
145
                                <td><a href="#modaction" onclick='editAction(
146
                                                    "[% ActionsLoo.mmta_id |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
147
                                                    "[% ActionsLoo.ordering |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
148
                                                    "[% ActionsLoo.action |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
149
                                                    "[% ActionsLoo.field_number |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
150
                                                    "[% ActionsLoo.from_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
151
                                                    "[% ActionsLoo.from_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
152
                                                    "[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
153
                                                    "[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
154
                                                    "[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
155
                                                    "[% ActionsLoo.to_regex_search |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
156
                                                    "[% ActionsLoo.to_regex_replace |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
157
                                                    "[% ActionsLoo.to_regex_modifiers |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
158
                                                    "[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
159
                                                    "[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
160
                                                    "[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
161
                                                    "[% ActionsLoo.conditional_comparison |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
162
                                                    "[% ActionsLoo.conditional_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
163
                                                    "[% ActionsLoo.conditional_regex |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
164
                                                    "[% ActionsLoo.description |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
165
                                                );updateAllEvery();'>Edit</a></td>
166
                                <td><a href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id %]" onclick="return confirmDeleteAction();">Delete</a></td>
167
                            </tr>
78
                            </tr>
168
                        [% END %]
79
                        </thead>
80
                        <tbody>
81
                            [% FOREACH TemplatesLoo IN TemplatesLoop %]
82
                                <tr>
83
                                    <td>[% TemplatesLoo.name %]</td>
84
                                    <td class="actions">
85
                                        <a class="btn btn-mini" href="/cgi-bin/koha/tools/marc_modification_templates.pl?template_id=[% TemplatesLoo.template_id %]&amp;op=select_template" ><i class="fa fa-fw fa-pencil"></i> Edit actions</a>
86
                                        <a class="btn btn-mini duplicate_template" href="#" data-toggle="modal" data-template_id="[% TemplatesLoo.template_id %]" data-target="#createTemplate"><i class="fa fa-fw fa-copy"></i> Duplicate</a>
87
                                        <a class="btn btn-mini" href="/cgi-bin/koha/tools/marc_modification_templates.pl?template_id=[% TemplatesLoo.template_id %]&amp;op=delete_template" class="delete_template" onclick="return confirmDeleteAction();"><i class="fa fa-fw fa-trash"></i> Delete</a>
88
                                    </td>
89
                                </tr>
90
                            [% END %]
91
                        </tbody>
169
                    </table>
92
                    </table>
93
170
                [% ELSE %]
94
                [% ELSE %]
171
                    <div class="dialog message"><p>There are no defined actions for this template.</p></div>
172
                [% END %]
173
95
174
                <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
96
                    <h2>Actions for <i>[% template_name %]</i></h2>
175
                    <a name="modaction"></a>
97
176
                    <fieldset>
98
                    [% IF ( ActionsLoop ) %]
177
                        <legend id="modaction_legend">Add a new action</legend>
99
178
                        <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>
100
                        <table id="template_actions" class="template_actions">
179
101
                            <thead>
180
                        <select name="action" id="action" onchange="onActionChange(this);">
102
                                <tr>
181
                            <option value="delete_field">Delete</option>
103
                                    <th>Change order</th>
182
                            <option value="update_field">Add/Update</option>
104
                                    <th>Order</th>
183
                            <option value="move_field">Move</option>
105
                                    <th>Action</th>
184
                            <option value="copy_field">Copy</option>
106
                                    <th>Description</th>
185
                            <option value="copy_and_replace_field">Copy and replace</option>
107
                                    <th>&nbsp;</th>
186
                        </select>
108
                                    <th>&nbsp;</th>
187
109
                                </tr>
188
                        <span id="field_number_block">
110
                            </thead>
189
                            <select name="field_number" id="field_number">
111
                            <tbody>
190
                                <option value="0">All</option>
112
                                [% FOREACH ActionsLoo IN ActionsLoop %]
191
                                <option value="1">1st</option>
113
                                    <tr>
114
                                        <td class="actions">
115
                                            <a title="Move action up" href="marc_modification_templates.pl?op=move_action&amp;where=up&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
116
                                            <img src="[% interface %]/[% theme %]/img/go-up.png" alt="Move action up" />
117
                                                </a>
118
119
                                        <a title="Move action to top" href="marc_modification_templates.pl?op=move_action&amp;where=top&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
120
                                            <img src="[% interface %]/[% theme %]/img/go-top.png" alt="Move action to the top" />
121
                                                </a>
122
123
                                                <a title="Move action to bottom" href="marc_modification_templates.pl?op=move_action&amp;where=bottom&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
124
                                            <img src="[% interface %]/[% theme %]/img/go-bottom.png" alt="Move action to the bottom" />
125
                                                </a>
126
127
                                                <a title="Move action down" href="marc_modification_templates.pl?op=move_action&amp;where=down&amp;template_id=[% ActionsLoo.template_id %]&amp;mmta_id=[% ActionsLoo.mmta_id %]">
128
                                            <img src="[% interface %]/[% theme %]/img/go-down.png" alt="Move action down" />
129
                                                </a>
130
                                        </td>
131
132
                                        <td>[% ActionsLoo.ordering %]</td>
133
                                        <td>
134
                                            [% IF ( ActionsLoo.action_delete_field ) %] Delete [% END %]
135
                                            [% IF ( ActionsLoo.action_update_field ) %] Update [% END %]
136
                                            [% IF ( ActionsLoo.action_move_field ) %] Move [% END %]
137
                                            [% IF ( ActionsLoo.action_copy_field ) %] Copy [% END %]
138
                                            [% IF ( ActionsLoo.action_copy_and_replace_field ) %] Copy and replace [% END %]
139
140
                                            [% UNLESS ( ActionsLoo.action_update_field ) %]
141
                                                [% IF ( ActionsLoo.field_number ) %]
142
                                                    1st
143
                                                [% END %]
144
                                            [% END %]
145
146
                                            field
147
148
                                            [% ActionsLoo.from_field %][% IF ( ActionsLoo.from_subfield ) %]$[% ActionsLoo.from_subfield %][% END %]
149
150
                                            [% IF ( ActionsLoo.field_value ) %]
151
                                                with value <i>[% ActionsLoo.field_value %]</i>
152
                                            [% END %]
153
154
                                            [% IF ( ActionsLoo.to_field ) %]
155
                                                to [% ActionsLoo.to_field %][% IF ( ActionsLoo.to_subfield ) %]$[% ActionsLoo.to_subfield %][% END %]
156
157
                                                [% IF ( ActionsLoo.to_regex_search ) %]
158
                                                     using RegEx s<strong>/[% ActionsLoo.to_regex_search %]/[% ActionsLoo.to_regex_replace %]/[% ActionsLoo.to_regex_modifiers %]</strong>
159
                                                [% END %]
160
                                            [% END %]
161
162
                                            [% IF ( ActionsLoo.conditional ) %]
163
                                                [% IF ( ActionsLoo.conditional_if ) %] if [% END %]
164
                                                [% IF ( ActionsLoo.conditional_unless ) %] unless [% END %]
165
166
                                                [% ActionsLoo.conditional_field %][% IF ( ActionsLoo.conditional_subfield ) %]$[% ActionsLoo.conditional_subfield %][% END %]
167
168
                                                [% IF ( ActionsLoo.conditional_comparison_exists ) %] exists [% END %]
169
                                                [% IF ( ActionsLoo.conditional_comparison_not_exists ) %] does not exist [% END %]
170
                                                [% IF ( ActionsLoo.conditional_comparison_equals ) %] matches [% END %]
171
                                                [% IF ( ActionsLoo.conditional_comparison_not_equals ) %] does not match [% END %]
172
173
                                                [% IF ( ActionsLoo.conditional_regex ) %] RegEx m/[% END %]
174
                                                <strong>[% ActionsLoo.conditional_value %]</strong>
175
                                                [% IF ( ActionsLoo.conditional_regex ) %]/[% END %]
176
                                            [% END %]
177
                                        </td>
178
                                        <td>[% ActionsLoo.description %]</td>
179
                                        <td>
180
                                            <a class="btn btn-mini" href="#modaction" onclick='editAction(
181
                                                            "[% ActionsLoo.mmta_id |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
182
                                                            "[% ActionsLoo.ordering |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
183
                                                            "[% ActionsLoo.action |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
184
                                                            "[% ActionsLoo.field_number |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
185
                                                            "[% ActionsLoo.from_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
186
                                                            "[% ActionsLoo.from_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
187
                                                            "[% ActionsLoo.field_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
188
                                                            "[% ActionsLoo.to_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
189
                                                            "[% ActionsLoo.to_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
190
                                                            "[% ActionsLoo.to_regex_search |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
191
                                                            "[% ActionsLoo.to_regex_replace |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
192
                                                            "[% ActionsLoo.to_regex_modifiers |replace('\\\\', '\\\\') |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
193
                                                            "[% ActionsLoo.conditional |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
194
                                                            "[% ActionsLoo.conditional_field |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
195
                                                            "[% ActionsLoo.conditional_subfield |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
196
                                                            "[% ActionsLoo.conditional_comparison |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
197
                                                            "[% ActionsLoo.conditional_value |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
198
                                                            "[% ActionsLoo.conditional_regex |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
199
                                                            "[% ActionsLoo.description |replace('\\\\', '\\\\') |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
200
                                                        );updateAllEvery();'><i class="fa fa-pencil"></i> Edit</a>
201
                                        </td>
202
                                        <td>
203
                                            <a class="btn btn-mini" href="marc_modification_templates.pl?template_id=[% ActionsLoo.template_id %]&op=delete_action&mmta_id=[% ActionsLoo.mmta_id %]" onclick="return confirmDeleteAction();"><i class="fa fa-trash"></i> Delete</a>
204
                                        </td>
205
                                    </tr>
206
                                [% END # /FOREACH ActionsLoo %]
207
                            </tbody>
208
                        </table>
209
                    [% ELSE %]
210
                        <div class="dialog message template_actions"><p>There are no defined actions for this template.</p></div>
211
                    [% END # /IF ActionsLoop %]
212
213
                    <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_action" >
214
                        <a name="modaction"></a>
215
                        <fieldset>
216
                            <legend id="modaction_legend">Add a new action</legend>
217
                            <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>
218
219
                            <select name="action" id="action" onchange="onActionChange(this);">
220
                                <option value="delete_field">Delete</option>
221
                                <option value="update_field">Add/Update</option>
222
                                <option value="move_field">Move</option>
223
                                <option value="copy_field">Copy</option>
224
                                <option value="copy_and_replace_field">Copy and replace</option>
192
                            </select>
225
                            </select>
193
                        </span>
194
226
195
                        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" />
227
                            <span id="field_number_block">
228
                                <select name="field_number" id="field_number">
229
                                    <option value="0">All</option>
230
                                    <option value="1">1st</option>
231
                                </select>
232
                            </span>
233
234
                            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" />
196
235
197
                        <span name="with_value_block" id="with_value_block" style="display:none;">
236
                            <span name="with_value_block" id="with_value_block" style="display:none;">
198
                            with value <input type="text" name="field_value" id="field_value" />
237
                                with value <input type="text" name="field_value" id="field_value" />
199
                        </span>
238
                            </span>
200
239
201
                        <span name="to_field_block" id="to_field_block" style="display:none;">
240
                            <span name="to_field_block" id="to_field_block" style="display:none;">
202
                            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" />
241
                                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" />
203
242
204
                            <span name="to_field_regex_block" id="to_field_regex_block">
243
                                <span name="to_field_regex_block" id="to_field_regex_block">
205
                                <sup>
244
                                    <sup>
206
                                    <label for="to_field_regex">RegEx</label>
245
                                        <label for="to_field_regex">RegEx</label>
207
                                    <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
246
                                        <input type="checkbox" name="to_field_regex" id="to_field_regex" onchange="onToFieldRegexChange(this);" />
208
247
209
                                    <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
248
                                        <span name="to_field_regex_value_block" id="to_field_regex_value_block" style="display:none;">
210
                                        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" />
249
                                            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" />
211
                                    </span>
250
                                        </span>
212
                                </sup>
251
                                    </sup>
252
                                </span>
213
                            </span>
253
                            </span>
214
                        </span>
215
254
216
                        <p/>
255
                            <p/>
217
256
218
                        <select name="conditional" id="conditional" onchange="onConditionalChange(this);">
257
                            <select name="conditional" id="conditional" onchange="onConditionalChange(this);">
219
                            <option value="" selected="selected" />
258
                                <option value="" selected="selected" />
220
                            <option value="if">if</option>
259
                                <option value="if">if</option>
221
                            <option value="unless">unless</option>
260
                                <option value="unless">unless</option>
222
                        </select>
261
                            </select>
223
262
224
                        <span name="conditional_block" id="conditional_block" style="display:none;">
263
                            <span name="conditional_block" id="conditional_block" style="display:none;">
225
                            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" />
264
                                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" />
226
265
227
                            <select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
266
                                <select name="conditional_comparison" id="conditional_comparison" onchange="onConditionalComparisonChange(this);">
228
                                <option value="" />
267
                                    <option value="" />
229
                                <option value="exists">exists</option>
268
                                    <option value="exists">exists</option>
230
                                <option value="not_exists">doesn't exist</option>
269
                                    <option value="not_exists">doesn't exist</option>
231
                                <option value="equals">matches</option>
270
                                    <option value="equals">matches</option>
232
                                <option value="not_equals">doesn't match</option>
271
                                    <option value="not_equals">doesn't match</option>
233
                            </select>
272
                                </select>
234
273
235
                            <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
274
                                <span name="conditional_comparison_block" id="conditional_comparison_block" style="display:none;">
236
275
237
                                <span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
276
                                    <span class="match_regex_prefix">m/</span><input type="text" id="conditional_value" name="conditional_value" /><span class="match_regex_suffix">/</span>
238
277
239
                                <sup>
278
                                    <sup>
240
                                    <label for="conditional_regex">RegEx</label>
279
                                        <label for="conditional_regex">RegEx</label>
241
                                    <input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
280
                                        <input type="checkbox" name="conditional_regex" id="conditional_regex" onchange="onConditionalRegexChange(this);" />
242
                                </sup>
281
                                    </sup>
243
282
283
                                </span>
244
                            </span>
284
                            </span>
245
                        </span>
246
285
247
                        <input type="hidden" name="template_id" value="[% template_id %]" />
286
                            <input type="hidden" name="template_id" value="[% template_id %]" />
248
                        <input type="hidden" name="mmta_id" id="mmta_id" />
287
                            <input type="hidden" name="mmta_id" id="mmta_id" />
249
                        <input type="hidden" name="op" value="add_action" />
288
                            <input type="hidden" name="op" value="add_action" />
250
289
251
                        <br/><br/>
290
                            <br/><br/>
252
                        <label for="description">Description:</label>
291
                            <label for="description">Description:</label>
253
                        <input type="text" name="description" id="description" size="60" />
292
                            <input type="text" name="description" id="description" size="60" />
254
293
255
                        <br/><br/>
294
                            <br/><br/>
256
                        <input id="action_submit" type="submit" value="Add action" /> <a href="#modaction" id="cancel_edit" onclick="cancelEditAction();" style="display:none;">Cancel</a>
295
                            <input id="action_submit" type="submit" value="Add action" /> <a href="#modaction" id="cancel_edit" onclick="cancelEditAction();">Cancel</a>
257
296
258
                    </fieldset>
297
                        </fieldset>
259
                </form>
298
                    </form>
299
300
                [% END %]
260
301
261
            [% ELSE %]
302
            [% ELSE %]
262
                <div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
303
                <div class="dialog message"><p>There are no defined templates. Please create a template first.</p></div>
263
            [% END %]
304
            [% END # /IF TemplatesLoop %]
264
305
265
            <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" class="validated">
306
            <!-- Modal to create new template -->
266
                <fieldset>
307
            <div class="modal hide" id="createTemplate" tabindex="-1" role="dialog" aria-labelledby="LabelcreateTemplate" aria-hidden="true">
267
                    <legend>Create a new template</legend>
308
                <div class="modal-header">
268
309
                    <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
269
                    <label for="template_name" class="required">Name: </label>
310
                    <h3 id="LabelcreateTemplate">Create a new template</h3>
270
                    <input name="template_name" id="template_name" type="text" size="30" required="required" class="required" />
311
                </div>
271
                    <span class="required">Required</span>
312
                <form method="post" action="/cgi-bin/koha/tools/marc_modification_templates.pl" id="add_template" class="validated">
272
313
                    <div class="modal-body">
273
                    <input type="hidden" name="op" value="create_template" />
314
                        <fieldset>
274
                    <input type="submit" value="Create template" />
315
                            <p>
275
316
                                <label for="template_name" class="required">Name: </label>
276
                    [% IF ( template_id ) %]
317
                                <input name="template_name" id="template_name" type="text" size="30" required="required" class="required" />
277
                        <input type="hidden" name="template_id" value="[% template_id %]" />
318
                                <span class="required">Required</span>
278
                        <input type="checkbox" name="duplicate_current_template" id="duplicate_current_template" />
319
                            </p>
279
                        <label for="duplicate_current_template">Duplicate current template</label>
320
280
                    [% END %]
321
                            <input type="hidden" name="op" value="create_template" />
281
                </fieldset>
322
282
            </form>
323
                            <p>
324
                                <label for="duplicate_a_template">Duplicate a template:</label>
325
                                <select name="template_id" id="duplicate_a_template">
326
                                    <option value=""> -- None --</option>
327
                                    [% FOREACH TemplatesLoo IN TemplatesLoop %]
328
                                        <option value="[% TemplatesLoo.template_id %]"> [% TemplatesLoo.name %]</option>
329
                                    [% END %]
330
                                </select>
331
                                <input type="hidden" name="duplicate_current_template" id="duplicate_current_template" />
332
                            </p>
333
                        </fieldset>
334
                    </div>
335
                    <div class="modal-footer">
336
                        <button type="submit" class="btn">Submit</button>
337
                        <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
338
                    </div>
339
                </form>
340
            </div>
283
        </div>
341
        </div>
284
    </div>
342
    </div>
285
343
Lines 287-291 Link Here
287
        [% INCLUDE 'tools-menu.inc' %]
345
        [% INCLUDE 'tools-menu.inc' %]
288
    </div>
346
    </div>
289
  </div>
347
  </div>
290
</div>
348
291
[% INCLUDE 'intranet-bottom.inc' %]
349
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/marc_modification_templates.js (-4 / +35 lines)
Lines 1-4 Link Here
1
$(document).ready(function() {
1
$(document).ready(function() {
2
    window.modaction_legend_innerhtml = document.getElementById('modaction_legend').innerHTML;
3
    window.action_submit_value = document.getElementById('action_submit').value;
4
2
    $('#select_template').find("input:submit").hide();
5
    $('#select_template').find("input:submit").hide();
3
    $('#select_template').change(function() {
6
    $('#select_template').change(function() {
4
        $('#select_template').submit();
7
        $('#select_template').submit();
Lines 43-48 $(document).ready(function() { Link Here
43
    $("#conditional_field,#from_field").change(function(){
46
    $("#conditional_field,#from_field").change(function(){
44
        updateAllEvery();
47
        updateAllEvery();
45
    });
48
    });
49
50
    $("#new_action").on("click",function(){
51
        cancelEditAction();
52
        $("#add_action").show();
53
        $("#action").focus();
54
    });
55
56
    $(".duplicate_template").on("click",function(){
57
        var template_id = $(this).data("template_id");
58
        $("#duplicate_a_template").val(template_id);
59
        $("#duplicate_current_template").val(1);
60
    });
61
62
    $('#createTemplate').on('shown', function () {
63
        $("#template_name").focus();
64
    });
65
66
    $("#duplicate_a_template").on("change",function(){
67
        if( this.value == '' ){
68
            $("#duplicate_current_template").val("");
69
        } else {
70
            $("#duplicate_current_template").val(1);
71
        }
72
    });
73
74
    $(".delete_template").on("click",function(){
75
        return confirmDelete();
76
    });
77
46
});
78
});
47
79
48
function updateAllEvery(){
80
function updateAllEvery(){
Lines 200-205 function editAction( mmta_id, ordering, action, field_number, from_field, from_s Link Here
200
    to_subfield, to_regex_search, to_regex_replace, to_regex_modifiers, conditional, conditional_field, conditional_subfield,
232
    to_subfield, to_regex_search, to_regex_replace, to_regex_modifiers, conditional, conditional_field, conditional_subfield,
201
    conditional_comparison, conditional_value, conditional_regex, description
233
    conditional_comparison, conditional_value, conditional_regex, description
202
) {
234
) {
235
    $("#add_action").show();
203
    document.getElementById('mmta_id').value = mmta_id;
236
    document.getElementById('mmta_id').value = mmta_id;
204
237
205
    setSelectByValue( 'action', action );
238
    setSelectByValue( 'action', action );
Lines 239-246 function editAction( mmta_id, ordering, action, field_number, from_field, from_s Link Here
239
272
240
    window.action_submit_value = document.getElementById('action_submit').value;
273
    window.action_submit_value = document.getElementById('action_submit').value;
241
    document.getElementById('action_submit').value = MSG_MMT_UPDATE_ACTION;
274
    document.getElementById('action_submit').value = MSG_MMT_UPDATE_ACTION;
242
243
    show('cancel_edit');
244
}
275
}
245
276
246
function cancelEditAction() {
277
function cancelEditAction() {
Lines 257-262 function cancelEditAction() { Link Here
257
    $("#to_regex_search").val("");
288
    $("#to_regex_search").val("");
258
    $("#to_regex_replace").val("");
289
    $("#to_regex_replace").val("");
259
    $("#to_regex_modifiers").val("");
290
    $("#to_regex_modifiers").val("");
291
    $("#description").val("");
260
292
261
    document.getElementById('to_field_regex').checked = false;
293
    document.getElementById('to_field_regex').checked = false;
262
    document.getElementById('to_field_regex').onchange();
294
    document.getElementById('to_field_regex').onchange();
Lines 276-283 function cancelEditAction() { Link Here
276
308
277
    document.getElementById('modaction_legend').innerHTML = window.modaction_legend_innerhtml;
309
    document.getElementById('modaction_legend').innerHTML = window.modaction_legend_innerhtml;
278
    document.getElementById('action_submit').value = window.action_submit_value;
310
    document.getElementById('action_submit').value = window.action_submit_value;
279
311
    $("#add_action").hide();
280
    hide('cancel_edit');
281
}
312
}
282
313
283
function setSelectByValue( selectId, value ) {
314
function setSelectByValue( selectId, value ) {
(-)a/tools/marc_modification_templates.pl (-6 lines)
Lines 113-123 if ( $op eq "create_template" ) { Link Here
113
113
114
my @templates = GetModificationTemplates( $template_id );
114
my @templates = GetModificationTemplates( $template_id );
115
115
116
unless ( $template_id ) {
117
  $template_id = $templates[0]->{'template_id'};
118
  @templates = GetModificationTemplates( $template_id );
119
}
120
121
my @actions = GetModificationTemplateActions( $template_id );
116
my @actions = GetModificationTemplateActions( $template_id );
122
foreach my $action ( @actions ) {
117
foreach my $action ( @actions ) {
123
  $action->{'action_delete_field'} = ( $action->{'action'} eq 'delete_field' );
118
  $action->{'action_delete_field'} = ( $action->{'action'} eq 'delete_field' );
124
- 

Return to bug 16148