stores/tables: fix payments override status
This commit is contained in:
parent
1f2983a7ec
commit
9fd2ee7d66
@ -2,7 +2,7 @@ import Validation from '../../validation';
|
|||||||
import type { ValidationParams } from '../../validation/types';
|
import type { ValidationParams } from '../../validation/types';
|
||||||
import type { Row } from './types';
|
import type { Row } from './types';
|
||||||
import type RootStore from '@/stores/root';
|
import type RootStore from '@/stores/root';
|
||||||
import type { IObservableArray } from 'mobx';
|
import type { IObservableArray, IObservableValue } from 'mobx';
|
||||||
import { makeAutoObservable, observable, reaction } from 'mobx';
|
import { makeAutoObservable, observable, reaction } from 'mobx';
|
||||||
import type { Status } from 'ui/elements/types';
|
import type { Status } from 'ui/elements/types';
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ export default class PaymentsTable {
|
|||||||
public validation: Validation;
|
public validation: Validation;
|
||||||
public values: IObservableArray<number>;
|
public values: IObservableArray<number>;
|
||||||
private statuses: IObservableArray<Status>;
|
private statuses: IObservableArray<Status>;
|
||||||
private overridedStatuses: IObservableArray<Status>;
|
private overridedStatus: IObservableValue<Status | undefined>;
|
||||||
|
|
||||||
constructor(rootStore: RootStore) {
|
constructor(rootStore: RootStore) {
|
||||||
this.validation = new Validation({
|
this.validation = new Validation({
|
||||||
@ -21,7 +21,7 @@ export default class PaymentsTable {
|
|||||||
|
|
||||||
this.values = observable<number>([]);
|
this.values = observable<number>([]);
|
||||||
this.statuses = observable<Status>([]);
|
this.statuses = observable<Status>([]);
|
||||||
this.overridedStatuses = observable<Status>([]);
|
this.overridedStatus = observable.box(undefined);
|
||||||
|
|
||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
this.root = rootStore;
|
this.root = rootStore;
|
||||||
@ -50,7 +50,7 @@ export default class PaymentsTable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public getStatus(index: number) {
|
public getStatus(index: number) {
|
||||||
return this.overridedStatuses?.length ? this.overridedStatuses?.[index] : this.statuses[index];
|
return this.overridedStatus.get() ?? this.statuses[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public setStatus = (index: number, status: Status) => {
|
public setStatus = (index: number, status: Status) => {
|
||||||
@ -58,13 +58,11 @@ export default class PaymentsTable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public overrideStatuses = (status: Status) => {
|
public overrideStatuses = (status: Status) => {
|
||||||
for (let index = 0; index < this.statuses.length; index++) {
|
this.overridedStatus.set(status);
|
||||||
this.overridedStatuses[index] = status;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public clearOverridedStatuses = () => {
|
public clearOverridedStatuses = () => {
|
||||||
this.overridedStatuses?.clear();
|
this.overridedStatus.set(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
public setStatuses = (statuses: Status[]) => {
|
public setStatuses = (statuses: Status[]) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user