@den4ik92/ng2-smart-table 19.2.3 → 19.2.4

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.
@@ -1761,14 +1761,15 @@ class TbodyCustomComponent {
1761
1761
  }
1762
1762
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TbodyCustomComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1763
1763
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: TbodyCustomComponent, isStandalone: true, selector: "ng2-st-tbody-custom", inputs: { grid: "grid", row: "row", source: "source" }, outputs: { custom: "custom" }, ngImport: i0, template: `
1764
- @for (action of customActions(); track $index) {
1764
+ @for (action of customActions(); track $index) { @if(!action.hasPermissionFunction ? true :
1765
+ action.hasPermissionFunction(row.getData())) {
1765
1766
  <a
1766
1767
  [id]="'row-' + row.index + '_action-' + action.name + '-button'"
1767
1768
  href="#"
1768
1769
  class="ng2-smart-action ng2-smart-action-custom-custom"
1769
1770
  [innerHTML]="action.title"
1770
1771
  (click)="$event.stopPropagation(); $event.preventDefault(); onCustom(action)"></a>
1771
- }
1772
+ } }
1772
1773
  `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1773
1774
  }
1774
1775
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TbodyCustomComponent, decorators: [{
@@ -1777,14 +1778,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
1777
1778
  selector: 'ng2-st-tbody-custom',
1778
1779
  changeDetection: ChangeDetectionStrategy.OnPush,
1779
1780
  template: `
1780
- @for (action of customActions(); track $index) {
1781
+ @for (action of customActions(); track $index) { @if(!action.hasPermissionFunction ? true :
1782
+ action.hasPermissionFunction(row.getData())) {
1781
1783
  <a
1782
1784
  [id]="'row-' + row.index + '_action-' + action.name + '-button'"
1783
1785
  href="#"
1784
1786
  class="ng2-smart-action ng2-smart-action-custom-custom"
1785
1787
  [innerHTML]="action.title"
1786
1788
  (click)="$event.stopPropagation(); $event.preventDefault(); onCustom(action)"></a>
1787
- }
1789
+ } }
1788
1790
  `,
1789
1791
  standalone: true,
1790
1792
  }]
