SUPPORT-9212: реконсиляция
This commit is contained in:
parent
5322bcc41d
commit
e8e6de4334
47 changed files with 2483 additions and 1164 deletions
|
|
@ -1,8 +1,13 @@
|
|||
import {AnalyticalScope, Behavior, LinkField, Visible} from "@webbpm/base-package";
|
||||
import {AnalyticalScope, Behavior, LinkField, NotNull, Visible} from "@webbpm/base-package";
|
||||
|
||||
@AnalyticalScope("LinkField")
|
||||
export class GridSetValuesScript extends Behavior {
|
||||
private linkField: LinkField;
|
||||
private userRemovedIps: Set<string> = new Set();
|
||||
private initialized = false;
|
||||
|
||||
@NotNull()
|
||||
public columnName: string;
|
||||
|
||||
initialize() {
|
||||
super.initialize();
|
||||
|
|
@ -10,16 +15,55 @@ export class GridSetValuesScript extends Behavior {
|
|||
}
|
||||
|
||||
@Visible()
|
||||
public setValues(values: string[]) {
|
||||
if (!values || !Array.isArray(values)) {
|
||||
public setValues(ipList: string) {
|
||||
if (!ipList) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rows = values.map(ip => ({
|
||||
row_uid: ip,
|
||||
'ip_directory$ip_address': ip
|
||||
}));
|
||||
const incomingIps = ipList
|
||||
.split(';')
|
||||
.map(ip => ip.trim())
|
||||
.filter(ip => ip);
|
||||
|
||||
if (!this.initialized) {
|
||||
this.addRows(incomingIps);
|
||||
this.initialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const existingRows = this.linkField.getAllRows();
|
||||
const existingIps = new Set(existingRows.map(row => row.row_uid));
|
||||
|
||||
incomingIps.forEach(ip => {
|
||||
if (!existingIps.has(ip)) {
|
||||
this.userRemovedIps.add(ip);
|
||||
}
|
||||
});
|
||||
|
||||
const toRemove = existingRows.filter(row =>
|
||||
!incomingIps.includes(row.row_uid) ||
|
||||
this.userRemovedIps.has(row.row_uid)
|
||||
);
|
||||
this.linkField.removeRows(toRemove);
|
||||
const toAdd = incomingIps
|
||||
.filter(ip =>
|
||||
!this.userRemovedIps.has(ip) &&
|
||||
!existingIps.has(ip)
|
||||
);
|
||||
this.addRows(toAdd);
|
||||
}
|
||||
|
||||
private addRows(ips: string[]) {
|
||||
const rows = ips.map(ip => ({
|
||||
row_uid: ip,
|
||||
[this.columnName]: ip
|
||||
}));
|
||||
this.linkField.addRows(rows);
|
||||
}
|
||||
|
||||
@Visible()
|
||||
public reset() {
|
||||
this.userRemovedIps.clear();
|
||||
this.initialized = false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue