Skip to content

Commit

Permalink
Deactivated wild cards in single node selection mode (equinor#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms authored Sep 14, 2023
1 parent 64467e8 commit 1951a2f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,25 @@ export class TreeData {
private _stringifiedData: string;
private _nodeData: TreeDataNodeMetaData[];
private _allowOrOperator: boolean;
private _allowWildcards: boolean;

constructor({
treeData,
delimiter,
allowOrOperator,
allowWildcards,
}: {
treeData: TreeDataNode[];
delimiter: string;
allowOrOperator: boolean;
allowWildcards: boolean;
}) {
this._treeData = treeData;
this._delimiter = delimiter;
this._nodeData = [];
this._stringifiedData = "";
this._allowOrOperator = allowOrOperator;
this._allowWildcards = allowWildcards;

this.populateNodes();
}
Expand Down Expand Up @@ -125,6 +129,13 @@ export class TreeData {
}

private adjustNodeName(nodeName: string): string {
if (!this._allowWildcards) {
return this.replaceAll(
this.replaceAll(this.replaceAll(this.escapeRegExp(nodeName), ":", ""), "*", "\\*"),
"?",
"\\."
);
}
return this.activateOrStatements(
this.replaceAll(
this.replaceAll(this.replaceAll(this.escapeRegExp(nodeName), ":", ""), "*", '[^:"]*'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export class SmartNodeSelectorComponent extends React.Component<SmartNodeSelecto
treeData: props.data,
delimiter: props.delimiter,
allowOrOperator: props.useBetaFeatures || false,
allowWildcards: props.maxNumSelectedNodes !== 1,
});
} catch (e) {
this.treeData = null;
Expand Down Expand Up @@ -250,6 +251,7 @@ export class SmartNodeSelectorComponent extends React.Component<SmartNodeSelecto
treeData: this.props.data,
delimiter: this.props.delimiter,
allowOrOperator: this.props.useBetaFeatures || false,
allowWildcards: this.props.maxNumSelectedNodes !== 1,
});
} catch (e) {
this.treeData = null;
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib/components/VectorSelector/vectorSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class VectorSelectorComponent extends SmartNodeSelectorComponent {
treeData: this.modifyTreeData(props.data, props.numMetaNodes, this.vectorDefinitions),
delimiter: props.delimiter,
allowOrOperator: props.useBetaFeatures || false,
allowWildcards: this.props.maxNumSelectedNodes !== 1,
});
} catch (e) {
this.treeData = null;
Expand Down Expand Up @@ -116,6 +117,7 @@ export class VectorSelectorComponent extends SmartNodeSelectorComponent {
treeData: this.modifyTreeData(this.props.data, this.props.numMetaNodes, this.vectorDefinitions),
delimiter: this.props.delimiter,
allowOrOperator: this.props.useBetaFeatures || false,
allowWildcards: this.props.maxNumSelectedNodes !== 1,
});
} catch (e) {
this.treeData = null;
Expand Down

0 comments on commit 1951a2f

Please sign in to comment.