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

(-)a/api/v1/swagger/definitions.json (-4 / +4 lines)
Lines 38-48 Link Here
38
  "ill_backend": {
38
  "ill_backend": {
39
    "$ref": "definitions/ill_backend.json"
39
    "$ref": "definitions/ill_backend.json"
40
  },
40
  },
41
  "import-batch-profile": {
41
  "import_batch_profile": {
42
    "$ref": "definitions/import-batch-profile.json"
42
    "$ref": "definitions/import_batch_profile.json"
43
  },
43
  },
44
  "import-batch-profiles": {
44
  "import_batch_profiles": {
45
    "$ref": "definitions/import-batch-profiles.json"
45
    "$ref": "definitions/import_batch_profiles.json"
46
  },
46
  },
47
  "library": {
47
  "library": {
48
    "$ref": "definitions/library.json"
48
    "$ref": "definitions/library.json"
(-)a/api/v1/swagger/definitions/import-batch-profiles.json (-6 lines)
Lines 1-6 Link Here
1
{
2
    "type": "array",
3
    "items": {
4
      "$ref": "import-batch-profile.json"
5
    }
6
  }
(-)a/api/v1/swagger/definitions/import_batch_profiles.json (+6 lines)
Line 0 Link Here
1
{
2
    "type": "array",
3
    "items": {
4
      "$ref": "import_batch_profile.json"
5
    }
6
  }
(-)a/api/v1/swagger/parameters.json (-1 / +1 lines)
Lines 12-18 Link Here
12
    "$ref": "parameters/patron.json#/patron_id_qp"
12
    "$ref": "parameters/patron.json#/patron_id_qp"
13
  },
13
  },
14
  "profile_id_pp": {
14
  "profile_id_pp": {
15
    "$ref": "parameters/import-batch-profile.json#/profile_id_pp"
15
    "$ref": "parameters/import_batch_profile.json#/profile_id_pp"
16
  },
16
  },
