Skip to content

Commit

Permalink
Implemented ability to address specific 'defaultProtocols'
Browse files Browse the repository at this point in the history
within the ProtocolParametersSelect.svelte component from the config\miappe\wizard.steps.config.js
  • Loading branch information
patrick-koenig committed Dec 12, 2024
1 parent 07f65a5 commit c450e2a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
8 changes: 7 additions & 1 deletion config/miappe/wizard.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ window.config = {

"defaultProtocols": [
{
"id": "growth",
"name": "Growth",
"parameters": [
{ "label":"Growth facility", "explanation":"Type of growth facility in which the study was carried out" },
Expand Down Expand Up @@ -136,7 +137,12 @@ window.config = {
]
},
{
"name": "Phenotyping"
"id": "phenotyping",
"name": "Phenotyping",
"parameters": [
{ "label": "Phenotyping method", "explanation": "The method that was used for phenotyping e.g. human bonitur" },
{ "label": "Phenotyping facility", "explanation": "Facility used for automatic plant phenotyping e.g. LemnaTec" },
]
}
]
}
Expand Down
19 changes: 19 additions & 0 deletions config/miappe/wizard.steps.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,32 @@ window.steps = [
{
title: 'Please select all Parameters, which are constant for all Samples of your Experiment.',
component: 'ProtocolParametersSelect',
protocolId: 'growth',
jsonPath: 'studies[0].protocols[0].parameters'
},
{
title: 'Select Factors that are different between the Samples.',
component: 'FactorsSelect',
jsonPath: 'studies[0].factors'
},
{
hooks: [
{
type: 'addProtocol',
parameters: {
protocolName: 'Phenotyping',
protocolVersion: 'MIAPPE v1.1',
protocolParameters: ['Phenotyping method']
}
}
],
title: 'Please select all Parameters corresponding to your phenotyping.',
component: 'ProtocolParametersSelect',
componentConfig: {
protocolId: 'phenotyping'
},
jsonPath: 'studies[0].protocols[1].parameters'
},
{
title: 'Upload template',
component: 'Uploader',
Expand Down
22 changes: 20 additions & 2 deletions src/components/isa/study/ProtocolParametersSelect.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
export let value;
export let jsonPath;
export let componentConfig = {};
import { onMount } from 'svelte';
Expand All @@ -12,13 +13,27 @@ import Schemas from '@/lib/schemas';
import { config } from '@/stores/config';
import { isaObj } from '@/stores/isa';
import { keyBy } from '@/lib/utils';
let parameters = [];
let parametersAvailable = config.checklist.defaultProtocols[0].parameters;
let parameterValues = {};
let parametersPredefined = [];
let selectedParameterNames = [];
console.log(componentConfig);
let parametersAvailable;
if (componentConfig.protocolId) {
//label = componentConfig.label;
let allDefaultProtocols = keyBy(config.checklist.defaultProtocols, 'id');
console.log(allDefaultProtocols);
parametersAvailable = allDefaultProtocols[componentConfig.protocolId].parameters
} else {
parametersAvailable = config.checklist.defaultProtocols[0].parameters
}
function addParameter(parameterName) {
if (!selectedParameterNames.includes(parameterName)) {
selectedParameterNames = [...selectedParameterNames, parameterName];
Expand All @@ -37,6 +52,9 @@ function removeParameter(parameterName) {
set($isaObj, jsonPath, parameters);
$isaObj = $isaObj;
parameters = get($isaObj, jsonPath);
selectedParameterNames = parameters.map(o => o.parameterName.annotationValue);
}
function _getParameter(parameterName) {
Expand Down Expand Up @@ -121,7 +139,7 @@ onMount(() => {
{/if}
{#if parametersAvailable.length > 0}
{#if parametersAvailable.filter(parameter => !selectedParameterNames.includes(parameter.label) ).length > 0}
<div style="height: 400px; padding-right: 10px; overflow-y: scroll;">
<table id="parameters-predefined">
<tr>
Expand Down
8 changes: 8 additions & 0 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const keyBy = (array, key) => {
return array.reduce((result, item) => {
if (item[key] !== undefined) {
result[item[key]] = item;
}
return result;
}, {});
};

0 comments on commit c450e2a

Please sign in to comment.