Skip to content

Commit 9667ca8

Browse files
committed
add update peptide filter action to data store
1 parent 0550110 commit 9667ca8

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

dataset-builder/frontend/src/stores/dataset.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ export const useDatasetStore = defineStore('dataset', () => {
4949

5050
// Step 4 requires states with peptides
5151
const hasValidStates = states.value.length > 0 &&
52-
states.value.every((s: StateData) => s.peptides.length > 0)
52+
states.value.every((s: StateData) => s.peptides.length > 0)
5353
if (!hasValidStates) return maxStep
5454
maxStep = 4
5555

5656
// Step 5 requires metadata
5757
const hasValidMetadata = metadata.value.authors.length > 0 &&
58-
metadata.value.license !== ''
58+
metadata.value.license !== ''
5959
if (!hasValidMetadata) return maxStep
6060
maxStep = 5
6161

@@ -159,6 +159,20 @@ export const useDatasetStore = defineStore('dataset', () => {
159159
}
160160
}
161161

162+
function updatePeptideFilter(stateId: string, peptideId: string, columnName: string, values: string[]) {
163+
const state = states.value.find(s => s.id === stateId)
164+
if (state) {
165+
const peptide = state.peptides.find(p => p.id === peptideId)
166+
if (peptide) {
167+
// Update the filters Record
168+
const updatedFilters = { ...peptide.filters, [columnName]: values }
169+
peptide.filters = updatedFilters
170+
return peptide
171+
}
172+
}
173+
return null
174+
}
175+
162176
function addAuthor() {
163177
metadata.value.authors.push({
164178
name: '',
@@ -261,7 +275,7 @@ export const useDatasetStore = defineStore('dataset', () => {
261275
filename: string,
262276
mimeType: string,
263277
fileType: 'data' | 'structure'
264-
// @ts-ignore - False positive: ES2020 includes Promise support
278+
// @ts-ignore - False positive: ES2020 includes Promise support
265279
): Promise<boolean> {
266280
try {
267281
const response = await fetch(url)
@@ -382,7 +396,7 @@ export const useDatasetStore = defineStore('dataset', () => {
382396
pH: 7.5,
383397
temperature: 293.15,
384398
dPercentage: 95.0,
385-
filters: { state: 'SecB WT apo' },
399+
filters: { state: ['SecB WT apo'] },
386400
chain: ['A']
387401
}
388402
]
@@ -443,6 +457,7 @@ export const useDatasetStore = defineStore('dataset', () => {
443457
addPeptide,
444458
removePeptide,
445459
updatePeptide,
460+
updatePeptideFilter,
446461
addStructureMapping,
447462
removeStructureMapping,
448463
updateStructureMapping,

0 commit comments

Comments
 (0)