client/src/constants/index.js
author ymh <ymh.work@gmail.com>
Fri, 30 Nov 2018 10:53:15 +0100
changeset 183 f8f3af9e5c83
parent 138 a1fb2ced3049
child 193 99e342f9fb0c
permissions -rw-r--r--
Change the settings to avoid using Session authentication for rest framework as it raise exceptions in case client and backend are on the same domain On the filter, adapt to take into account new version of django_filters
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
129
d48946d164c6 Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
export const ActionEnum = {
d48946d164c6 Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
  NONE: 0,
d48946d164c6 Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
  CREATED: 1,
d48946d164c6 Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
  UPDATED: 2,
d48946d164c6 Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
  DELETED: 3
d48946d164c6 Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
}
138
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
     7
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
     8
export const defaultAnnotationsCategories = [
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
     9
  { key: 'important', name: 'Important',    color: '#F1C40F' },
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    10
  { key: 'keyword',   name: 'Mot-clé',      color: '#2ECC71' },
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    11
  { key: 'comment',   name: 'Commentaire',  color: '#3498DB', hasComment: true }
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    12
];
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    13
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    14
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    15
export const extractAnnotationCategories = (protocol) => {
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    16
  const metacategories = (protocol)?protocol['metacategories']:null;
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    17
  if(!metacategories) {
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    18
    return defaultAnnotationsCategories;
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    19
  }
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    20
  return metacategories.map((m) => {
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    21
    return {
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    22
      key: m.id,
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    23
      name: m.name,
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    24
      description: m.description,
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    25
      color: m.color,
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    26
      hasComment: m.has_comment
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    27
    }
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    28
  })
a1fb2ced3049 propagate annotations categories from session protocol definition
ymh <ymh.work@gmail.com>
parents: 129
diff changeset
    29
}