Skip to content

Commit

Permalink
Allow enable/disable NLP
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Oct 5, 2021
1 parent 4a98967 commit 99fcf0f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/SearchBlock/SearchBlockEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SearchBlockView from './SearchBlockView';
import config from '@plone/volto/registry';

const SearchBlockEdit = (props) => {
const schema = SearchBlockSchema(props);
const schema = SearchBlockSchema({ formData: props.data });
const conf = config.settings.searchlib.searchui;
schema.properties.appName.choices = Object.keys(conf).map((k) => [
k,
Expand Down
4 changes: 2 additions & 2 deletions src/SearchBlock/SearchBlockView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const applyBlockSettings = (config, appName, data, schema) => {
}
branch = branch[bit];
});
console.log('set', { branch, key, field: data[fieldName], fieldName });
// console.log('set', { branch, key, field: data[fieldName], fieldName });
branch[key] = data[fieldName];
}
});
Expand All @@ -54,7 +54,7 @@ export default function SearchBlockView(props) {
data,
schema,
);
console.log('registry', { data, registry });
// console.log('registry', { data, registry });
return (
<div className="searchlib-block">
<SearchApp registry={registry} appName={appName} mode={mode} />
Expand Down
24 changes: 17 additions & 7 deletions src/SearchBlock/schema.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

export const SearchBlockSchema = () => ({
export const SearchBlockSchema = ({ formData }) => ({
title: 'Searchlib Block',

fieldsets: [
Expand All @@ -12,13 +12,17 @@ export const SearchBlockSchema = () => ({
{
id: 'general',
title: 'General settings',
fields: ['headline', 'subheadline'],
},
{
id: 'nlp',
title: 'NLP Capabilities Settings',
fields: ['use_qa_dp', 'qa_queryTypes', 'cutoffScore'],
fields: ['headline', 'subheadline', 'enableNLP'],
},
...(formData.enableNLP
? [
{
id: 'nlp',
title: 'NLP Capabilities Settings',
fields: ['use_qa_dp', 'qa_queryTypes', 'cutoffScore'],
},
]
: []),
],

properties: {
Expand All @@ -27,6 +31,12 @@ export const SearchBlockSchema = () => ({
choices: [],
},

enableNLP: {
type: 'boolean',
title: 'Enable NLP capabilities?',
configPath: 'enableNLP',
},

headline: {
title: 'Main headline',
configPath: 'title',
Expand Down

0 comments on commit 99fcf0f

Please sign in to comment.