forked from egbot/Symbiota
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.1] - select collections from the url if present #1400
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c47344b
select collections from the url if present
Atticus29 cb2ff76
DRY up sanitizedCollectionSource section, which has the same pattern …
Atticus29 308c95c
fix typo
Atticus29 ca47232
change default to empty array
Atticus29 b3cf85a
add better type checking to collIdsFromUrl
Atticus29 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
if($LANG_TAG != 'en' && file_exists($SERVER_ROOT.'/content/lang/collections/search/index.' . $LANG_TAG . '.php')) include_once($SERVER_ROOT.'/content/lang/collections/search/index.' . $LANG_TAG . '.php'); | ||
else include_once($SERVER_ROOT . '/content/lang/collections/search/index.en.php'); | ||
|
||
$collIdsFromUrl = array_key_exists("db",$_GET) ? explode(",", str_replace(array('[',']'), '', $_GET["db"])) : ''; | ||
|
||
$collManager = new OccurrenceManager(); | ||
$collectionSource = $collManager->getQueryTermStr(); | ||
|
||
|
@@ -567,31 +569,15 @@ | |
ul.outerWidth(this.element.outerWidth()); | ||
} | ||
const collectionSource = <?php echo isset($collectionSource) ? json_encode($collectionSource) : 'null'; ?>; | ||
const collIdsFromUrl = <?php echo isset($collIdsFromUrl) ? json_encode($collIdsFromUrl) : 'null'; ?>; | ||
if (collIdsFromUrl.length > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this would need to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in b3cf85a |
||
uncheckEverything(); | ||
checkTheCollectionsThatShouldBeChecked(collIdsFromUrl); | ||
} | ||
const sanitizedCollectionSource = collectionSource.replace('db=',''); | ||
|
||
if(collectionSource){ | ||
// go through all collections and set them all to unchecked | ||
const collectionCheckboxes = document.querySelectorAll('input[id^="coll"]'); | ||
collectionCheckboxes.forEach(collection => { | ||
collection.checked = false; | ||
}); | ||
|
||
//go through all collections and set the parent collections to unchecked | ||
const parentCollectionCheckboxes = document.querySelectorAll('input[id^="cat-"]'); | ||
parentCollectionCheckboxes.forEach(collection => { | ||
collection.checked = false; | ||
}); | ||
|
||
// set the one with collectionSource as checked | ||
const targetCheckbox = document.querySelectorAll('input[id^="coll-' + sanitizedCollectionSource + '"]'); | ||
targetCheckbox.forEach(collection => { | ||
collection.checked = true; | ||
}); | ||
//do the same for collections with slightly different format | ||
const targetCheckboxAlt = document.querySelectorAll('input[id^="collection-' + sanitizedCollectionSource + '"]'); | ||
targetCheckboxAlt.forEach(collection => { | ||
collection.checked = true; | ||
}); | ||
if (collectionSource) { | ||
uncheckEverything(); | ||
checkTheCollectionsThatShouldBeChecked(sanitizedCollectionSource); | ||
updateChip(); | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is safe current based on its use however the contents of this can be unsafe so just fyi I guess