Skip to content

Commit

Permalink
make domain settings maps keyed case insensitively
Browse files Browse the repository at this point in the history
  • Loading branch information
birarda committed Nov 20, 2018
1 parent 87cac67 commit b0aa1b2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
8 changes: 5 additions & 3 deletions domain-server/resources/web/js/base-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ function validateInputs() {
if (keyVal.length === 0) {
empty = true

markParentRowInvalid(input);
markParentRowInvalid(input)
return;
}

Expand All @@ -373,11 +373,13 @@ function validateInputs() {
_.each(otherKeys, function(otherKeyCell) {
var keyInput = $(otherKeyCell).children('input');

var lowerNewValue = keyVal.toLowerCase();

if (keyInput.length) {
if ($(keyInput).val() == keyVal) {
if ($(keyInput).val().toLowerCase() == lowerNewValue) {
duplicateKey = true;
}
} else if ($(otherKeyCell).html() == keyVal) {
} else if ($(otherKeyCell).html().toLowerCase() == lowerNewValue) {
duplicateKey = true;
}

Expand Down
34 changes: 22 additions & 12 deletions domain-server/src/DomainServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3172,23 +3172,33 @@ void DomainServer::processPathQueryPacket(QSharedPointer<ReceivedMessage> messag
const QString PATH_VIEWPOINT_KEY = "viewpoint";
const QString INDEX_PATH = "/";

QString responseViewpoint;

// check out paths in the _configMap to see if we have a match
auto keypath = QString(PATHS_SETTINGS_KEYPATH_FORMAT).arg(SETTINGS_PATHS_KEY).arg(pathQuery);
QVariant pathMatch = _settingsManager.valueForKeyPath(keypath);
auto pathsVariant = _settingsManager.valueForKeyPath(SETTINGS_PATHS_KEY);

if (pathMatch.isValid() || pathQuery == INDEX_PATH) {
// we got a match, respond with the resulting viewpoint
auto nodeList = DependencyManager::get<LimitedNodeList>();
auto lowerPathQuery = pathQuery.toLower();

QString responseViewpoint;
if (pathsVariant.canConvert<QVariantMap>()) {
auto pathsMap = pathsVariant.toMap();

// if we didn't match the path BUT this is for the index path then send back our default
if (pathMatch.isValid()) {
responseViewpoint = pathMatch.toMap()[PATH_VIEWPOINT_KEY].toString();
} else {
const QString DEFAULT_INDEX_PATH = "/0,0,0/0,0,0,1";
responseViewpoint = DEFAULT_INDEX_PATH;
// enumerate the paths and look case-insensitively for a matching one
for (auto it = pathsMap.constKeyValueBegin(); it != pathsMap.constKeyValueEnd(); ++it) {
if ((*it).first.toLower() == lowerPathQuery) {
responseViewpoint = (*it).second.toMap()[PATH_VIEWPOINT_KEY].toString().toLower();
break;
}
}
}

if (responseViewpoint.isEmpty() && pathQuery == INDEX_PATH) {
const QString DEFAULT_INDEX_PATH = "/0,0,0/0,0,0,1";
responseViewpoint = DEFAULT_INDEX_PATH;
}

if (!responseViewpoint.isEmpty()) {
// we got a match, respond with the resulting viewpoint
auto nodeList = DependencyManager::get<LimitedNodeList>();

if (!responseViewpoint.isEmpty()) {
QByteArray viewpointUTF8 = responseViewpoint.toUtf8();
Expand Down

0 comments on commit b0aa1b2

Please sign in to comment.