Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,19 @@ module('Acceptance | Program Year - Objective Vocabulary Terms', function (hooks
assert.ok(page.details.objectives.objectiveList.objectives[0].taxonomyManager.isPresent);
assert.strictEqual(
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms.length,
2,
1,
);
assert.strictEqual(
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[0].title,
'Resources (school 0)',
);
assert.strictEqual(
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[0].terms
.length,
0,
);
assert.strictEqual(
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[1].title,
'Topics (school 0)',
);
assert.strictEqual(
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[1].terms
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[0].terms
.length,
1,
);
assert.strictEqual(
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[1].terms[0]
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[0].terms[0]
.name,
'term 0',
);
Expand Down Expand Up @@ -141,7 +132,7 @@ module('Acceptance | Program Year - Objective Vocabulary Terms', function (hooks
page.details.objectives.objectiveList.objectives[0].taxonomyManager.availableTerms[3]
.isSelected,
);
await page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[1].terms[0].remove();
await page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[0].terms[0].remove();
await page.details.objectives.objectiveList.objectives[0].taxonomyManager.availableTerms[3].toggle();
await page.details.objectives.objectiveList.objectives[0].selectedTerms.save();
assert.strictEqual(
Expand Down Expand Up @@ -186,19 +177,19 @@ module('Acceptance | Program Year - Objective Vocabulary Terms', function (hooks
assert.ok(page.details.objectives.objectiveList.objectives[0].taxonomyManager.isPresent);
assert.strictEqual(
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms.length,
2,
1,
);
assert.strictEqual(
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[1].title,
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[0].title,
'Topics (school 0)',
);
assert.strictEqual(
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[1].terms
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[0].terms
.length,
1,
);
assert.strictEqual(
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[1].terms[0]
page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[0].terms[0]
.name,
'term 0',
);
Expand Down Expand Up @@ -245,7 +236,7 @@ module('Acceptance | Program Year - Objective Vocabulary Terms', function (hooks
page.details.objectives.objectiveList.objectives[0].taxonomyManager.availableTerms[3]
.isSelected,
);
await page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[1].terms[0].remove();
await page.details.objectives.objectiveList.objectives[0].taxonomyManager.selectedTerms[0].terms[0].remove();
await page.details.objectives.objectiveList.objectives[0].taxonomyManager.availableTerms[3].toggle();
await page.details.objectives.objectiveList.objectives[0].selectedTerms.cancel();
assert.strictEqual(
Expand Down
12 changes: 1 addition & 11 deletions packages/ilios-common/addon/components/taxonomy-manager.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,8 @@ export default class TaxonomyManager extends Component {

get listableVocabularies() {
return this.nonEmptyVocabularies.filter((vocab) => {
if (vocab.active) {
return true;
}
const terms = this.args.selectedTerms;
let hasTerms = false;
terms.forEach((term) => {
if (term.belongsTo('vocabulary').id() === vocab.id) {
hasTerms = true;
}
});

return hasTerms;
return terms.some((term) => term.belongsTo('vocabulary').id() === vocab.id);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ module('Integration | Component | taxonomy manager', function (hooks) {
title: 'Gamma',
vocabulary: vocab2,
});
this.server.create('term', {
active: true,
title: 'Banana',
vocabulary: vocab3,
});

this.vocabModel1 = await this.owner.lookup('service:store').findRecord('vocabulary', vocab1.id);
this.vocabModel2 = await this.owner.lookup('service:store').findRecord('vocabulary', vocab2.id);
Expand Down Expand Up @@ -92,10 +97,12 @@ module('Integration | Component | taxonomy manager', function (hooks) {
assert.strictEqual(component.selectedTerms[1].title, 'Bar (Medicine) (inactive)');
assert.strictEqual(component.selectedTerms[1].terms[0].name, 'Gamma');

assert.strictEqual(component.vocabulary.options.length, 1);
assert.strictEqual(component.vocabulary.options.length, 2);
assert.strictEqual(component.vocabulary.options[0].value, '1');
assert.strictEqual(component.vocabulary.options[0].text, 'Foo (Medicine)');
assert.ok(component.vocabulary.options[0].isSelected);
assert.strictEqual(component.vocabulary.options[1].value, '3');
assert.strictEqual(component.vocabulary.options[1].text, 'Baz (Medicine)');

assert.strictEqual(component.availableTerms.length, 2);
assert.strictEqual(component.availableTerms[0].name, 'Alpha');
Expand Down Expand Up @@ -247,7 +254,7 @@ module('Integration | Component | taxonomy manager', function (hooks) {
</template>,
);

assert.strictEqual(component.vocabulary.options.length, 2);
assert.strictEqual(component.vocabulary.options.length, 3);
assert.notOk(component.vocabulary.options[0].isSelected);
assert.ok(component.vocabulary.options[1].isSelected);
assert.strictEqual(component.availableTerms.length, 1);
Expand Down
Loading