Skip to content

Commit 70c8ba4

Browse files
authored
Merge pull request #263 from harunurhan/fix-169
add sortable config for lists
2 parents 4af2045 + 264e36d commit 70c8ba4

File tree

12 files changed

+41
-25
lines changed

12 files changed

+41
-25
lines changed

example/app/app.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class AppConfig {
3030
disabled: true
3131
},
3232
'/references': {
33+
sortable: true,
3334
longListNavigatorConfig: {
3435
findSingle: (value, expression) => {
3536
return value.getIn(['reference', 'number']) === parseInt(expression, 10);

src/abstract-list-field/abstract-list-field.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,8 @@ export abstract class AbstractListFieldComponent extends AbstractFieldComponent
8383
return this.pathCache[valuePathString];
8484
}
8585

86+
get sortableClass() {
87+
return this.schema.sortable ? 'sortable' : '';
88+
}
89+
8690
}

src/add-field-dropdown/add-field-dropdown.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<div *ngIf="!disabled" class="btn-group add-field-dropdown-container" dropdown keyboardNav="true" (onShown)="onDropdownShown()">
2-
<button id="simple-btn-keyboard-nav" type="button" class="btn-add-field-dropdown" dropdownToggle><ng-content></ng-content> <span class="caret"></span></button>
3-
<ul class="dropdown-menu" *dropdownMenu aria-labelledby="simple-btn-keyboard-nav">
2+
<button type="button" class="btn-add-field-dropdown" dropdownToggle>
3+
<ng-content></ng-content> <i class="fa fa-caret-down"></i>
4+
</button>
5+
<ul class="dropdown-menu" *dropdownMenu>
46
<li class="dropdown-filter-container">
57
<input [(ngModel)]="expression" placeholder="filter" (click)="$event.stopPropagation()">
68
</li>

src/add-field-dropdown/add-field-dropdown.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.btn-add-field-dropdown {
22
padding: 0 5px 0 0;
3-
font-size: 21px;
3+
font-size: 11px;
44
opacity: 0.4;
55
border: 0;
66
background: transparent;

src/complex-list-field/complex-list-field.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<div *ngFor="let pIndex of paginatedIndices; let i = index; trackBy:trackByIndex">
4343
<div class="complex-list-field-wrapper">
4444
<object-field [value]="values.get(pIndex)" [schema]="schema.items" [path]="getElementPath(pIndex)">
45-
<list-action-group (onMove)="moveElement(i, $event)" (onDelete)="deleteElement(i)"></list-action-group>
45+
<list-action-group (onMove)="moveElement(i, $event)" (onDelete)="deleteElement(i)" [canMove]="schema.sortable"></list-action-group>
4646
</object-field>
4747
</div>
4848
</div>

src/json-editor.component.scss

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
$text-button-font-size: 13px;
2-
$button-font-size: 16px;
32
$table-editable-rows-background: #edf6fd;
43
$label-color: #c1c1c1;
54
$error-color: #f2968d;
@@ -108,7 +107,6 @@ bs-dropdown-container {
108107
}
109108

110109
.editor-btn-delete {
111-
font-size: $button-font-size;
112110
font-weight: bold;
113111
line-height: 1;
114112
text-shadow: 0 1px 0 #fff;
@@ -150,7 +148,11 @@ ul.pagination-top {
150148
}
151149

152150
td.button-holder, th.button-holder {
153-
width: 46px;
151+
width: 26.33px;
152+
153+
&.sortable {
154+
width: 46px;
155+
}
154156
}
155157

156158
div.error {
@@ -227,13 +229,6 @@ button.btn-toggle {
227229

228230
.list-action-group-container {
229231
text-align: right;
230-
button {
231-
font-size: 21px !important;
232-
}
233-
234-
i {
235-
font-size: 15px !important;
236-
}
237232
}
238233

239234
.max-height-90-vh {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<div>
22
<button type="button" class="editor-btn-delete" (click)="onDelete.emit()">
3-
&times;
3+
<i class="fa fa-times"></i>
44
</button>
5-
<button type="button" class="editor-btn-move-up" (click)="onMove.emit(-1)">
5+
<button *ngIf="canMove" type="button" class="editor-btn-move-up" (click)="onMove.emit(-1)">
66
<i class="fa fa-chevron-up"></i>
77
</button>
8-
<button type="button" class="editor-btn-move-down" (click)="onMove.emit(1)">
8+
<button *ngIf="canMove" type="button" class="editor-btn-move-down" (click)="onMove.emit(1)">
99
<i class="fa fa-chevron-down"></i>
1010
</button>
1111
</div>

src/list-action-group/list-action-group.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import {
2424
Component,
25+
Input,
2526
Output,
2627
EventEmitter,
2728
OnInit,
@@ -41,6 +42,7 @@ import {
4142
})
4243
export class ListActionGroupComponent {
4344

45+
@Input() canMove: boolean;
4446
@Output() onDelete = new EventEmitter<void>();
4547
@Output() onMove = new EventEmitter<number>();
4648

src/object-field/object-field.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
<!-- ADD SUB FIELD FROM SCHEMA DROPDOWN -->
2222
<tr>
2323
<td class="button-holder">
24-
<add-field-dropdown [fields]="keys" [pathString]="pathString" (onFieldAdd)="onFieldAdd($event)" [schema]="schema">+</add-field-dropdown>
24+
<add-field-dropdown [fields]="keys" [pathString]="pathString" (onFieldAdd)="onFieldAdd($event)" [schema]="schema">
25+
<i class="fa fa-plus"></i>
26+
</add-field-dropdown>
2527
</td>
2628
<td class="button-holder list-action-group-container">
2729
<!-- list-action-group (up/down and delete buttons), Set only if it's an element of an list (complex-list) -->

src/primitive-list-field/primitive-list-field.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<td>
66
<primitive-field [value]="value" [schema]="schema.items" [path]="getElementPath(i)"></primitive-field>
77
</td>
8-
<td *ngIf="values.size > 0" class="button-holder">
9-
<list-action-group (onMove)="moveElement(i, $event)" (onDelete)="deleteElement(i)"></list-action-group>
8+
<td *ngIf="values.size > 0" class="button-holder" [ngClass]="sortableClass">
9+
<list-action-group (onMove)="moveElement(i, $event)" (onDelete)="deleteElement(i)" [canMove]="schema.sortable"></list-action-group>
1010
</td>
1111
</tr>
1212
</table>

0 commit comments

Comments
 (0)