<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to permanently delete items in search trash? in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-permanently-delete-items-in-search-trash/m-p/316911#M3912</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;the solution to this is quite tricky, as I think there is a small bug in "nuxeo-delete-documents-button" element, more specifically in the "_isAvailable" function. Anyway, here is the step-by-step solution:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1)&lt;/STRONG&gt; First of all, create your own "nuxeo-delete-documents-button" element. Take special attention to the "_isAvailable" function, as I have changed it. The last condition should be &lt;STRONG&gt;this.hard &amp;amp;&amp;amp; this._checkDocsAreTrashed()&lt;/STRONG&gt;. In this way, the "hard delete" button will only appears if you are selecting trashed documents.&lt;/P&gt;
&lt;P&gt;As you are creating a new element, remember to change its "id" in the first line and in the Polymer script. In my case, for example, I named it "nuxeo-delete-documents-button-v2".&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dom-module id="nuxeo-delete-documents-button-v2" assetpath="nuxeo-document-bulk-actions/"&amp;gt;
  &amp;lt;template&amp;gt;
    &amp;lt;style include="nuxeo-action-button-styles"&amp;gt;&amp;lt;/style&amp;gt;

    &amp;lt;nuxeo-operation id="deleteOp" op="Document.Delete" sync-indexing=""&amp;gt;&amp;lt;/nuxeo-operation&amp;gt;

    &amp;lt;nuxeo-operation id="trashOp" op="Document.Trash" sync-indexing=""&amp;gt;&amp;lt;/nuxeo-operation&amp;gt;

    &amp;lt;template is="dom-if" if="[[_isAvailable(documents.splices)]]"&amp;gt;
      &amp;lt;div class="action" on-tap="deleteDocuments"&amp;gt;
        &amp;lt;paper-icon-button icon="[[_icon]]" id="deleteAllButton"&amp;gt;&amp;lt;/paper-icon-button&amp;gt;
        &amp;lt;span class="label" hidden$="[[!showLabel]]"&amp;gt;[[_label]]&amp;lt;/span&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;nuxeo-tooltip for="deleteAllButton" position="[[tooltipPosition]]"&amp;gt;[[_label]]&amp;lt;/nuxeo-tooltip&amp;gt;
    &amp;lt;/template&amp;gt;
  &amp;lt;/template&amp;gt;

  &amp;lt;script&amp;gt;
    Polymer({
      is: 'nuxeo-delete-documents-button-v2',
      behaviors: [Nuxeo.I18nBehavior, Nuxeo.FiltersBehavior],
      properties: {
        documents: {
          type: Array,
          notify: true,
          value: []
        },

        /**
         * Permanently delete the documents.
         */
        hard: {
          type: Boolean,
          value: false
        },

        tooltipPosition: {
          type: String,
          value: 'bottom'
        },

        /**
         * `true` if the action should display the label, `false` otherwise.
         */
        showLabel: {
          type: Boolean,
          value: false,
        },

        _icon: {
          type: 'String',
          computed: '_computeIcon(hard)'
        },

        _label: {
          type: 'String',
          computed: '_computeLabel(hard, i18n)'
        }
      },

      deleteDocuments: function() {
        if (this.docsHavePermissions &amp;amp;&amp;amp; confirm(this.i18n('deleteDocumentsButton.confirm.deleteDocuments'))) {
          if (this.documents &amp;amp;&amp;amp; this.documents.length) {
            var uids = this.documents.map(function(doc) {
              return doc.uid;
            }).join(',');
            var op = this.hard ? this.$.deleteOp : this.$.trashOp;
            op.input = 'docs:' + uids;
            op.execute().then(function() {
              this.fire('nuxeo-documents-deleted', {documents: this.documents});
              this.documents = [];
              this.fire('refresh');
            }.bind(this),
            function(error) {
              this.fire('nuxeo-documents-deleted', {error: error, documents: this.documents});
            }.bind(this));
          }
        }
      },

      /**
       * Action is available if all selected items are not trashed and `hard` is not active OR if all selected items
       * are trashed and `hard` is active.
       */
      _isAvailable: function() {
        return this.documents &amp;amp;&amp;amp; this.documents.length &amp;gt; 0 &amp;amp;&amp;amp; this._checkDocsPermissions() &amp;amp;&amp;amp;
            (this.hard &amp;amp;&amp;amp; this._checkDocsAreTrashed());
      },

      /**
       * Checks if all selected documents are trashed.
       */
      _checkDocsAreTrashed: function() {
        return this.documents.every(function(document) {
          return this.isTrashed(document);
        }.bind(this));
      },

      _checkDocsPermissions: function() {
        this.docsHavePermissions = this.documents &amp;amp;&amp;amp; !(this.documents.some(
          function(document) {
            return !this._docHasPermissions(document);
          }.bind(this)));
        return this.docsHavePermissions;
      },

      /*
       * Checks if a single given document has 'Everything' permission to delete or 'Write' to trash
       */
      _docHasPermissions: function(document) {
        return this.hasPermission(document, 'Everything') || (!this.hard &amp;amp;&amp;amp; this.hasPermission(document, 'Write'));
      },

      _computeIcon: function(hard) {
        return hard ? 'nuxeo:delete-permanently' : 'nuxeo:delete';
      },

      _computeLabel: function(hard) {
        return this.i18n(hard ? 'deleteDocumentsButton.tooltip.permanently' : 'deleteDocumentsButton.tooltip');
      }
    });
  &amp;lt;/script&amp;gt;

