make PropertyValueList dynamically add and remove values
This commit is contained in:
Vendored
+10
-3
@@ -2533,17 +2533,24 @@
|
|||||||
return viewBuilder(matchingObjects);
|
return viewBuilder(matchingObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/View/Components/propertyList.tsx
|
// src/View/Components/propertyValueList.tsx
|
||||||
function PropertyValueList(propertyKey, stringEntryObjectConverter, objects, viewBuilder) {
|
function PropertyValueList(propertyKey, stringEntryObjectConverter, objects, viewBuilder) {
|
||||||
const propertyValues = new ListState();
|
const propertyValues = new ListState();
|
||||||
function collectValues() {
|
function collectValues() {
|
||||||
propertyValues.clear();
|
|
||||||
const values = collectObjectValuesForKey(
|
const values = collectObjectValuesForKey(
|
||||||
propertyKey,
|
propertyKey,
|
||||||
stringEntryObjectConverter,
|
stringEntryObjectConverter,
|
||||||
[...objects.value.values()]
|
[...objects.value.values()]
|
||||||
);
|
);
|
||||||
propertyValues.add(...values);
|
for (const existingValue of values) {
|
||||||
|
if (propertyValues.value.has(existingValue)) continue;
|
||||||
|
propertyValues.add(existingValue);
|
||||||
|
}
|
||||||
|
for (const displayedValue of propertyValues.value.values()) {
|
||||||
|
if (values.includes(displayedValue) == false) {
|
||||||
|
propertyValues.remove(displayedValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
objects.subscribe(() => {
|
objects.subscribe(() => {
|
||||||
collectValues();
|
collectValues();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as React from "bloatless-react";
|
|||||||
|
|
||||||
import BoardViewModel from "../../ViewModel/Pages/boardViewModel";
|
import BoardViewModel from "../../ViewModel/Pages/boardViewModel";
|
||||||
import { FilteredList } from "../Components/filteredList";
|
import { FilteredList } from "../Components/filteredList";
|
||||||
import { PropertyValueList } from "../Components/propertyList";
|
import { PropertyValueList } from "../Components/propertyValueList";
|
||||||
import { TaskCategoryBulkChangeViewModel } from "../../ViewModel/Utility/taskPropertyBulkChangeViewModel";
|
import { TaskCategoryBulkChangeViewModel } from "../../ViewModel/Utility/taskPropertyBulkChangeViewModel";
|
||||||
import TaskViewModel from "../../ViewModel/Pages/taskViewModel";
|
import TaskViewModel from "../../ViewModel/Pages/taskViewModel";
|
||||||
import { TaskViewModelToEntry } from "../Components/taskEntry";
|
import { TaskViewModelToEntry } from "../Components/taskEntry";
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
|
|
||||||
import BoardViewModel from "../../ViewModel/Pages/boardViewModel";
|
import BoardViewModel from "../../ViewModel/Pages/boardViewModel";
|
||||||
import { FilteredList } from "../Components/filteredList";
|
import { FilteredList } from "../Components/filteredList";
|
||||||
import { PropertyValueList } from "../Components/propertyList";
|
import { PropertyValueList } from "../Components/propertyValueList";
|
||||||
import TaskViewModel from "../../ViewModel/Pages/taskViewModel";
|
import TaskViewModel from "../../ViewModel/Pages/taskViewModel";
|
||||||
import { TaskViewModelToEntry } from "../Components/taskEntry";
|
import { TaskViewModelToEntry } from "../Components/taskEntry";
|
||||||
import { allowDrop } from "../utility";
|
import { allowDrop } from "../utility";
|
||||||
|
|||||||
@@ -14,13 +14,21 @@ export function PropertyValueList<T>(
|
|||||||
const propertyValues: React.ListState<string> = new React.ListState();
|
const propertyValues: React.ListState<string> = new React.ListState();
|
||||||
|
|
||||||
function collectValues() {
|
function collectValues() {
|
||||||
propertyValues.clear();
|
|
||||||
const values: string[] = collectObjectValuesForKey(
|
const values: string[] = collectObjectValuesForKey(
|
||||||
propertyKey,
|
propertyKey,
|
||||||
stringEntryObjectConverter,
|
stringEntryObjectConverter,
|
||||||
[...objects.value.values()]
|
[...objects.value.values()]
|
||||||
);
|
);
|
||||||
propertyValues.add(...values);
|
for (const existingValue of values) {
|
||||||
|
if (propertyValues.value.has(existingValue)) continue;
|
||||||
|
propertyValues.add(existingValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const displayedValue of propertyValues.value.values()) {
|
||||||
|
if (values.includes(displayedValue) == false) {
|
||||||
|
propertyValues.remove(displayedValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
objects.subscribe(() => {
|
objects.subscribe(() => {
|
||||||
Reference in New Issue
Block a user