Skip to content

Commit 434bb1b

Browse files
Alexandre-Monneyfrinyvonnick
authored andcommitted
feat: use isManagingStudents & showSkills from features
1 parent 8691cfd commit 434bb1b

File tree

6 files changed

+102
-53
lines changed

6 files changed

+102
-53
lines changed

admin/app/models/organization.js

+28-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ export default class Organization extends Model {
99
@attr('nullable-string') logoUrl;
1010
@attr('nullable-string') externalId;
1111
@attr('nullable-string') provinceCode;
12-
@attr('boolean') isManagingStudents;
1312
@attr('number') credit;
1413
@attr('nullable-string') email;
1514
@attr() createdBy;
1615
@attr('date') createdAt;
1716
@attr('nullable-string') documentationUrl;
18-
@attr('boolean') showSkills;
1917
@attr('nullable-string') archivistFullName;
2018
@attr('date') archivedAt;
2119
@attr('nullable-string') creatorFullName;
@@ -41,16 +39,44 @@ export default class Organization extends Model {
4139
PLACES_MANAGEMENT: 'PLACES_MANAGEMENT',
4240
COMPUTE_ORGANIZATION_LEARNER_CERTIFICABILITY: 'COMPUTE_ORGANIZATION_LEARNER_CERTIFICABILITY',
4341
LEARNER_IMPORT: 'LEARNER_IMPORT',
42+
IS_MANAGING_STUDENTS: 'IS_MANAGING_STUDENTS',
4443
SHOW_NPS: 'SHOW_NPS',
44+
SHOW_SKILLS: 'SHOW_SKILLS',
4545
ATTESTATIONS_MANAGEMENT: 'ATTESTATIONS_MANAGEMENT',
4646
};
4747
}
4848

49+
get isManagingStudents() {
50+
if (!this.features) return false;
51+
return this.features[Organization.featureList.IS_MANAGING_STUDENTS].active;
52+
}
53+
54+
set isManagingStudents(value) {
55+
if (!this.features) {
56+
this.features = {};
57+
this.features[Organization.featureList.IS_MANAGING_STUDENTS] = {};
58+
}
59+
this.features[Organization.featureList.IS_MANAGING_STUDENTS].active = value;
60+
}
61+
4962
get showNPS() {
5063
if (!this.features) return false;
5164
return this.features[Organization.featureList.SHOW_NPS].active;
5265
}
5366

67+
get showSkills() {
68+
if (!this.features) return false;
69+
return this.features[Organization.featureList.SHOW_SKILLS].active;
70+
}
71+
72+
set showSkills(value) {
73+
if (!this.features) {
74+
this.features = {};
75+
this.features[Organization.featureList.SHOW_SKILLS] = {};
76+
}
77+
this.features[Organization.featureList.SHOW_SKILLS].active = value;
78+
}
79+
5480
get formNPSUrl() {
5581
if (!this.features) return false;
5682
if (!this.showNPS) return null;

admin/tests/acceptance/authenticated/organizations/information-management-test.js

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ module('Acceptance | Organizations | Information management', function (hooks) {
2525
COMPUTE_ORGANIZATION_LEARNER_CERTIFICABILITY: { active: false },
2626
ATTESTATIONS_MANAGEMENT: { active: false },
2727
SHOW_NPS: { active: false },
28+
SHOW_SKILLS: { active: false },
29+
IS_MANAGING_STUDENTS: { active: false },
2830
},
2931
});
3032
this.server.create('organization', { id: '1234' });

admin/tests/integration/components/organizations/information-section-view-test.gjs

