From 1492047b59a2bef3cfcde64c526ff25fe29dfb5b Mon Sep 17 00:00:00 2001
From: "a.schindlbeck" <a.schindlbeck@adito.de>
Date: Wed, 8 May 2019 16:29:23 +0200
Subject: [PATCH] NotificatinCenter: actionProzesse und fixes

---
 .../create_asys_notificationcontents.xml      |  2 +-
 .../Notification_entity.aod                   | 36 +++++++++++++------
 .../entityfields/creationdate/valueProcess.js |  2 ++
 .../entityfields/icon/valueProcess.js         |  2 --
 .../rowclickaction/onActionProcess.js         | 12 +++++++
 .../children/archieve/onActionProcess.js      | 18 ++--------
 .../children/setread/onActionProcess.js       | 18 ++--------
 .../children/setunread/onActionProcess.js     | 18 ++--------
 .../entityfields/state/displayValueProcess.js |  6 ++++
 .../recordcontainers/db/orderClauseProcess.js |  7 ++++
 .../NotificationFilter_view.aod               |  7 ++--
 11 files changed, 61 insertions(+), 67 deletions(-)
 create mode 100644 entity/Notification_entity/entityfields/creationdate/valueProcess.js
 create mode 100644 entity/Notification_entity/entityfields/rowclickaction/onActionProcess.js
 create mode 100644 entity/Notification_entity/entityfields/state/displayValueProcess.js
 create mode 100644 entity/Notification_entity/recordcontainers/db/orderClauseProcess.js

diff --git a/.liquibase/_____SYSTEMALIAS/basic/2019.2/create_asys_notificationcontents.xml b/.liquibase/_____SYSTEMALIAS/basic/2019.2/create_asys_notificationcontents.xml
index d045c993887..b5195dab42f 100644
--- a/.liquibase/_____SYSTEMALIAS/basic/2019.2/create_asys_notificationcontents.xml
+++ b/.liquibase/_____SYSTEMALIAS/basic/2019.2/create_asys_notificationcontents.xml
@@ -7,7 +7,7 @@
         </column>
         <column name="BACKPACK" type="CLOB"/>
         <column name="CAPTION" type="VARCHAR(512)"/>
-        <column name="CREATIONDATE" type="BIGINT"/>
+        <column name="CREATIONDATE" type="TIMESTAMP"/>
         <column name="DESCRIPTION" type="VARCHAR(1023)"/>
         <column name="FORCEDPRIORITY" type="VARCHAR(15)"/>
         <column name="ICON_INFO" type="VARCHAR(1023)"/>
diff --git a/entity/Notification_entity/Notification_entity.aod b/entity/Notification_entity/Notification_entity.aod
index 487b2ab08a2..0c86a8e18f1 100644
--- a/entity/Notification_entity/Notification_entity.aod
+++ b/entity/Notification_entity/Notification_entity.aod
@@ -24,18 +24,26 @@
     </entityField>
     <entityField>
       <name>STATE</name>
+      <title>State</title>
+      <displayValueProcess>%aditoprj%/entity/Notification_entity/entityfields/state/displayValueProcess.js</displayValueProcess>
     </entityField>
     <entityField>
       <name>BACKPACK</name>
     </entityField>
     <entityField>
       <name>CAPTION</name>
+      <title>title</title>
     </entityField>
     <entityField>
       <name>CREATIONDATE</name>
+      <title>Date</title>
+      <contentType>DATE</contentType>
+      <resolution>MINUTE</resolution>
+      <valueProcess>%aditoprj%/entity/Notification_entity/entityfields/creationdate/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>DESCRIPTION</name>
+      <title>description</title>
     </entityField>
     <entityField>
       <name>FORCEDPRIORITY</name>
@@ -73,6 +81,15 @@
     <entityActionGroup>
       <name>setNotificationState</name>
       <children>
+        <entityActionField>
+          <name>archieve</name>
+          <fieldType>ACTION</fieldType>
+          <description></description>
+          <onActionProcess>%aditoprj%/entity/Notification_entity/entityfields/setnotificationstate/children/archieve/onActionProcess.js</onActionProcess>
+          <isSelectionAction v="true" />
+          <iconId>VAADIN:ARCHIVE</iconId>
+          <tooltip>archieve</tooltip>
+        </entityActionField>
         <entityActionField>
           <name>setRead</name>
           <fieldType>ACTION</fieldType>
@@ -80,7 +97,7 @@
           <onActionProcess>%aditoprj%/entity/Notification_entity/entityfields/setnotificationstate/children/setread/onActionProcess.js</onActionProcess>
           <isSelectionAction v="true" />
           <iconId>VAADIN:OPEN_BOOK</iconId>
-          <tooltip>gelesen setzen</tooltip>
+          <tooltip>set read</tooltip>
         </entityActionField>
         <entityActionField>
           <name>setUnread</name>
@@ -89,19 +106,15 @@
           <onActionProcess>%aditoprj%/entity/Notification_entity/entityfields/setnotificationstate/children/setunread/onActionProcess.js</onActionProcess>
           <isSelectionAction v="true" />
           <iconId>VAADIN:BOOK</iconId>
-          <tooltip>ungelesen setzen</tooltip>
-        </entityActionField>
-        <entityActionField>
-          <name>archieve</name>
-          <fieldType>ACTION</fieldType>
-          <description></description>
-          <onActionProcess>%aditoprj%/entity/Notification_entity/entityfields/setnotificationstate/children/archieve/onActionProcess.js</onActionProcess>
-          <isSelectionAction v="true" />
-          <iconId>VAADIN:ARCHIVE</iconId>
-          <tooltip>archivieren</tooltip>
+          <tooltip>set unread</tooltip>
         </entityActionField>
       </children>
     </entityActionGroup>
+    <entityActionField>
+      <name>rowClickAction</name>
+      <fieldType>ACTION</fieldType>
+      <onActionProcess>%aditoprj%/entity/Notification_entity/entityfields/rowclickaction/onActionProcess.js</onActionProcess>
+    </entityActionField>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
@@ -109,6 +122,7 @@
       <alias>_____SYSTEMALIAS</alias>
       <isPageable v="false" />
       <conditionProcess>%aditoprj%/entity/Notification_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
+      <orderClauseProcess>%aditoprj%/entity/Notification_entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess>
       <linkInformation>
         <linkInformation>
           <name>33b9740c-cd3d-43ec-97e6-65c9e880655a</name>
diff --git a/entity/Notification_entity/entityfields/creationdate/valueProcess.js b/entity/Notification_entity/entityfields/creationdate/valueProcess.js
new file mode 100644
index 00000000000..139597f9cb0
--- /dev/null
+++ b/entity/Notification_entity/entityfields/creationdate/valueProcess.js
@@ -0,0 +1,2 @@
+
+
diff --git a/entity/Notification_entity/entityfields/icon/valueProcess.js b/entity/Notification_entity/entityfields/icon/valueProcess.js
index 8286cb65453..42ceb3e1161 100644
--- a/entity/Notification_entity/entityfields/icon/valueProcess.js
+++ b/entity/Notification_entity/entityfields/icon/valueProcess.js
@@ -6,7 +6,5 @@ import("system.notification");
 if(vars.get("$field.TYPECODE"))
 {
     var type = notification.getType(vars.get("$field.TYPECODE"));
-    logging.log("type: " + type);
-
     result.string(type["icon"]);
 }
\ No newline at end of file
diff --git a/entity/Notification_entity/entityfields/rowclickaction/onActionProcess.js b/entity/Notification_entity/entityfields/rowclickaction/onActionProcess.js
new file mode 100644
index 00000000000..c58075c3e25
--- /dev/null
+++ b/entity/Notification_entity/entityfields/rowclickaction/onActionProcess.js
@@ -0,0 +1,12 @@
+import("system.vars");
+import("system.tools");
+import("system.notification");
+import("system.neon");
+
+var user = tools.getCurrentUser();
+var selectedNotifications = JSON.parse(vars.get("$sys.selection"));
+
+for(var i = 0; i < selectedNotifications.length; i++)
+    notification.updateUserNotificationState(user["name"], selectedNotifications[i], notification.STATE_CONFIRMED);
+
+neon.refreshAll();
\ No newline at end of file
diff --git a/entity/Notification_entity/entityfields/setnotificationstate/children/archieve/onActionProcess.js b/entity/Notification_entity/entityfields/setnotificationstate/children/archieve/onActionProcess.js
index 8a6a2c0e846..48b80068317 100644
--- a/entity/Notification_entity/entityfields/setnotificationstate/children/archieve/onActionProcess.js
+++ b/entity/Notification_entity/entityfields/setnotificationstate/children/archieve/onActionProcess.js
@@ -1,4 +1,3 @@
-import("system.logging");
 import("system.vars");
 import("system.tools");
 import("system.notification");
@@ -7,20 +6,7 @@ import("system.neon");
 var user = tools.getCurrentUser();
 var selectedNotifications = JSON.parse(vars.get("$sys.selection"));
 
-var userNotis = notification.getUserNotifications(user["name"], null);
-var contentId;
-
-for(var x = 0; x < selectedNotifications.length; x++)
-{
-    for(var i = 0; i < userNotis.length; i++)
-    {
-        if(userNotis[i][notification.PROP_ID] == selectedNotifications[x])
-        {
-            contentId = userNotis[i][notification.PROP_CONTENTID];
-            notification.updateUserNotificationState(user["name"], contentId, notification.STATE_ARCHIVE);
-            break;
-        }
-    }
-}
+for(var i = 0; i < selectedNotifications.length; i++)
+    notification.updateUserNotificationState(user["name"], selectedNotifications[i], notification.STATE_ARCHIVE);
 
 neon.refreshAll();
\ No newline at end of file
diff --git a/entity/Notification_entity/entityfields/setnotificationstate/children/setread/onActionProcess.js b/entity/Notification_entity/entityfields/setnotificationstate/children/setread/onActionProcess.js
index b00ff316d43..c58075c3e25 100644
--- a/entity/Notification_entity/entityfields/setnotificationstate/children/setread/onActionProcess.js
+++ b/entity/Notification_entity/entityfields/setnotificationstate/children/setread/onActionProcess.js
@@ -1,4 +1,3 @@
-import("system.logging");
 import("system.vars");
 import("system.tools");
 import("system.notification");
@@ -7,20 +6,7 @@ import("system.neon");
 var user = tools.getCurrentUser();
 var selectedNotifications = JSON.parse(vars.get("$sys.selection"));
 
-var userNotis = notification.getUserNotifications(user["name"], null);
-var contentId;
-
-for(var x = 0; x < selectedNotifications.length; x++)
-{
-    for(var i = 0; i < userNotis.length; i++)
-    {
-        if(userNotis[i][notification.PROP_ID] == selectedNotifications[x])
-        {
-            contentId = userNotis[i][notification.PROP_CONTENTID];
-            notification.updateUserNotificationState(user["name"], contentId, notification.STATE_CONFIRMED);
-            break;
-        }
-    }
-}
+for(var i = 0; i < selectedNotifications.length; i++)
+    notification.updateUserNotificationState(user["name"], selectedNotifications[i], notification.STATE_CONFIRMED);
 
 neon.refreshAll();
\ No newline at end of file
diff --git a/entity/Notification_entity/entityfields/setnotificationstate/children/setunread/onActionProcess.js b/entity/Notification_entity/entityfields/setnotificationstate/children/setunread/onActionProcess.js
index e2b7ef56da9..c56286bb565 100644
--- a/entity/Notification_entity/entityfields/setnotificationstate/children/setunread/onActionProcess.js
+++ b/entity/Notification_entity/entityfields/setnotificationstate/children/setunread/onActionProcess.js
@@ -1,4 +1,3 @@
-import("system.logging");
 import("system.vars");
 import("system.tools");
 import("system.notification");