@@ -1805,22 +1807,32 @@ class TbodyEditDeleteComponent {
1805
1807
  this.deleteConfirm = input.required();
1806
1808
  this.edit = output();
1807
1809
  this.delete = output();
1808
- this.isActionEdit = false;
1809
- this.isActionDelete = false;
1810
- this.isExternalMode = false;
1811
- this.editRowButtonContent = 'Edit';
1812
- this.deleteRowButtonContent = 'Delete';
1813
- effect(() => {
1814
- const settings = this.grid().settings();
1815
- const actions = settings.actions;
1816
- if (actions) {
1817
- this.isActionDelete = !!actions.delete;
1818
- this.isActionEdit = !!actions.edit;
1819
- }
1820
- this.isExternalMode = settings.mode === 'external';
1821
- this.editRowButtonContent = settings.edit ? settings.edit.editButtonContent || 'Edit' : 'Edit';
1822
- this.deleteRowButtonContent = settings.delete ? settings.delete.deleteButtonContent || 'Delete' : 'Delete';
1823
- this.cdr.detectChanges();
1810
+ this.isActionEdit = computed(() => {
1811
+ const actions = this.grid().settings().actions;
1812
+ return actions ? !!actions.edit : false;
1813
+ });
1814
+ this.isActionDelete = computed(() => {
1815
+ const actions = this.grid().settings().actions;
1816
+ return actions ? !!actions.delete : false;
1817
+ });
1818
+ this.isExternalMode = computed(() => {
1819
+ return this.grid().settings().mode === 'external';
1820
+ });
1821
+ this.canDeleteFunction = computed(() => {
1822
+ const deleteConfig = this.grid().settings().delete;
1823
+ return deleteConfig ? deleteConfig.hasPermissionFunction || ((data) => true) : (data) => true;
1824
+ });
1825
+ this.canEditFunction = computed(() => {
1826
+ const edit = this.grid().settings().edit;
1827
+ return edit ? edit.hasPermissionFunction || ((data) => true) : (data) => true;
1828
+ });
1829
+ this.editRowButtonContent = computed(() => {
1830
+ const edit = this.grid().settings().edit;
1831
+ return edit ? edit.editButtonContent || 'Edit' : 'Edit';
1832
+ });
1833
+ this.deleteRowButtonContent = computed(() => {
1834
+ const deleteConfig = this.grid().settings().delete;
1835
+ return deleteConfig ? deleteConfig.deleteButtonContent || 'Delete' : 'Delete';
1824
1836
  });
1825
1837
  }
1826
1838
  onEdit(event) {
@@ -1837,7 +1849,7 @@ class TbodyEditDeleteComponent {
1837
1849
  onDelete(event) {
1838
1850
  event.preventDefault();
1839
1851
  event.stopPropagation();
1840
- if (this.isExternalMode) {
1852
+ if (this.isExternalMode()) {
1841
1853
  this.delete.emit({
1842
1854
  data: this.row().getData(),
1843
1855
  source: this.source(),
@@ -1848,165 +1860,12 @@ class TbodyEditDeleteComponent {
1848
1860
  }
1849
1861
  }
1850
1862
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TbodyEditDeleteComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1851
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: TbodyEditDeleteComponent, isStandalone: true, selector: "ng2-st-tbody-edit-delete", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null }, row: { classPropertyName: "row", publicName: "row", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, deleteConfirm: { classPropertyName: "deleteConfirm", publicName: "deleteConfirm", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { edit: "edit", delete: "delete" }, ngImport: i0, template: `
1852
- @if (!row().pending()) { @if (isActionEdit) {
1853
- <a
1854
- href="#"
1855
- [id]="'row-' + row().index + '_action-edit-button'"
1856
- class="ng2-smart-action ng2-smart-action-edit-edit"
1857
- [innerHTML]="editRowButtonContent"
1858
- (click)="onEdit($event)"></a>
1859
- } @if (isActionDelete) {
1860
- <a
1861
- href="#"
1862
- [id]="'row-' + row().index + '_action-delete-button'"
1863
- class="ng2-smart-action ng2-smart-action-delete-delete"
1864
- [innerHTML]="deleteRowButtonContent"
1865
- (click)="onDelete($event)"></a>
1866
- } } @else {
1867
- <div style="display: flex;">
1868
- @if (isActionEdit) {
1869
- <svg
1870
- role="none"
1871
- (click)="$event.stopPropagation()"
1872
- style="height: 2rem; width: 2rem;"
1873
- version="1.1"
1874
- id="L9"
1875
- xmlns="http://www.w3.org/2000/svg"
1876
- xmlns:xlink="http://www.w3.org/1999/xlink"
1877
- x="0px"
1878
- y="0px"
1879
- viewBox="0 0 100 100"
1880
- enable-background="new 0 0 0 0"
1881
- xml:space="preserve">
1882
- <path
1883
- fill="#e9e9e9"
1884
- d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
1885
- <animateTransform
1886
- attributeName="transform"
1887
- attributeType="XML"
1888
- type="rotate"
1889
- dur="1s"
1890
- from="0 50 50"
1891
- to="360 50 50"
1892
- repeatCount="indefinite" />
1893
- </path>
1894
- </svg>
1895
- } @if (isActionDelete) {
1896
- <svg
1897
- role="none"
1898
- (click)="$event.stopPropagation()"
1899
- style="height: 2rem; width: 2rem;"
1900
- version="1.1"
1901
- id="L9"
1902
- xmlns="http://www.w3.org/2000/svg"
1903
- xmlns:xlink="http://www.w3.org/1999/xlink"
1904
- x="0px"
1905
- y="0px"
1906
- viewBox="0 0 100 100"
1907
- enable-background="new 0 0 0 0"
1908
- xml:space="preserve">
1909
- <path
1910
- fill="#e9e9e9"
1911
- d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
1912
- <animateTransform
1913
- attributeName="transform"
1914
- attributeType="XML"
1915
- type="rotate"
1916
- dur="1s"
1917
- from="0 50 50"
1918
- to="360 50 50"
1919
- repeatCount="indefinite" />
1920
- </path>
1921
- </svg>
1922
- }
1923
- </div>
1924
- }
1925
- `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1863
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.3", type: TbodyEditDeleteComponent, isStandalone: true, selector: "ng2-st-tbody-edit-delete", inputs: { grid: { classPropertyName: "grid", publicName: "grid", isSignal: true, isRequired: true, transformFunction: null }, row: { classPropertyName: "row", publicName: "row", isSignal: true, isRequired: true, transformFunction: null }, source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, deleteConfirm: { classPropertyName: "deleteConfirm", publicName: "deleteConfirm", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { edit: "edit", delete: "delete" }, ngImport: i0, template: "@if (!row().pending()) { @if (isActionEdit() && canEditFunction()(row().getData())) {\n<a\n href=\"#\"\n [id]=\"'row-' + row().index + '_action-edit-button'\"\n class=\"ng2-smart-action ng2-smart-action-edit-edit\"\n [innerHTML]=\"editRowButtonContent()\"\n (click)=\"onEdit($event)\"></a>\n} @if (isActionDelete() && canDeleteFunction()(row().getData())) {\n<a\n href=\"#\"\n [id]=\"'row-' + row().index + '_action-delete-button'\"\n class=\"ng2-smart-action ng2-smart-action-delete-delete\"\n [innerHTML]=\"deleteRowButtonContent()\"\n (click)=\"onDelete($event)\"></a>\n} } @else {\n<div style=\"display: flex\">\n @if (isActionEdit()) {\n <svg\n role=\"none\"\n (click)=\"$event.stopPropagation()\"\n style=\"height: 2rem; width: 2rem\"\n version=\"1.1\"\n id=\"L9\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 100 100\"\n enable-background=\"new 0 0 0 0\"\n xml:space=\"preserve\">\n <path\n fill=\"#e9e9e9\"\n d=\"M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50\">\n <animateTransform\n attributeName=\"transform\"\n attributeType=\"XML\"\n type=\"rotate\"\n dur=\"1s\"\n from=\"0 50 50\"\n to=\"360 50 50\"\n repeatCount=\"indefinite\" />\n </path>\n </svg>\n } @if (isActionDelete()) {\n <svg\n role=\"none\"\n (click)=\"$event.stopPropagation()\"\n style=\"height: 2rem; width: 2rem\"\n version=\"1.1\"\n id=\"L9\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 100 100\"\n enable-background=\"new 0 0 0 0\"\n xml:space=\"preserve\">\n <path\n fill=\"#e9e9e9\"\n d=\"M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50\">\n <animateTransform\n attributeName=\"transform\"\n attributeType=\"XML\"\n type=\"rotate\"\n dur=\"1s\"\n from=\"0 50 50\"\n to=\"360 50 50\"\n repeatCount=\"indefinite\" />\n </path>\n </svg>\n }\n</div>\n}\n", changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1926
1864
  }
1927
1865
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: TbodyEditDeleteComponent, decorators: [{
1928
1866
  type: Component,
1929
- args: [{
1930
- selector: 'ng2-st-tbody-edit-delete',
1931
- template: `
1932
- @if (!row().pending()) { @if (isActionEdit) {
1933
- <a
1934
- href="#"
1935
- [id]="'row-' + row().index + '_action-edit-button'"
1936
- class="ng2-smart-action ng2-smart-action-edit-edit"
1937
- [innerHTML]="editRowButtonContent"
1938
- (click)="onEdit($event)"></a>
1939
- } @if (isActionDelete) {
1940
- <a
1941
- href="#"
1942
- [id]="'row-' + row().index + '_action-delete-button'"
1943
- class="ng2-smart-action ng2-smart-action-delete-delete"
1944
- [innerHTML]="deleteRowButtonContent"
1945
- (click)="onDelete($event)"></a>
1946
- } } @else {
1947
- <div style="display: flex;">
1948
- @if (isActionEdit) {
1949
- <svg
1950
- role="none"
1951
- (click)="$event.stopPropagation()"
1952
- style="height: 2rem; width: 2rem;"
1953
- version="1.1"
1954
- id="L9"
1955
- xmlns="http://www.w3.org/2000/svg"
1956
- xmlns:xlink="http://www.w3.org/1999/xlink"
1957
- x="0px"
1958
- y="0px"
1959
- viewBox="0 0 100 100"
1960
- enable-background="new 0 0 0 0"
1961
- xml:space="preserve">
1962
- <path
1963
- fill="#e9e9e9"
1964
- d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
1965
- <animateTransform
1966
- attributeName="transform"
1967
- attributeType="XML"
1968
- type="rotate"
1969
- dur="1s"
1970
- from="0 50 50"
1971
- to="360 50 50"
1972
- repeatCount="indefinite" />
1973
- </path>
1974
- </svg>
1975
- } @if (isActionDelete) {
1976
- <svg
1977
- role="none"
1978
- (click)="$event.stopPropagation()"
1979
- style="height: 2rem; width: 2rem;"
1980
- version="1.1"
1981
- id="L9"
1982
- xmlns="http://www.w3.org/2000/svg"
1983
- xmlns:xlink="http://www.w3.org/1999/xlink"
1984
- x="0px"
1985
- y="0px"
1986
- viewBox="0 0 100 100"
1987
- enable-background="new 0 0 0 0"
1988
- xml:space="preserve">
1989
- <path
1990
- fill="#e9e9e9"
1991
- d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
1992
- <animateTransform
1993
- attributeName="transform"
1994
- attributeType="XML"
1995
- type="rotate"
1996
- dur="1s"
1997
- from="0 50 50"
1998
- to="360 50 50"
1999
- repeatCount="indefinite" />
2000
- </path>
2001
- </svg>
2002
- }
2003
- </div>
2004
- }
2005
- `,
2006
- standalone: true,
2007
- changeDetection: ChangeDetectionStrategy.OnPush,
2008
- }]
2009
- }], ctorParameters: () => [] });
1867
+ args: [{ selector: 'ng2-st-tbody-edit-delete', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (!row().pending()) { @if (isActionEdit() && canEditFunction()(row().getData())) {\n<a\n href=\"#\"\n [id]=\"'row-' + row().index + '_action-edit-button'\"\n class=\"ng2-smart-action ng2-smart-action-edit-edit\"\n [innerHTML]=\"editRowButtonContent()\"\n (click)=\"onEdit($event)\"></a>\n} @if (isActionDelete() && canDeleteFunction()(row().getData())) {\n<a\n href=\"#\"\n [id]=\"'row-' + row().index + '_action-delete-button'\"\n class=\"ng2-smart-action ng2-smart-action-delete-delete\"\n [innerHTML]=\"deleteRowButtonContent()\"\n (click)=\"onDelete($event)\"></a>\n} } @else {\n<div style=\"display: flex\">\n @if (isActionEdit()) {\n <svg\n role=\"none\"\n (click)=\"$event.stopPropagation()\"\n style=\"height: 2rem; width: 2rem\"\n version=\"1.1\"\n id=\"L9\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 100 100\"\n enable-background=\"new 0 0 0 0\"\n xml:space=\"preserve\">\n <path\n fill=\"#e9e9e9\"\n d=\"M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50\">\n <animateTransform\n attributeName=\"transform\"\n attributeType=\"XML\"\n type=\"rotate\"\n dur=\"1s\"\n from=\"0 50 50\"\n to=\"360 50 50\"\n repeatCount=\"indefinite\" />\n </path>\n </svg>\n } @if (isActionDelete()) {\n <svg\n role=\"none\"\n (click)=\"$event.stopPropagation()\"\n style=\"height: 2rem; width: 2rem\"\n version=\"1.1\"\n id=\"L9\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n x=\"0px\"\n y=\"0px\"\n viewBox=\"0 0 100 100\"\n enable-background=\"new 0 0 0 0\"\n xml:space=\"preserve\">\n <path\n fill=\"#e9e9e9\"\n d=\"M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50\">\n <animateTransform\n attributeName=\"transform\"\n attributeType=\"XML\"\n type=\"rotate\"\n dur=\"1s\"\n from=\"0 50 50\"\n to=\"360 50 50\"\n repeatCount=\"indefinite\" />\n </path>\n </svg>\n }\n</div>\n}\n" }]
1868
+ }] });
2010
1869
 
2011
1870
  class Ng2SmartTableTbodyComponent {
2012
1871
  constructor() {