client/src/constants/index.js
changeset 138 a1fb2ced3049
parent 129 d48946d164c6
child 193 99e342f9fb0c
--- a/client/src/constants/index.js	Thu Aug 03 23:04:33 2017 +0200
+++ b/client/src/constants/index.js	Fri Aug 04 09:48:09 2017 +0200
@@ -4,3 +4,26 @@
   UPDATED: 2,
   DELETED: 3
 }
+
+export const defaultAnnotationsCategories = [
+  { key: 'important', name: 'Important',    color: '#F1C40F' },
+  { key: 'keyword',   name: 'Mot-clé',      color: '#2ECC71' },
+  { key: 'comment',   name: 'Commentaire',  color: '#3498DB', hasComment: true }
+];
+
+
+export const extractAnnotationCategories = (protocol) => {
+  const metacategories = (protocol)?protocol['metacategories']:null;
+  if(!metacategories) {
+    return defaultAnnotationsCategories;
+  }
+  return metacategories.map((m) => {
+    return {
+      key: m.id,
+      name: m.name,
+      description: m.description,
+      color: m.color,
+      hasComment: m.has_comment
+    }
+  })
+}