&amp;lt;/dom-module&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;2)&lt;/STRONG&gt; The next step is to contribute to the "RESULTS_SELECTION_ACTIONS" slot. You can do this by creating another HTML file with the following content. I named this file "nuxeo-custom-bundle-contribution.html", but you can name it as you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;link rel="import" href="nuxeo-delete-documents-button-v2.html"&amp;gt;

&amp;lt;nuxeo-slot-content name="hardDeleteSelectionAction" slot="RESULTS_SELECTION_ACTIONS" order="30"&amp;gt;
  &amp;lt;template&amp;gt;
    &amp;lt;nuxeo-delete-documents-button-v2 documents="[[selectedItems]]" hard&amp;gt;&amp;lt;/nuxeo-delete-documents-button-v2&amp;gt;
  &amp;lt;/template&amp;gt;
&amp;lt;/nuxeo-slot-content&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Take in mind that you need to import the HTML we have created before, and add the new element (that in my case, I named "nuxeo-delete-documents-button-v2"). Also pay attention to the "hard" label I have added in the element.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;3)&lt;/STRONG&gt; Just like any WebUI contribution, you need to add it to the resources point. To do that, create a new extension like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;extension target="org.nuxeo.ecm.platform.WebResources" point="resources"&amp;gt;
    &amp;lt;resource name="nuxeo-custom-bundle-contribution.html" type="import" shrinkable="false"&amp;gt;
	&amp;lt;uri&amp;gt;/ui/nuxeo-custom-bundle-contribution.html&amp;lt;/uri&amp;gt;
    &amp;lt;/resource&amp;gt;
&amp;lt;/extension&amp;gt;
&amp;lt;extension target="org.nuxeo.ecm.platform.WebResources" point="bundles"&amp;gt;
    &amp;lt;bundle name="web-ui"&amp;gt;
	&amp;lt;resources append="true"&amp;gt;
	        &amp;lt;resource&amp;gt;nuxeo-custom-bundle-contribution.html&amp;lt;/resource&amp;gt;
	&amp;lt;/resources&amp;gt;
    &amp;lt;/bundle&amp;gt;
&amp;lt;/extension&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see, I have referenced "nuxeo-custom-bundle-contribution.html" file, which is the file I have created in step 2.&lt;/P&gt;
&lt;P&gt;With this, you will have the "hard delete" button when you select trashed documents, keeping the "trash document" button if you select not trashed documents.&lt;/P&gt;
&lt;P&gt;Regards!&lt;/P&gt;</description>
    <pubDate>Sat, 07 Mar 2020 10:18:40 GMT</pubDate>
    <dc:creator>Rodri_</dc:creator>
    <dc:date>2020-03-07T10:18:40Z</dc:date>
    <item>
      <title>How to permanently delete items in search trash?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-permanently-delete-items-in-search-trash/m-p/316908#M3909</link>
      <description>&lt;P&gt;How to permanently delete items in search trash?&lt;/P&gt;
&lt;P&gt;In Web UI :&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;No action button as "empty trash" is visible&lt;/LI&gt;
&lt;LI&gt;No action button appears in blue menu bar when items are selected&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;If it is not possible in Web UI, is there any solution using Nuxeo API?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 16:06:09 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-permanently-delete-items-in-search-trash/m-p/316908#M3909</guid>
      <dc:creator>Jean-Michel_Cau</dc:creator>
      <dc:date>2020-03-05T16:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to permanently delete items in search trash?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-permanently-delete-items-in-search-trash/m-p/316909#M3910</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;You need to disable solft delete default config (see &lt;A href="https://doc.nuxeo.com/nxdoc/trash-service/#soft-delete"&gt;https://doc.nuxeo.com/nxdoc/trash-service/#soft-delete&lt;/A&gt; and optionally remove the corresponding Web UI slot contribution &lt;A href="https://doc.nuxeo.com/nxdoc/how-to-disable-trash/"&gt;https://doc.nuxeo.com/nxdoc/how-to-disable-trash/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 16:13:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-permanently-delete-items-in-search-trash/m-p/316909#M3910</guid>
      <dc:creator>Gregory_Carlin</dc:creator>
      <dc:date>2020-03-05T16:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to permanently delete items in search trash?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-permanently-delete-items-in-search-trash/m-p/316910#M3911</link>
      <description>&lt;P&gt;Thanks, but I don't want to remove soft delete feature.
