RED-6786, made saving faster.
This commit is contained in:
parent
3e4f6026f9
commit
8fb36e1d31
@ -58,6 +58,7 @@ export class DictionaryScreenComponent implements OnInit {
|
||||
null,
|
||||
true,
|
||||
DICTIONARY_TO_ENTRY_TYPE_MAP[this.type],
|
||||
false,
|
||||
);
|
||||
await this._loadEntries();
|
||||
} catch (e) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<ngx-monaco-editor
|
||||
(init)="onCodeEditorInit($event)"
|
||||
(ngModelChange)="_editorTextChanged$.next($event)"
|
||||
(paste)="onPaste()"
|
||||
(paste)="onPaste($event)"
|
||||
*ngIf="!showDiffEditor"
|
||||
[(ngModel)]="value"
|
||||
[options]="editorOptions"
|
||||
|
||||
@ -77,8 +77,10 @@ export class EditorComponent implements OnInit, OnChanges {
|
||||
return this.currentEntries.length;
|
||||
}
|
||||
|
||||
onPaste() {
|
||||
this._loadingService.start();
|
||||
onPaste(event: ClipboardEvent) {
|
||||
if ((event.target as HTMLTextAreaElement).ariaRoleDescription === 'editor') {
|
||||
this._loadingService.start();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
|
||||
@ -94,23 +94,17 @@ export class DictionaryService extends EntitiesService<IDictionary, Dictionary>
|
||||
dossierId: string,
|
||||
showToast = true,
|
||||
dictionaryEntryType = DictionaryEntryTypes.ENTRY,
|
||||
removeCurrent = true,
|
||||
) {
|
||||
const entriesToAdd: Array<string> = [];
|
||||
const initialEntriesSet = new Set(initialEntries);
|
||||
let hasInvalidRows = false;
|
||||
let hasNewEntries = false;
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
const entry = entries.at(i);
|
||||
if (!entry.trim()) {
|
||||
if (!entry.trim() || initialEntriesSet.has(entry)) {
|
||||
continue;
|
||||
}
|
||||
if (entry.length < MIN_WORD_LENGTH) {
|
||||
hasInvalidRows = true;
|
||||
}
|
||||
if (!hasNewEntries && !initialEntriesSet.has(entry)) {
|
||||
hasNewEntries = true;
|
||||
}
|
||||
|
||||
hasInvalidRows ||= entry.length < MIN_WORD_LENGTH;
|
||||
entriesToAdd.push(entry);
|
||||
}
|
||||
if (hasInvalidRows) {
|
||||
@ -132,8 +126,8 @@ export class DictionaryService extends EntitiesService<IDictionary, Dictionary>
|
||||
if (deletedEntries.length) {
|
||||
await this._deleteEntries(deletedEntries, dossierTemplateId, type, dictionaryEntryType, dossierId);
|
||||
}
|
||||
if (hasNewEntries) {
|
||||
await this._addEntries(entriesToAdd, dossierTemplateId, type, dictionaryEntryType, dossierId);
|
||||
if (entriesToAdd.length) {
|
||||
await this._addEntries(entriesToAdd, dossierTemplateId, type, dictionaryEntryType, dossierId, removeCurrent);
|
||||
}
|
||||
|
||||
if (showToast) {
|
||||
@ -241,11 +235,12 @@ export class DictionaryService extends EntitiesService<IDictionary, Dictionary>
|
||||
type: string,
|
||||
dictionaryEntryType: DictionaryEntryType,
|
||||
dossierId: string,
|
||||
removeCurrent = true,
|
||||
) {
|
||||
const queryParams: List<QueryParam> = [
|
||||
{ key: 'dossierId', value: dossierId },
|
||||
{ key: 'dictionaryEntryType', value: dictionaryEntryType },
|
||||
{ key: 'removeCurrent', value: true },
|
||||
{ key: 'removeCurrent', value: removeCurrent },
|
||||
];
|
||||
const url = `${this._defaultModelPath}/${type}/${dossierTemplateId}`;
|
||||
return firstValueFrom(this._post(entries, url, queryParams));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user