Implement best-practice click handling

pull/3356/head
Kamran Ahmed 2 years ago
parent 4711ab9a6f
commit c2dda3bc35
  1. 11
      src/components/TopicOverlay/topic.js

@ -23,7 +23,7 @@ export class Topic {
this.handleOverlayClick = this.handleOverlayClick.bind(this); this.handleOverlayClick = this.handleOverlayClick.bind(this);
this.markAsDone = this.markAsDone.bind(this); this.markAsDone = this.markAsDone.bind(this);
this.markAsPending = this.markAsPending.bind(this); this.markAsPending = this.markAsPending.bind(this);
this.queryRoadmapElementsByTopicId = this.queryRoadmapElementsByTopicId.bind(this); this.querySvgElementsByTopicId = this.querySvgElementsByTopicId.bind(this);
this.rightClickListener = this.rightClickListener.bind(this); this.rightClickListener = this.rightClickListener.bind(this);
this.isTopicDone = this.isTopicDone.bind(this); this.isTopicDone = this.isTopicDone.bind(this);
@ -150,8 +150,7 @@ export class Topic {
this.activeTopicId = topicId; this.activeTopicId = topicId;
this.resetDOM(); this.resetDOM();
this.renderTopicFromUrl(`/best-practices/${bestPracticeId}/${topicId.replaceAll(':', '/')}`);
alert('Best practices are not yet implemented!');
} }
handleRoadmapTopicClick(e) { handleRoadmapTopicClick(e) {
@ -169,7 +168,7 @@ export class Topic {
this.renderTopicFromUrl(`/${roadmapId}/${topicId.replaceAll(':', '/')}`); this.renderTopicFromUrl(`/${roadmapId}/${topicId.replaceAll(':', '/')}`);
} }
queryRoadmapElementsByTopicId(topicId) { querySvgElementsByTopicId(topicId) {
const elements = document.querySelectorAll(`[data-group-id$="-${topicId}"]`); const elements = document.querySelectorAll(`[data-group-id$="-${topicId}"]`);
const matchingElements = []; const matchingElements = [];
@ -189,7 +188,7 @@ export class Topic {
const updatedTopicId = topicId.replace(/^\d+-/, ''); const updatedTopicId = topicId.replace(/^\d+-/, '');
localStorage.setItem(updatedTopicId, 'done'); localStorage.setItem(updatedTopicId, 'done');
this.queryRoadmapElementsByTopicId(updatedTopicId).forEach((item) => { this.querySvgElementsByTopicId(updatedTopicId).forEach((item) => {
item?.classList?.add('done'); item?.classList?.add('done');
}); });
} }
@ -198,7 +197,7 @@ export class Topic {
const updatedTopicId = topicId.replace(/^\d+-/, ''); const updatedTopicId = topicId.replace(/^\d+-/, '');
localStorage.removeItem(updatedTopicId); localStorage.removeItem(updatedTopicId);
this.queryRoadmapElementsByTopicId(updatedTopicId).forEach((item) => { this.querySvgElementsByTopicId(updatedTopicId).forEach((item) => {
item?.classList?.remove('done'); item?.classList?.remove('done');
}); });
} }

Loading…
Cancel
Save