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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt (-20 / +34 lines)
Lines 113-121 Link Here
113
                                    [% FOREACH text_field IN TABL.text_fields %]
113
                                    [% FOREACH text_field IN TABL.text_fields %]
114
                                    [% IF ( text_field.select_field ) %]
114
                                    [% IF ( text_field.select_field ) %]
115
                                        <td>
115
                                        <td>
116
                                            <a class="delete_image btn btn-default btn-xs" href="/cgi-bin/koha/patroncards/image-manage.pl?op=delete&image_id=[% text_field.field_value | html %]"><i class="fa fa-trash-can"></i> Delete</a>
116
                                            <a class="delete_image btn btn-default btn-xs" data-image_id="[% text_field.field_value | html %]" href="/cgi-bin/koha/patroncards/image-manage.pl?op=delete&image_id=[% text_field.field_value | html %]"><i class="fa fa-trash-can"></i> Delete</a>
117
                                        </td>
117
                                        </td>
118
                                        <td align="center"><input type="checkbox" name="action" value="[% text_field.field_value | html %]" /></td>
118
                                        <td align="center"><input type="checkbox" id="image_id_[% text_field.field_value | html %]" name="image_id" value="[% text_field.field_value | html %]" /></td>
119
                                    [% ELSIF ( text_field.field_value ) %]
119
                                    [% ELSIF ( text_field.field_value ) %]
120
                                        <td>[% text_field.field_value | html %]</td>
120
                                        <td>[% text_field.field_value | html %]</td>
121
                                    [% ELSE %]
121
                                    [% ELSE %]
Lines 165-176 Link Here
165
[% MACRO jsinclude BLOCK %]
165
[% MACRO jsinclude BLOCK %]
166
    <script>
166
    <script>
167
        function DeleteConfirm() {
167
        function DeleteConfirm() {
168
            var results = selected_images("delete");
168
            var results = selected_images();
169
            if (results.images) {
169
            if (results) {
170
                var msg = _("Are you sure you want to delete image(s): %s?").format(results.image_ids);
170
                var msg = _("Are you sure you want to delete image(s): %s?").format(results.image_ids);
171
                var answer = confirm(msg);
171
                var answer = confirm(msg);
172
                if (answer) {
172
                if (answer) {
173
                    window.location = "/cgi-bin/koha/patroncards/image-manage.pl?op=delete&" + results.images;
173
                    const delete_form = document.delete_images;
174
                    if (delete_form){
175
                        delete_form.submit();
176
                    }
174
                } else {
177
                } else {
175
                    return; // abort delete
178
                    return; // abort delete
176
                }
179
                }
Lines 179-208 Link Here
179
            }
182
            }
180
        }
183
        }
181
184
182
        function selected_images(op) {
185
        function selected_images() {
183
            var selected = new Array;
184
            var image_ids = new Array;
186
            var image_ids = new Array;
185
            if (document.delete_images.action.length) {
187
            if (document.delete_images.image_id.length) {
186
                for (i=0;i<document.delete_images.action.length;i++){
188
                for (i=0;i<document.delete_images.image_id.length;i++){
187
                    if (document.delete_images.action[i].checked){
189
                    if (document.delete_images.image_id[i].checked){
188
                        selected.push("image_id=" + document.delete_images.action[i].value);
190
                        image_ids.push(document.delete_images.image_id[i].value);
189
                        image_ids.push(document.delete_images.action[i].value);
190
                    }
191
                    }
191
                }
192
                }
192
                images = selected.join("&");
193
                return {images:images, image_ids:image_ids};
194
            }
193
            }
195
            else if (document.delete_images.action.checked){
194
            if (image_ids.length){
196
                    return {images:"image_id="+document.delete_images.action.value, image_ids:document.delete_images.action.value};
195
                return {image_ids:image_ids};
197
            }
196
            }
198
            return (-1);
197
            return null;
199
        }
198
        }
200
        $(document).ready(function() {
199
        $(document).ready(function() {
201
            $("#delete").click(function(){
200
            $("#delete").click(function(){
202
                return DeleteConfirm();
201
                return DeleteConfirm();
203
            });
202
            });
204
            $(".delete_image").on("click", function(){
203
            $(".delete_image").on("click", function(ev){
205
                return confirmDelete( _("Are you sure you want to delete this image?") );
204
                ev.preventDefault();
205
                const this_image = ev.target;
206
                const image_id = this_image.dataset.image_id;
207
                for (i=0;i<document.delete_images.image_id.length;i++){
208
                    const row_image_id = document.delete_images.image_id[i].value;
209
                    const row_checkbox = document.querySelector(`#image_id_${row_image_id}`);
210
                    if (image_id === row_image_id){
211
                        row_checkbox.checked = true;
212
                    }
213
                    else {
214
                        row_checkbox.checked = false;
215
                    }
216
                }
217
                const confirmed = confirmDelete( _("Are you sure you want to delete image: %s?").format(image_id) );
218
                if (confirmed){
219
                    document.delete_images.submit();
220
                }
206
            });
221
            });
207
        });
222
        });
208
    </script>
223
    </script>
209
- 

Return to bug 38275