From 857316710d18b17876ffbf81fd85430a7b1b7a88 Mon Sep 17 00:00:00 2001 From: Robin Tissot <tissotrobin@gmail.com> Date: Fri, 27 Nov 2020 12:43:30 +0100 Subject: [PATCH] Fixes creating region without type when splitting and unbinding of keyboard when no region/line is selected and hiting T. --- app/apps/core/static/js/edit/components/seg_panel.js | 6 +++--- app/apps/core/static/js/edit/store/part.js | 2 ++ app/escriptorium/static/js/baseline.editor.js | 6 +++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/apps/core/static/js/edit/components/seg_panel.js b/app/apps/core/static/js/edit/components/seg_panel.js index a24f05c3..1da2ad0b 100644 --- a/app/apps/core/static/js/edit/components/seg_panel.js +++ b/app/apps/core/static/js/edit/components/seg_panel.js @@ -65,7 +65,6 @@ const SegPanel = BasePanel.extend({ // same event for creation and modification of a line/region let data = ev.detail; this.extractPrevious(data); - let toCreate = { lines: data.lines && data.lines.filter(l=>l.context.pk===null) || [], regions: data.regions && data.regions.filter(l=>l.context.pk===null) || [] @@ -85,7 +84,7 @@ const SegPanel = BasePanel.extend({ }); }.bind(this), function() { // redo - this.bulkCreate(toCreate, createInEditor=true) + this.bulkCreate(toCreate, createInEditor=true); this.bulkUpdate(toUpdate); }.bind(this) ); @@ -209,7 +208,8 @@ const SegPanel = BasePanel.extend({ this.$parent.$emit( 'create:region', { pk: data.regions[i].pk, - box: data.regions[i].box + box: data.regions[i].box, + type: data.regions[i].type }, function(region) { if (createInEditor) { this.segmenter.loadRegion(region); diff --git a/app/apps/core/static/js/edit/store/part.js b/app/apps/core/static/js/edit/store/part.js index d5b285e3..7757e082 100644 --- a/app/apps/core/static/js/edit/store/part.js +++ b/app/apps/core/static/js/edit/store/part.js @@ -339,8 +339,10 @@ const partStore = { createRegion(region, callback) { let uri = this.getApiPart() + 'blocks/'; + let type = region.type && this.types.regions.find(t=>t.name==region.type); data = { document_part: this.pk, + typology: type && type.pk || null, box: region.box }; this.push(uri, data, method="post") diff --git a/app/escriptorium/static/js/baseline.editor.js b/app/escriptorium/static/js/baseline.editor.js index 70912bd7..83d93059 100644 --- a/app/escriptorium/static/js/baseline.editor.js +++ b/app/escriptorium/static/js/baseline.editor.js @@ -1701,6 +1701,9 @@ class Segmenter { } else { this.regionTypesSelect.value = 'None'; } + } else { + // avoid unbinding keyboard then + return; } var self = this; // mandatory for unbinding @@ -1999,7 +2002,8 @@ class Segmenter { region.polygonPath.removeSegments(); coumpound.children[0].segments.forEach(s=>region.polygonPath.add(s)); for (let i=1;i<coumpound.children.length;i++) { - let newRegion = this.createRegion(null, coumpound.children[i].segments, region.type, null, false); + let newRegion = this.createRegion(null, coumpound.children[i].segments, + region.type, null, false); newRegion.updateDataFromCanvas(); coumpound.children[i].remove(); } -- GitLab