@ecodev/natural 41.0.0 → 41.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -654,6 +654,18 @@
654
654
  return source;
655
655
  }
656
656
  }
657
+ /**
658
+ * Copy text to clipboard.
659
+ * Accepts line breaks `\n` as textarea do.
660
+ */
661
+ function copyToClipboard(document, text) {
662
+ var input = document.createElement('textarea');
663
+ document.body.append(input);
664
+ input.value = text;
665
+ input.select();
666
+ document.execCommand('copy');
667
+ document.body.removeChild(input);
668
+ }
657
669
 
658
670
  // Basic; loosely typed structure for graphql-doctrine filters
659
671
  // Logical operator to be used in conditions
@@ -742,9 +754,13 @@
742
754
  }
743
755
  this.updateVariables();
744
756
  };
757
+ /**
758
+ * Return a deep clone of the variables for the given channel name.
759
+ *
760
+ * Avoid returning the same reference to prevent an attribute change, then another channel update that would
761
+ * used this changed attribute without having explicitly asked QueryVariablesManager to update it.
762
+ */
745
763
  NaturalQueryVariablesManager.prototype.get = function (channelName) {
746
- // Avoid to return the same reference to prevent an attribute change, then another channel update that would used this changed
747
- // attribute without having explicitly asked QueryVariablesManager to update it.
748
764
  return lodashEs.cloneDeep(this.channels.get(channelName));
749
765
  };
750
766
  /**
@@ -8816,6 +8832,13 @@
8816
8832
  * no effect.
8817
8833
  */
8818
8834
  _this.selectable = false;
