@01-edu/shared 1.1.5 → 1.1.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 CHANGED
@@ -209,6 +209,7 @@ const autoRejectWhereLabel = `Automatic reject if`
209
209
  const sharedAutoValidationOperator = action => ({
210
210
  type: 'string',
211
211
  restrictive: true,
212
+ editable: true,
212
213
  label: `${action} - number of conditions to fulfil`,
213
214
  ...Functions({ all: () => 'and', one: () => 'or' }),
214
215
  })
@@ -2438,7 +2439,7 @@ types.levelDefinition = TypeObject({
2438
2439
  check: (level, object) => {
2439
2440
  checkIntegerInBetween(level, 1, MAX_LEVEL)
2440
2441
 
2441
- const definitionsWithSameLevel = object.attrs.levelsDefinitions.filter(
2442
+ const definitionsWithSameLevel = object.attrs.levelsDefinitions?.filter(
2442
2443
  levelDefinition => levelDefinition.level === level,
2443
2444
  )
2444
2445
  if (definitionsWithSameLevel?.length > 1) {
@@ -2627,7 +2628,7 @@ types.rankDefinitionName = Literal('', {
2627
2628
  // checkNotEmpty(name): have to be commented or it's impossible
2628
2629
  // to add a new rank to the ranks definition, as default value is ''
2629
2630
  // and check is done before add
2630
- const definitionsWithSameName = object.attrs.ranksDefinitions.filter(
2631
+ const definitionsWithSameName = object.attrs.ranksDefinitions?.filter(
2631
2632
  rankDefinition => rankDefinition.name === name,
2632
2633
  )
2633
2634
  if (definitionsWithSameName?.length > 1) {
@@ -2651,7 +2652,7 @@ types.rankDefinition = TypeObject({
2651
2652
  check: (level, object) => {
2652
2653
  checkIntegerInBetween(level, 0, MAX_LEVEL)
2653
2654
 
2654
- const definitionsWithSameLevel = object.attrs.ranksDefinitions.filter(
2655
+ const definitionsWithSameLevel = object.attrs.ranksDefinitions?.filter(
2655
2656
  rankDefinition => rankDefinition.level === level,
2656
2657
  )
2657
2658
  if (definitionsWithSameLevel?.length > 1) {
@@ -3636,7 +3637,7 @@ types.timelineChunk = TypeObject({
3636
3637
  check: (month, object) => {
3637
3638
  checkIntegerInBetween(month, 1, 120)
3638
3639
 
3639
- const definitionsWithSameMonth = object.attrs.timeline.filter(
3640
+ const definitionsWithSameMonth = object.attrs.timeline?.filter(
3640
3641
  guideline => guideline.month === month,
3641
3642
  )
3642
3643
  if (definitionsWithSameMonth?.length > 1) {
@@ -3677,7 +3678,9 @@ types.timelineChunk = TypeObject({
3677
3678
  )
3678
3679
  }
3679
3680
 
3680
- const ranksNames = object.attrs.ranksDefinitions.map(({ name }) => name)
3681
+ const ranksNames = object.attrs.ranksDefinitions?.map(
3682
+ ({ name }) => name,
3683
+ )
3681
3684
  if (!ranksNames.includes(rank)) {
3682
3685
  throw Error(
3683
3686
  `Must match one of the following existing rank names: ${ranksNames.join(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@01-edu/shared",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "scripts": {
package/toolbox.js CHANGED
@@ -5,7 +5,7 @@ import { onboardingTypes } from './onboarding.js'
5
5
  const keyCodes = {
6
6
  13: ({ save, value, event, allowLineBreak }) => {
7
7
  if (event.shiftKey || allowLineBreak) return false
8
- save(value)
8
+ return save(value)
9
9
  }, // enter
10
10
  27: ({ set, originalValue }) => set(originalValue), // esc
11
11
  83: ({ save, value, event }) =>
@@ -491,12 +491,12 @@ export const timePlusDelay = (time, delay) =>
491
491
  new Date(new Date(time).getTime() + delay).toISOString()
492
492
 
493
493
  export const getRecordStatus = record => {
494
- if (!isFinished(record.startAt)) return 'starting soon'
495
- if (record.endAt && isFinished(record.endAt)) {
494
+ if (!isFinished(record?.startAt)) return 'starting soon'
495
+ if (record?.endAt && isFinished(record?.endAt)) {
496
496
  return 'finished'
497
497
  }
498
- if (record.type.isPermanent) return 'permanent'
499
- return record.endAt ? 'in progress' : 'unblock required'
498
+ if (record?.type.isPermanent) return 'permanent'
499
+ return record?.endAt ? 'in progress' : 'unblock required'
500
500
  }
501
501
 
502
502
  export const createFrequencyMap = arr =>