From adef3adfc487ff35704b7b2735c871ed9abf0983 Mon Sep 17 00:00:00 2001
From: "a.schindlbeck" <a.schindlbeck@adito.de>
Date: Tue, 21 May 2019 15:06:20 +0200
Subject: [PATCH] NotificationCenter: Prios

---
 .../Notification_entity.aod                   |   6 ++
 .../calculatedpriority/valueProcess.js        |  48 +++++++++
 .../entityfields/icon/valueProcess.js         |   2 +-
 neonNotificationType/Andis/Andis.aod          |  18 ++--
 .../Geburtstag/Geburtstag.aod                 |   8 ++
 .../NotificationFilter_view.aod               | 102 +++++++++---------
 6 files changed, 127 insertions(+), 57 deletions(-)
 create mode 100644 entity/Notification_entity/entityfields/calculatedpriority/valueProcess.js
 create mode 100644 neonNotificationType/Geburtstag/Geburtstag.aod

diff --git a/entity/Notification_entity/Notification_entity.aod b/entity/Notification_entity/Notification_entity.aod
index 4d32b33ed19..7fffae481c5 100644
--- a/entity/Notification_entity/Notification_entity.aod
+++ b/entity/Notification_entity/Notification_entity.aod
@@ -136,6 +136,12 @@
       <fieldType>ACTION</fieldType>
       <onActionProcess>%aditoprj%/entity/Notification_entity/entityfields/rowclickaction/onActionProcess.js</onActionProcess>
     </entityActionField>
+    <entityField>
+      <name>CALCULATEDPRIORITY</name>
+      <title>Priority</title>
+      <contentType>IMAGE</contentType>
+      <valueProcess>%aditoprj%/entity/Notification_entity/entityfields/calculatedpriority/valueProcess.js</valueProcess>
+    </entityField>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/Notification_entity/entityfields/calculatedpriority/valueProcess.js b/entity/Notification_entity/entityfields/calculatedpriority/valueProcess.js
new file mode 100644
index 00000000000..7ff3a5ee122
--- /dev/null
+++ b/entity/Notification_entity/entityfields/calculatedpriority/valueProcess.js
@@ -0,0 +1,48 @@
+import("system.notification");
+import("system.vars");
+import("system.logging");
+import("system.result");
+
+var typecode = vars.get("$field.TYPECODE");
+var typeObject = notification.getType(typecode);
+
+    logging.log("2");
+if(typeObject != null)
+{
+    
+    logging.log("1");
+    var defaultPrio = typeObject[notification.TYPEPROP_DEFAULT_PRIO];
+    var userPrio = typeObject[notification.TYPEPROP_USER_PRIO];
+    var forcedPrio = vars.get("$field.FORCEDPRIORITY");
+
+    var realPrio; 
+
+    if(forcedPrio && forcedPrio != notification.PRIO_NONE)
+        realPrio = forcedPrio;
+
+    else if(userPrio && userPrio != notification.PRIO_NONE)
+        realPrio = userPrio;
+
+    else if(defaultPrio && defaultPrio != notification.PRIO_NONE)
+        realPrio = defaultPrio;
+
+
+    switch(realPrio)
+    {
+        case "LOW":
+            result.string(notification.PRIO_LOW_BASE64);
+            break;
+        case "NORMAL":
+            result.string(notification.PRIO_NORMAL_BASE64);
+            break;
+        case "HIGH":
+            result.string(notification.PRIO_HIGH_BASE64);
+            break;
+        case "MAX":
+            result.string(notification.PRIO_MAX_BASE64);
+            break;
+        default:
+            result.string(notification.PRIO_NONE_BASE64); 
+            break;
+    }
+}
\ No newline at end of file
diff --git a/entity/Notification_entity/entityfields/icon/valueProcess.js b/entity/Notification_entity/entityfields/icon/valueProcess.js
index 9aec602ea95..71475bd8b0d 100644
--- a/entity/Notification_entity/entityfields/icon/valueProcess.js
+++ b/entity/Notification_entity/entityfields/icon/valueProcess.js
@@ -5,5 +5,5 @@ import("system.notification");
 if(vars.get("$field.TYPECODE"))
 {
     var type = notification.getType(vars.get("$field.TYPECODE"));
-    result.string(type["icon"]);
+    result.string(type[notification.TYPEPROP_ICON]);
 }