17
  "city_id_pp": {
17
  "city_id_pp": {
18
    "$ref": "parameters/city.json#/city_id_pp"
18
    "$ref": "parameters/city.json#/city_id_pp"
(-)a/api/v1/swagger/paths.json (-4 / +4 lines)
Lines 110-120 Link Here
110
  "/illrequests": {
110
  "/illrequests": {
111
    "$ref": "paths/illrequests.json#/~1illrequests"
111
    "$ref": "paths/illrequests.json#/~1illrequests"
112
  },
112
  },
113
  "/import-batch-profiles": {
113
  "/import_batch_profiles": {
114
    "$ref": "paths/import-batch-profiles.json#/~1import-batch-profiles"
114
    "$ref": "paths/import_batch_profiles.json#/~1import_batch_profiles"
115
  },
115
  },
116
  "/import-batch-profiles/{profile_id}": {
116
  "/import_batch_profiles/{profile_id}": {
117
    "$ref": "paths/import-batch-profiles.json#/~1import-batch-profiles~1{profile_id}"
117
    "$ref": "paths/import_batch_profiles.json#/~1import_batch_profiles~1{profile_id}"
118
  },
118
  },
119
  "/rotas/{rota_id}/stages/{stage_id}/position": {
119
  "/rotas/{rota_id}/stages/{stage_id}/position": {
120
    "$ref": "paths/rotas.json#/~1rotas~1{rota_id}~1stages~1{stage_id}~1position"
120
    "$ref": "paths/rotas.json#/~1rotas~1{rota_id}~1stages~1{stage_id}~1position"
(-)a/api/v1/swagger/paths/import-batch-profiles.json (-5 / +5 lines)
Lines 1-5 Link Here
1
{
1
{
2
  "/import-batch-profiles": {
2
  "/import_batch_profiles": {
3
    "get": {
3
    "get": {
4
      "x-mojo-to": "ImportBatchProfiles#list",
4
      "x-mojo-to": "ImportBatchProfiles#list",
5
      "operationId": "listImportBatchProfiles",
5
      "operationId": "listImportBatchProfiles",
Lines 37-43 Link Here
37
        "200": {
37
        "200": {
38
          "description": "A list of import batch profiles",
38
          "description": "A list of import batch profiles",
39
          "schema": {
39
          "schema": {
40
            "$ref": "../definitions.json#/import-batch-profiles"
40
            "$ref": "../definitions.json#/import_batch_profiles"
41
          }
41
          }
42
        },
42
        },
43
        "401": {
43
        "401": {
Lines 140-146 Link Here
140
        "201": {
140
        "201": {
141
          "description": "Created Profile",
141
          "description": "Created Profile",
142
          "schema": {
142
          "schema": {
143
            "$ref": "../definitions.json#/import-batch-profile"
143
            "$ref": "../definitions.json#/import_batch_profile"
144
          }
144
          }
145
        },
145
        },
146
        "400": {
146
        "400": {
Lines 187-193 Link Here
187
      }
187
      }
188
    }
188
    }
189
  },
189
  },
190
  "/import-batch-profiles/{profile_id}": {
190
  "/import_batch_profiles/{profile_id}": {
191
    "put": {
191
    "put": {
192
      "x-mojo-to": "ImportBatchProfiles#edit",
192
      "x-mojo-to": "ImportBatchProfiles#edit",
193
      "operationId": "editImportBatchProfiles",
193
      "operationId": "editImportBatchProfiles",
Lines 260-266 Link Here
260
        "200": {
260
        "200": {
261
          "description": "Updated profile",
261
          "description": "Updated profile",
262
          "schema": {
262
          "schema": {
263
            "$ref": "../definitions.json#/import-batch-profile"
263
            "$ref": "../definitions.json#/import_batch_profile"
264
          }
264
          }
265
        },
265
        },
266
        "400": {
266
        "400": {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt (-84 / +22 lines)
Lines 103-120 Link Here
103
            <select name="profile" id="profile">
103
            <select name="profile" id="profile">
104
                <option value="">Do not use profile</option>
104
                <option value="">Do not use profile</option>
105
            </select>
105
            </select>
106
        </li>
106
            <div class="hint">When you select a profile it pre-fills your form with profile values.</div>
107
        <li>
107
            <div class="hint">Later you can modify your form and that's what matters on import.</div>
108
            <label for="profile_name">Profile name</label>
109
            <input type="text" id="profile_name" name="profile_name" />
110
111
        </li>
108
        </li>
112
    </ol>
109
    </ol>
113
    <fieldset class="action">
114
        <button id="add_profile" disabled>Add profile</button>
115
        <button id="mod_profile" disabled>Update profile</button>
116
        <button id="del_profile" disabled>Remove profile</button>
117
    </fieldset>
118
</fieldset>
110
</fieldset>
119
111
120
    <form method="post" id="processfile" action="[% SCRIPT_NAME | html %]" enctype="multipart/form-data">
112
    <form method="post" id="processfile" action="[% SCRIPT_NAME | html %]" enctype="multipart/form-data">
Lines 216-222 Link Here
216
      </li>
208
      </li>
217
    </ol>
209
    </ol>
218
  </fieldset>
210
  </fieldset>
219
  <fieldset class="action"><input type="button" id="mainformsubmit" value="Stage for import" /></fieldset>
211
  <fieldset class="action">
212
    <input type="button" id="mainformsubmit" value="Stage for import" />
213
    <button id="add_profile" disabled>Save profile</button>
214
    <input type="text" id="profile_name" name="profile_name" placeholder="Profile name"/>
215
    <button id="del_profile" disabled>Remove profile</button>
216
  </fieldset>
220
 
217
 
221
       <div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
218
       <div id="jobpanel"><div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
222
     <div id="jobfailed"></div></div>
219
     <div id="jobfailed"></div></div>
Lines 241-246 Link Here
241
    [% Asset.js("js/file-upload.js") | $raw %]
238
    [% Asset.js("js/file-upload.js") | $raw %]
242
    <script>
239
    <script>
243
        var xhr;
240
        var xhr;
241
        var PROFILE_SAVE_MSG = _("Profile saved");
242
        var PROFILE_DEL_MSG = _("Profile deleted");
244
        $(document).ready(function(){
243
        $(document).ready(function(){
245
            $("#processfile").hide();
244
            $("#processfile").hide();
246
            $('#profile_fieldset').hide();
245
            $('#profile_fieldset').hide();
Lines 298-307 Link Here
298
297
299
            $("#profile_name").keyup(function(){
298
            $("#profile_name").keyup(function(){
300
                $("#add_profile").prop("disabled", this.value.trim()=='');
299
                $("#add_profile").prop("disabled", this.value.trim()=='');
301
                $("#mod_profile").prop("disabled", this.value.trim()=='' || !$("#profile").val())
302
            });
300
            });
303
301
304
            $("#add_profile").click(function() {
302
            $("#add_profile").click(function(event) {
303
                event.preventDefault();
305
                var name = $("#profile_name").val().trim();
304
                var name = $("#profile_name").val().trim();
306
                if(!name) {
305
                if(!name) {
307
                    alert(_("Profile must have a name"));
306
                    alert(_("Profile must have a name"));
Lines 317-323 Link Here
317
                    });
316
                    });
318
317
319
                if(profile.length) {
318
                if(profile.length) {
320
                    if(!confirm(_("There is another profile with this name.")+"\n\n"+_("Do you want to replace it?"))) {
319
                    if(!confirm(_("There is another profile with this name.")+"\n\n"+_("Do you want to update it with new values?"))) {
321
                        return;
320
                        return;
322
                    }
321
                    }
323
                }
322
                }
Lines 340-346 Link Here
340
339
341
                    if(profile.length) {
340
                    if(profile.length) {
342
                        $.ajax({
341
                        $.ajax({
343
                            url: "/api/v1/import-batch-profiles/"+profile[0].profile_id,
342
                            url: "/api/v1/import_batch_profiles/"+profile[0].profile_id,
344
                            method: "PUT",
343
                            method: "PUT",
345
                            data: JSON.stringify(params),
344
                            data: JSON.stringify(params),
346
                            contentType: 'application/json'
345
                            contentType: 'application/json'
Lines 349-355 Link Here
349
                        .fail(reject);
348
                        .fail(reject);
350
                    } else {
349
                    } else {
351
                        $.ajax({
350
                        $.ajax({
352
                            url: "/api/v1/import-batch-profiles/",
351
                            url: "/api/v1/import_batch_profiles/",
353
                            method: "POST",
352
                            method: "POST",
354
                            data: JSON.stringify(params),
353
                            data: JSON.stringify(params),
355
                            contentType: 'application/json'
354
                            contentType: 'application/json'
Lines 359-364 Link Here
359
                    }
358
                    }
360
                })
359
                })
361
                .then(function(profile) {
360
                .then(function(profile) {
361
                    humanMsg.displayAlert(PROFILE_SAVE_MSG);
362
                    return getProfiles(profile.profile_id);
362
                    return getProfiles(profile.profile_id);
363
                })
363
                })
364
                .catch(function(error) {
364
                .catch(function(error) {
Lines 366-435 Link Here
366
                })
366
                })
367
            });
367
            });
368
368
369
            $("#mod_profile").click(function() {
369
            $("#del_profile").click(function(event) {
370
                var name = $("#profile_name").val().trim();
370
                event.preventDefault();
371
                var id = $("#profile").val();
372
                if(!id) return;
373
                if(!name) {
374
                    alert(_("Profile must have a name"));
375
                    return;
376
                }
377
                var profile = $("#profile option[value!='']")
378
                    .map(function() {
379
                        return $(this).data('profile');
380
                    })
381
                    .filter(function() {
382
                        return this.name == name && this.profile_id != id;
383
                    });
384
385
                if(profile.length) {
386
                    if(!confirm(_("There is another profile with this name.")+"\n\n"+_("Do you want to replace it?"))) {
387
                        return;
388
                    }
389
                }
390
                new Promise(function(resolve, reject) {
391
                    if(!profile.length) return resolve();
392
                    $.ajax({
393
                        url: "/api/v1/import-batch-profiles/"+profile[0].profile_id,
394
                        method: "DELETE"
395
                    })
396
                    .done(resolve)
397
                    .fail(reject);
398
                })
399
                .then(function(){
400
                    const params = {
401
                        comments: $("#comments").val() || null,
402
                        record_type: $("#record_type").val() || null,
403
                        encoding: $("#encoding").val() || null,
404
                        format: $("#format").val() || null,
405
                        template_id: $("#marc_modification_template_id").val() || null,
406
                        matcher_id: $("#matcher").val() || null,
407
                        overlay_action: $("#overlay_action").val() || null,
408
                        nomatch_action: $("#nomatch_action").val() || null,
409
                        parse_items: !!parseInt($("input[name='parse_items']:checked").val()) || null,
410
                        item_action: $("#item_action").val() || null,
411
                        name: name
412
                    };
413
                    return new Promise(function(resolve, reject) {
414
                        $.ajax({
415
                            url: "/api/v1/import-batch-profiles/"+id,
416
                            method: "PUT",
417
                            data: JSON.stringify(params),
418
                            contentType: 'application/json'
419
                        })
420
                        .done(resolve)
421
                        .fail(reject);
422
                    });
423
                })
424
                .then(function() {
425
                    return getProfiles(id);
426
                })
427
                .catch(function(error) {
428
                    alert(_("An error occurred")+"\n\n"+error.message);
429
                })
430
            });
431
432
            $("#del_profile").click(function() {
433
                var id = $("#profile").val();
371
                var id = $("#profile").val();
434
                if(!id) return;
372
                if(!id) return;
435
                if(!confirm(_("Are you sure you want to delete this profile?"))) {
373
                if(!confirm(_("Are you sure you want to delete this profile?"))) {
Lines 437-457 Link Here
437
                }
375
                }
438
                new Promise(function(resolve, reject) {
376
                new Promise(function(resolve, reject) {
439
                    $.ajax({
377
                    $.ajax({
440
                        url: "/api/v1/import-batch-profiles/"+id,
378
                        url: "/api/v1/import_batch_profiles/"+id,
441
                        method: "DELETE"
379
                        method: "DELETE"
442
                    })
380
                    })
443
                    .done(resolve)
381
                    .done(resolve)
444
                    .fail(reject);
382
                    .fail(reject);
445
                })
383
                })
446
                .then(function() {
384
                .then(function() {
385
                    humanMsg.displayAlert(PROFILE_DEL_MSG);
447
                    return getProfiles();
386
                    return getProfiles();
448
                })
387
                })
449
                .catch(function(error) {
388
                .catch(function(error) {
450
                    alert(_("An error occurred")+"\n\n"+error);
389
                    alert(_("An error occurred")+"\n\n"+error);
451
                })
390
                })
452
            });
391
            });
453
454
        });
392
        });
393
455
        function CheckForm(f) {
394
        function CheckForm(f) {
456
            if ($("#fileToUpload").value == '') {
395
            if ($("#fileToUpload").value == '') {
457
                alert(_("Please upload a file first."));
396
                alert(_("Please upload a file first."));
Lines 510-516 Link Here
510
            const select = $("#profile");
449
            const select = $("#profile");
511
            $("option[value!='']", select).remove();
450
            $("option[value!='']", select).remove();
512
            return new Promise(function(resolve, reject) {
451
            return new Promise(function(resolve, reject) {
513
                $.ajax("/api/v1/import-batch-profiles")
452
                $.ajax("/api/v1/import_batch_profiles")
514
                .then(resolve, reject);
453
                .then(resolve, reject);
515
            })
454
            })
516
            .then(function(profiles) {
455
            .then(function(profiles) {
517
- 

Return to bug 23019