ScheduleEntry position
This commit is contained in:
parent
db79d17f7d
commit
7bd2e2f93d
@ -17,7 +17,7 @@ export class Schedule {
|
|||||||
validateNumberNotNull(json['id']),
|
validateNumberNotNull(json['id']),
|
||||||
validateBooleanNotNull(json['enabled']),
|
validateBooleanNotNull(json['enabled']),
|
||||||
validateStringNotEmptyNotNull(json['title']),
|
validateStringNotEmptyNotNull(json['title']),
|
||||||
validateListOrEmpty(json['entries'], ScheduleEntry.fromJson, ScheduleEntry.compare),
|
validateListOrEmpty(json['entries'], ScheduleEntry.fromJson, ScheduleEntry.comparePosition),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,10 +25,6 @@ export class Schedule {
|
|||||||
return item.id;
|
return item.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static compareId(a: Schedule, b: Schedule): number {
|
|
||||||
return a.id - b.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static compareName(a: Schedule, b: Schedule): number {
|
public static compareName(a: Schedule, b: Schedule): number {
|
||||||
return a.title.localeCompare(b.title);
|
return a.title.localeCompare(b.title);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ export class ScheduleEntry {
|
|||||||
|
|
||||||
private constructor(
|
private constructor(
|
||||||
public id: number,
|
public id: number,
|
||||||
|
public position: number,
|
||||||
public enabled: boolean,
|
public enabled: boolean,
|
||||||
public monday: boolean,
|
public monday: boolean,
|
||||||
public tuesday: boolean,
|
public tuesday: boolean,
|
||||||
@ -38,6 +39,7 @@ export class ScheduleEntry {
|
|||||||
static fromJson(json: any): ScheduleEntry {
|
static fromJson(json: any): ScheduleEntry {
|
||||||
return new ScheduleEntry(
|
return new ScheduleEntry(
|
||||||
validateNumberNotNull(json['id']),
|
validateNumberNotNull(json['id']),
|
||||||
|
validateNumberNotNull(json['position']),
|
||||||
validateBooleanNotNull(json['enabled']),
|
validateBooleanNotNull(json['enabled']),
|
||||||
validateBooleanNotNull(json['monday']),
|
validateBooleanNotNull(json['monday']),
|
||||||
validateBooleanNotNull(json['tuesday']),
|
validateBooleanNotNull(json['tuesday']),
|
||||||
@ -65,13 +67,8 @@ export class ScheduleEntry {
|
|||||||
return item.id;
|
return item.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static compare(a: ScheduleEntry, b: ScheduleEntry): number {
|
public static comparePosition(a: ScheduleEntry, b: ScheduleEntry): number {
|
||||||
if (a.nextFuzzyTimestamp === null) {
|
return a.position - b.position;
|
||||||
return +1;
|
|
||||||
} else if (b.nextFuzzyTimestamp === null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return getDaySeconds(a.nextFuzzyTimestamp.date) - getDaySeconds(b.nextFuzzyTimestamp.date);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,9 +30,11 @@
|
|||||||
<th colspan="6">Nächste Ausführung</th>
|
<th colspan="6">Nächste Ausführung</th>
|
||||||
<th colspan="2">Eingeschaft setzen</th>
|
<th colspan="2">Eingeschaft setzen</th>
|
||||||
<th>Massenverarbeitung</th>
|
<th>Massenverarbeitung</th>
|
||||||
<th> </th>
|
<th class="noBorderFirst"> </th>
|
||||||
|
<th class="noBorderMiddle"> </th>
|
||||||
|
<th class="noBorderLast"> </th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr *ngFor="let entry of schedule.entries" [class.disabled]="entry.nextClearTimestamp === null">
|
<tr *ngFor="let entry of schedule.entries; trackBy: ScheduleEntry.trackBy" [class.disabled]="entry.nextClearTimestamp === null">
|
||||||
<ng-container *ngTemplateOutlet="boolean;context:{entry: entry, value: entry.enabled, key:'enabled'}"></ng-container>
|
<ng-container *ngTemplateOutlet="boolean;context:{entry: entry, value: entry.enabled, key:'enabled'}"></ng-container>
|
||||||
<ng-container *ngTemplateOutlet="boolean;context:{entry: entry, value: entry.monday, key:'monday'}"></ng-container>
|
<ng-container *ngTemplateOutlet="boolean;context:{entry: entry, value: entry.monday, key:'monday'}"></ng-container>
|
||||||
<ng-container *ngTemplateOutlet="boolean;context:{entry: entry, value: entry.tuesday, key:'tuesday'}"></ng-container>
|
<ng-container *ngTemplateOutlet="boolean;context:{entry: entry, value: entry.tuesday, key:'tuesday'}"></ng-container>
|
||||||
@ -173,8 +175,16 @@
|
|||||||
<app-search [searchService]="bulkService" [initial]="entry.bulk?.id" (valueChange)="set(entry, 'bulk', $event)"></app-search>
|
<app-search [searchService]="bulkService" [initial]="entry.bulk?.id" (valueChange)="set(entry, 'bulk', $event)"></app-search>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="delete" (click)="delete(entry)">
|
<td class="delete noBorderFirst" (click)="delete(entry)">
|
||||||
<fa-icon title="Löschen" [icon]="faTimes"></fa-icon>
|
<fa-icon [icon]="faTimes"></fa-icon>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="noBorderMiddle" (click)="set(entry, 'position', entry.position - 1)">
|
||||||
|
<fa-icon *ngIf="entry.position > 0" [icon]="faUp"></fa-icon>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="noBorderLast" (click)="set(entry, 'position', entry.position + 1)">
|
||||||
|
<fa-icon *ngIf="entry.position < schedule.entries.length - 1" [icon]="faDown"></fa-icon>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import {ScheduleService} from "../../../api/schedule/schedule.service";
|
|||||||
import {Schedule} from "../../../api/schedule/Schedule";
|
import {Schedule} from "../../../api/schedule/Schedule";
|
||||||
import {ScheduleEntry} from "../../../api/schedule/entry/ScheduleEntry";
|
import {ScheduleEntry} from "../../../api/schedule/entry/ScheduleEntry";
|
||||||
import {ScheduleEntryService} from "../../../api/schedule/entry/schedule-entry.service";
|
import {ScheduleEntryService} from "../../../api/schedule/entry/schedule-entry.service";
|
||||||
import {faCheckCircle, faCircle, faTimesCircle} from '@fortawesome/free-regular-svg-icons';
|
import {faArrowAltCircleDown, faArrowAltCircleUp, faCheckCircle, faCircle, faTimesCircle} from '@fortawesome/free-regular-svg-icons';
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {PropertyService} from "../../../api/property/property.service";
|
import {PropertyService} from "../../../api/property/property.service";
|
||||||
import {Scene} from "../../../api/scene/Scene";
|
import {Scene} from "../../../api/scene/Scene";
|
||||||
@ -19,12 +19,18 @@ import {NO_OP} from "../../../api/api.service";
|
|||||||
})
|
})
|
||||||
export class ScheduleEditorComponent implements OnInit {
|
export class ScheduleEditorComponent implements OnInit {
|
||||||
|
|
||||||
|
readonly ScheduleEntry = ScheduleEntry;
|
||||||
|
|
||||||
readonly faCheckCircle = faCheckCircle;
|
readonly faCheckCircle = faCheckCircle;
|
||||||
|
|
||||||
readonly faCircle = faCircle;
|
readonly faCircle = faCircle;
|
||||||
|
|
||||||
readonly faTimes = faTimesCircle;
|
readonly faTimes = faTimesCircle;
|
||||||
|
|
||||||
|
readonly faUp = faArrowAltCircleUp;
|
||||||
|
|
||||||
|
readonly faDown = faArrowAltCircleDown;
|
||||||
|
|
||||||
readonly Schedule = Schedule;
|
readonly Schedule = Schedule;
|
||||||
|
|
||||||
schedule!: Schedule;
|
schedule!: Schedule;
|
||||||
|
|||||||
@ -79,6 +79,19 @@ table.vertical {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.noBorderFirst {
|
||||||
|
border-right-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.noBorderMiddle {
|
||||||
|
border-right-width: 0;
|
||||||
|
border-left-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.noBorderLast {
|
||||||
|
border-left-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.first {
|
.first {
|
||||||
border-right-width: 0;
|
border-right-width: 0;
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
|
|||||||
@ -12,6 +12,8 @@ public class ScheduleEntryDto implements Serializable {
|
|||||||
|
|
||||||
public final long id;
|
public final long id;
|
||||||
|
|
||||||
|
public final int position;
|
||||||
|
|
||||||
public final boolean enabled;
|
public final boolean enabled;
|
||||||
|
|
||||||
public final boolean monday;
|
public final boolean monday;
|
||||||
@ -54,6 +56,7 @@ public class ScheduleEntryDto implements Serializable {
|
|||||||
|
|
||||||
public ScheduleEntryDto(final ScheduleEntry entry, final PropertyDto property, final BulkDto bulk) {
|
public ScheduleEntryDto(final ScheduleEntry entry, final PropertyDto property, final BulkDto bulk) {
|
||||||
this.id = entry.getId();
|
this.id = entry.getId();
|
||||||
|
this.position = entry.getPosition();
|
||||||
this.enabled = entry.isEnabled();
|
this.enabled = entry.isEnabled();
|
||||||
this.monday = entry.isMonday();
|
this.monday = entry.isMonday();
|
||||||
this.tuesday = entry.isTuesday();
|
this.tuesday = entry.isTuesday();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user