Skip to content

Commit 5bd246e

Browse files
committed
feat(admin): add orgnanization id on quest editor
1 parent 7dca01e commit 5bd246e

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

admin/app/components/quests/form.gjs

+9-6
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,21 @@ export default class QuestForm extends Component {
8080
const snippets = JSON.parse(window.localStorage.getItem(LOCAL_STORAGE_KEY)) ?? {
8181
objectRequirementsByLabel: {},
8282
};
83-
const eligibilityRequirements = this.popToRootToPip(
83+
const eligibilityRequirements = this.buildArrayRequirement(
8484
this.eligibilityRequirementsStr,
8585
snippets.objectRequirementsByLabel,
8686
);
8787

88-
const successRequirements = this.popToRootToPip(this.successRequirementsStr, snippets.objectRequirementsByLabel);
88+
const successRequirements = this.buildArrayRequirement(
89+
this.successRequirementsStr,
90+
snippets.objectRequirementsByLabel,
91+
);
8992

9093
const questToJson = JSON.stringify({
9194
rewardId: parseInt(this.rewardId),
9295
rewardType: this.rewardType,
93-
eligibilityRequirements: [eligibilityRequirements],
94-
successRequirements: successRequirements ? [successRequirements] : [],
96+
eligibilityRequirements: eligibilityRequirements,
97+
successRequirements: successRequirements,
9598
});
9699

97100
console.log(questToJson);
@@ -121,7 +124,7 @@ export default class QuestForm extends Component {
121124
ALL(ONE-OF(A,B),C) ---> Le jeton d'opération (all ou one-of) se trouve au début, et en arguments
122125
on trouve la liste des opérandes.
123126
*/
124-
popToRootToPip(str, objectRequirementsByLabel) {
127+
buildArrayRequirement(str, objectRequirementsByLabel) {
125128
// Dictionnaire des "mots" qui correspondent à des requirements feuilles
126129
// qu'on pourrait retrouver dans la formule
127130
const snippetNames = Object.keys(objectRequirementsByLabel);
@@ -248,7 +251,7 @@ export default class QuestForm extends Component {
248251
</PixButtonLink>
249252

250253
<PixButton @size="small" @variant="success" @triggerAction={{this.copyEligibilityRequirementsToClipboard}}>
251-
Mettre le json des requirements d'éligibilité dans le presse-papiers
254+
Copiez le JSON de quête dans le presse-papiers
252255
</PixButton>
253256
</div>
254257
</section>

admin/app/components/quests/requirements/object/object-configuration.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ const organizationConfigField_isManagingStudents = new FieldConfiguration({
9393
refersToAnArray: false,
9494
allowedValues: ['true', 'false'],
9595
});
96+
const organizationConfigField_id = new FieldConfiguration({
97+
name: 'id',
98+
type: FieldConfiguration.TYPES.NUMBER,
99+
refersToAnArray: false,
100+
});
96101
const organizationConfigField_tags = new FieldConfiguration({
97102
name: 'tags',
98103
type: FieldConfiguration.TYPES.STRING,
@@ -111,6 +116,7 @@ const organizationConfiguration = new ObjectConfiguration({
111116
organizationConfigField_isManagingStudents,
112117
organizationConfigField_tags,
113118
organizationConfigField_type,
119+
organizationConfigField_id,
114120
],
115121
});
116122

@@ -171,7 +177,7 @@ const cappedTubeConfiguration_threshold = new FieldConfiguration({
171177

172178
const cappedTubeConfiguration = new ObjectConfiguration({
173179
name: 'cappedTubes',
174-
refersToAnArray: false,
180+
refersToAnArray: true,
175181
mergeFields: true,
176182
fieldConfigurations: [cappedTubeConfiguration_cappedTubes, cappedTubeConfiguration_threshold],
177183
});

0 commit comments

Comments
 (0)