From c76fa83a936033518d0170cdbc49943ae6f6797c Mon Sep 17 00:00:00 2001
From: "a.schindlbeck" <a.schindlbeck@adito.de>
Date: Mon, 24 Sep 2018 10:47:49 +0200
Subject: [PATCH] Calendar Category Integration

---
 entity/Address_entity/Address_entity.aod      |  1 +
 .../entityfields/country/valueProcess.js      |  0
 .../Appointment_entity/Appointment_entity.aod |  6 ++++
 entity/Appointment_entity/contentProcess.js   |  2 --
 .../categories/possibleItemsProcess.js        | 13 +++++++++
 .../entityfields/categories/valueProcess.js   |  6 ++++
 entity/Appointment_entity/onUpdate.js         |  4 ++-
 entity/Pers_entity/Pers_entity.aod            |  7 +++++
 .../AppointmentEdit_view.aod                  |  1 +
 .../_____PREFERENCES_PROJECT.aod              | 28 +++++++++++++++++++
 10 files changed, 65 insertions(+), 3 deletions(-)
 create mode 100644 entity/Address_entity/entityfields/country/valueProcess.js
 create mode 100644 entity/Appointment_entity/entityfields/categories/possibleItemsProcess.js
 create mode 100644 entity/Appointment_entity/entityfields/categories/valueProcess.js

diff --git a/entity/Address_entity/Address_entity.aod b/entity/Address_entity/Address_entity.aod
index 71b99fd88ce..c80ff8c1405 100644
--- a/entity/Address_entity/Address_entity.aod
+++ b/entity/Address_entity/Address_entity.aod
@@ -54,6 +54,7 @@
       <columnName>COUNTRY</columnName>
       <caption>Country</caption>
       <possibleItemsProcess>%aditoprj%/entity/Address_entity/entityfields/country/possibleItemsProcess.js</possibleItemsProcess>
+      <valueProcess>%aditoprj%/entity/Address_entity/entityfields/country/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>DATE_EDIT</name>
diff --git a/entity/Address_entity/entityfields/country/valueProcess.js b/entity/Address_entity/entityfields/country/valueProcess.js
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/entity/Appointment_entity/Appointment_entity.aod b/entity/Appointment_entity/Appointment_entity.aod
index 9992bec4e32..6831f1ee639 100644
--- a/entity/Appointment_entity/Appointment_entity.aod
+++ b/entity/Appointment_entity/Appointment_entity.aod
@@ -85,5 +85,11 @@
     <entityField>
       <name>REMINDER</name>
     </entityField>
+    <entityField>
+      <name>CATEGORIES</name>
+      <possibleItemsProcess>%aditoprj%/entity/Appointment_entity/entityfields/categories/possibleItemsProcess.js</possibleItemsProcess>
+      <newItemsAllowed v="true" />
+      <valueProcess>%aditoprj%/entity/Appointment_entity/entityfields/categories/valueProcess.js</valueProcess>
+    </entityField>
   </entityFields>
 </entity>
diff --git a/entity/Appointment_entity/contentProcess.js b/entity/Appointment_entity/contentProcess.js
index c09809b1379..23c6e3df703 100644
--- a/entity/Appointment_entity/contentProcess.js
+++ b/entity/Appointment_entity/contentProcess.js
@@ -23,8 +23,6 @@ if(vars.exists("$image.entry"))
     var reminder = entry[calendars.REMINDER];
     var remindercheck = entry[calendars.HASREMINDER]
     var classification = entry[calendars.CLASSIFICATION];
-    
-    logging.log("contentproc: entry location:" + location + " desc: " + description + " summary: " + summary);
   
     //@TODO Icon 
   
