-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix circular dependencies on c125_annotations branch (#3636)
* Fixed circular dependencies * moved forceselection to a utils file * fix travis build
- Loading branch information
Showing
15 changed files
with
164 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Copyright 2019, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const FeatureGridEditorUtils = { | ||
forceSelection: ( {oldValue, changedValue, data, allowEmpty}) => { | ||
if (allowEmpty && changedValue === "") { | ||
return ""; | ||
} | ||
return data.indexOf(changedValue) !== -1 ? changedValue : oldValue; | ||
} | ||
}; | ||
|
||
module.exports = FeatureGridEditorUtils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2019, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const expect = require('expect'); | ||
const { | ||
forceSelection | ||
} = require('../FeatureGridEditorUtils'); | ||
|
||
describe('FeatureGridEditorUtils', () => { | ||
it('forceSelection allowEmpty=true', () => { | ||
const oldValue = "old"; | ||
const changedValue = "new"; | ||
const data = ["new", "old", "agile"]; | ||
const allowEmpty = true; | ||
const newVal = forceSelection({oldValue, changedValue, data, allowEmpty}); | ||
expect(newVal).toBe("new"); | ||
}); | ||
it('forceSelection allowEmpty=true with "" value', () => { | ||
const oldValue = "old"; | ||
const changedValue = ""; | ||
const data = ["new", "old", "agile"]; | ||
const allowEmpty = true; | ||
const newVal = forceSelection({oldValue, changedValue, data, allowEmpty}); | ||
expect(newVal).toBe(""); | ||
}); | ||
it('forceSelection allowEmpty=false with "" value', () => { | ||
const oldValue = "old"; | ||
const changedValue = ""; | ||
const data = ["new", "old", "agile"]; | ||
const allowEmpty = false; | ||
const newVal = forceSelection({oldValue, changedValue, data, allowEmpty}); | ||
expect(newVal).toBe("old"); | ||
}); | ||
it('forceSelection allowEmpty=false with "agile" value', () => { | ||
const oldValue = "old"; | ||
const changedValue = "agile"; | ||
const data = ["new", "old", "agile"]; | ||
const allowEmpty = false; | ||
const newVal = forceSelection({oldValue, changedValue, data, allowEmpty}); | ||
expect(newVal).toBe("agile"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.