Skip to content

Commit b7ea5b3

Browse files
authored
Bug: multiple changes in quick succession on new entry cause exception (part 2) (#1761)
* Properly wait for saving to complete * Improve/reorganise editor styles.
1 parent ddda330 commit b7ea5b3

3 files changed

Lines changed: 35 additions & 31 deletions

File tree

src/angular-app/languageforge/lexicon/editor/_editor.scss

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,35 @@
44

55
@import "../../../../Site/views/languageforge/theme/default/sass/variables";
66

7+
#lexAppEditView {
8+
display: flex;
9+
justify-content: center;
10+
.container {
11+
margin: 0;
12+
}
13+
}
14+
15+
.container-sticky {
16+
position: sticky;
17+
top: 0px;
18+
z-index: 30;
19+
margin-bottom: 10px;
20+
background: white;
21+
}
22+
23+
.container-scroll {
24+
overflow-y: scroll;
25+
overflow-x: hidden;
26+
27+
@include media-breakpoint-up(md) {
28+
height: calc(100vh - 240px);
29+
}
30+
31+
@include media-breakpoint-down(sm) {
32+
height: calc(100vh - 215px);
33+
}
34+
}
35+
736
.lexAppToolbar {
837
border: 1px solid $line-color;
938
margin: 0 0 5px;

src/angular-app/languageforge/lexicon/editor/comment/lex-comments-view.scss

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,6 @@
33
@import "../../../../../../node_modules/bootstrap/scss/variables";
44
@import "../../../../../../node_modules/bootstrap/scss/mixins";
55

6-
#lexAppEditView {
7-
display: flex;
8-
justify-content: center;
9-
.container {
10-
margin: 0;
11-
}
12-
}
13-
14-
.container-sticky {
15-
position: sticky;
16-
top: 0px;
17-
z-index: 3;
18-
margin-bottom: 10px;
19-
}
20-
21-
.container-scroll {
22-
overflow-y: scroll;
23-
overflow-x: hidden;
24-
25-
@include media-breakpoint-up(md) {
26-
height: calc(100vh - 230px);
27-
}
28-
29-
@include media-breakpoint-down(sm) {
30-
height: calc(100vh - 215px);
31-
}
32-
}
33-
346
.comments-right-panel {
357
color: $Eden;
368
font-size: 14px;

src/angular-app/languageforge/lexicon/editor/editor.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { LexiconProject } from '../shared/model/lexicon-project.model';
3333
import { LexOptionList } from '../shared/model/option-list.model';
3434
import { FieldControl } from './field/field-control.model';
3535
import { OfflineCacheUtilsService } from '../../../bellows/core/offline/offline-cache-utils.service';
36-
import { IPromise } from 'angular';
36+
import { IDeferred } from 'angular';
3737

3838
class Show {
3939
more: () => void;
@@ -78,7 +78,7 @@ export class LexiconEditorController implements angular.IController {
7878

7979
private pristineEntry: LexEntry = new LexEntry();
8080
private warnOfUnsavedEditsId: string;
81-
private saving$: IPromise<void>;
81+
private saving$: IDeferred<void>;
8282

8383
static $inject = ['$filter', '$interval',
8484
'$q', '$scope',
@@ -360,9 +360,11 @@ export class LexiconEditorController implements angular.IController {
360360
const isNewEntry = LexiconEditorController.entryIsNew(this.currentEntry);
361361
if (isNewEntry) {
362362
// We have to wait for the initial save to complete so that we have
363-
await this.saving$;
363+
await this.saving$.promise;
364364
}
365365

366+
this.saving$ = this.$q.defer<void>();
367+
366368
// `doSetEntry` is mainly used for when the save button is pressed, that is when the user is saving the current
367369
// entry and is NOT going to a different entry (as is the case with editing another entry.
368370
let newEntryTempId: string;
@@ -461,6 +463,7 @@ export class LexiconEditorController implements angular.IController {
461463
} else {
462464
successCallback();
463465
}
466+
this.saving$.resolve();
464467
}
465468

466469
async editEntryAndScroll(id: string): Promise<void> {

0 commit comments

Comments
 (0)