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
cdkDragLockAxis="y">
<sqx-array-item
(remove)="removeItem(i)"
[canUnset]="canUnset"
[form]="form"
[formContext]="formContext"
@ -20,7 +19,9 @@
[isLast]="isLast"
[language]="language"
[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>
</sqx-array-item>
</div>

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

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

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

@ -35,7 +35,7 @@
<i class="icon-clone"></i>
</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>
</button>
</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 {
@Output()
public remove = new EventEmitter();
public itemRemove = new EventEmitter();
@Output()
public move = new EventEmitter<number>();
public itemMove = new EventEmitter<number>();
@Output()
public clone = new EventEmitter();
@ -113,19 +113,19 @@ export class ArrayItemComponent extends StatefulComponent<State> implements OnCh
}
public moveTop() {
this.move.emit(0);
this.itemMove.emit(0);
}
public moveUp() {
this.move.emit(this.index - 1);
this.itemMove.emit(this.index - 1);
}
public moveDown() {
this.move.emit(this.index + 1);
this.itemMove.emit(this.index + 1);
}
public moveBottom() {
this.move.emit(99999);
this.itemMove.emit(99999);
}
public reset() {

Loading…
Cancel
Save