-
Notifications
You must be signed in to change notification settings - Fork 319
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
Remember flagged state when searching on moderation pages; Fixes #181 #489
Conversation
Yep. +1 |
Hmmm somethings weird here... http://localhost:8080/?library=true&flagged=true&flagged=true&q=jerone brings up a script that isn't normally in the list at http://localhost:8080/?library=true&flagged=true |
http://localhost:8080/mod/removed?q=zren brings up nothing but Zren has 11 entries there. |
@Martii commented on 7 dec. 2014 18:57 CET:
Because that url will return Edited |
@Martii commented on 7 dec. 2014 19:00 CET:
Also not an issue with this PR. Will investigate why that happens. |
Hmm. Wonder why i didnt use a hashmap there. Probably because you cant get the key when iterating in mustache. Looks like there needs we need to either check before pushing to that array, use a hahsmap and compile to a list for the view, or delete duplicates before rendering. |
Or just store the key inside the value as well as in the key. |
@jerone commented on 7 dec. 2014 19:08 CET:
A found the reason: the column |
-1 until the associated issue is created and associated PR is merged along with this one. Remark PR READY when that happens please... this addition is currently useless with no benefit if the whole process doesn't work correctly. e.g. trading one bug for another isn't going to help when searching on moderation pages. |
Some steps to reproduce:
EDIT: Shorter steps to reproduce:
Issue not presented before this patch. The incremental addition of <form method="get" action="/">
<input type="hidden" value="true" name="library">
<input type="hidden" value="true" name="flagged">
<input type="hidden" value="true" name="flagged">
<input type="hidden" value="true" name="flagged">
<input type="hidden" value="true" name="flagged">
<input type="hidden" value="true" name="flagged">
<div class="input-group col-xs-12">
<input type="text" value="" class="search form-control" placeholder="Search Libraries" name="q">
<span class="input-group-btn">
<button type="submit" class="btn btn-default">
<i class="fa fa-search"></i>
</button>
</span>
</div>
</form> |
@jerone var applyModelListQueryFlaggedFilter = function (aModelListQuery, aOptions, aFlaggedQuery) {
var found = null;
// Only list flagged items if authedUser >= moderator or if authedUser owns the item.
if (aOptions.isYou || aOptions.isMod) {
// Mod
if (aFlaggedQuery) {
if (aFlaggedQuery === 'true') {
aOptions.isFlagged = true;
// Check for an existing name/value prop
found = false;
aOptions.searchBarFormHiddenVariables.forEach(function (aProp) {
if (aProp.name === 'flagged' && aProp.value === 'true') {
found = true;
}
});
if (!found) {
aOptions.searchBarFormHiddenVariables.push({ name: 'flagged', value: 'true' });
}
aModelListQuery.and({ flags: { $gt: 0 } });
}
}
} else {
// Hide
// Script.flagged is undefined by default.
aModelListQuery.and({ flagged: { $ne: true } });
}
}; EDIT: This still doesn't address general lib searching though as I mentioned above... so that's still a bug with this PR. e.g |
Use _.findWhere(list, properties) please if that's the fix you choose. if (!_.findWhere(aOptions.searchBarFormHiddenVariables, { name: 'flagged' }) {
aOptions.searchBarFormHiddenVariables.push({ name: 'flagged', value: 'true' });
} Edit: Woops. I had mixed up the properties parameter in the example. |
I don't have time for this. Feel free to fix it. |
Keep forgetting we do have some lib based functions in the underscore package... not a critical point in our code so I don't see an issue with using it instead. @Zren |
|
Well I noticed that too but the additional duplicate form parameters are the issue here... the chicken/egg syndrome I believe with that part. After a flagged search then general lib searching adds this patch in which messes up that search so it would need to be not added in. |
* Apparently flagged true form variable is carried over between tabs/refreshes so remove it when not on a flagged query * Resolve incremental form variable by moving `isFlagged` into conditional * Stray trailing comma in object fix * Remove some dead code * Some STYLEGUIDE.md conformance with missing braces and newlines, and some strict equality test *(still one left in this file but not testing there yet)* * Tested non-flagged routes and checks okay Closes OpenUserJS#181
Applies to OpenUserJS#181, OpenUserJS#489 and implemented in OpenUserJS#491 See also request at OpenUserJS#181 (comment)
Fixes #181
@Zren Is this the solution you had in mind too?