Changeset 35752
- Timestamp:
- 2021-11-25T15:49:30+13:00 (2 years ago)
- Location:
- main/trunk/model-interfaces-dev/atea/ocr/src/components
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-interfaces-dev/atea/ocr/src/components/MainPage.vue
r35751 r35752 24 24 </button> 25 25 26 <button class="btn-primary" @click="download" :disabled="ocrResult === null || ocrResult.length === 0"> 27 <span class="material-icons">download</span> 28 <span>{{ translations.get("MainPage_Download") }}</span> 29 </button> 30 26 31 <button class="btn-primary" @click="reset(false)" :disabled="ocrInProgress"> 27 32 <span class="material-icons">restart_alt</span> … … 36 41 <img class="image-display" :src="imageUrl" /> 37 42 38 <div class="text-container"> 39 <span v-if="ocrResult === null && !ocrInProgress" class="text-placeholder">{{ translations.get("MainPage_OCRHint") }}</span> 40 <pre>{{ ocrResult }}</pre> 41 </div> 43 <textarea class="text-container" v-model="ocrResult" :placeholder="translations.get('MainPage_OCRHint')" 44 @input="modalChecks.ocrTextEdited = true" /> 42 45 </div> 43 46 </div> … … 135 138 .ocr-progress { 136 139 grid-column-start: span 2; 137 }138 139 .text-container {140 overflow: scroll;141 140 } 142 141 </style> … … 171 170 description: "", 172 171 buttons: [] 172 }, 173 modalChecks: { 174 ocrTextEdited: false, 175 pendingReset: false 173 176 } 174 177 } … … 210 213 211 214 async doOcr() { 215 if (this.modalChecks.ocrTextEdited) { 216 this.modal.title = this.translations.get("OCREditedModal_Title"); 217 this.modal.description = this.translations.get("OCREditedModal_Description"); 218 this.modal.buttons = [ 219 this.translations.get("OCREditedModal_ButtonContinue"), 220 this.translations.get("OCREditedModal_ButtonCancel") 221 ]; 222 this.modal.show = true; 223 224 return; 225 } 226 212 227 try { 213 228 this.ocrInProgress = true; … … 225 240 226 241 this.ocrResult = result[0].text; 242 this.modalChecks.ocrTextEdited = false; 227 243 } 228 244 catch (ex) { … … 253 269 reset(hard) { 254 270 if (!hard) { 255 // TODO: Translate 271 this.modalChecks.pendingReset = true; 272 256 273 this.modal.title = this.translations.get("NewImageModal_Title"); 257 274 this.modal.description = this.translations.get("NewImageModal_Description"); … … 259 276 this.translations.get("NewImageModal_ButtonContinue"), 260 277 this.translations.get("NewImageModal_ButtonCancel") 261 ] 262 this.modal.resetConfirmation = true; 278 ]; 263 279 this.modal.show = true; 264 280 … … 274 290 }, 275 291 276 onModalClose(button) {292 async onModalClose(button) { 277 293 this.modal.show = false; 278 294 279 if (this.modal.resetConfirmation) { 295 if (this.modalChecks.pendingReset) { 296 console.log("reset is indeed pending"); 280 297 if (button === "Continue") { 281 298 this.reset(true); 282 299 } 283 300 284 this.modal.resetConfirmation = false; 285 } 301 this.modalChecks.pendingReset = false; 302 } 303 else if (this.modalChecks.ocrTextEdited) { 304 if (button === "Continue") { 305 this.modalChecks.ocrTextEdited = false; 306 await this.doOcr(); 307 } 308 } 309 }, 310 311 async download() { 312 const blob = new Blob([ this.ocrResult ], { type: "text/plain;charset=utf-8" }); 313 const date = new Date(); 314 const fileName = `ocr-${date.getHours()}${date.getMinutes()}${date.getSeconds()}.txt`; 315 316 const { saveAs } = await import("file-saver"); 317 saveAs(blob, fileName); 286 318 } 287 319 } -
main/trunk/model-interfaces-dev/atea/ocr/src/components/ModalDialog.vue
r35751 r35752 1 1 <template> 2 2 <div class="background-cover"> 3 <div class="paper ">3 <div class="paper modal"> 4 4 <span class="heading3">{{ title }}</span> 5 5 <hr /> … … 28 28 } 29 29 30 .modal { 31 max-width: 50%; 32 } 33 30 34 .buttons { 31 35 display: flex;
Note:
See TracChangeset
for help on using the changeset viewer.