fix
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import { SelectableModel } from './selectable.model';
|
||||
|
||||
describe('SelectableModel', () => {
|
||||
it('should create an instance', () => {
|
||||
expect(new SelectableModel()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface ISelectableModel<T> {
|
||||
model: T;
|
||||
selected: boolean;
|
||||
}
|
||||
@@ -1,7 +1,15 @@
|
||||
account-motion:nth-child(even) {
|
||||
filter: brightness(1)
|
||||
:host-context(body.dark)account-motion:nth-child(even) {
|
||||
filter: brightness(1);
|
||||
}
|
||||
|
||||
account-motion:nth-child(odd) {
|
||||
filter: brightness(1.75)
|
||||
:host-context(body.dark)account-motion:nth-child(odd) {
|
||||
filter: brightness(1.75);
|
||||
}
|
||||
|
||||
:host-context(body.light)account-motion:nth-child(even) {
|
||||
filter: brightness(0.75);
|
||||
}
|
||||
|
||||
:host-context(body.light)account-motion:nth-child(odd) {
|
||||
filter: brightness(1);
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ export class MotionComponent {
|
||||
this.setInProgress();
|
||||
|
||||
var data: MotionModel = {
|
||||
date: this.form.value.date,
|
||||
description: this.form.value.description,
|
||||
plus: this.form.value.plus || 0,
|
||||
minus: this.form.value.minus || 0,
|
||||
|
||||
@@ -10,6 +10,16 @@
|
||||
<div class="card">
|
||||
<div class="body">
|
||||
<div id="mail-nav">
|
||||
<ul>
|
||||
<mat-form-field class="example-full-width right-content" *ngIf="selectedCount > 0">
|
||||
<mat-label>Move to category</mat-label>
|
||||
<mat-select [(ngModel)]="category" (selectionChange)="onCategoryChange($event)">
|
||||
<mat-option *ngFor="let category of categories" [value]="category.id">
|
||||
{{category.name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</ul>
|
||||
<ul class="" id="mail-folders">
|
||||
<li *ngFor="let category of categories" [class.active]="selectedCategory && selectedCategory.id == category.id">
|
||||
<a href="javascript:;" (click)="selectCategory(category)" title="{{category.name}}">{{category.name}}</a>
|
||||
@@ -36,9 +46,13 @@
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr *ngFor="let item of items">
|
||||
<td>{{item.name}}</td>
|
||||
<td>
|
||||
<button class="btn-space" (click)="edit(item)" mat-raised-button color="primary">
|
||||
<mat-checkbox [(ngModel)]="item.selected" (change)="onCheckboxChange(item)">
|
||||
{{item.model.name}}
|
||||
</mat-checkbox>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn-space" (click)="edit(item.model)" mat-raised-button color="primary">
|
||||
Edit
|
||||
</button>
|
||||
</td>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
.card-title {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.left-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.right-content {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { MatDialog } from '@angular/material/dialog';
|
||||
import { ApiRoutes } from '../../../api-routes';
|
||||
import { SettingsItemEditComponent } from './edit.item.component';
|
||||
import { ItemService } from '../../../services/item.service';
|
||||
import { ISelectableModel } from '../../../core/models/selectable.model';
|
||||
import { ItemModel } from '../../../model/item.model';
|
||||
import { ItemCategoryModel } from '../../../model/item.category.model';
|
||||
|
||||
@@ -18,9 +19,11 @@ import { ItemCategoryModel } from '../../../model/item.category.model';
|
||||
styleUrls: ['./item.component.scss'],
|
||||
})
|
||||
export class SettingsItemComponent {
|
||||
public items?: ItemModel[];
|
||||
public items?: ISelectableModel<ItemModel>[];
|
||||
public categories?: ItemCategoryModel[];
|
||||
public selectedCategory?: ItemCategoryModel;
|
||||
public selectedCount: number = 0;
|
||||
public category?: ItemCategoryModel;
|
||||
|
||||
constructor(
|
||||
private dialogModel: MatDialog,
|
||||
@@ -53,7 +56,7 @@ export class SettingsItemComponent {
|
||||
this.selectedCategory = category;
|
||||
this.itemService.getItems(category.id)
|
||||
.subscribe(data => {
|
||||
this.items = data;
|
||||
this.items = data.map<ISelectableModel<ItemModel>>(x => { return { model: x, selected: false } });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -95,4 +98,22 @@ export class SettingsItemComponent {
|
||||
this.load();
|
||||
});
|
||||
}
|
||||
|
||||
onCheckboxChange(item: ISelectableModel<ItemModel>) {
|
||||
this.selectedCount += item.selected ? 1 : -1;
|
||||
}
|
||||
|
||||
onCategoryChange(item: any) {
|
||||
var data = {
|
||||
category: item.value,
|
||||
items: this.items!.filter(x => x.selected).map(x => x.model.id)
|
||||
}
|
||||
this.httpClient.post(ApiRoutes.SettingsItems, data)
|
||||
.subscribe(data => {
|
||||
this.category = undefined;
|
||||
this.selectedCount = 0;
|
||||
this.load();
|
||||
}, error => {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user