+23-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,22 @@ module('Integration | Component | organizations/information-section-view', funct
1111
setupIntlRenderingTest(hooks);
1212

1313
module('when user has access', function (hooks) {
14+
let features;
1415
hooks.beforeEach(function () {
1516
class AccessControlStub extends Service {
1617
hasAccessToOrganizationActionsScope = true;
1718
}
1819
this.owner.register('service:access-control', AccessControlStub);
20+
features = {
21+
IS_MANAGING_STUDENTS: { active: false },
22+
SHOW_NPS: { active: false, params: { formNPSUrl: 'plop' } },
23+
SHOW_SKILLS: { active: false },
24+
LEARNER_IMPORT: { active: false },
25+
MULTIPLE_SENDING_ASSESSMENT: { active: false },
26+
PLACES_MANAGEMENT: { active: false },
27+
COMPUTE_ORGANIZATION_LEARNER_CERTIFICABILITY: { active: false },
28+
ATTESTATIONS_MANAGEMENT: { active: false },
29+
};
1930
});
2031

2132
test('it renders general information about organization', async function (assert) {
@@ -221,15 +232,17 @@ module('Integration | Component | organizations/information-section-view', funct
221232
assert.dom(screen.getByText('Archivée le 22/02/2022 par Rob Lochon.')).exists();
222233
});
223234
});
224-
225235
module('when organization is parent', function () {
226236
test('it should display parent label', async function (assert) {
227237
//given
228238
const store = this.owner.lookup('service:store');
229-
const child = store.createRecord('organization', { type: 'SCO', isManagingStudents: true });
239+
const child = store.createRecord('organization', {
240+
type: 'SCO',
241+
features,
242+
});
230243
const organization = store.createRecord('organization', {
231244
type: 'SCO',
232-
isManagingStudents: true,
245+
features,
233246
children: [child],
234247
});
235248

@@ -245,10 +258,14 @@ module('Integration | Component | organizations/information-section-view', funct
245258
test('it displays child label and parent organization name', async function (assert) {
246259
//given
247260
const store = this.owner.lookup('service:store');
248-
const parentOrganization = store.createRecord('organization', { id: 5, type: 'SCO', isManagingStudents: true });
261+
const parentOrganization = store.createRecord('organization', {
262+
id: 5,
263+
type: 'SCO',
264+
features,
265+
});
249266
const organization = store.createRecord('organization', {
250267
type: 'SCO',
251-
isManagingStudents: true,
268+
features,
252269
parentOrganizationId: parentOrganization.id,
253270
parentOrganizationName: 'Shibusen',
254271
});
@@ -269,7 +286,7 @@ module('Integration | Component | organizations/information-section-view', funct
269286
const organization = store.createRecord('organization', {
270287
type: 'SCO',
271288
name: 'notParent',
272-
isManagingStudents: true,
289+
features,
273290
});
274291

275292
// when

admin/tests/unit/components/organizations/information-section-edit-test.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ module('Unit | Component | organizations/information-section-edit', function (ho
1414
const organization = store.createRecord('organization', {
1515
id: 1,
1616
features: {
17-
PLACES_MANAGEMENT: { active: false },
17+
IS_MANAGING_STUDENTS: { active: false },
18+
SHOW_NPS: { active: false, params: { formNPSUrl: 'plop' } },
19+
SHOW_SKILLS: { active: false },
20+
LEARNER_IMPORT: { active: false },
1821
MULTIPLE_SENDING_ASSESSMENT: { active: false },
22+
PLACES_MANAGEMENT: { active: false },
1923
COMPUTE_ORGANIZATION_LEARNER_CERTIFICABILITY: { active: false },
24+
ATTESTATIONS_MANAGEMENT: { active: false },
2025
},
2126
});
2227
const component = createGlimmerComponent('component:organizations/information-section-edit', {

api/src/organizational-entities/domain/models/OrganizationForAdmin.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,13 @@ class OrganizationForAdmin {
173173
this.identityProviderForCampaigns = identityProviderForCampaigns;
174174
}
175175

176-
updateIsManagingStudents(isManagingStudents, features) {
176+
updateIsManagingStudents(features) {
177177
const hasLearnerImportFeature =
178178
features[ORGANIZATION_FEATURE.LEARNER_IMPORT.key] && features[ORGANIZATION_FEATURE.LEARNER_IMPORT.key].active;
179179

180-
this.isManagingStudents = hasLearnerImportFeature ? false : isManagingStudents;
180+
this.isManagingStudents = hasLearnerImportFeature
181+
? false
182+
: features[ORGANIZATION_FEATURE.IS_MANAGING_STUDENTS.key].active;
181183
}
182184

183185
updateWithDataProtectionOfficerAndTags(organization, dataProtectionOfficer = {}, tags = []) {
@@ -191,8 +193,8 @@ class OrganizationForAdmin {
191193
this.externalId = organization.externalId;
192194
this.updateProvinceCode(organization.provinceCode);
193195
this.documentationUrl = organization.documentationUrl;
194-
this.updateIsManagingStudents(organization.isManagingStudents, organization.features);
195-
this.showSkills = organization.showSkills;
196+
this.updateIsManagingStudents(organization.features);
197+
this.showSkills = organization.features[ORGANIZATION_FEATURE.SHOW_SKILLS.key].active;
196198
this.updateIdentityProviderForCampaigns(organization.identityProviderForCampaigns);
197199
this.dataProtectionOfficer.updateInformation(dataProtectionOfficer);
198200
this.features = organization.features;

0 commit comments

Comments
 (0)