I just want to have a hard delete action to permanently delete document when browsing the trash search.
This action is available on a folder document but not in trash search...
Regards&lt;/P&gt;</description>
      <pubDate>Thu, 05 Mar 2020 16:40:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-permanently-delete-items-in-search-trash/m-p/316910#M3911</guid>
      <dc:creator>Jean-Michel_Cau</dc:creator>
      <dc:date>2020-03-05T16:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to permanently delete items in search trash?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-permanently-delete-items-in-search-trash/m-p/316911#M3912</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;the solution to this is quite tricky, as I think there is a small bug in "nuxeo-delete-documents-button" element, more specifically in the "_isAvailable" function. Anyway, here is the step-by-step solution:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1)&lt;/STRONG&gt; First of all, create your own "nuxeo-delete-documents-button" element. Take special attention to the "_isAvailable" function, as I have changed it. The last condition should be &lt;STRONG&gt;this.hard &amp;amp;&amp;amp; this._checkDocsAreTrashed()&lt;/STRONG&gt;. In this way, the "hard delete" button will only appears if you are selecting trashed documents.&lt;/P&gt;
&lt;P&gt;As you are creating a new element, remember to change its "id" in the first line and in the Polymer script. In my case, for example, I named it "nuxeo-delete-documents-button-v2".&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dom-module id="nuxeo-delete-documents-button-v2" assetpath="nuxeo-document-bulk-actions/"&amp;gt;
  &amp;lt;template&amp;gt;
    &amp;lt;style include="nuxeo-action-button-styles"&amp;gt;&amp;lt;/style&amp;gt;

    &amp;lt;nuxeo-operation id="deleteOp" op="Document.Delete" sync-indexing=""&amp;gt;&amp;lt;/nuxeo-operation&amp;gt;

    &amp;lt;nuxeo-operation id="trashOp" op="Document.Trash" sync-indexing=""&amp;gt;&amp;lt;/nuxeo-operation&amp;gt;

    &amp;lt;template is="dom-if" if="[[_isAvailable(documents.splices)]]"&amp;gt;
      &amp;lt;div class="action" on-tap="deleteDocuments"&amp;gt;
        &amp;lt;paper-icon-button icon="[[_icon]]" id="deleteAllButton"&amp;gt;&amp;lt;/paper-icon-button&amp;gt;
        &amp;lt;span class="label" hidden$="[[!showLabel]]"&amp;gt;[[_label]]&amp;lt;/span&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;nuxeo-tooltip for="deleteAllButton" position="[[tooltipPosition]]"&amp;gt;[[_label]]&amp;lt;/nuxeo-tooltip&amp;gt;
    &amp;lt;/template&amp;gt;
  &amp;lt;/template&amp;gt;

  &amp;lt;script&amp;gt;
    Polymer({
      is: 'nuxeo-delete-documents-button-v2',
      behaviors: [Nuxeo.I18nBehavior, Nuxeo.FiltersBehavior],
      properties: {
        documents: {
          type: Array,
          notify: true,
          value: []
        },

        /**
         * Permanently delete the documents.
         */
        hard: {
          type: Boolean,
          value: false
        },

        tooltipPosition: {
          type: String,
          value: 'bottom'
        },

        /**
         * `true` if the action should display the label, `false` otherwise.
         */
        showLabel: {
          type: Boolean,
          value: false,
        },

        _icon: {
          type: 'String',
          computed: '_computeIcon(hard)'
        },

        _label: {
          type: 'String',
          computed: '_computeLabel(hard, i18n)'
        }
      },

      deleteDocuments: function() {
        if (this.docsHavePermissions &amp;amp;&amp;amp; confirm(this.i18n('deleteDocumentsButton.confirm.deleteDocuments'))) {
          if (this.documents &amp;amp;&amp;amp; this.documents.length) {
            var uids = this.documents.map(function(doc) {
              return doc.uid;
            }).join(',');
            var op = this.hard ? this.$.deleteOp : this.$.trashOp;
            op.input = 'docs:' + uids;
            op.execute().then(function() {
              this.fire('nuxeo-documents-deleted', {documents: this.documents});
              this.documents = [];
              this.fire('refresh');
            }.bind(this),
            function(error) {
              this.fire('nuxeo-documents-deleted', {error: error, documents: this.documents});
            }.bind(this));
          }
        }
      },

      /**
       * Action is available if all selected items are not trashed and `hard` is not active OR if all selected items
       * are trashed and `hard` is active.
       */
      _isAvailable: function() {
        return this.documents &amp;amp;&amp;amp; this.documents.length &amp;gt; 0 &amp;amp;&amp;amp; this._checkDocsPermissions() &amp;amp;&amp;amp;
            (this.hard &amp;amp;&amp;amp; this._checkDocsAreTrashed());
      },

      /**
       * Checks if all selected documents are trashed.
       */
      _checkDocsAreTrashed: function() {
        return this.documents.every(function(document) {
          return this.isTrashed(document);
        }.bind(this));
      },

      _checkDocsPermissions: function() {
        this.docsHavePermissions = this.documents &amp;amp;&amp;amp; !(this.documents.some(
          function(document) {
            return !this._docHasPermissions(document);
          }.bind(this)));
        return this.docsHavePermissions;
      },

      /*
       * Checks if a single given document has 'Everything' permission to delete or 'Write' to trash
       */
      _docHasPermissions: function(document) {
        return this.hasPermission(document, 'Everything') || (!this.hard &amp;amp;&amp;amp; this.hasPermission(document, 'Write'));
      },

      _computeIcon: function(hard) {
        return hard ? 'nuxeo:delete-permanently' : 'nuxeo:delete';
      },

      _computeLabel: function(hard) {
        return this.i18n(hard ? 'deleteDocumentsButton.tooltip.permanently' : 'deleteDocumentsButton.tooltip');
      }
    });
  &amp;lt;/script&amp;gt;