8835
+ /**
8836
+ * If true, the file selection will be broadcast through `NaturalFileService.filesChanged`.
8837
+ *
8838
+ * It is useful to set this to false if there is two upload on a page with different purpose
8839
+ * and the second upload should not be confused with the first one.
8840
+ */
8841
+ _this.broadcast = true;
8819
8842
  /**
8820
8843
  * The single valid file that has been selected.
8821
8844
  *
@@ -8909,7 +8932,9 @@
8909
8932
  }
8910
8933
  if (selection.valid.length || selection.invalid.length) {
8911
8934
  this.filesChange.emit(selection);
8912
- this.naturalFileService.filesChanged.next(selection);
8935
+ if (this.broadcast) {
8936
+ this.naturalFileService.filesChanged.next(selection);
8937
+ }
8913
8938
  }
8914
8939
  this.getFileElement().value = '';
8915
8940
  };
@@ -8998,6 +9023,7 @@
8998
9023
  maxSize: [{ type: i0.Input }],
8999
9024
  fileSelectionDisabled: [{ type: i0.Input }],
9000
9025
  selectable: [{ type: i0.Input }],
9026
+ broadcast: [{ type: i0.Input }],
9001
9027
  fileChange: [{ type: i0.Output }],
9002
9028
  filesChange: [{ type: i0.Output }],
9003
9029
  onChange: [{ type: i0.HostListener, args: ['change', ['$event'],] }]
@@ -9082,7 +9108,9 @@
9082
9108
  this.closeDrags();
9083
9109
  };
9084
9110
  NaturalFileDropDirective.prototype.hasObservers = function () {
9085
- return this.fileChange.observed || this.filesChange.observed || this.naturalFileService.filesChanged.observed;
9111
+ return (this.fileChange.observed ||
9112
+ this.filesChange.observed ||
9113
+ (this.broadcast && this.naturalFileService.filesChanged.observed));
9086
9114
  };
9087
9115
  return NaturalFileDropDirective;
9088
9116
  }(NaturalAbstractFile));
@@ -10027,7 +10055,7 @@
10027
10055
  NaturalRelationsComponent.decorators = [
10028
10056
  { type: i0.Component, args: [{
10029
10057
  selector: 'natural-relations',
10030
- template: "<div class=\"body\">\n <ng-template #defaultNameCell let-item=\"item\">\n {{ getDisplayFn()(item) }}\n </ng-template>\n\n <table *ngIf=\"dataSource\" [dataSource]=\"dataSource\" class=\"natural-row-click\" mat-table>\n <tr *matHeaderRowDef=\"displayedColumns\" mat-header-row style=\"display: none\"></tr>\n <tr *matRowDef=\"let row; columns: displayedColumns\" mat-row></tr>\n\n <ng-container matColumnDef=\"name\">\n <th *matHeaderCellDef i18n mat-header-cell>Titre</th>\n <td *matCellDef=\"let item\" mat-cell>\n <ng-template\n [ngTemplateOutletContext]=\"{item: item}\"\n [ngTemplateOutlet]=\"itemTemplate ? itemTemplate : defaultNameCell\"\n ></ng-template>\n </td>\n </ng-container>\n\n <ng-container matColumnDef=\"unlink\">\n <th *matHeaderCellDef mat-header-cell></th>\n <td *matCellDef=\"let element\" mat-cell>\n <button\n (click)=\"removeRelation(element)\"\n color=\"warn\"\n mat-icon-button\n i18n-matTooltip\n matTooltip=\"Dissocier\"\n >\n <natural-icon name=\"link_off\"></natural-icon>\n </button>\n </td>\n </ng-container>\n </table>\n\n <mat-paginator\n (page)=\"pagination($event)\"\n *ngIf=\"dataSource?.data && (dataSource?.data?.length || 0) > (dataSource?.data?.pageSize || 0)\"\n [length]=\"dataSource?.data?.length || 0\"\n [pageIndex]=\"dataSource?.data?.pageIndex || 0\"\n [pageSizeOptions]=\"pageSizeOptions\"\n [pageSize]=\"dataSource?.data?.pageSize || 0\"\n ></mat-paginator>\n\n <div *ngIf=\"!loading && dataSource?.data?.length === 0\" class=\"margin-v mat-body\">\n <span i18n>Aucun r\u00E9sultat</span>\n </div>\n\n <mat-progress-spinner *ngIf=\"loading\" [diameter]=\"40\" class=\"loading\" mode=\"indeterminate\"></mat-progress-spinner>\n</div>\n\n<natural-select\n #select\n (selectionChange)=\"addRelations([$any($event)])\"\n *ngIf=\"!hierarchicSelectorConfig && service && !disabled\"\n [displayWith]=\"getDisplayFn()\"\n [filter]=\"autocompleteSelectorFilter\"\n [placeholder]=\"placeholder\"\n [service]=\"service\"\n [showIcon]=\"false\"\n></natural-select>\n\n<div *ngIf=\"hierarchicSelectorConfig && !disabled\">\n <button (click)=\"openNaturalHierarchicSelector()\" color=\"primary\" mat-flat-button>{{ placeholder }}</button>\n</div>\n",
10058
+ template: "<div class=\"body\">\n <ng-template #defaultNameCell let-item=\"item\">\n {{ getDisplayFn()(item) }}\n </ng-template>\n\n <table *ngIf=\"dataSource\" [dataSource]=\"dataSource\" class=\"natural-row-click\" mat-table>\n <tr *matHeaderRowDef=\"displayedColumns\" mat-header-row style=\"display: none\"></tr>\n <tr *matRowDef=\"let row; columns: displayedColumns\" mat-row></tr>\n\n <ng-container matColumnDef=\"name\">\n <th *matHeaderCellDef i18n mat-header-cell>Titre</th>\n <td *matCellDef=\"let item\" mat-cell>\n <ng-template\n [ngTemplateOutletContext]=\"{item: item}\"\n [ngTemplateOutlet]=\"itemTemplate ? itemTemplate : defaultNameCell\"\n ></ng-template>\n </td>\n </ng-container>\n\n <ng-container matColumnDef=\"unlink\">\n <th *matHeaderCellDef mat-header-cell></th>\n <td *matCellDef=\"let element\" mat-cell>\n <button\n *ngIf=\"!disabled\"\n (click)=\"removeRelation(element)\"\n color=\"warn\"\n mat-icon-button\n i18n-matTooltip\n matTooltip=\"Dissocier\"\n >\n <natural-icon name=\"link_off\"></natural-icon>\n </button>\n </td>\n </ng-container>\n </table>\n\n <mat-paginator\n (page)=\"pagination($event)\"\n *ngIf=\"dataSource?.data && (dataSource?.data?.length || 0) > (dataSource?.data?.pageSize || 0)\"\n [length]=\"dataSource?.data?.length || 0\"\n [pageIndex]=\"dataSource?.data?.pageIndex || 0\"\n [pageSizeOptions]=\"pageSizeOptions\"\n [pageSize]=\"dataSource?.data?.pageSize || 0\"\n ></mat-paginator>\n\n <div *ngIf=\"!loading && dataSource?.data?.length === 0\" class=\"margin-v mat-body\">\n <span i18n>Aucun r\u00E9sultat</span>\n </div>\n\n <mat-progress-spinner *ngIf=\"loading\" [diameter]=\"40\" class=\"loading\" mode=\"indeterminate\"></mat-progress-spinner>\n</div>\n\n<natural-select\n #select\n (selectionChange)=\"addRelations([$any($event)])\"\n *ngIf=\"!hierarchicSelectorConfig && service && !disabled\"\n [displayWith]=\"getDisplayFn()\"\n [filter]=\"autocompleteSelectorFilter\"\n [placeholder]=\"placeholder\"\n [service]=\"service\"\n [showIcon]=\"false\"\n></natural-select>\n\n<div *ngIf=\"hierarchicSelectorConfig && !disabled\">\n <button (click)=\"openNaturalHierarchicSelector()\" color=\"primary\" mat-flat-button>{{ placeholder }}</button>\n</div>\n",
10031
10059
  styles: [":host{display:flex;flex-direction:column}:host>*:not(:last-child){margin-bottom:20px}:host .body{display:flex;flex-direction:column}:host .loading{margin:20px auto}:host .mat-column-unlink{width:2.5em}\n"]
10032
10060
  },] }
10033
10061
  ];
@@ -11236,6 +11264,7 @@
11236
11264
  exports.cancellableTimeout = cancellableTimeout;
11237
11265
  exports.cleanSameValues = cleanSameValues;
11238
11266
  exports.collectErrors = collectErrors;
11267
+ exports.copyToClipboard = copyToClipboard;
11239
11268
  exports.debug = debug;
11240
11269
  exports.decimal = decimal;
11241
11270
  exports.deliverableEmail = deliverableEmail;