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