\ No newline at end of file
diff --git a/neonNotificationType/Andis/Andis.aod b/neonNotificationType/Andis/Andis.aod
index 9f75b4b3d53..21f410c7abb 100644
--- a/neonNotificationType/Andis/Andis.aod
+++ b/neonNotificationType/Andis/Andis.aod
@@ -1,8 +1,10 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<neonNotificationType xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonNotificationType/1.1.0">
-  <name>Andis</name>
-  <title>Andis Noti</title>
-  <majorModelMode>DISTRIBUTED</majorModelMode>
-  <icon>VAADIN:COMMENT_ELLIPSIS_O</icon>
-  <resultFrameNeon></resultFrameNeon>
-</neonNotificationType>
+<?xml version="1.0" encoding="UTF-8"?>
+<neonNotificationType xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonNotificationType/1.1.0">
+  <name>Andis</name>
+  <title>Andis Noti</title>
+  <name>Andis</name>
+  <title>Andis Noti</title>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <name>Andis</name>
+  <title>Andis Noti</title>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
diff --git a/neonNotificationType/Geburtstag/Geburtstag.aod b/neonNotificationType/Geburtstag/Geburtstag.aod
new file mode 100644
index 00000000000..bc107def870
--- /dev/null
+++ b/neonNotificationType/Geburtstag/Geburtstag.aod
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<neonNotificationType xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonNotificationType/1.1.0">
+  <name>Geburtstag</name>
+  <title>Geburtstag</title>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <icon>VAADIN:COFFEE</icon>
+  <defaultPriority>LOW</defaultPriority>
+</neonNotificationType>
diff --git a/neonView/NotificationFilter_view/NotificationFilter_view.aod b/neonView/NotificationFilter_view/NotificationFilter_view.aod
index 013dec87c32..135de7aa272 100644
--- a/neonView/NotificationFilter_view/NotificationFilter_view.aod
+++ b/neonView/NotificationFilter_view/NotificationFilter_view.aod
@@ -1,48 +1,54 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.1">
-  <name>NotificationFilter_view</name>
-  <majorModelMode>DISTRIBUTED</majorModelMode>
-  <filterable v="true" />
-  <layout>
-    <boxLayout>
-      <name>layout</name>
-    </boxLayout>
-  </layout>
-  <children>
-    <tableViewTemplate>
-      <name>Table</name>
-      <favoriteActionGroup1>setNotificationState</favoriteActionGroup1>
-      <entryAction>rowClickAction</entryAction>
-      <entityField>#ENTITY</entityField>
-      <isEditable v="false" />
-      <showHeader v="true" />
-      <isSaveable v="false" />
-      <columns>
-        <neonTableColumn>
-          <name>1cff3be1-523d-4a5a-b7d1-389d7cbb726f</name>
-          <entityField>ICON</entityField>
-        </neonTableColumn>
-        <neonTableColumn>
-          <name>ebf8b6d5-1057-425d-a57b-d02e25dbd2a4</name>
-          <entityField>TYPECODE</entityField>
-        </neonTableColumn>
-        <neonTableColumn>
-          <name>0ed20b46-be6a-424c-a583-a3f7496ec3f9</name>
-          <entityField>CREATIONDATE</entityField>
-        </neonTableColumn>
-        <neonTableColumn>
-          <name>3bf425ed-227c-4768-b339-4794aa0d6063</name>
-          <entityField>CAPTION</entityField>
-        </neonTableColumn>
-        <neonTableColumn>
-          <name>ff33a6c1-7ac6-4acd-a083-e56a36f89977</name>
-          <entityField>DESCRIPTION</entityField>
-        </neonTableColumn>
-        <neonTableColumn>
-          <name>5cb09de4-4413-41e5-8a7c-4970a3cf6a62</name>
-          <entityField>STATE</entityField>
-        </neonTableColumn>
-      </columns>
-    </tableViewTemplate>
-  </children>
-</neonView>
+<?xml version="1.0" encoding="UTF-8"?>
+<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.1">
+  <name>NotificationFilter_view</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <filterable v="true" />
+  <layout>
+    <boxLayout>
+      <name>layout</name>
+    </boxLayout>
+  </layout>
+  <children>
+    <tableViewTemplate>
+      <name>Table</name>
+      <favoriteActionGroup1>setNotificationState</favoriteActionGroup1>
+      <entryAction>rowClickAction</entryAction>
+      <entityField>#ENTITY</entityField>
+      <isEditable v="false" />
+      <showHeader v="true" />
+      <isSaveable v="false" />
+      <columns>
+        <neonTableColumn>
+          <name>1cff3be1-523d-4a5a-b7d1-389d7cbb726f</name>
+          <entityField>ICON</entityField>
+        </neonTableColumn>
+        <neonTableColumn>
+          <name>ebf8b6d5-1057-425d-a57b-d02e25dbd2a4</name>
+          <entityField>TYPECODE</entityField>
+        </neonTableColumn>
+        <neonTableColumn>
+          <name>e6296097-b6cc-4eb3-a32a-eed56a046ff0</name>
+          <entityField>CALCULATEDPRIORITY</entityField>
+          <width v="30" />
+          <expandRatio v="0" />
+        </neonTableColumn>
+        <neonTableColumn>
+          <name>0ed20b46-be6a-424c-a583-a3f7496ec3f9</name>
+          <entityField>CREATIONDATE</entityField>
+        </neonTableColumn>
+        <neonTableColumn>
+          <name>3bf425ed-227c-4768-b339-4794aa0d6063</name>
+          <entityField>CAPTION</entityField>
+        </neonTableColumn>
+        <neonTableColumn>
+          <name>ff33a6c1-7ac6-4acd-a083-e56a36f89977</name>
+          <entityField>DESCRIPTION</entityField>
+        </neonTableColumn>
+        <neonTableColumn>
+          <name>5cb09de4-4413-41e5-8a7c-4970a3cf6a62</name>
+          <entityField>STATE</entityField>
+        </neonTableColumn>
+      </columns>
+    </tableViewTemplate>
+  </children>
+</neonView>
-- 
GitLab