AddEdgeModal/SearchContainer: change separator character '#' to long string

master
Clément Notin 2019-02-15 19:00:20 +01:00 committed by cnotin
parent 5b8ee5e28f
commit b4a6564f31
2 changed files with 16 additions and 12 deletions

View File

@ -2,6 +2,8 @@ import React, { Component } from "react";
import { Modal } from "react-bootstrap"; import { Modal } from "react-bootstrap";
import { buildSearchQuery } from 'utils'; import { buildSearchQuery } from 'utils';
const SEPARATOR = "#BLOODHOUNDSEPARATOR#";
export default class AddEdgeModal extends Component { export default class AddEdgeModal extends Component {
constructor() { constructor() {
super(); super();
@ -49,7 +51,7 @@ export default class AddEdgeModal extends Component {
type: record._fields[0].labels[0] type: record._fields[0].labels[0]
}); });
map[index] = props; map[index] = props;
data.push(`${props.name}#${index}`); data.push(`${props.name}${SEPARATOR}${index}`);
}) })
this.map = map; this.map = map;
@ -58,11 +60,11 @@ export default class AddEdgeModal extends Component {
}) })
}, },
updater: function(item){ updater: function(item){
let [_, index] = item.split('#'); let [_, index] = item.split(SEPARATOR);
return this.map[index]; return this.map[index];
}, },
matcher: function(item){ matcher: function(item){
let [name,index] = item.split('#'); let [name,index] = item.split(SEPARATOR);
let obj = this.map[index]; let obj = this.map[index];
let searchTerm = this.query.includes(':') ? this.query.split(':')[1] : this.query; let searchTerm = this.query.includes(':') ? this.query.split(':')[1] : this.query;
@ -75,7 +77,7 @@ export default class AddEdgeModal extends Component {
} }
}, },
highlighter: function(item){ highlighter: function(item){
let [name,index] = item.split('#'); let [name,index] = item.split(SEPARATOR);
let obj = this.map[index]; let obj = this.map[index];
let searchTerm = this.query.includes(':') ? this.query.split(':')[1] : this.query; let searchTerm = this.query.includes(':') ? this.query.split(':')[1] : this.query;
let type = obj.type; let type = obj.type;

View File

@ -4,6 +4,8 @@ import Icon from "../Icon";
import TabContainer from "./TabContainer"; import TabContainer from "./TabContainer";
import { buildSearchQuery, buildSelectQuery } from "utils"; import { buildSearchQuery, buildSelectQuery } from "utils";
const SEPARATOR = "#BLOODHOUNDSEPARATOR#";
export default class SearchContainer extends Component { export default class SearchContainer extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -73,7 +75,7 @@ export default class SearchContainer extends Component {
type: record._fields[0].labels[0] type: record._fields[0].labels[0]
}); });
map[index] = props; map[index] = props;
data.push(`${props.name}#${index}`); data.push(`${props.name}${SEPARATOR}${index}`);
}) })
this.map = map; this.map = map;
@ -113,13 +115,13 @@ export default class SearchContainer extends Component {
}.bind(this), }.bind(this),
autoSelect: false, autoSelect: false,
updater: function (item) { updater: function (item) {
let spl = item.split("#"); let spl = item.split(SEPARATOR);
let index = spl[1]; let index = spl[1];
let obj = this.map[index]; let obj = this.map[index];
return obj; return obj;
}, },
matcher: function (item) { matcher: function (item) {
let spl = item.split("#"); let spl = item.split(SEPARATOR);
let name = spl[0]; let name = spl[0];
let index = spl[1]; let index = spl[1];
let obj = this.map[index]; let obj = this.map[index];
@ -144,7 +146,7 @@ export default class SearchContainer extends Component {
} }
}, },
highlighter: function (item) { highlighter: function (item) {
let spl = item.split("#"); let spl = item.split(SEPARATOR);
let name = spl[0]; let name = spl[0];
let index = spl[1]; let index = spl[1];
let obj = this.map[index]; let obj = this.map[index];
@ -210,7 +212,7 @@ export default class SearchContainer extends Component {
type: record._fields[0].labels[0] type: record._fields[0].labels[0]
}); });
map[index] = props; map[index] = props;
data.push(`${props.name}#${index}`); data.push(`${props.name}${SEPARATOR}${index}`);
index++; index++;
}) })
@ -237,13 +239,13 @@ export default class SearchContainer extends Component {
}.bind(this), }.bind(this),
autoSelect: false, autoSelect: false,
updater: function (item) { updater: function (item) {
let spl = item.split("#"); let spl = item.split(SEPARATOR);
let index = spl[1]; let index = spl[1];
let obj = this.map[index]; let obj = this.map[index];
return obj; return obj;
}, },
matcher: function (item) { matcher: function (item) {
let spl = item.split("#"); let spl = item.split(SEPARATOR);
let name = spl[0]; let name = spl[0];
let index = spl[1]; let index = spl[1];
let obj = this.map[index]; let obj = this.map[index];
@ -268,7 +270,7 @@ export default class SearchContainer extends Component {
} }
}, },
highlighter: function (item) { highlighter: function (item) {
let spl = item.split("#"); let spl = item.split(SEPARATOR);
let name = spl[0]; let name = spl[0];
let index = spl[1]; let index = spl[1];
let obj = this.map[index]; let obj = this.map[index];