nadavspi/UnwiseConnect

Search by full phase tree

Closed this issue · 3 comments

For example, if a ticket is in "Backend > Phase 1 > Phase 1.1" it'd be nice if "Backend" matched it in search. Perhaps it could show this as a tooltip too.

I think we could implement this using the phases lookup on projects.

const phasesURI = `/project/projects/${projectId}/phases`;
return cw.ProjectAPI.Projects.api(phasesURI, 'GET', {}).then(phases => {
  let phaseParentIds = {};
  let phasesById = {};

  phases.forEach(phase => {
    phasesById[phase.id] = phase;
    if (phase.parentPhase) {
      phaseParentIds[phase.id] = phase.parentPhase.id;
    }
  });

  const getName = id => {
    if (id in phaseParentIds) {
      return getName(phaseParentIds[id]) + " > " + phasesById[id].description;
    }
    return phasesById[id].description;
  };
  return phases.map(phase => getName(phase.id));
});

Which would give us a map of phase.id to full name.

gil-- commented

Semi-related or the same thing, select2 multi-select phases.

Would be nice to see all phases while searching and possible select more than one phase.

Implemented in #69. Copied code from another repo, rather than the above.