Skip to content
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

Use optgroup to distinguish between campaigns and topics #1053

Merged
merged 4 commits into from Jun 5, 2019

Conversation

rstorey
Copy link
Member

@rstorey rstorey commented Jun 5, 2019

Use optgroup to distinguish between campaigns and topics in activity UI dropdown.

@rstorey rstorey requested a review from acdha June 5, 2019 16:52
@rstorey rstorey self-assigned this Jun 5, 2019
Copy link
Member

@acdha acdha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing this is making me think that we should rename the campaign selector to a less-specific name now that it's doing double-duty but am not coming up with non-awkward generic language. Maybe something like “containerFilter”?


if (
this.campaignSelect.options[this.campaignSelect.selectedIndex]
.parentElement.label == 'Topics'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it's worth keying this test off of a class so it won't change if we touch the UI labels?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing this is making me think that we should rename the campaign selector to a less-specific name now that it's doing double-duty but am not coming up with non-awkward generic language. Maybe something like “containerFilter”?

I hear you on this, but I think we should wait until we see what happens next and whether we're going to refactor Campaigns/Topics so that the whole design is cleaner.

concordia/static/js/action-app/index.js Outdated Show resolved Hide resolved
@@ -839,6 +882,13 @@ export class ActionApp {
continue;
}

if (
currentTopicId &&
!this.assetHasTopic(asset, currentTopicId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether this should simply be !asset.topics.contains(currentTopicId)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if I flatten asset.topics to a plain array of just IDs - it's currently an array of dictionaries.

Copy link
Member

@acdha acdha Jun 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, right – I hadn't gotten that far in the code yet when I left that comment. It might be nice to avoid a check-at-a-distance but I'm not sure that's worth changing topics into a dictionary.

// The values specified in API responses are integers, not DOM strings:
currentCampaignId = parseInt(currentCampaignId, 10);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove this block by converting currentCampaignSelectValue first so there's only one parseInt call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can de-dupe the parseInt call but I only want currentCampaignId to be defined if it's a campaign that was selected and not a topic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The de-dupe is what I was thinking about. Leaving the variables is a little busy but the ways to refactor that would either take repeated extra string comparisons against campaignOrTopic, function calls, etc. and I'd prefer not to tackle something bigger yet.

concordia/views.py Outdated Show resolved Hide resolved
@rstorey rstorey requested a review from acdha June 5, 2019 17:52
if (
this.campaignSelect.options[
this.campaignSelect.selectedIndex
].parentElement.classList.contains('topic-optgroup')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably favor a class name which doesn't describe the tag (e.g. topics) but I'm not sure it's that big a deal.

@rstorey
Copy link
Member Author

rstorey commented Jun 5, 2019

Okay, I'm going to merge this and test in crowd-dev, then prep the release and test in crowd-stage. If all goes well it's going out by COB today.

@rstorey rstorey merged commit 8fb6aec into master Jun 5, 2019
@rstorey rstorey deleted the campaigns-topics-dropdown branch June 5, 2019 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants