Bladeren bron

menu communication

Vincent GUFFON 5 jaren geleden
bovenliggende
commit
f82ec7dd02
3 gewijzigde bestanden met toevoegingen van 55 en 0 verwijderingen
  1. 23 0
      config/abilities/pages/communication.yaml
  2. 4 0
      lang/layout/fr-FR.js
  3. 28 0
      use/template/menu.ts

+ 23 - 0
config/abilities/pages/communication.yaml

@@ -0,0 +1,23 @@
+  inbox_page:
+    action: 'display'
+    services:
+      access:
+        - {function: hasAbility, parameters: [{action: 'read', subject: 'mails'},{action: 'read', subject: 'emails'},{action: 'read', subject: 'sms'}]}
+      organization:
+        - {function: hasModule, parameters: ['MessagesAdvanced']}
+
+  message_send_page:
+    action: 'display'
+    services:
+      access:
+        - {function: hasAbility, parameters: [{action: 'read', subject: 'mails'},{action: 'read', subject: 'emails'},{action: 'read', subject: 'sms'}]}
+      organization:
+        - {function: hasModule, parameters: ['MessagesAdvanced']}
+
+  message_templates_page:
+    action: 'display'
+    services:
+      access:
+        - {function: hasAbility, parameters: [{action: 'manage', subject: 'mails'},{action: 'manage', subject: 'emails'},{action: 'manage', subject: 'sms'}]}
+      organization:
+        - {function: hasModule, parameters: ['MessagesAdvanced']}

+ 4 - 0
lang/layout/fr-FR.js

@@ -27,5 +27,9 @@ export default (context, locale) => {
     pes_export: 'Export JVS',
     berger_levrault_export: 'Export Berger Levrault',
     jvs_export: 'Export JVS',
+    inbox: 'Boite d\'envoi',
+    message_send: 'Éléments envoyés',
+    message_templates: 'Modèles',
+    communication: 'Communication',
   })
 }

+ 28 - 0
use/template/menu.ts

@@ -48,6 +48,9 @@ class Menu{
     const billingMenu = this.billingMenu()
     if(billingMenu) menu.push(billingMenu)
 
+    const communicationMenu = this.communicationMenu()
+    if(communicationMenu) menu.push(communicationMenu)
+
     return ref(menu)
   }
 
@@ -198,6 +201,31 @@ class Menu{
     return children.length > 0 ? this.constructMenu('fa-euro-sign', 'billing', undefined, undefined, children) : null;
   }
 
+  /**
+   * Construit le menu Communication ou null si aucune page accessible
+   * @return {ItemMenu | null}
+   */
+  communicationMenu():ItemMenu | null {
+    const children:ItemsMenu = [];
+
+    if (this.$ability().can('display', 'inbox_page')) {
+      children.push(this.constructMenu('fa-inbox', 'inbox', '/messages/list/', true))
+    }
+
+    if (this.$ability().can('display', 'message_send_page')) {
+      children.push(this.constructMenu('fa-paper-plane', 'message_send', '/messagessends/list/', true))
+    }
+
+    if (this.$ability().can('display', 'message_templates_page')) {
+      children.push(this.constructMenu('fa-edit', 'message_templates', '/templates/list/', true))
+    }
+
+    if(children.length === 1){
+      return children[0];
+    }
+    return children.length > 0 ? this.constructMenu('fa-comments', 'communication', undefined, undefined, children) : null;
+  }
+
 
   /**
    * Construit un ItemMenu