@@ -7,20 +6,7 @@ import("system.neon");
 var user = tools.getCurrentUser();
 var selectedNotifications = JSON.parse(vars.get("$sys.selection"));
 
-var userNotis = notification.getUserNotifications(user["name"], null);
-var contentId;
-
-for(var x = 0; x < selectedNotifications.length; x++)
-{
-    for(var i = 0; i < userNotis.length; i++)
-    {
-        if(userNotis[i][notification.PROP_ID] == selectedNotifications[x])
-        {
-            contentId = userNotis[i][notification.PROP_CONTENTID];
-            notification.updateUserNotificationState(user["name"], contentId, notification.STATE_UNSEEN);
-            break;
-        }
-    }
-}
+for(var i = 0; i < selectedNotifications.length; i++)
+    notification.updateUserNotificationState(user["name"], selectedNotifications[i], notification.STATE_UNSEEN);
 
 neon.refreshAll();
\ No newline at end of file
diff --git a/entity/Notification_entity/entityfields/state/displayValueProcess.js b/entity/Notification_entity/entityfields/state/displayValueProcess.js
new file mode 100644
index 00000000000..7e736b66763
--- /dev/null
+++ b/entity/Notification_entity/entityfields/state/displayValueProcess.js
@@ -0,0 +1,6 @@
+import("system.translate");
+import("system.result");
+import("system.vars");
+
+
+result.string(translate.text(vars.get("$this.value")));
\ No newline at end of file
diff --git a/entity/Notification_entity/recordcontainers/db/orderClauseProcess.js b/entity/Notification_entity/recordcontainers/db/orderClauseProcess.js
new file mode 100644
index 00000000000..eb0a11a5c9c
--- /dev/null
+++ b/entity/Notification_entity/recordcontainers/db/orderClauseProcess.js
@@ -0,0 +1,7 @@
+import("system.result");
+import("system.db");
+
+result.object({
+    "ASYS_NOTIFICATIONS.STATE": db.DESCENDING,
+    "ASYS_NOTIFICATIONCONTENTS.CREATIONDATE": db.DESCENDING
+    });
\ No newline at end of file
diff --git a/neonView/NotificationFilter_view/NotificationFilter_view.aod b/neonView/NotificationFilter_view/NotificationFilter_view.aod
index 5d2a40b9838..c5cd6b4f449 100644
--- a/neonView/NotificationFilter_view/NotificationFilter_view.aod
+++ b/neonView/NotificationFilter_view/NotificationFilter_view.aod
@@ -12,6 +12,7 @@
     <tableViewTemplate>
       <name>Table</name>
       <favoriteActionGroup1>setNotificationState</favoriteActionGroup1>
+      <entryAction>rowClickAction</entryAction>
       <showHeader v="true" />
       <isSaveable v="false" />
       <isEditable v="false" />
@@ -19,7 +20,7 @@
       <columns>
         <neonTableColumn>
           <name>0ed20b46-be6a-424c-a583-a3f7496ec3f9</name>
-          <entityField>ICON</entityField>
+          <entityField>CREATIONDATE</entityField>
         </neonTableColumn>
         <neonTableColumn>
           <name>3bf425ed-227c-4768-b339-4794aa0d6063</name>
@@ -29,10 +30,6 @@
           <name>ff33a6c1-7ac6-4acd-a083-e56a36f89977</name>
           <entityField>DESCRIPTION</entityField>
         </neonTableColumn>
-        <neonTableColumn>
-          <name>63df503b-2502-4123-917a-77c932f61268</name>
-          <entityField>ORIGINATORNAME</entityField>
-        </neonTableColumn>
         <neonTableColumn>
           <name>5cb09de4-4413-41e5-8a7c-4970a3cf6a62</name>
           <entityField>STATE</entityField>
-- 
GitLab