diff --git a/app/apps/api/serializers.py b/app/apps/api/serializers.py index f99a17131bfbf5a7c439562facb2f3b5e714c8be..220b4642cad65332ddbcfe54e75cdc545788d109 100644 --- a/app/apps/api/serializers.py +++ b/app/apps/api/serializers.py @@ -106,7 +106,8 @@ class LineTypeSerializer(serializers.ModelSerializer): class DocumentSerializer(serializers.ModelSerializer): - main_script = serializers.CharField(source='main_script.name') + main_script = serializers.SlugRelatedField(slug_field='name', + queryset=Script.objects.all()) transcriptions = TranscriptionSerializer(many=True, read_only=True) valid_block_types = BlockTypeSerializer(many=True, read_only=True) valid_line_types = LineTypeSerializer(many=True, read_only=True) @@ -126,12 +127,6 @@ class DocumentSerializer(serializers.ModelSerializer): except Script.DoesNotExist: raise serializers.ValidationError('This script does not exists in the database.') - def update(self, instance, validated_data): - instance.name = validated_data.get('name', instance.name) - instance.main_script = validated_data.get('main_script')['name'] or instance.main_script - instance.read_direction = validated_data.get('read_direction', instance.read_direction) - return instance - class PartSerializer(serializers.ModelSerializer): image = ImageField(required=False, thumbnails=['card', 'large']) diff --git a/front/vue/components/TranscriptionModal.vue b/front/vue/components/TranscriptionModal.vue index 5cb968f7afa9f6580d7c78900bb27bcfc6a32970..a610323983bab8e97eb5a8cef0833128e32bdcdb 100644 --- a/front/vue/components/TranscriptionModal.vue +++ b/front/vue/components/TranscriptionModal.vue @@ -11,7 +11,7 @@ type="button" id="next-btn" @click="$store.dispatch('lines/editLine', 'next')" - title="Next" + title="Next (up arrow)" class="btn btn-sm mr-1 btn-secondary"> <i class="fas fa-arrow-circle-left"></i> </button> @@ -19,7 +19,7 @@ type="button" id="prev-btn" @click="$store.dispatch('lines/editLine', 'previous')" - title="Previous" + title="Previous (up arrow)" class="btn btn-sm mr-1 btn-secondary"> <i class="fas fa-arrow-circle-left"></i> </button> @@ -28,7 +28,7 @@ type="button" id="prev-btn" @click="$store.dispatch('lines/editLine', 'previous')" - title="Previous" + title="Previous (down arrow)" class="btn btn-sm mr-1 btn-secondary"> <i class="fas fa-arrow-circle-right"></i> </button> @@ -36,7 +36,7 @@ type="button" id="next-btn" @click="$store.dispatch('lines/editLine', 'next')" - title="Next" + title="Next (down arrow)" class="btn btn-sm mr-1 btn-secondary"> <i class="fas fa-arrow-circle-right"></i> </button> @@ -83,9 +83,9 @@ autofocus/> <!--Hidden input for ttb text: --> <input v-else - id="trans-input" + id="trans-input" ref="transInput" - name="content" + name="content" type="hidden" v-model.lazy="localTranscription" autocomplete="off" /> @@ -217,8 +217,8 @@ export default Vue.extend({ // no need to make focus on hiden input with a ttb text if(this.$store.state.document.mainTextDirection != 'ttb'){ input.focus(); - }else{ // avoid some br or other html tag for a copied text on an editable input div (vertical_text_input): - // + }else{ // avoid some br or other html tag for a copied text on an editable input div (vertical_text_input): + // document.getElementById("vertical_text_input").addEventListener("paste", function(e) { // cancel paste to treat its content before inserting it @@ -287,7 +287,7 @@ export default Vue.extend({ document.getElementById("vertical_text_input").innerHTML = document.getElementById("vertical_text_input").textContent; }, recomputeInputCharsScaleY(){ - + let inputHeight = document.getElementById("vertical_text_input").clientHeight; let wrapperHeight = document.getElementById("textInputBorderWrapper").clientHeight; let textScaleY = wrapperHeight / (inputHeight + 10); @@ -342,7 +342,7 @@ export default Vue.extend({ // calculate rotation needed to get the line horizontal let target_angle = 0; // all lines should be topologically ltr if(this.$store.state.document.mainTextDirection == 'ttb') // add a 90 angle for vertical texts - target_angle = 90; + target_angle = 90; let angle = target_angle - this.getLineAngle(); // apply it to the polygon and get the resulting bbox @@ -483,8 +483,8 @@ export default Vue.extend({ //document.getElementById('vertical_text_input').style.height = 100/scaleY + '%'; // not needed here } else { verticalTextInput.style.transform = 'none'; - verticalTextInput.style.height = modalImgContainer.clientHeight + 'px'; - } + verticalTextInput.style.height = modalImgContainer.clientHeight + 'px'; + } textInputWrapper.style.height = modalImgContainer.clientHeight + 'px'; // simulate an input field border to fix it to the actual size of the image textInputBorderWrapper.style.width = verticalTextInput.clientWidth+'px'; @@ -506,7 +506,7 @@ export default Vue.extend({ // let ratio = 1; - let lineHeight = 150; + let lineHeight = 150; if(this.$store.state.document.mainTextDirection != 'ttb') { @@ -523,9 +523,9 @@ export default Vue.extend({ modalImgContainer.style.height=String(window.innerHeight-230) + "px"; // needed to fix height or ratio is nulled ratio = modalImgContainer.clientHeight / (bbox.height + (2*bbox.width*hContext)); let MAX_WIDTH = 30; - lineHeight = Math.max(30, Math.round(bbox.width*ratio)); - - if (lineHeight > MAX_WIDTH) { + lineHeight = Math.max(30, Math.round(bbox.width*ratio)); + + if (lineHeight > MAX_WIDTH) { // change the ratio so that the image can not get too big ratio = (MAX_WIDTH/lineHeight)*ratio; lineHeight = MAX_WIDTH;