@01-edu/shared 1.2.6 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/attrs-defs.js +0 -110
- package/package.json +1 -1
package/attrs-defs.js
CHANGED
|
@@ -2668,121 +2668,11 @@ const sharedRanksDefinitions = {
|
|
|
2668
2668
|
},
|
|
2669
2669
|
}
|
|
2670
2670
|
|
|
2671
|
-
types.relatesToContent = Literal('', {
|
|
2672
|
-
label: 'Content',
|
|
2673
|
-
instruction:
|
|
2674
|
-
'Select a child object to link this learning path status to. Each child can only be linked once.',
|
|
2675
|
-
editable: true,
|
|
2676
|
-
restrictive: true,
|
|
2677
|
-
options: (object, value) => {
|
|
2678
|
-
const learnPathStatus = object.attrs?.learnPathStatus
|
|
2679
|
-
?.flatMap(({ relatesTo }) => relatesTo)
|
|
2680
|
-
.filter(v => v !== value)
|
|
2681
|
-
|
|
2682
|
-
const options = object.children ? Object.keys(object.children) : []
|
|
2683
|
-
return !learnPathStatus
|
|
2684
|
-
? options
|
|
2685
|
-
: options.filter(k => !learnPathStatus.includes(k))
|
|
2686
|
-
},
|
|
2687
|
-
})
|
|
2688
|
-
|
|
2689
|
-
types.relatesToArray = TypeObject({
|
|
2690
|
-
label: 'Relates to',
|
|
2691
|
-
instruction:
|
|
2692
|
-
'Link one or more child objects to this learning path status. You can add multiple links by clicking the add button. If student did at least one he will have that status',
|
|
2693
|
-
editable: true,
|
|
2694
|
-
required: true,
|
|
2695
|
-
restrictive: true,
|
|
2696
|
-
value: (...args) => [
|
|
2697
|
-
mapValues(types.relatesToArray.type, subDef =>
|
|
2698
|
-
getDefaultValue(subDef, ...args),
|
|
2699
|
-
),
|
|
2700
|
-
],
|
|
2701
|
-
type: [types.relatesToContent],
|
|
2702
|
-
})
|
|
2703
|
-
|
|
2704
|
-
types.learnerPathStatusName = Literal('', {
|
|
2705
|
-
label: 'Name',
|
|
2706
|
-
editable: true,
|
|
2707
|
-
required: true,
|
|
2708
|
-
primary: true,
|
|
2709
|
-
})
|
|
2710
|
-
types.definitionRelatesTo = TypeObject({
|
|
2711
|
-
label: 'Status Definition',
|
|
2712
|
-
type: {
|
|
2713
|
-
name: types.learnerPathStatusName,
|
|
2714
|
-
milestone: Literal('', {
|
|
2715
|
-
label: 'Hover description',
|
|
2716
|
-
instruction:
|
|
2717
|
-
'Text that appears when users hover over this item. Use this to provide additional context or helpful information.',
|
|
2718
|
-
editable: true,
|
|
2719
|
-
}),
|
|
2720
|
-
relatesTo: types.relatesToArray,
|
|
2721
|
-
},
|
|
2722
|
-
check: (value, object) => {
|
|
2723
|
-
const { relatesTo: currentRelatesTo, name } = value
|
|
2724
|
-
const { learnPathStatus } = object.attrs
|
|
2725
|
-
const previousValue = learnPathStatus.find(
|
|
2726
|
-
({ relatesTo }) =>
|
|
2727
|
-
!(
|
|
2728
|
-
currentRelatesTo.length !== relatesTo.length ||
|
|
2729
|
-
currentRelatesTo.some((val, i) => val !== relatesTo[i])
|
|
2730
|
-
),
|
|
2731
|
-
)
|
|
2732
|
-
if (!previousValue) return
|
|
2733
|
-
|
|
2734
|
-
const isDifferent =
|
|
2735
|
-
previousValue.relatesTo.length !== currentRelatesTo.length ||
|
|
2736
|
-
previousValue.relatesTo.some((val, i) => val !== currentRelatesTo[i])
|
|
2737
|
-
|
|
2738
|
-
const hasSameKey = previousValue.name === name
|
|
2739
|
-
if (!isDifferent && hasSameKey) return
|
|
2740
|
-
|
|
2741
|
-
const definitionsWithSameName = object.attrs.learnPathStatus?.find(
|
|
2742
|
-
v => v.name === name,
|
|
2743
|
-
)
|
|
2744
|
-
if (definitionsWithSameName) {
|
|
2745
|
-
throw Error(
|
|
2746
|
-
`Name "${name}" is already set for a learner path status! A given name can only be attributed once.`,
|
|
2747
|
-
)
|
|
2748
|
-
}
|
|
2749
|
-
},
|
|
2750
|
-
})
|
|
2751
|
-
|
|
2752
|
-
const learnPathStatus = {
|
|
2753
|
-
label: 'Learner Path Status',
|
|
2754
|
-
instruction: 'List of Learner Status During Campus Steps',
|
|
2755
|
-
editable: true,
|
|
2756
|
-
restrictive: true,
|
|
2757
|
-
value: (...args) => [
|
|
2758
|
-
mapValues(types.learnPathStatus.type, subDef =>
|
|
2759
|
-
getDefaultValue(subDef, ...args),
|
|
2760
|
-
),
|
|
2761
|
-
],
|
|
2762
|
-
type: [types.definitionRelatesTo],
|
|
2763
|
-
check: (definition, object) => {
|
|
2764
|
-
if (!object.childrenRelation.length) {
|
|
2765
|
-
throw Error('Must contain at least one relation')
|
|
2766
|
-
}
|
|
2767
|
-
if (!definition?.length || !Array.isArray(definition)) {
|
|
2768
|
-
throw Error('Must be a non empty array')
|
|
2769
|
-
}
|
|
2770
|
-
},
|
|
2771
|
-
}
|
|
2772
|
-
|
|
2773
2671
|
attrs.ranksDefinitions = {
|
|
2774
2672
|
module: sharedRanksDefinitions,
|
|
2775
2673
|
piscine: sharedRanksDefinitions,
|
|
2776
2674
|
}
|
|
2777
2675
|
|
|
2778
|
-
attrs.learnPathStatus = {
|
|
2779
|
-
// the learn path status will define what the student is during the steps
|
|
2780
|
-
// - applicant (user that registered to the platform and passed the onboarding steps, up until being accepted to participate on the selection piscine/program)
|
|
2781
|
-
// - candidate (user that is participating on the selection piscine)
|
|
2782
|
-
// - learner (user that succeeded on the selection piscine and is participating on the module event)
|
|
2783
|
-
campus: learnPathStatus,
|
|
2784
|
-
}
|
|
2785
|
-
|
|
2786
2676
|
const sharedRegistrationDuration = {
|
|
2787
2677
|
label: 'Registration duration (to an event)',
|
|
2788
2678
|
required: true,
|