Browse Source

Touch fixed with editors.

pull/519/head
Sebastian 6 years ago
parent
commit
a944c7dc89
  1. 1
      frontend/app/features/content/shared/forms/stock-photo-editor.component.ts
  2. 1
      frontend/app/framework/angular/forms/editors/autocomplete.component.ts
  3. 20
      frontend/app/framework/angular/forms/editors/tag-editor.component.ts
  4. 6
      frontend/app/shared/components/forms/references-dropdown.component.ts

1
frontend/app/features/content/shared/forms/stock-photo-editor.component.ts

@ -70,6 +70,7 @@ export class StockPhotoEditorComponent extends StatefulControlComponent<State, s
this.valueControl.valueChanges this.valueControl.valueChanges
.subscribe(value => { .subscribe(value => {
this.callChange(value); this.callChange(value);
this.callTouched();
})); }));
} }

1
frontend/app/framework/angular/forms/editors/autocomplete.component.ts

@ -216,6 +216,7 @@ export class AutocompleteComponent extends StatefulControlComponent<State, Reado
} }
this.callChange(selection); this.callChange(selection);
this.callTouched();
} finally { } finally {
this.resetState(); this.resetState();
} }

20
frontend/app/framework/angular/forms/editors/tag-editor.component.ts

@ -326,7 +326,7 @@ export class TagEditorComponent extends StatefulControlComponent<State, Readonly
} }
public remove(index: number) { public remove(index: number) {
this.updateItems(this.snapshot.items.filter((_, i) => i !== index)); this.updateItems(this.snapshot.items.filter((_, i) => i !== index), true);
} }
public resetSize() { public resetSize() {
@ -396,7 +396,7 @@ export class TagEditorComponent extends StatefulControlComponent<State, Readonly
const value = <string>this.addInput.value; const value = <string>this.addInput.value;
if (!value || value.length === 0) { if (!value || value.length === 0) {
this.updateItems(this.snapshot.items.slice(0, this.snapshot.items.length - 1)); this.updateItems(this.snapshot.items.slice(0, this.snapshot.items.length - 1), false);
return false; return false;
} }
@ -436,7 +436,7 @@ export class TagEditorComponent extends StatefulControlComponent<State, Readonly
if (tagValue) { if (tagValue) {
if (this.allowDuplicates || !this.isSelected(tagValue)) { if (this.allowDuplicates || !this.isSelected(tagValue)) {
this.updateItems([...this.snapshot.items, tagValue]); this.updateItems([...this.snapshot.items, tagValue], true);
} }
this.resetForm(); this.resetForm();
@ -449,9 +449,9 @@ export class TagEditorComponent extends StatefulControlComponent<State, Readonly
public toggleValue(isSelected: boolean, tagValue: TagValue) { public toggleValue(isSelected: boolean, tagValue: TagValue) {
if (isSelected) { if (isSelected) {
this.updateItems([...this.snapshot.items, tagValue]); this.updateItems([...this.snapshot.items, tagValue], true);
} else { } else {
this.updateItems(this.snapshot.items.filter(x => x.id !== tagValue.id)); this.updateItems(this.snapshot.items.filter(x => x.id !== tagValue.id), true);
} }
} }
@ -495,7 +495,7 @@ export class TagEditorComponent extends StatefulControlComponent<State, Readonly
if (!this.hasSelection()) { if (!this.hasSelection()) {
this.onCopy(event); this.onCopy(event);
this.updateItems([]); this.updateItems([], false);
} }
} }
@ -526,7 +526,7 @@ export class TagEditorComponent extends StatefulControlComponent<State, Readonly
} }
} }
this.updateItems(values); this.updateItems(values, false);
} }
event.preventDefault(); event.preventDefault();
@ -540,7 +540,7 @@ export class TagEditorComponent extends StatefulControlComponent<State, Readonly
return s && e && (e - s) > 0; return s && e && (e - s) > 0;
} }
private updateItems(items: ReadonlyArray<TagValue>) { private updateItems(items: ReadonlyArray<TagValue>, touched: boolean) {
this.next(s => ({ ...s, items })); this.next(s => ({ ...s, items }));
if (items.length === 0 && this.undefinedWhenEmpty) { if (items.length === 0 && this.undefinedWhenEmpty) {
@ -549,6 +549,10 @@ export class TagEditorComponent extends StatefulControlComponent<State, Readonly
this.callChange(items.map(x => x.value)); this.callChange(items.map(x => x.value));
} }
if (touched) {
this.callTouched();
}
this.resetSize(); this.resetSize();
} }
} }

6
frontend/app/shared/components/forms/references-dropdown.component.ts

@ -77,22 +77,20 @@ export class ReferencesDropdownComponent extends StatefulControlComponent<State,
.subscribe((value: ContentName) => { .subscribe((value: ContentName) => {
if (this.selectionControl.enabled) { if (this.selectionControl.enabled) {
if (value && value.id) { if (value && value.id) {
this.callTouched();
if (this.mode === 'Single') { if (this.mode === 'Single') {
this.callChange(value.id); this.callChange(value.id);
} else { } else {
this.callChange([value.id]); this.callChange([value.id]);
} }
} else { } else {
this.callTouched();
if (this.mode === 'Single') { if (this.mode === 'Single') {
this.callChange(null); this.callChange(null);
} else { } else {
this.callChange([]); this.callChange([]);
} }
} }
this.callTouched();
} }
})); }));
} }

Loading…
Cancel
Save