&amp;lt;/dom-module&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;2)&lt;/STRONG&gt; The next step is to contribute to the "RESULTS_SELECTION_ACTIONS" slot. You can do this by creating another HTML file with the following content. I named this file "nuxeo-custom-bundle-contribution.html", but you can name it as you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;link rel="import" href="nuxeo-delete-documents-button-v2.html"&amp;gt;

&amp;lt;nuxeo-slot-content name="hardDeleteSelectionAction" slot="RESULTS_SELECTION_ACTIONS" order="30"&amp;gt;
  &amp;lt;template&amp;gt;
    &amp;lt;nuxeo-delete-documents-button-v2 documents="[[selectedItems]]" hard&amp;gt;&amp;lt;/nuxeo-delete-documents-button-v2&amp;gt;
  &amp;lt;/template&amp;gt;
&amp;lt;/nuxeo-slot-content&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Take in mind that you need to import the HTML we have created before, and add the new element (that in my case, I named "nuxeo-delete-documents-button-v2"). Also pay attention to the "hard" label I have added in the element.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;3)&lt;/STRONG&gt; Just like any WebUI contribution, you need to add it to the resources point. To do that, create a new extension like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;extension target="org.nuxeo.ecm.platform.WebResources" point="resources"&amp;gt;
    &amp;lt;resource name="nuxeo-custom-bundle-contribution.html" type="import" shrinkable="false"&amp;gt;
	&amp;lt;uri&amp;gt;/ui/nuxeo-custom-bundle-contribution.html&amp;lt;/uri&amp;gt;
    &amp;lt;/resource&amp;gt;
&amp;lt;/extension&amp;gt;
&amp;lt;extension target="org.nuxeo.ecm.platform.WebResources" point="bundles"&amp;gt;
    &amp;lt;bundle name="web-ui"&amp;gt;
	&amp;lt;resources append="true"&amp;gt;
	        &amp;lt;resource&amp;gt;nuxeo-custom-bundle-contribution.html&amp;lt;/resource&amp;gt;
	&amp;lt;/resources&amp;gt;
    &amp;lt;/bundle&amp;gt;
&amp;lt;/extension&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see, I have referenced "nuxeo-custom-bundle-contribution.html" file, which is the file I have created in step 2.&lt;/P&gt;
&lt;P&gt;With this, you will have the "hard delete" button when you select trashed documents, keeping the "trash document" button if you select not trashed documents.&lt;/P&gt;
&lt;P&gt;Regards!&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 10:18:40 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-permanently-delete-items-in-search-trash/m-p/316911#M3912</guid>
      <dc:creator>Rodri_</dc:creator>
      <dc:date>2020-03-07T10:18:40Z</dc:date>
    </item>
  </channel>
</rss>

