Browse Source

Fix array sorting in UI.

pull/614/head
Sebastian 5 years ago
parent
commit
079d6904fb
  1. 5
      frontend/app/features/content/shared/forms/array-editor.component.html
  2. 2
      frontend/app/features/content/shared/forms/array-editor.component.ts
  3. 2
      frontend/app/features/content/shared/forms/array-item.component.html
  4. 12
      frontend/app/features/content/shared/forms/array-item.component.ts

5
frontend/app/features/content/shared/forms/array-editor.component.html

@ -9,7 +9,6 @@
cdkDrag cdkDrag
cdkDragLockAxis="y"> cdkDragLockAxis="y">
<sqx-array-item <sqx-array-item
(remove)="removeItem(i)"
[canUnset]="canUnset" [canUnset]="canUnset"
[form]="form" [form]="form"
[formContext]="formContext" [formContext]="formContext"
@ -20,7 +19,9 @@
[isLast]="isLast" [isLast]="isLast"
[language]="language" [language]="language"
[languages]="languages" [languages]="languages"
(clone)="addItem(itemForm)" (move)="move(itemForm, $event)" > (clone)="addItem(itemForm)"
(itemRemove)="removeItem(i)"
(itemMove)="move(itemForm, $event)" >
<i cdkDragHandle class="icon-drag2"></i> <i cdkDragHandle class="icon-drag2"></i>
</sqx-array-item> </sqx-array-item>
</div> </div>

2
frontend/app/features/content/shared/forms/array-editor.component.ts

@ -83,7 +83,7 @@ export class ArrayEditorComponent implements OnChanges {
this.reset(); this.reset();
} }
public move(index: number, item: FieldArrayItemForm) { public move(item: FieldArrayItemForm, index: number) {
this.formModel.move(index, item); this.formModel.move(index, item);
this.reset(); this.reset();

2
frontend/app/features/content/shared/forms/array-item.component.html

@ -35,7 +35,7 @@
<i class="icon-clone"></i> <i class="icon-clone"></i>
</button> </button>
<button type="button" class="btn btn-text-danger" [disabled]="isDisabled" (click)="remove.emit()"> <button type="button" class="btn btn-text-danger" [disabled]="isDisabled" (click)="itemRemove.emit()">
<i class="icon-bin2"></i> <i class="icon-bin2"></i>
</button> </button>
</div> </div>

12
frontend/app/features/content/shared/forms/array-item.component.ts

@ -25,10 +25,10 @@ interface State {
}) })
export class ArrayItemComponent extends StatefulComponent<State> implements OnChanges { export class ArrayItemComponent extends StatefulComponent<State> implements OnChanges {
@Output() @Output()
public remove = new EventEmitter(); public itemRemove = new EventEmitter();
@Output() @Output()
public move = new EventEmitter<number>(); public itemMove = new EventEmitter<number>();
@Output() @Output()
public clone = new EventEmitter(); public clone = new EventEmitter();
@ -113,19 +113,19 @@ export class ArrayItemComponent extends StatefulComponent<State> implements OnCh
} }
public moveTop() { public moveTop() {
this.move.emit(0); this.itemMove.emit(0);
} }
public moveUp() { public moveUp() {
this.move.emit(this.index - 1); this.itemMove.emit(this.index - 1);
} }
public moveDown() { public moveDown() {
this.move.emit(this.index + 1); this.itemMove.emit(this.index + 1);
} }
public moveBottom() { public moveBottom() {
this.move.emit(99999); this.itemMove.emit(99999);
} }
public reset() { public reset() {

Loading…
Cancel
Save