name: persons-app
icon: icon-persona
appClass: info.magnolia.ui.framework.app.BaseApp
class: info.magnolia.ui.contentapp.configuration.ContentAppDescriptor

datasource: &datasource
  $type: jcrDatasource
  workspace: persons
  nodeNameProperty: jcrName
  #This is a custom class check further info https://jira.magnolia-cms.com/browse/SUPPORT-13322
  #TODO commented to not block you!
  #preview:
  #  class: info.magnolia.ui.contentapp.preview.PxcJcrPreviewDefinition
  #  damLinkPropertyName: personalPagePicture
  rootPath: /persons
  allowedNodeTypes:
    - mgnl:person

subApps:
  browser:
    class: info.magnolia.ui.contentapp.configuration.BrowserDescriptor
    workbench:
      contentViews:
        - name: tree
          $type: treeView
          columns:
            - name: jcrName
              $type: jcrTitleColumn
              nodeTypeToIcon:
                mgnl:folder: icon-folder
    actions:
      addPerson:
        icon: icon-add-item
        $type: openDetailSubappAction
        appName: persons-app
        subAppName: detail
        viewType: add
        availability:
          root: true
          nodeTypes:
            person: 'mgnl:person'
          rules:
            IsNotDeletedRule: &IsNotDeletedRule
              $type: jcrIsDeletedRule
              negate: true
      editPerson:
        $type: openDetailSubappAction
        icon: icon-edit
        appName: persons-app
        subAppName: detail
        viewType: edit
        availability:
          nodeTypes:
            person: 'mgnl:person'
          rules:
            IsNotDeletedRule: *IsNotDeletedRule
      activate:
        $type: jcrCommandAction
        command: publish
        icon: icon-publish
        asynchronous: true
        timeToWait: 0
        description: Publishing persons info
        availability:
          writePermissionRequired: true
          rules:
            IsNotDeletedRule: *IsNotDeletedRule
      deactivate:
        $type: jcrCommandAction
        command: unpublish
        icon: icon-unpublish
        asynchronous: true
        timeToWait: 0
        description: Publishing persons info
        availability:
          rules:
            IsPublishedRule:
              $type: jcrPublishedRule
      confirmDeletePerson:
        $type: contentDependencies:deleteConfirmationAction
        icon: icon-delete
        successActionName: delete
        availability:
          multiple: true
          writePermissionRequired: true
          rules:
            IsNotDeletedRule: *IsNotDeletedRule
        references:
          website:
            nodeType: mgnl:page
            workspace: website
      delete:
        $type: markAsDeletedAction
        asynchronous: true
        timeToWait: 0
        description: Deleting persons info
        availability:
          writePermissionRequired: true
      exportYAML:
        icon: icon-export
        $type: exportAction
        label: Export to YAML
        availability:
          rules:
            IsNotDeletedRule: *IsNotDeletedRule
      exportXML:
        icon: icon-export
        $type: exportAction
        label: Export to XML
        format: xml
        availability:
          rules:
            IsNotDeletedRule: *IsNotDeletedRule
      import:
        icon: icon-import
        $type: openDialogAction
        dialogId: ui-framework-jcr:import
        availability:
          root: true
          writePermissionRequired: true
          rules:
            IsNotDeletedRule: *IsNotDeletedRule
      restorePreviousVersion:
        icon: icon-undo
        $type: restorePreviousJcrVersionAction
        availability:
          writePermissionRequired: true
          rules:
            IsDeletedRule: &IsDeletedRule
              $type: jcrIsDeletedRule
            HasVersionsRule:
              $type: jcrHasVersionsRule
      activateDeleted:
        icon: icon-publish
        $type: jcrCommandAction
        command: publish
        catalog: versioned
        availability:
          writePermissionRequired: true
          rules:
            IsDeletedRule: *IsDeletedRule

    actionbar:
      defaultAction: editPerson
      sections:
        root:
          label: Person creation
          availability:
            nodes: false
            root: true
          groups:
            addActions:
              items:
                addPerson: {}
            importExportActions:
              items:
                import: {}
        deletedPerson:
          availability:
            nodeTypes:
              person: mgnl:person
            rules:
              IsDeletedRule: *IsDeletedRule
          groups:
            activationActions:
              items:
                activateDeleted: { }
                deactivate: {}
            deletedActions:
              items:
                restorePreviousVersion: {}
        person:
          availability:
            nodeTypes:
              person: mgnl:person
          groups:
            editActions:
              items:
                editPerson: {}
                confirmDeletePerson: {}
            activationActions:
              items:
                activate: {}
                deactivate: {}
            importExportActions:
              items:
                exportYAML: {}
                exportXML: {}

    # workbench:
    #   contentViews:
    #     - !include  /pxc-core/includes/workbench/persons/app-columns-treeView.yaml
    #     - !include  /pxc-core/includes/workbench/persons/app-columns-listView.yaml
    #     - !include  /pxc-core/includes/workbench/persons/app-columns-thumbnailView.yaml

  detail:
    class: info.magnolia.ui.contentapp.detail.DetailDescriptor
    itemProvider:
      $type: jcrNodeFromLocationProvider
      workspace: persons
      nodeType: mgnl:person
    datasource:
      <<: *datasource
      describeByProperty: jcrName
    form:
      properties:
        firstName:
          $type: textField
          required: true
        lastName:
          $type: textField
          required: true
        personCategory:
          $type: checkBoxGroupField
          required: true
          datasource:
            $type: optionListDatasource
            options:
              executiveCommittee:
                value: executiveCommittee
              board:
                value: board
              other:
                value: other
        function:
          $type: textField
          required: true
          i18n: true
        personalPageLink:
          $type: pageLinkField
          textInputAllowed: true
        personalPagePicture:
          $type: damLinkField
        personalPagePictureMobile:
          $type: damLinkField
        carouselPicture:
          $type: damLinkField
        quotePicture:
          $type: damLinkField
        twitterLink:
          $type: textField
        linkedInLink:
          $type: textField
      layout:
        $type: tabbedLayout
        tabs:
          tabMain:
            fields:
              - name: firstName
              - name: lastName
              - name: personCategory
              - name: function
              - name: personalPageLink
              - name: personalPagePicture
              - name: personalPagePictureMobile
              - name: carouselPicture
              - name: quotePicture
              - name: twitterLink
              - name: linkedInLink
  #   # actions:
  #   #   commit:
  #   #     class: be.belgacom.pxc.core.actions.SaveDetailFormPersonActionDefinition
  #   #     browserName: ''
  #   #   cancel:
  #   #     $type: closeAction