diff --git a/entity/Appointment_entity/entityfields/categories/possibleItemsProcess.js b/entity/Appointment_entity/entityfields/categories/possibleItemsProcess.js
new file mode 100644
index 00000000000..e59b81e02e6
--- /dev/null
+++ b/entity/Appointment_entity/entityfields/categories/possibleItemsProcess.js
@@ -0,0 +1,13 @@
+import("system.result");
+import("system.translate");
+import("system.calendars");
+
+var rawElements = calendars.getElementPrefs()[calendars.ELEM_CATEGORIES_EVENT];
+
+var resultName = [[]];
+
+for (var i = 0; i < rawElements.length; i++)
+{
+    resultName[i] = [translate.text(rawElements[i]), translate.text(rawElements[i])];
+}
+result.object(resultName);
\ No newline at end of file
diff --git a/entity/Appointment_entity/entityfields/categories/valueProcess.js b/entity/Appointment_entity/entityfields/categories/valueProcess.js
new file mode 100644
index 00000000000..667d4466912
--- /dev/null
+++ b/entity/Appointment_entity/entityfields/categories/valueProcess.js
@@ -0,0 +1,6 @@
+import("system.result");
+import("system.vars");
+import("system.calendars");
+
+var categs = vars.get("$image.entry")[calendars.CATEGORIES];
+result.string(categs);
\ No newline at end of file
diff --git a/entity/Appointment_entity/onUpdate.js b/entity/Appointment_entity/onUpdate.js
index 95a51ce1a5f..b5fa3598b9b 100644
--- a/entity/Appointment_entity/onUpdate.js
+++ b/entity/Appointment_entity/onUpdate.js
@@ -62,7 +62,9 @@ if(vars.exists("$image.entry"))
             event[calendars.CLASSIFICATION] = vars.get("$field.CLASSIFICATION");
         //    event[calendars.TRANSPARENCY] = vars.get("$comp.transparency");  
             //event[calendars.AFFECTEDUSERS] = getAffectedUsers( event ); 
-        //    event[calendars.CATEGORIES] = vars.get("$comp.categories");
+            var categs = vars.get("$field.CATEGORIES");
+            logging.log(categs);
+            event[calendars.CATEGORIES] = categs;
         //    calcrecurrence(event);
         //    if (event[calendars.RRULE] != undefined)     recurrencend(event);
         // Links updaten
diff --git a/entity/Pers_entity/Pers_entity.aod b/entity/Pers_entity/Pers_entity.aod
index bbef94d5867..91347c5f0e9 100644
--- a/entity/Pers_entity/Pers_entity.aod
+++ b/entity/Pers_entity/Pers_entity.aod
@@ -240,6 +240,13 @@
         </entityParameter>
       </children>
     </entityOutgoingField>
+    <entityOutgoingField>
+      <name>PersAppointment_dfo</name>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+      </dependency>
+    </entityOutgoingField>
   </entityFields>
   <linkInformation>
     <linkInformation>
diff --git a/neonView/AppointmentEdit_view/AppointmentEdit_view.aod b/neonView/AppointmentEdit_view/AppointmentEdit_view.aod
index e43e16d3987..8b94f211fc1 100644
--- a/neonView/AppointmentEdit_view/AppointmentEdit_view.aod
+++ b/neonView/AppointmentEdit_view/AppointmentEdit_view.aod
@@ -19,6 +19,7 @@
       <privateField>CLASSIFICATION</privateField>
       <statusField>STATUS</statusField>
       <locationField>LOCATION</locationField>
+      <categoriesField>CATEGORIES</categoriesField>
       <entityField>#ENTITY</entityField>
     </appointmentEditViewTemplate>
   </children>
diff --git a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod
index 8fcbb815aad..b058fa28a99 100644
--- a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod
+++ b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod
@@ -4,6 +4,34 @@
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <projectName>xRM-Basic 5</projectName>
   <jditoMaxContentSize v="57671680" />
+  <calendarCategories>
+    <entry>
+      <key>Meeting</key>
+      <value></value>
+    </entry>
+    <entry>
+      <key>Privat</key>
+      <value></value>
+    </entry>
+    <entry>
+      <key>Organisatorisch</key>
+      <value></value>
+    </entry>
+  </calendarCategories>
+  <calendarCategoriesEvent>
+    <entry>
+      <key>MeetingEvent</key>
+      <value></value>
+    </entry>
+    <entry>
+      <key>PrivatEvent</key>
+      <value></value>
+    </entry>
+    <entry>
+      <key>OrganisatorischEvent</key>
+      <value></value>
+    </entry>
+  </calendarCategoriesEvent>
   <clientSearchOptimizedForSpeed v="true" />
   <clientSearchExcludeForIgnorecase v="true" />
   <blobHandlingMethod>DATABASE</blobHandlingMethod>
-- 
GitLab