mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { ConfirmDialogComponent } from './confirm-dialog.component';
|
||||
import { ConfirmDialogComponent } from './confirm-dialog.component'
|
||||
|
||||
describe('ConfirmDialogComponent', () => {
|
||||
let component: ConfirmDialogComponent;
|
||||
let fixture: ComponentFixture<ConfirmDialogComponent>;
|
||||
let component: ConfirmDialogComponent
|
||||
let fixture: ComponentFixture<ConfirmDialogComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ConfirmDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [ConfirmDialogComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ConfirmDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(ConfirmDialogComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,15 +1,14 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Subject } from 'rxjs';
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { Subject } from 'rxjs'
|
||||
|
||||
@Component({
|
||||
selector: 'app-confirm-dialog',
|
||||
templateUrl: './confirm-dialog.component.html',
|
||||
styleUrls: ['./confirm-dialog.component.scss']
|
||||
styleUrls: ['./confirm-dialog.component.scss'],
|
||||
})
|
||||
export class ConfirmDialogComponent {
|
||||
|
||||
constructor(public activeModal: NgbActiveModal) { }
|
||||
constructor(public activeModal: NgbActiveModal) {}
|
||||
|
||||
@Output()
|
||||
public confirmClicked = new EventEmitter()
|
||||
@@ -24,7 +23,7 @@ export class ConfirmDialogComponent {
|
||||
message
|
||||
|
||||
@Input()
|
||||
btnClass = "btn-primary"
|
||||
btnClass = 'btn-primary'
|
||||
|
||||
@Input()
|
||||
btnCaption = $localize`Confirm`
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { DateDropdownComponent } from './date-dropdown.component';
|
||||
import { DateDropdownComponent } from './date-dropdown.component'
|
||||
|
||||
describe('DateDropdownComponent', () => {
|
||||
let component: DateDropdownComponent;
|
||||
let fixture: ComponentFixture<DateDropdownComponent>;
|
||||
let component: DateDropdownComponent
|
||||
let fixture: ComponentFixture<DateDropdownComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ DateDropdownComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [DateDropdownComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DateDropdownComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(DateDropdownComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,10 +1,17 @@
|
||||
import { formatDate } from '@angular/common';
|
||||
import { Component, EventEmitter, Input, Output, OnInit, OnDestroy } from '@angular/core';
|
||||
import { NgbDateAdapter } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Subject, Subscription } from 'rxjs';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
import { SettingsService } from 'src/app/services/settings.service';
|
||||
import { ISODateAdapter } from 'src/app/utils/ngb-iso-date-adapter';
|
||||
import { formatDate } from '@angular/common'
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
Input,
|
||||
Output,
|
||||
OnInit,
|
||||
OnDestroy,
|
||||
} from '@angular/core'
|
||||
import { NgbDateAdapter } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { Subject, Subscription } from 'rxjs'
|
||||
import { debounceTime } from 'rxjs/operators'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
import { ISODateAdapter } from 'src/app/utils/ngb-iso-date-adapter'
|
||||
|
||||
export interface DateSelection {
|
||||
before?: string
|
||||
@@ -20,21 +27,18 @@ const LAST_YEAR = 3
|
||||
selector: 'app-date-dropdown',
|
||||
templateUrl: './date-dropdown.component.html',
|
||||
styleUrls: ['./date-dropdown.component.scss'],
|
||||
providers: [
|
||||
{provide: NgbDateAdapter, useClass: ISODateAdapter},
|
||||
]
|
||||
providers: [{ provide: NgbDateAdapter, useClass: ISODateAdapter }],
|
||||
})
|
||||
export class DateDropdownComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(settings: SettingsService) {
|
||||
this.datePlaceHolder = settings.getLocalizedDateInputFormat()
|
||||
}
|
||||
|
||||
quickFilters = [
|
||||
{id: LAST_7_DAYS, name: $localize`Last 7 days`},
|
||||
{id: LAST_MONTH, name: $localize`Last month`},
|
||||
{id: LAST_3_MONTHS, name: $localize`Last 3 months`},
|
||||
{id: LAST_YEAR, name: $localize`Last year`}
|
||||
{ id: LAST_7_DAYS, name: $localize`Last 7 days` },
|
||||
{ id: LAST_MONTH, name: $localize`Last month` },
|
||||
{ id: LAST_3_MONTHS, name: $localize`Last 3 months` },
|
||||
{ id: LAST_YEAR, name: $localize`Last year` },
|
||||
]
|
||||
|
||||
datePlaceHolder: string
|
||||
@@ -62,9 +66,7 @@ export class DateDropdownComponent implements OnInit, OnDestroy {
|
||||
private sub: Subscription
|
||||
|
||||
ngOnInit() {
|
||||
this.sub = this.datesSetDebounce$.pipe(
|
||||
debounceTime(400)
|
||||
).subscribe(() => {
|
||||
this.sub = this.datesSetDebounce$.pipe(debounceTime(400)).subscribe(() => {
|
||||
this.onChange()
|
||||
})
|
||||
}
|
||||
@@ -81,11 +83,11 @@ export class DateDropdownComponent implements OnInit, OnDestroy {
|
||||
switch (qf) {
|
||||
case LAST_7_DAYS:
|
||||
date.setDate(date.getDate() - 7)
|
||||
break;
|
||||
break
|
||||
|
||||
case LAST_MONTH:
|
||||
date.setMonth(date.getMonth() - 1)
|
||||
break;
|
||||
break
|
||||
|
||||
case LAST_3_MONTHS:
|
||||
date.setMonth(date.getMonth() - 3)
|
||||
@@ -94,20 +96,22 @@ export class DateDropdownComponent implements OnInit, OnDestroy {
|
||||
case LAST_YEAR:
|
||||
date.setFullYear(date.getFullYear() - 1)
|
||||
break
|
||||
|
||||
}
|
||||
this.dateAfter = formatDate(date, 'yyyy-MM-dd', "en-us", "UTC")
|
||||
}
|
||||
this.dateAfter = formatDate(date, 'yyyy-MM-dd', 'en-us', 'UTC')
|
||||
this.onChange()
|
||||
}
|
||||
|
||||
onChange() {
|
||||
this.dateAfterChange.emit(this.dateAfter)
|
||||
this.dateBeforeChange.emit(this.dateBefore)
|
||||
this.datesSet.emit({after: this.dateAfter, before: this.dateBefore})
|
||||
this.datesSet.emit({ after: this.dateAfter, before: this.dateBefore })
|
||||
}
|
||||
|
||||
onChangeDebounce() {
|
||||
this.datesSetDebounce$.next({after: this.dateAfter, before: this.dateBefore})
|
||||
this.datesSetDebounce$.next({
|
||||
after: this.dateAfter,
|
||||
before: this.dateBefore,
|
||||
})
|
||||
}
|
||||
|
||||
clearBefore() {
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { EditDialogComponent } from './edit-dialog.component';
|
||||
import { EditDialogComponent } from './edit-dialog.component'
|
||||
|
||||
describe('EditDialogComponent', () => {
|
||||
let component: EditDialogComponent;
|
||||
let fixture: ComponentFixture<EditDialogComponent>;
|
||||
let component: EditDialogComponent
|
||||
let fixture: ComponentFixture<EditDialogComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ EditDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [EditDialogComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(EditDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(EditDialogComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,20 +1,22 @@
|
||||
import { Directive, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { MATCHING_ALGORITHMS, MATCH_AUTO } from 'src/app/data/matching-model';
|
||||
import { ObjectWithId } from 'src/app/data/object-with-id';
|
||||
import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperless-service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { Directive, EventEmitter, Input, OnInit, Output } from '@angular/core'
|
||||
import { FormGroup } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { Observable } from 'rxjs'
|
||||
import { map } from 'rxjs/operators'
|
||||
import { MATCHING_ALGORITHMS, MATCH_AUTO } from 'src/app/data/matching-model'
|
||||
import { ObjectWithId } from 'src/app/data/object-with-id'
|
||||
import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperless-service'
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
|
||||
@Directive()
|
||||
export abstract class EditDialogComponent<T extends ObjectWithId> implements OnInit {
|
||||
|
||||
export abstract class EditDialogComponent<T extends ObjectWithId>
|
||||
implements OnInit
|
||||
{
|
||||
constructor(
|
||||
private service: AbstractPaperlessService<T>,
|
||||
private activeModal: NgbActiveModal,
|
||||
private toastService: ToastService) { }
|
||||
private toastService: ToastService
|
||||
) {}
|
||||
|
||||
@Input()
|
||||
dialogMode: string = 'create'
|
||||
@@ -43,7 +45,7 @@ export abstract class EditDialogComponent<T extends ObjectWithId> implements OnI
|
||||
// wait to enable close button so it doesnt steal focus from input since its the first clickable element in the DOM
|
||||
setTimeout(() => {
|
||||
this.closeEnabled = true
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
getCreateTitle() {
|
||||
@@ -65,7 +67,7 @@ export abstract class EditDialogComponent<T extends ObjectWithId> implements OnI
|
||||
case 'edit':
|
||||
return this.getEditTitle()
|
||||
default:
|
||||
break;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,25 +80,31 @@ export abstract class EditDialogComponent<T extends ObjectWithId> implements OnI
|
||||
}
|
||||
|
||||
save() {
|
||||
var newObject = Object.assign(Object.assign({}, this.object), this.objectForm.value)
|
||||
var newObject = Object.assign(
|
||||
Object.assign({}, this.object),
|
||||
this.objectForm.value
|
||||
)
|
||||
var serverResponse: Observable<T>
|
||||
switch (this.dialogMode) {
|
||||
case 'create':
|
||||
serverResponse = this.service.create(newObject)
|
||||
break;
|
||||
break
|
||||
case 'edit':
|
||||
serverResponse = this.service.update(newObject)
|
||||
default:
|
||||
break;
|
||||
break
|
||||
}
|
||||
this.networkActive = true
|
||||
serverResponse.subscribe(result => {
|
||||
this.activeModal.close()
|
||||
this.success.emit(result)
|
||||
}, error => {
|
||||
this.error = error.error
|
||||
this.networkActive = false
|
||||
})
|
||||
serverResponse.subscribe(
|
||||
(result) => {
|
||||
this.activeModal.close()
|
||||
this.success.emit(result)
|
||||
},
|
||||
(error) => {
|
||||
this.error = error.error
|
||||
this.networkActive = false
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
cancel() {
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { FilterableDropodownComponent } from './filterable-dropdown.component';
|
||||
import { FilterableDropodownComponent } from './filterable-dropdown.component'
|
||||
|
||||
describe('FilterableDropodownComponent', () => {
|
||||
let component: FilterableDropodownComponent;
|
||||
let fixture: ComponentFixture<FilterableDropodownComponent>;
|
||||
let component: FilterableDropodownComponent
|
||||
let fixture: ComponentFixture<FilterableDropodownComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ FilterableDropodownComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [FilterableDropodownComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(FilterableDropodownComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(FilterableDropodownComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,17 +1,23 @@
|
||||
import { Component, EventEmitter, Input, Output, ElementRef, ViewChild } from '@angular/core';
|
||||
import { FilterPipe } from 'src/app/pipes/filter.pipe';
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
Input,
|
||||
Output,
|
||||
ElementRef,
|
||||
ViewChild,
|
||||
} from '@angular/core'
|
||||
import { FilterPipe } from 'src/app/pipes/filter.pipe'
|
||||
import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { ToggleableItemState } from './toggleable-dropdown-button/toggleable-dropdown-button.component';
|
||||
import { MatchingModel } from 'src/app/data/matching-model';
|
||||
import { Subject } from 'rxjs';
|
||||
import { ToggleableItemState } from './toggleable-dropdown-button/toggleable-dropdown-button.component'
|
||||
import { MatchingModel } from 'src/app/data/matching-model'
|
||||
import { Subject } from 'rxjs'
|
||||
|
||||
export interface ChangedItems {
|
||||
itemsToAdd: MatchingModel[],
|
||||
itemsToAdd: MatchingModel[]
|
||||
itemsToRemove: MatchingModel[]
|
||||
}
|
||||
|
||||
export class FilterableDropdownSelectionModel {
|
||||
|
||||
changed = new Subject<FilterableDropdownSelectionModel>()
|
||||
|
||||
multiple = false
|
||||
@@ -22,14 +28,20 @@ export class FilterableDropdownSelectionModel {
|
||||
|
||||
get itemsSorted(): MatchingModel[] {
|
||||
// TODO: this is getting called very often
|
||||
return this.items.sort((a,b) => {
|
||||
return this.items.sort((a, b) => {
|
||||
if (a.id == null && b.id != null) {
|
||||
return -1
|
||||
} else if (a.id != null && b.id == null) {
|
||||
return 1
|
||||
} else if (this.getNonTemporary(a.id) == ToggleableItemState.NotSelected && this.getNonTemporary(b.id) != ToggleableItemState.NotSelected) {
|
||||
} else if (
|
||||
this.getNonTemporary(a.id) == ToggleableItemState.NotSelected &&
|
||||
this.getNonTemporary(b.id) != ToggleableItemState.NotSelected
|
||||
) {
|
||||
return 1
|
||||
} else if (this.getNonTemporary(a.id) != ToggleableItemState.NotSelected && this.getNonTemporary(b.id) == ToggleableItemState.NotSelected) {
|
||||
} else if (
|
||||
this.getNonTemporary(a.id) != ToggleableItemState.NotSelected &&
|
||||
this.getNonTemporary(b.id) == ToggleableItemState.NotSelected
|
||||
) {
|
||||
return -1
|
||||
} else {
|
||||
return a.name.localeCompare(b.name)
|
||||
@@ -42,11 +54,17 @@ export class FilterableDropdownSelectionModel {
|
||||
private temporarySelectionStates = new Map<number, ToggleableItemState>()
|
||||
|
||||
getSelectedItems() {
|
||||
return this.items.filter(i => this.temporarySelectionStates.get(i.id) == ToggleableItemState.Selected)
|
||||
return this.items.filter(
|
||||
(i) =>
|
||||
this.temporarySelectionStates.get(i.id) == ToggleableItemState.Selected
|
||||
)
|
||||
}
|
||||
|
||||
getExcludedItems() {
|
||||
return this.items.filter(i => this.temporarySelectionStates.get(i.id) == ToggleableItemState.Excluded)
|
||||
return this.items.filter(
|
||||
(i) =>
|
||||
this.temporarySelectionStates.get(i.id) == ToggleableItemState.Excluded
|
||||
)
|
||||
}
|
||||
|
||||
set(id: number, state: ToggleableItemState, fireEvent = true) {
|
||||
@@ -62,9 +80,16 @@ export class FilterableDropdownSelectionModel {
|
||||
|
||||
toggle(id: number, fireEvent = true) {
|
||||
let state = this.temporarySelectionStates.get(id)
|
||||
if (state == null || (state != ToggleableItemState.Selected && state != ToggleableItemState.Excluded)) {
|
||||
if (
|
||||
state == null ||
|
||||
(state != ToggleableItemState.Selected &&
|
||||
state != ToggleableItemState.Excluded)
|
||||
) {
|
||||
this.temporarySelectionStates.set(id, ToggleableItemState.Selected)
|
||||
} else if (state == ToggleableItemState.Selected || state == ToggleableItemState.Excluded) {
|
||||
} else if (
|
||||
state == ToggleableItemState.Selected ||
|
||||
state == ToggleableItemState.Excluded
|
||||
) {
|
||||
this.temporarySelectionStates.delete(id)
|
||||
}
|
||||
|
||||
@@ -91,7 +116,7 @@ export class FilterableDropdownSelectionModel {
|
||||
}
|
||||
}
|
||||
|
||||
exclude(id: number, fireEvent:boolean = true) {
|
||||
exclude(id: number, fireEvent: boolean = true) {
|
||||
let state = this.temporarySelectionStates.get(id)
|
||||
if (state == null || state != ToggleableItemState.Excluded) {
|
||||
this.temporarySelectionStates.set(id, ToggleableItemState.Excluded)
|
||||
@@ -130,7 +155,9 @@ export class FilterableDropdownSelectionModel {
|
||||
}
|
||||
|
||||
get(id: number) {
|
||||
return this.temporarySelectionStates.get(id) || ToggleableItemState.NotSelected
|
||||
return (
|
||||
this.temporarySelectionStates.get(id) || ToggleableItemState.NotSelected
|
||||
)
|
||||
}
|
||||
|
||||
selectionSize() {
|
||||
@@ -150,9 +177,19 @@ export class FilterableDropdownSelectionModel {
|
||||
}
|
||||
|
||||
isDirty() {
|
||||
if (!Array.from(this.temporarySelectionStates.keys()).every(id => this.temporarySelectionStates.get(id) == this.selectionStates.get(id))) {
|
||||
if (
|
||||
!Array.from(this.temporarySelectionStates.keys()).every(
|
||||
(id) =>
|
||||
this.temporarySelectionStates.get(id) == this.selectionStates.get(id)
|
||||
)
|
||||
) {
|
||||
return true
|
||||
} else if (!Array.from(this.selectionStates.keys()).every(id => this.selectionStates.get(id) == this.temporarySelectionStates.get(id))) {
|
||||
} else if (
|
||||
!Array.from(this.selectionStates.keys()).every(
|
||||
(id) =>
|
||||
this.selectionStates.get(id) == this.temporarySelectionStates.get(id)
|
||||
)
|
||||
) {
|
||||
return true
|
||||
} else if (this.temporaryLogicalOperator !== this._logicalOperator) {
|
||||
return true
|
||||
@@ -162,7 +199,10 @@ export class FilterableDropdownSelectionModel {
|
||||
}
|
||||
|
||||
isNoneSelected() {
|
||||
return this.selectionSize() == 1 && this.get(null) == ToggleableItemState.Selected
|
||||
return (
|
||||
this.selectionSize() == 1 &&
|
||||
this.get(null) == ToggleableItemState.Selected
|
||||
)
|
||||
}
|
||||
|
||||
init(map) {
|
||||
@@ -187,8 +227,17 @@ export class FilterableDropdownSelectionModel {
|
||||
|
||||
diff(): ChangedItems {
|
||||
return {
|
||||
itemsToAdd: this.items.filter(item => this.temporarySelectionStates.get(item.id) == ToggleableItemState.Selected && this.selectionStates.get(item.id) != ToggleableItemState.Selected),
|
||||
itemsToRemove: this.items.filter(item => !this.temporarySelectionStates.has(item.id) && this.selectionStates.has(item.id)),
|
||||
itemsToAdd: this.items.filter(
|
||||
(item) =>
|
||||
this.temporarySelectionStates.get(item.id) ==
|
||||
ToggleableItemState.Selected &&
|
||||
this.selectionStates.get(item.id) != ToggleableItemState.Selected
|
||||
),
|
||||
itemsToRemove: this.items.filter(
|
||||
(item) =>
|
||||
!this.temporarySelectionStates.has(item.id) &&
|
||||
this.selectionStates.has(item.id)
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,10 +245,9 @@ export class FilterableDropdownSelectionModel {
|
||||
@Component({
|
||||
selector: 'app-filterable-dropdown',
|
||||
templateUrl: './filterable-dropdown.component.html',
|
||||
styleUrls: ['./filterable-dropdown.component.scss']
|
||||
styleUrls: ['./filterable-dropdown.component.scss'],
|
||||
})
|
||||
export class FilterableDropdownComponent {
|
||||
|
||||
@ViewChild('listFilterTextInput') listFilterTextInput: ElementRef
|
||||
@ViewChild('dropdown') dropdown: NgbDropdown
|
||||
|
||||
@@ -211,7 +259,7 @@ export class FilterableDropdownComponent {
|
||||
this._selectionModel.items = Array.from(items)
|
||||
this._selectionModel.items.unshift({
|
||||
name: $localize`:Filter drop down element to filter for documents with no correspondent/type/tag assigned:Not assigned`,
|
||||
id: null
|
||||
id: null,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -229,7 +277,7 @@ export class FilterableDropdownComponent {
|
||||
model.items = this.selectionModel.items
|
||||
model.multiple = this.selectionModel.multiple
|
||||
}
|
||||
model.changed.subscribe(updatedModel => {
|
||||
model.changed.subscribe((updatedModel) => {
|
||||
this.selectionModelChange.next(updatedModel)
|
||||
})
|
||||
this._selectionModel = model
|
||||
@@ -255,7 +303,7 @@ export class FilterableDropdownComponent {
|
||||
title: string
|
||||
|
||||
@Input()
|
||||
filterPlaceholder: string = ""
|
||||
filterPlaceholder: string = ''
|
||||
|
||||
@Input()
|
||||
icon: string
|
||||
@@ -276,14 +324,17 @@ export class FilterableDropdownComponent {
|
||||
open = new EventEmitter()
|
||||
|
||||
get operatorToggleEnabled(): boolean {
|
||||
return this.selectionModel.selectionSize() > 1 && this.selectionModel.getExcludedItems().length == 0
|
||||
return (
|
||||
this.selectionModel.selectionSize() > 1 &&
|
||||
this.selectionModel.getExcludedItems().length == 0
|
||||
)
|
||||
}
|
||||
|
||||
modelIsDirty: boolean = false
|
||||
|
||||
constructor(private filterPipe: FilterPipe) {
|
||||
this.selectionModel = new FilterableDropdownSelectionModel()
|
||||
this.selectionModelChange.subscribe(updatedModel => {
|
||||
this.selectionModelChange.subscribe((updatedModel) => {
|
||||
this.modelIsDirty = updatedModel.isDirty()
|
||||
})
|
||||
}
|
||||
@@ -300,7 +351,7 @@ export class FilterableDropdownComponent {
|
||||
dropdownOpenChange(open: boolean): void {
|
||||
if (open) {
|
||||
setTimeout(() => {
|
||||
this.listFilterTextInput.nativeElement.focus();
|
||||
this.listFilterTextInput.nativeElement.focus()
|
||||
}, 0)
|
||||
if (this.editing) {
|
||||
this.selectionModel.reset()
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { ToggleableDropdownButtonComponent } from './toggleable-dropdown-button.component';
|
||||
import { ToggleableDropdownButtonComponent } from './toggleable-dropdown-button.component'
|
||||
|
||||
describe('ToggleableDropdownButtonComponent', () => {
|
||||
let component: ToggleableDropdownButtonComponent;
|
||||
let fixture: ComponentFixture<ToggleableDropdownButtonComponent>;
|
||||
let component: ToggleableDropdownButtonComponent
|
||||
let fixture: ComponentFixture<ToggleableDropdownButtonComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ToggleableDropdownButtonComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [ToggleableDropdownButtonComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ToggleableDropdownButtonComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(ToggleableDropdownButtonComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,20 +1,19 @@
|
||||
import { Component, EventEmitter, Input, Output, OnInit } from '@angular/core';
|
||||
import { MatchingModel } from 'src/app/data/matching-model';
|
||||
import { Component, EventEmitter, Input, Output, OnInit } from '@angular/core'
|
||||
import { MatchingModel } from 'src/app/data/matching-model'
|
||||
|
||||
export enum ToggleableItemState {
|
||||
NotSelected = 0,
|
||||
Selected = 1,
|
||||
PartiallySelected = 2,
|
||||
Excluded = 3
|
||||
Excluded = 3,
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-toggleable-dropdown-button',
|
||||
templateUrl: './toggleable-dropdown-button.component.html',
|
||||
styleUrls: ['./toggleable-dropdown-button.component.scss']
|
||||
styleUrls: ['./toggleable-dropdown-button.component.scss'],
|
||||
})
|
||||
export class ToggleableDropdownButtonComponent {
|
||||
|
||||
@Input()
|
||||
item: MatchingModel
|
||||
|
||||
|
@@ -1,30 +1,29 @@
|
||||
import { Directive, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { ControlValueAccessor } from '@angular/forms';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { Directive, ElementRef, Input, OnInit, ViewChild } from '@angular/core'
|
||||
import { ControlValueAccessor } from '@angular/forms'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
@Directive()
|
||||
export class AbstractInputComponent<T> implements OnInit, ControlValueAccessor {
|
||||
|
||||
@ViewChild("inputField")
|
||||
@ViewChild('inputField')
|
||||
inputField: ElementRef
|
||||
|
||||
constructor() { }
|
||||
constructor() {}
|
||||
|
||||
onChange = (newValue: T) => {};
|
||||
onChange = (newValue: T) => {}
|
||||
|
||||
onTouched = () => {};
|
||||
onTouched = () => {}
|
||||
|
||||
writeValue(newValue: any): void {
|
||||
this.value = newValue
|
||||
}
|
||||
registerOnChange(fn: any): void {
|
||||
this.onChange = fn;
|
||||
this.onChange = fn
|
||||
}
|
||||
registerOnTouched(fn: any): void {
|
||||
this.onTouched = fn;
|
||||
this.onTouched = fn
|
||||
}
|
||||
setDisabledState?(isDisabled: boolean): void {
|
||||
this.disabled = isDisabled;
|
||||
this.disabled = isDisabled
|
||||
}
|
||||
|
||||
focus() {
|
||||
@@ -37,7 +36,7 @@ export class AbstractInputComponent<T> implements OnInit, ControlValueAccessor {
|
||||
title: string
|
||||
|
||||
@Input()
|
||||
disabled = false;
|
||||
disabled = false
|
||||
|
||||
@Input()
|
||||
error: string
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { CheckComponent } from './check.component';
|
||||
import { CheckComponent } from './check.component'
|
||||
|
||||
describe('CheckComponent', () => {
|
||||
let component: CheckComponent;
|
||||
let fixture: ComponentFixture<CheckComponent>;
|
||||
let component: CheckComponent
|
||||
let fixture: ComponentFixture<CheckComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ CheckComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [CheckComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CheckComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(CheckComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,22 +1,22 @@
|
||||
import { Component, forwardRef, Input, OnInit } from '@angular/core';
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { AbstractInputComponent } from '../abstract-input';
|
||||
import { Component, forwardRef, Input, OnInit } from '@angular/core'
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { AbstractInputComponent } from '../abstract-input'
|
||||
|
||||
@Component({
|
||||
providers: [{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => CheckComponent),
|
||||
multi: true
|
||||
}],
|
||||
providers: [
|
||||
{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => CheckComponent),
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
selector: 'app-input-check',
|
||||
templateUrl: './check.component.html',
|
||||
styleUrls: ['./check.component.scss']
|
||||
styleUrls: ['./check.component.scss'],
|
||||
})
|
||||
export class CheckComponent extends AbstractInputComponent<boolean> {
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { ColorComponent } from './color.component';
|
||||
import { ColorComponent } from './color.component'
|
||||
|
||||
describe('ColorComponent', () => {
|
||||
let component: ColorComponent;
|
||||
let fixture: ComponentFixture<ColorComponent>;
|
||||
let component: ColorComponent
|
||||
let fixture: ComponentFixture<ColorComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ColorComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [ColorComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ColorComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(ColorComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,20 +1,21 @@
|
||||
import { Component, forwardRef } from '@angular/core';
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { randomColor } from 'src/app/utils/color';
|
||||
import { AbstractInputComponent } from '../abstract-input';
|
||||
import { Component, forwardRef } from '@angular/core'
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { randomColor } from 'src/app/utils/color'
|
||||
import { AbstractInputComponent } from '../abstract-input'
|
||||
|
||||
@Component({
|
||||
providers: [{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => ColorComponent),
|
||||
multi: true
|
||||
}],
|
||||
providers: [
|
||||
{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => ColorComponent),
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
selector: 'app-input-color',
|
||||
templateUrl: './color.component.html',
|
||||
styleUrls: ['./color.component.scss']
|
||||
styleUrls: ['./color.component.scss'],
|
||||
})
|
||||
export class ColorComponent extends AbstractInputComponent<string> {
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { DateComponent } from './date.component';
|
||||
import { DateComponent } from './date.component'
|
||||
|
||||
describe('DateComponent', () => {
|
||||
let component: DateComponent;
|
||||
let fixture: ComponentFixture<DateComponent>;
|
||||
let component: DateComponent
|
||||
let fixture: ComponentFixture<DateComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ DateComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [DateComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DateComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(DateComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,21 +1,24 @@
|
||||
import { Component, forwardRef, OnInit } from '@angular/core';
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { SettingsService } from 'src/app/services/settings.service';
|
||||
import { AbstractInputComponent } from '../abstract-input';
|
||||
|
||||
import { Component, forwardRef, OnInit } from '@angular/core'
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
import { AbstractInputComponent } from '../abstract-input'
|
||||
|
||||
@Component({
|
||||
providers: [{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => DateComponent),
|
||||
multi: true
|
||||
}],
|
||||
providers: [
|
||||
{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => DateComponent),
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
selector: 'app-input-date',
|
||||
templateUrl: './date.component.html',
|
||||
styleUrls: ['./date.component.scss']
|
||||
styleUrls: ['./date.component.scss'],
|
||||
})
|
||||
export class DateComponent extends AbstractInputComponent<string> implements OnInit {
|
||||
|
||||
export class DateComponent
|
||||
extends AbstractInputComponent<string>
|
||||
implements OnInit
|
||||
{
|
||||
constructor(private settings: SettingsService) {
|
||||
super()
|
||||
}
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { NumberComponent } from './number.component';
|
||||
import { NumberComponent } from './number.component'
|
||||
|
||||
describe('NumberComponent', () => {
|
||||
let component: NumberComponent;
|
||||
let fixture: ComponentFixture<NumberComponent>;
|
||||
let component: NumberComponent
|
||||
let fixture: ComponentFixture<NumberComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ NumberComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [NumberComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(NumberComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(NumberComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,21 +1,22 @@
|
||||
import { Component, forwardRef } from '@angular/core';
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { FILTER_ASN_ISNULL } from 'src/app/data/filter-rule-type';
|
||||
import { DocumentService } from 'src/app/services/rest/document.service';
|
||||
import { AbstractInputComponent } from '../abstract-input';
|
||||
import { Component, forwardRef } from '@angular/core'
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { FILTER_ASN_ISNULL } from 'src/app/data/filter-rule-type'
|
||||
import { DocumentService } from 'src/app/services/rest/document.service'
|
||||
import { AbstractInputComponent } from '../abstract-input'
|
||||
|
||||
@Component({
|
||||
providers: [{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => NumberComponent),
|
||||
multi: true
|
||||
}],
|
||||
providers: [
|
||||
{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => NumberComponent),
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
selector: 'app-input-number',
|
||||
templateUrl: './number.component.html',
|
||||
styleUrls: ['./number.component.scss']
|
||||
styleUrls: ['./number.component.scss'],
|
||||
})
|
||||
export class NumberComponent extends AbstractInputComponent<number> {
|
||||
|
||||
constructor(private documentService: DocumentService) {
|
||||
super()
|
||||
}
|
||||
@@ -24,16 +25,17 @@ export class NumberComponent extends AbstractInputComponent<number> {
|
||||
if (this.value) {
|
||||
return
|
||||
}
|
||||
this.documentService.listFiltered(1, 1, "archive_serial_number", true, [{rule_type: FILTER_ASN_ISNULL, value: "false"}]).subscribe(
|
||||
results => {
|
||||
this.documentService
|
||||
.listFiltered(1, 1, 'archive_serial_number', true, [
|
||||
{ rule_type: FILTER_ASN_ISNULL, value: 'false' },
|
||||
])
|
||||
.subscribe((results) => {
|
||||
if (results.count > 0) {
|
||||
this.value = results.results[0].archive_serial_number + 1
|
||||
} else {
|
||||
this.value = 1
|
||||
}
|
||||
this.onChange(this.value)
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { SelectComponent } from './select.component';
|
||||
import { SelectComponent } from './select.component'
|
||||
|
||||
describe('SelectComponent', () => {
|
||||
let component: SelectComponent;
|
||||
let fixture: ComponentFixture<SelectComponent>;
|
||||
let component: SelectComponent
|
||||
let fixture: ComponentFixture<SelectComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ SelectComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [SelectComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SelectComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(SelectComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,23 +1,30 @@
|
||||
import { Component, EventEmitter, forwardRef, Input, Output } from '@angular/core';
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { AbstractInputComponent } from '../abstract-input';
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
forwardRef,
|
||||
Input,
|
||||
Output,
|
||||
} from '@angular/core'
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { AbstractInputComponent } from '../abstract-input'
|
||||
|
||||
@Component({
|
||||
providers: [{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => SelectComponent),
|
||||
multi: true
|
||||
}],
|
||||
providers: [
|
||||
{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => SelectComponent),
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
selector: 'app-input-select',
|
||||
templateUrl: './select.component.html',
|
||||
styleUrls: ['./select.component.scss']
|
||||
styleUrls: ['./select.component.scss'],
|
||||
})
|
||||
export class SelectComponent extends AbstractInputComponent<number> {
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
this.addItemRef = this.addItem.bind(this)
|
||||
}
|
||||
}
|
||||
|
||||
@Input()
|
||||
items: any[]
|
||||
@@ -47,7 +54,9 @@ export class SelectComponent extends AbstractInputComponent<number> {
|
||||
|
||||
getSuggestions() {
|
||||
if (this.suggestions && this.items) {
|
||||
return this.suggestions.filter(id => id != this.value).map(id => this.items.find(item => item.id == id))
|
||||
return this.suggestions
|
||||
.filter((id) => id != this.value)
|
||||
.map((id) => this.items.find((item) => item.id == id))
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
@@ -75,7 +84,6 @@ export class SelectComponent extends AbstractInputComponent<number> {
|
||||
onBlur() {
|
||||
setTimeout(() => {
|
||||
this.clearLastSearchTerm()
|
||||
}, 3000);
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { TagsComponent } from './tags.component';
|
||||
import { TagsComponent } from './tags.component'
|
||||
|
||||
describe('TagsComponent', () => {
|
||||
let component: TagsComponent;
|
||||
let fixture: ComponentFixture<TagsComponent>;
|
||||
let component: TagsComponent
|
||||
let fixture: ComponentFixture<TagsComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ TagsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [TagsComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TagsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(TagsComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,45 +1,46 @@
|
||||
import { Component, forwardRef, Input, OnInit } from '@angular/core';
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { TagEditDialogComponent } from 'src/app/components/manage/tag-list/tag-edit-dialog/tag-edit-dialog.component';
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag';
|
||||
import { TagService } from 'src/app/services/rest/tag.service';
|
||||
import { Component, forwardRef, Input, OnInit } from '@angular/core'
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { TagEditDialogComponent } from 'src/app/components/manage/tag-list/tag-edit-dialog/tag-edit-dialog.component'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { TagService } from 'src/app/services/rest/tag.service'
|
||||
|
||||
@Component({
|
||||
providers: [{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => TagsComponent),
|
||||
multi: true
|
||||
}],
|
||||
providers: [
|
||||
{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => TagsComponent),
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
selector: 'app-input-tags',
|
||||
templateUrl: './tags.component.html',
|
||||
styleUrls: ['./tags.component.scss']
|
||||
styleUrls: ['./tags.component.scss'],
|
||||
})
|
||||
export class TagsComponent implements OnInit, ControlValueAccessor {
|
||||
|
||||
constructor(private tagService: TagService, private modalService: NgbModal) {
|
||||
this.createTagRef = this.createTag.bind(this)
|
||||
}
|
||||
|
||||
onChange = (newValue: number[]) => {};
|
||||
onChange = (newValue: number[]) => {}
|
||||
|
||||
onTouched = () => {};
|
||||
onTouched = () => {}
|
||||
|
||||
writeValue(newValue: number[]): void {
|
||||
this.value = newValue
|
||||
}
|
||||
registerOnChange(fn: any): void {
|
||||
this.onChange = fn;
|
||||
this.onChange = fn
|
||||
}
|
||||
registerOnTouched(fn: any): void {
|
||||
this.onTouched = fn;
|
||||
this.onTouched = fn
|
||||
}
|
||||
setDisabledState?(isDisabled: boolean): void {
|
||||
this.disabled = isDisabled;
|
||||
this.disabled = isDisabled
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.tagService.listAll().subscribe(result => {
|
||||
this.tagService.listAll().subscribe((result) => {
|
||||
this.tags = result.results
|
||||
})
|
||||
}
|
||||
@@ -63,7 +64,7 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
|
||||
|
||||
getTag(id) {
|
||||
if (this.tags) {
|
||||
return this.tags.find(tag => tag.id == id)
|
||||
return this.tags.find((tag) => tag.id == id)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
@@ -80,12 +81,15 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
|
||||
}
|
||||
|
||||
createTag(name: string = null) {
|
||||
var modal = this.modalService.open(TagEditDialogComponent, {backdrop: 'static'})
|
||||
var modal = this.modalService.open(TagEditDialogComponent, {
|
||||
backdrop: 'static',
|
||||
})
|
||||
modal.componentInstance.dialogMode = 'create'
|
||||
if (name) modal.componentInstance.object = { name: name }
|
||||
else if (this._lastSearchTerm) modal.componentInstance.object = { name: this._lastSearchTerm }
|
||||
modal.componentInstance.success.subscribe(newTag => {
|
||||
this.tagService.listAll().subscribe(tags => {
|
||||
else if (this._lastSearchTerm)
|
||||
modal.componentInstance.object = { name: this._lastSearchTerm }
|
||||
modal.componentInstance.success.subscribe((newTag) => {
|
||||
this.tagService.listAll().subscribe((tags) => {
|
||||
this.tags = tags.results
|
||||
this.value = [...this.value, newTag.id]
|
||||
this.onChange(this.value)
|
||||
@@ -95,7 +99,9 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
|
||||
|
||||
getSuggestions() {
|
||||
if (this.suggestions && this.tags) {
|
||||
return this.suggestions.filter(id => !this.value.includes(id)).map(id => this.tags.find(tag => tag.id == id))
|
||||
return this.suggestions
|
||||
.filter((id) => !this.value.includes(id))
|
||||
.map((id) => this.tags.find((tag) => tag.id == id))
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
@@ -117,7 +123,6 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
|
||||
onBlur() {
|
||||
setTimeout(() => {
|
||||
this.clearLastSearchTerm()
|
||||
}, 3000);
|
||||
}, 3000)
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { TextComponent } from './text.component';
|
||||
import { TextComponent } from './text.component'
|
||||
|
||||
describe('TextComponent', () => {
|
||||
let component: TextComponent;
|
||||
let fixture: ComponentFixture<TextComponent>;
|
||||
let component: TextComponent
|
||||
let fixture: ComponentFixture<TextComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ TextComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [TextComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TextComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(TextComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,21 +1,21 @@
|
||||
import { Component, forwardRef } from '@angular/core';
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { AbstractInputComponent } from '../abstract-input';
|
||||
import { Component, forwardRef } from '@angular/core'
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
import { AbstractInputComponent } from '../abstract-input'
|
||||
|
||||
@Component({
|
||||
providers: [{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => TextComponent),
|
||||
multi: true
|
||||
}],
|
||||
providers: [
|
||||
{
|
||||
provide: NG_VALUE_ACCESSOR,
|
||||
useExisting: forwardRef(() => TextComponent),
|
||||
multi: true,
|
||||
},
|
||||
],
|
||||
selector: 'app-input-text',
|
||||
templateUrl: './text.component.html',
|
||||
styleUrls: ['./text.component.scss']
|
||||
styleUrls: ['./text.component.scss'],
|
||||
})
|
||||
export class TextComponent extends AbstractInputComponent<string> {
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { PageHeaderComponent } from './page-header.component';
|
||||
import { PageHeaderComponent } from './page-header.component'
|
||||
|
||||
describe('PageHeaderComponent', () => {
|
||||
let component: PageHeaderComponent;
|
||||
let fixture: ComponentFixture<PageHeaderComponent>;
|
||||
let component: PageHeaderComponent
|
||||
let fixture: ComponentFixture<PageHeaderComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ PageHeaderComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [PageHeaderComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PageHeaderComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(PageHeaderComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,17 +1,16 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { Component, Input } from '@angular/core'
|
||||
import { Title } from '@angular/platform-browser'
|
||||
import { environment } from 'src/environments/environment'
|
||||
|
||||
@Component({
|
||||
selector: 'app-page-header',
|
||||
templateUrl: './page-header.component.html',
|
||||
styleUrls: ['./page-header.component.scss']
|
||||
styleUrls: ['./page-header.component.scss'],
|
||||
})
|
||||
export class PageHeaderComponent {
|
||||
constructor(private titleService: Title) {}
|
||||
|
||||
constructor(private titleService: Title) { }
|
||||
|
||||
_title = ""
|
||||
_title = ''
|
||||
|
||||
@Input()
|
||||
set title(title: string) {
|
||||
@@ -24,6 +23,5 @@ export class PageHeaderComponent {
|
||||
}
|
||||
|
||||
@Input()
|
||||
subTitle: string = ""
|
||||
|
||||
subTitle: string = ''
|
||||
}
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { SelectDialogComponent } from './select-dialog.component';
|
||||
import { SelectDialogComponent } from './select-dialog.component'
|
||||
|
||||
describe('SelectDialogComponent', () => {
|
||||
let component: SelectDialogComponent;
|
||||
let fixture: ComponentFixture<SelectDialogComponent>;
|
||||
let component: SelectDialogComponent
|
||||
let fixture: ComponentFixture<SelectDialogComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ SelectDialogComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [SelectDialogComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SelectDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(SelectDialogComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,15 +1,14 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { ObjectWithId } from 'src/app/data/object-with-id';
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { ObjectWithId } from 'src/app/data/object-with-id'
|
||||
|
||||
@Component({
|
||||
selector: 'app-select-dialog',
|
||||
templateUrl: './select-dialog.component.html',
|
||||
styleUrls: ['./select-dialog.component.scss']
|
||||
styleUrls: ['./select-dialog.component.scss'],
|
||||
})
|
||||
|
||||
export class SelectDialogComponent implements OnInit {
|
||||
constructor(public activeModal: NgbActiveModal) { }
|
||||
constructor(public activeModal: NgbActiveModal) {}
|
||||
|
||||
@Output()
|
||||
public selectClicked = new EventEmitter()
|
||||
@@ -25,8 +24,7 @@ export class SelectDialogComponent implements OnInit {
|
||||
|
||||
selected: number
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
ngOnInit(): void {}
|
||||
|
||||
cancelClicked() {
|
||||
this.activeModal.close()
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { TagComponent } from './tag.component';
|
||||
import { TagComponent } from './tag.component'
|
||||
|
||||
describe('TagComponent', () => {
|
||||
let component: TagComponent;
|
||||
let fixture: ComponentFixture<TagComponent>;
|
||||
let component: TagComponent
|
||||
let fixture: ComponentFixture<TagComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ TagComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [TagComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TagComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(TagComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,25 +1,22 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag';
|
||||
import { Component, Input, OnInit } from '@angular/core'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
|
||||
@Component({
|
||||
selector: 'app-tag',
|
||||
templateUrl: './tag.component.html',
|
||||
styleUrls: ['./tag.component.scss']
|
||||
styleUrls: ['./tag.component.scss'],
|
||||
})
|
||||
export class TagComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
constructor() {}
|
||||
|
||||
@Input()
|
||||
tag: PaperlessTag
|
||||
|
||||
@Input()
|
||||
linkTitle: string = ""
|
||||
linkTitle: string = ''
|
||||
|
||||
@Input()
|
||||
clickable: boolean = false
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
ngOnInit(): void {}
|
||||
}
|
||||
|
@@ -1,25 +1,24 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
|
||||
import { ToastsComponent } from './toasts.component';
|
||||
import { ToastsComponent } from './toasts.component'
|
||||
|
||||
describe('ToastsComponent', () => {
|
||||
let component: ToastsComponent;
|
||||
let fixture: ComponentFixture<ToastsComponent>;
|
||||
let component: ToastsComponent
|
||||
let fixture: ComponentFixture<ToastsComponent>
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ ToastsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
declarations: [ToastsComponent],
|
||||
}).compileComponents()
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ToastsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
fixture = TestBed.createComponent(ToastsComponent)
|
||||
component = fixture.componentInstance
|
||||
fixture.detectChanges()
|
||||
})
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
expect(component).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
@@ -1,15 +1,14 @@
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { Toast, ToastService } from 'src/app/services/toast.service';
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core'
|
||||
import { Subscription } from 'rxjs'
|
||||
import { Toast, ToastService } from 'src/app/services/toast.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-toasts',
|
||||
templateUrl: './toasts.component.html',
|
||||
styleUrls: ['./toasts.component.scss']
|
||||
styleUrls: ['./toasts.component.scss'],
|
||||
})
|
||||
export class ToastsComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(private toastService: ToastService) { }
|
||||
constructor(private toastService: ToastService) {}
|
||||
|
||||
subscription: Subscription
|
||||
|
||||
@@ -20,7 +19,8 @@ export class ToastsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.subscription = this.toastService.getToasts().subscribe(toasts => this.toasts = toasts)
|
||||
this.subscription = this.toastService
|
||||
.getToasts()
|
||||
.subscribe((toasts) => (this.toasts = toasts))
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user