Ignore:
Timestamp:
2021-11-25T14:58:41+13:00 (2 years ago)
Author:
cstephen
Message:

Lazy-load jimp to improve startup time.
Add modal dialog.
Confirm with user before resetting.
npm: Add pdf.js

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/ocr/src/components/MainPage.vue

    r35748 r35751  
    11<template>
    22<div class="main-page-root">
     3    <modal-dialog v-if="modal.show" :title="modal.title" :description="modal.description" :buttons="modal.buttons" @close="onModalClose" />
    34    <edit-page v-if="showEditor" class="image-editor" :src="imageUrl" :imageBuffer="imageBuffer"
    45        @closeAndDiscard="onEditorCloseRequested" @closeAndSave="onEditorSave" />
     
    2324                </button>
    2425
    25                 <button class="btn-primary" @click="reset" :disabled="ocrInProgress">
     26                <button class="btn-primary" @click="reset(false)" :disabled="ocrInProgress">
    2627                    <span class="material-icons">restart_alt</span>
    2728                    <span>{{ translations.get("MainPage_NewImage") }}</span>
     
    144145import { mapState } from "vuex";
    145146import EditPage from "./EditPage.vue";
     147import ModalDialog from "./ModalDialog.vue"
    146148import OcrService, { OcrOptions } from "../js/OcrService"
    147149import { log } from "../js/Util";
     
    152154    name: "MainPage",
    153155    components: {
    154         EditPage
     156        EditPage,
     157        ModalDialog
    155158    },
    156159    data() {
     
    162165            ocrInProgress: false,
    163166            ocrResult: null,
    164             showEditor: false
     167            showEditor: false,
     168            modal: {
     169                show: false,
     170                title: "",
     171                description: "",
     172                buttons: []
     173            }
    165174        }
    166175    },
     
    242251        },
    243252
    244         reset() {
     253        reset(hard) {
     254            if (!hard) {
     255                // TODO: Translate
     256                this.modal.title = this.translations.get("NewImageModal_Title");
     257                this.modal.description = this.translations.get("NewImageModal_Description");
     258                this.modal.buttons = [
     259                    this.translations.get("NewImageModal_ButtonContinue"),
     260                    this.translations.get("NewImageModal_ButtonCancel")
     261                ]
     262                this.modal.resetConfirmation = true;
     263                this.modal.show = true;
     264
     265                return;
     266            }
     267
    245268            URL.revokeObjectURL(this.imageUrl);
    246269            this.imageUrl = null;
     
    249272            this.showEditor = false;
    250273            this.$refs.fileInput.value = "";
     274        },
     275
     276        onModalClose(button) {
     277            this.modal.show = false;
     278
     279            if (this.modal.resetConfirmation) {
     280                if (button === "Continue") {
     281                    this.reset(true);
     282                }
     283
     284                this.modal.resetConfirmation = false;
     285            }
    251286        }
    252287    }
Note: See TracChangeset for help on using the changeset viewer.