ps-toolkit-ui 0.0.111 → 0.0.115

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.
@@ -125,6 +125,7 @@ const strings = {
125
125
  AccessDenied: 'عدم دسترسی',
126
126
  Image: 'تصویر',
127
127
  Grade: 'پایه تحصیلی',
128
+ Close: 'بستن',
128
129
  Desc: 'توضیحات',
129
130
  Admin: 'ادمین',
130
131
  Print: 'گزارش',
@@ -154,7 +155,9 @@ const strings = {
154
155
  ChooseMonth: 'انتخاب ماه',
155
156
  FullName: 'نام کامل',
156
157
  FirstName: 'نام',
158
+ Backup: 'بک آپ',
157
159
  LastName: 'نام خانوادگی',
160
+ OperationSuccessful: 'عملیات با موفقیت انجام شد',
158
161
  Reject: 'رد کردن',
159
162
  Code: 'کد تایید',
160
163
  InvalidRequest: 'درخواست شما نامعتبر است',
@@ -466,20 +469,23 @@ var PermissionTypeEnum;
466
469
  PermissionTypeEnum[PermissionTypeEnum["Form"] = -1] = "Form";
467
470
  PermissionTypeEnum[PermissionTypeEnum["Item"] = 0] = "Item";
468
471
  PermissionTypeEnum[PermissionTypeEnum["Access"] = 1] = "Access";
469
- PermissionTypeEnum[PermissionTypeEnum["Button"] = 2] = "Button";
470
- PermissionTypeEnum[PermissionTypeEnum["Option"] = 3] = "Option";
471
- PermissionTypeEnum[PermissionTypeEnum["OptionLink"] = 4] = "OptionLink";
472
- PermissionTypeEnum[PermissionTypeEnum["OptionLinkNewTab"] = 5] = "OptionLinkNewTab";
473
- PermissionTypeEnum[PermissionTypeEnum["OptionReport"] = 6] = "OptionReport";
474
- PermissionTypeEnum[PermissionTypeEnum["OptionFile"] = 7] = "OptionFile";
475
- PermissionTypeEnum[PermissionTypeEnum["OptionModal"] = 8] = "OptionModal";
476
- PermissionTypeEnum[PermissionTypeEnum["OptionConfirm"] = 9] = "OptionConfirm";
472
+ PermissionTypeEnum[PermissionTypeEnum["Option"] = 2] = "Option";
477
473
  })(PermissionTypeEnum || (PermissionTypeEnum = {}));
478
- var PermissionOptionTypeEnum;
479
- (function (PermissionOptionTypeEnum) {
480
- PermissionOptionTypeEnum[PermissionOptionTypeEnum["Icon"] = 0] = "Icon";
481
- PermissionOptionTypeEnum[PermissionOptionTypeEnum["Button"] = 1] = "Button";
482
- })(PermissionOptionTypeEnum || (PermissionOptionTypeEnum = {}));
474
+ var PermissionInputActionEnum;
475
+ (function (PermissionInputActionEnum) {
476
+ PermissionInputActionEnum[PermissionInputActionEnum["None"] = 0] = "None";
477
+ PermissionInputActionEnum[PermissionInputActionEnum["Link"] = 1] = "Link";
478
+ PermissionInputActionEnum[PermissionInputActionEnum["LinkNewTab"] = 2] = "LinkNewTab";
479
+ PermissionInputActionEnum[PermissionInputActionEnum["Report"] = 3] = "Report";
480
+ PermissionInputActionEnum[PermissionInputActionEnum["File"] = 4] = "File";
481
+ PermissionInputActionEnum[PermissionInputActionEnum["Modal"] = 5] = "Modal";
482
+ PermissionInputActionEnum[PermissionInputActionEnum["Confirm"] = 6] = "Confirm";
483
+ })(PermissionInputActionEnum || (PermissionInputActionEnum = {}));
484
+ var PermissionInputTypeEnum;
485
+ (function (PermissionInputTypeEnum) {
486
+ PermissionInputTypeEnum[PermissionInputTypeEnum["Icon"] = 0] = "Icon";
487
+ PermissionInputTypeEnum[PermissionInputTypeEnum["Button"] = 1] = "Button";
488
+ })(PermissionInputTypeEnum || (PermissionInputTypeEnum = {}));
483
489
  var VehicleType;
484
490
  (function (VehicleType) {
485
491
  VehicleType[VehicleType["Car"] = 1] = "Car";
@@ -739,10 +745,10 @@ class HelperClass {
739
745
  static getName(n) {
740
746
  return n.replace(/ک/g, 'ك').replace(/ی/g, 'ي').replace(/آ/g, 'آ');
741
747
  }
742
- static addNotification(m) {
748
+ static addNotification(m, e = true) {
743
749
  const id = HelperClass.random(20);
744
750
  // tslint:disable-next-line
745
- $('#Notifications').append('<div id="' + id + '" class="con"><div class="item"><i class="fas fa-times"></i><div>' + m + '</div></div></div>');
751
+ $('#Notifications').append('<div id="' + id + '" class="con"><div class="item ' + (e ? 'error' : 'success') + '"><i class="fas fa-times"></i><div>' + m + '</div></div></div>');
746
752
  setTimeout(() => {
747
753
  const d = $('#' + id);
748
754
  d.fadeOut(300, () => {
@@ -1836,6 +1842,51 @@ TablePaginationComponent.propDecorators = {
1836
1842
  table: [{ type: Input }]
1837
1843
  };
1838
1844
 
1845
+ class PermissionClass {
1846
+ constructor(Name = '', Icon = '', Type = null, InputType = null, InputAction = null, Area = '', Controller = '', Action = '', Condition = null, Accesses = []) {
1847
+ this.Name = Name;
1848
+ this.Icon = Icon;
1849
+ this.Type = Type;
1850
+ this.InputType = InputType;
1851
+ this.InputAction = InputAction;
1852
+ this.Area = Area;
1853
+ this.Controller = Controller;
1854
+ this.Action = Action;
1855
+ this.Condition = Condition;
1856
+ this.Accesses = Accesses;
1857
+ this.RelatedId = null;
1858
+ this.OnClick = null;
1859
+ }
1860
+ getAccess(a) {
1861
+ const c = this.Accesses.filter(x => x.Action === a && x.Type === PermissionTypeEnum.Access);
1862
+ return c.length > 0 ? c[0] : null;
1863
+ }
1864
+ hasAccess(a) {
1865
+ return this.Accesses.filter(x => x.Action === a && x.Type === PermissionTypeEnum.Access).length > 0;
1866
+ }
1867
+ getAccesses() {
1868
+ return this.Accesses.filter(x => x.Type === PermissionTypeEnum.Access);
1869
+ }
1870
+ delete(a) {
1871
+ this.Accesses = this.Accesses.filter(x => x.Action !== a);
1872
+ }
1873
+ hasOption(a) {
1874
+ return this.Accesses.filter(x => x.Action === a && x.Type === PermissionTypeEnum.Option).length > 0;
1875
+ }
1876
+ getOptions() {
1877
+ return this.Accesses.filter(x => x.Type === PermissionTypeEnum.Option);
1878
+ }
1879
+ getOption(a) {
1880
+ const c = this.Accesses.filter(x => x.Action === a && x.Type === PermissionTypeEnum.Option);
1881
+ return c.length > 0 ? c[0] : null;
1882
+ }
1883
+ getUrl() {
1884
+ return (this.Area ? '/' + this.Area : '') + '/' + this.Controller + '/' +
1885
+ (this.RelatedId ? `${this.RelatedId}/` : '') +
1886
+ (this.Action ? this.Action : '');
1887
+ }
1888
+ }
1889
+
1839
1890
  class TableRowComponent {
1840
1891
  constructor(service) {
1841
1892
  this.service = service;
@@ -1868,23 +1919,23 @@ class TableRowComponent {
1868
1919
  if (this.table.permissions.hasAccess('Insert')) {
1869
1920
  this.addChildren = new InputClass(this.table.environment, this.table.l, this.table.name + 'AddSubsetTitle', 'fad fa-plus fa-rotate-90', InputType.Icon, 'green m-h-5 h-25 d-ib va-m f-u');
1870
1921
  this.addChildren.onClick = () => {
1871
- this.table.form.inputs.find(x => x.name === 'ParentId').setValue(this.row.Id, false);
1922
+ this.table.form.inputs.find(x => x.name === 'ParentId').setValue(this.row.Data.Id, false);
1872
1923
  this.table.form.onSuccessBase = () => {
1873
1924
  this.table.modal.hide();
1874
1925
  this.showChildren.type = InputType.Icon;
1875
- this.loadChildren(this.row.Id);
1926
+ this.loadChildren(this.row.Data.Id);
1876
1927
  };
1877
1928
  this.table.showInsertModal();
1878
1929
  };
1879
1930
  }
1880
- this.showChildren = new InputClass(this.table.environment, this.table.l, this.table.name + 'SubsetTitle', 'fad fa-angle-left f-s-22', this.row.CountChild > 0 || (!this.table.childrenAutoLoad && this.children.length > 0) ? InputType.Icon : InputType.Hidden, 'h-25 m-h-5 d-ib va-m f-u');
1931
+ this.showChildren = new InputClass(this.table.environment, this.table.l, this.table.name + 'SubsetTitle', 'fad fa-angle-left f-s-22', this.row.Data.CountChild > 0 || (!this.table.childrenAutoLoad && this.children.length > 0) ? InputType.Icon : InputType.Hidden, 'h-25 m-h-5 d-ib va-m f-u');
1881
1932
  this.showChildren.onClick = () => {
1882
1933
  if ($(this.childrenDiv.nativeElement).is(':visible')) {
1883
1934
  $(this.childrenDiv.nativeElement).hide();
1884
1935
  this.showChildren.icon = 'fad fa-angle-left f-s-22';
1885
1936
  }
1886
1937
  else if (this.children.length === 0) {
1887
- this.loadChildren(this.row.Id);
1938
+ this.loadChildren(this.row.Data.Id);
1888
1939
  }
1889
1940
  else {
1890
1941
  $(this.childrenDiv.nativeElement).show();
@@ -1893,8 +1944,8 @@ class TableRowComponent {
1893
1944
  };
1894
1945
  }
1895
1946
  if (this.table.hasStatus) {
1896
- this.optStatus = new InputClass(this.table.environment, this.table.l, 'Status', this.row.Active ? 'fa-toggle-on' : 'fa-toggle-off', InputType.Icon, 'm-h-5 h-20 ' + (this.row.Active ? 'green' : ''));
1897
- this.optStatus.row = this.row;
1947
+ this.optStatus = new InputClass(this.table.environment, this.table.l, 'Status', this.row.Data.Active ? 'fa-toggle-on' : 'fa-toggle-off', InputType.Icon, 'm-h-5 h-20 ' + (this.row.Data.Active ? 'green' : ''));
1948
+ this.optStatus.row = this.row.Data;
1898
1949
  this.optStatus.onClick = (btn) => {
1899
1950
  new RequestClass(this.table.l).send(this.table.url + '/Status/' + btn.row.Id, Method.Post, null, btn, (r) => {
1900
1951
  btn.class = 'm-h-5 h-20 ' + (r ? 'green' : '');
@@ -1902,16 +1953,15 @@ class TableRowComponent {
1902
1953
  });
1903
1954
  };
1904
1955
  }
1905
- this.options = this.getOptions();
1906
1956
  if (this.optEdit !== null) {
1907
1957
  if (this.table.form) {
1908
1958
  this.optEdit.onClick = () => {
1909
- this.table.form.url = this.table.url + 'Update/' + this.row.Id;
1910
- if (this.table.hasChildren && this.row.ParentId != null) {
1959
+ this.table.form.url = this.table.url + 'Update/' + this.row.Data.Id;
1960
+ if (this.table.hasChildren && this.row.Data.ParentId != null) {
1911
1961
  this.table.form.onSuccessBase = () => {
1912
1962
  this.table.modal.hide();
1913
1963
  if (this.table.childrenAutoLoad) {
1914
- this.loadParent.emit(this.row.ParentId);
1964
+ this.loadParent.emit(this.row.Data.ParentId);
1915
1965
  }
1916
1966
  else {
1917
1967
  this.table.load();
@@ -1931,7 +1981,7 @@ class TableRowComponent {
1931
1981
  };
1932
1982
  }
1933
1983
  else {
1934
- this.optEdit.url = this.table.url + '/Update/' + this.row.Id;
1984
+ this.optEdit.url = this.table.url + '/Update/' + this.row.Data.Id;
1935
1985
  }
1936
1986
  }
1937
1987
  if (this.optDelete != null) {
@@ -1940,13 +1990,13 @@ class TableRowComponent {
1940
1990
  this.table.form.clear();
1941
1991
  }
1942
1992
  if (this.table.permissions.Type === PermissionTypeEnum.Form) {
1943
- this.table.rows = this.table.rows.filter(x => x.Id !== this.row.Id);
1944
- this.changeRows.emit(this.row);
1993
+ this.table.rows = this.table.rows.filter(x => x.Id !== this.row.Data.Id);
1994
+ this.changeRows.emit(this.row.Data);
1945
1995
  }
1946
1996
  else {
1947
- this.confirmShow.emit({ id: this.row.Id, accept: () => {
1948
- if (this.table.hasChildren && this.table.childrenAutoLoad && this.row.ParentId != null) {
1949
- this.loadParent.emit(this.row.ParentId);
1997
+ this.confirmShow.emit({ id: this.row.Data.Id, accept: () => {
1998
+ if (this.table.hasChildren && this.table.childrenAutoLoad && this.row.Data.ParentId != null) {
1999
+ this.loadParent.emit(this.row.Data.ParentId);
1950
2000
  }
1951
2001
  else {
1952
2002
  this.table.load();
@@ -1969,7 +2019,7 @@ class TableRowComponent {
1969
2019
  });
1970
2020
  }
1971
2021
  select() {
1972
- this.row.selected = !this.row.selected;
2022
+ this.row.Data.selected = !this.row.Data.selected;
1973
2023
  }
1974
2024
  onChangeRows(e) {
1975
2025
  return this.changeRows.emit(e);
@@ -1999,25 +2049,127 @@ class TableRowComponent {
1999
2049
  }, 500);
2000
2050
  }
2001
2051
  getOptions() {
2002
- return (this.addChildren !== null && (this.table.level === null || this.table.level > this.level) ? [this.addChildren] : [])
2003
- .concat(this.table.options.filter(x => x.condition == null ||
2004
- (x.condition.startsWith('!') ? !this.row[x.condition.substring(1)] : this.row[x.condition])).map((o) => {
2005
- const i = HelperClass.clone(o);
2006
- if (i.url) {
2007
- i.url = i.url.replace('{}', this.row.Id);
2052
+ const opts = this.addChildren !== null && (this.table.level === null || this.table.level > this.level) ?
2053
+ [this.addChildren] : [];
2054
+ for (const option of this.row.Options) {
2055
+ if (this.table.options.filter(x => x.name === option.Name).length > 0) {
2056
+ continue;
2008
2057
  }
2009
- i.row = this.row;
2010
- i.class = i.class + ' m-h-5 h-25 d-ib va-m f-u';
2011
- return i;
2012
- })).concat(this.table.hasStatus ? [this.optStatus] : [])
2013
- .concat(this.table.permissions.hasAccess('Update') ? [this.optEdit] : [])
2014
- .concat(this.table.permissions.hasAccess('Delete') ? [this.optDelete] : []);
2058
+ const opt = new InputClass(this.table.environment, this.table.l, option.Name, option.Icon, option.InputType === PermissionInputTypeEnum.Icon ? InputType.Icon : InputType.Button, 'blue h-25 m-h-5 d-ib va-m f-u');
2059
+ opt.condition = option.Condition;
2060
+ if (option.InputAction === PermissionInputActionEnum.Link || option.InputAction === PermissionInputActionEnum.LinkNewTab) {
2061
+ const p = new PermissionClass();
2062
+ p.RelatedId = this.table.permissions.RelatedId;
2063
+ p.Area = this.table.permissions.Area;
2064
+ p.Controller = option.Controller ? option.Controller : this.table.permissions.Controller;
2065
+ p.Action = this.table.permissions.Action;
2066
+ opt.url = p.getUrl() + option.Action + '/{}';
2067
+ opt.urlNewTab = option.InputAction === PermissionInputActionEnum.LinkNewTab;
2068
+ }
2069
+ else if (option.InputAction === PermissionInputActionEnum.Modal) {
2070
+ opt.modal = option.Modal;
2071
+ opt.onClick = (btn) => {
2072
+ if (opt.modal.table) {
2073
+ const p = new PermissionClass();
2074
+ p.RelatedId = btn.row.Id;
2075
+ p.Area = this.table.permissions.Area;
2076
+ p.Controller = this.table.permissions.Controller;
2077
+ p.Action = option.Action;
2078
+ p.Accesses = option.Accesses;
2079
+ opt.modal.table.permissions = p;
2080
+ if (opt.modal.table.form) {
2081
+ opt.modal.table.form.url = p.getUrl() + 'Insert';
2082
+ opt.modal.table.form.baseUrl = p.getUrl() + 'Insert';
2083
+ }
2084
+ opt.modal.table.set();
2085
+ }
2086
+ if (opt.modal.form) {
2087
+ opt.modal.form.name = option.Name;
2088
+ opt.modal.form.url = opt.modal.form.baseUrl + 'Update/' + btn.row.Id;
2089
+ opt.modal.form.loadData(opt.modal.form.baseUrl + 'Get/' + btn.row.Id);
2090
+ opt.modal.form.onSuccessBase = () => {
2091
+ opt.modal.hide();
2092
+ };
2093
+ }
2094
+ if (opt.modal.accordion) {
2095
+ for (const r of opt.modal.accordion.rows) {
2096
+ if (r.table) {
2097
+ const p = new PermissionClass();
2098
+ p.RelatedId = btn.row.Id;
2099
+ p.Area = this.table.permissions.Area;
2100
+ p.Controller = this.table.permissions.Controller;
2101
+ p.Action = r.name;
2102
+ p.Accesses = option.Accesses;
2103
+ r.table.permissions = p;
2104
+ if (r.table.form) {
2105
+ r.table.form.url = p.getUrl() + 'Insert';
2106
+ r.table.form.baseUrl = p.getUrl() + 'Insert';
2107
+ }
2108
+ r.table.set();
2109
+ }
2110
+ }
2111
+ }
2112
+ };
2113
+ }
2114
+ else if (option.InputAction === PermissionInputActionEnum.Report) {
2115
+ const p = new PermissionClass();
2116
+ p.RelatedId = 'Index';
2117
+ p.Area = this.table.permissions.Area;
2118
+ p.Controller = 'Print';
2119
+ p.Action = option.Action;
2120
+ opt.url = '/Report' + p.getUrl() + '/{}';
2121
+ opt.urlNewTab = true;
2122
+ }
2123
+ else if (option.InputAction === PermissionInputActionEnum.File) {
2124
+ const p = new PermissionClass();
2125
+ p.RelatedId = this.table.permissions.RelatedId;
2126
+ p.Area = this.table.permissions.Area;
2127
+ p.Controller = this.table.permissions.Controller;
2128
+ p.Action = (this.table.permissions.Action ? this.table.permissions.Action : '') + option.Action;
2129
+ opt.url = '/File' + p.getUrl() + '/{}';
2130
+ opt.urlNewTab = true;
2131
+ }
2132
+ else if (option.InputAction === PermissionInputActionEnum.Confirm) {
2133
+ opt.onClick = (btn) => {
2134
+ const p = new PermissionClass();
2135
+ p.RelatedId = this.table.permissions.RelatedId;
2136
+ p.Area = this.table.permissions.Area;
2137
+ p.Controller = this.table.permissions.Controller;
2138
+ p.Action = option.Action;
2139
+ this.table.showConfirm(this.table.l(option.Action + 'Confirm'), p.getUrl() + '/' + btn.row.Id, null, () => {
2140
+ this.table.load();
2141
+ });
2142
+ };
2143
+ }
2144
+ else if (option.Type === PermissionTypeEnum.Option) {
2145
+ if (option.OnClick) {
2146
+ opt.onClick = (btn) => {
2147
+ option.OnClick(btn);
2148
+ };
2149
+ }
2150
+ }
2151
+ opts.push(opt);
2152
+ }
2153
+ return opts;
2154
+ // return (this.addChildren !== null && (this.table.level === null || this.table.level > this.level) ? [this.addChildren] : [])
2155
+ // .concat(this.table.options.filter(x => x.condition == null ||
2156
+ // (x.condition.startsWith('!') ? !this.row.Data[x.condition.substring(1)] : this.row.Data[x.condition])).map((o) => {
2157
+ // const i = HelperClass.clone(o);
2158
+ // if (i.url){
2159
+ // i.url = i.url.replace('{}', this.row.Data.Id);
2160
+ // }
2161
+ // i.row = this.row.Data;
2162
+ // i.class = i.class + ' m-h-5 h-25 d-ib va-m f-u';
2163
+ // return i;
2164
+ // })).concat(this.table.hasStatus ? [this.optStatus] : [])
2165
+ // .concat(this.table.permissions.hasAccess('Update') ? [this.optEdit] : [])
2166
+ // .concat(this.table.permissions.hasAccess('Delete') ? [this.optDelete] : []);
2015
2167
  }
2016
2168
  getCell(col) {
2017
2169
  console.log('getCell');
2018
- const cv = get(this.row, col.name);
2170
+ const cv = get(this.row.Data, col.name);
2019
2171
  if (col.fun != null) {
2020
- return col.fun(this.row);
2172
+ return col.fun(this.row.Data);
2021
2173
  }
2022
2174
  else if (col.enum !== null) {
2023
2175
  return col.enum.get(cv);
@@ -2069,7 +2221,7 @@ class TableRowComponent {
2069
2221
  return this.table.l(cv);
2070
2222
  }
2071
2223
  getCol(n) {
2072
- let c = this.row;
2224
+ let c = this.row.Data;
2073
2225
  n.split('.').forEach((x) => {
2074
2226
  c = c[x];
2075
2227
  });
@@ -2079,15 +2231,15 @@ class TableRowComponent {
2079
2231
  const editAccess = this.table.permissions.getAccess('Update');
2080
2232
  if (this.table.permissions.Type === PermissionTypeEnum.Form) {
2081
2233
  this.table.form.name = editAccess.Name;
2082
- this.table.form.setData(this.row);
2083
- this.table.form.setButtons(this.table.form.onTop, true, this.row.Id);
2234
+ this.table.form.setData(this.row.Data);
2235
+ this.table.form.setButtons(this.table.form.onTop, true, this.row.Data.Id);
2084
2236
  this.table.form.inputs.filter(x => x.inEditDisabled).forEach(x => x.disabled = true);
2085
2237
  this.table.form.inputs.filter(x => !x.inEditVisible).forEach(x => x.visible = false);
2086
2238
  }
2087
2239
  else {
2088
- new RequestClass(this.table.environment, this.table.l).send(this.table.url + 'Get/' + this.row.Id, Method.Post, null, this.optEdit, (result) => {
2240
+ new RequestClass(this.table.environment, this.table.l).send(this.table.url + 'Get/' + this.row.Data.Id, Method.Post, null, this.optEdit, (result) => {
2089
2241
  this.table.form.name = editAccess.Name;
2090
- this.table.form.setButtons(this.table.form.onTop, true, this.row.Id);
2242
+ this.table.form.setButtons(this.table.form.onTop, true, this.row.Data.Id);
2091
2243
  this.table.form.setData(result);
2092
2244
  this.table.form.inputs.filter(x => x.inEditDisabled).forEach(x => x.disabled = true);
2093
2245
  this.table.form.inputs.filter(x => !x.inEditVisible).forEach(x => x.visible = false);
@@ -2098,7 +2250,7 @@ class TableRowComponent {
2098
2250
  }
2099
2251
  }
2100
2252
  getChildren() {
2101
- return this.row.Id ? this.table.rows.filter(x => x.ParentId === this.row.Id) : [];
2253
+ return this.row.Data.Id ? this.table.rows.filter(x => x.ParentId === this.row.Data.Id) : [];
2102
2254
  }
2103
2255
  }
2104
2256
  TableRowComponent.decorators = [
@@ -4257,47 +4409,6 @@ FormSelectComponent.propDecorators = {
4257
4409
  inputLabel: [{ type: ViewChild, args: ['inputLabel',] }]
4258
4410
  };
4259
4411
 
4260
- class PermissionClass {
4261
- constructor(Name = '', Icon = '', Type = null, OptionType = null, Area = '', Controller = '', Action = '', Condition = null, Accesses = []) {
4262
- this.Name = Name;
4263
- this.Icon = Icon;
4264
- this.Type = Type;
4265
- this.OptionType = OptionType;
4266
- this.Area = Area;
4267
- this.Controller = Controller;
4268
- this.Action = Action;
4269
- this.Condition = Condition;
4270
- this.Accesses = Accesses;
4271
- this.RelatedId = null;
4272
- this.OnClick = null;
4273
- }
4274
- getAccess(a) {
4275
- const c = this.Accesses.filter(x => x.Action === a && x.Type === PermissionTypeEnum.Access);
4276
- return c.length > 0 ? c[0] : null;
4277
- }
4278
- hasAccess(a) {
4279
- return this.Accesses.filter(x => x.Action === a && x.Type === PermissionTypeEnum.Access).length > 0;
4280
- }
4281
- delete(a) {
4282
- this.Accesses = this.Accesses.filter(x => x.Action !== a);
4283
- }
4284
- hasOption(a) {
4285
- return this.Accesses.filter(x => x.Action === a && x.Type !== PermissionTypeEnum.Access).length > 0;
4286
- }
4287
- getOptions() {
4288
- return this.Accesses.filter(x => x.Type !== PermissionTypeEnum.Access);
4289
- }
4290
- getOption(a) {
4291
- const c = this.Accesses.filter(x => x.Action === a && x.Type !== PermissionTypeEnum.Access);
4292
- return c.length > 0 ? c[0] : null;
4293
- }
4294
- getUrl() {
4295
- return (this.Area ? '/' + this.Area : '') + '/' + this.Controller + '/' +
4296
- (this.RelatedId ? `${this.RelatedId}/` : '') +
4297
- (this.Action ? this.Action : '');
4298
- }
4299
- }
4300
-
4301
4412
  class FormTableComponent {
4302
4413
  constructor() {
4303
4414
  this.changeIndex = new EventEmitter();
@@ -4998,13 +5109,12 @@ class AlertComponent {
4998
5109
  this.alert.form.inputs = [
4999
5110
  this.alertLabel
5000
5111
  ];
5001
- this.alert.form.addButtons('Accept', 'blue', false);
5002
5112
  }
5003
5113
  show(l, accept) {
5004
5114
  this.alertLabel.value = l;
5005
- this.alert.form.onSuccess = (btn) => {
5115
+ this.alert.onHide = () => {
5006
5116
  this.alert.hide();
5007
- accept(btn);
5117
+ accept();
5008
5118
  };
5009
5119
  this.alert.show();
5010
5120
  }
@@ -5910,7 +6020,7 @@ NotificationComponent.decorators = [
5910
6020
  { type: Component, args: [{
5911
6021
  selector: 'lib-notification',
5912
6022
  template: "<div id=\"Notifications\">\r\n</div>\r\n",
5913
- styles: ["#Notifications{bottom:20px;position:fixed;right:0;width:350px;z-index:9999}::ng-deep #Notifications .con{float:right;padding:5px 20px;width:calc(100% - 40px)}::ng-deep #Notifications .item{background-color:var(--red);border-radius:5px;box-shadow:var(--box-shadow);color:#fff;float:right;position:relative;text-align:center;width:100%}::ng-deep #Notifications .item i{cursor:pointer;float:right;height:30px;line-height:30px;width:30px}::ng-deep #Notifications .item i:hover{background-color:var(--red-dark)}::ng-deep #Notifications .item div{float:right;font-size:12px;line-height:20px;padding:10px;width:calc(100% - 30px)}"]
6023
+ styles: ["#Notifications{bottom:20px;position:fixed;right:0;width:350px;z-index:9999}::ng-deep #Notifications .con{float:right;padding:5px 20px;width:calc(100% - 40px)}::ng-deep #Notifications .item{background-color:var(--red);border-radius:5px;box-shadow:var(--box-shadow);color:#fff;float:right;position:relative;text-align:center;width:100%}::ng-deep #Notifications .item.success{background-color:var(--green)}::ng-deep #Notifications .item i{cursor:pointer;float:right;height:30px;line-height:30px;width:30px}::ng-deep #Notifications .item i:hover{background-color:var(--red-dark)}::ng-deep #Notifications .item.success i:hover{background-color:var(--green-dark)}::ng-deep #Notifications .item div{float:right;font-size:12px;line-height:20px;padding:10px;width:calc(100% - 30px)}"]
5914
6024
  },] }
5915
6025
  ];
5916
6026
  NotificationComponent.ctorParameters = () => [];
@@ -5998,7 +6108,7 @@ class BaseComponent {
5998
6108
  return p.length > 0 ? this.getPermissionClass(p[0]) : null;
5999
6109
  }
6000
6110
  getPermissionClass(p) {
6001
- return new PermissionClass(p.Name, p.Icon, p.Type, p.OptionType, this.app.area, p.Controller, p.Action, p.Condition, this.getPermissionAccessesClass(p.Id));
6111
+ return new PermissionClass(p.Name, p.Icon, p.Type, p.InputType, p.InputAction, this.app.area, p.Controller, p.Action, p.Condition, this.getPermissionAccessesClass(p.Id));
6002
6112
  }
6003
6113
  getPermissionAccessesClass(parentId) {
6004
6114
  return this.app.currentUser.Permissions.filter(x => x.ParentId === parentId).map(x => this.getPermissionClass(x));
@@ -6145,50 +6255,49 @@ class TableClass {
6145
6255
  this.permission = false;
6146
6256
  return;
6147
6257
  }
6148
- const insertAccess = this.permissions.getAccess('Insert');
6149
- if (insertAccess != null) {
6150
- const insert = new InputClass(this.environment, this.l, insertAccess.Name, 'fad fa-plus fa-rotate-90', InputType.Button, 'w-u green h-30');
6151
- if (this.form) {
6152
- this.form.url = this.form.baseUrl = this.url + 'Insert';
6153
- if (!this.form.onTop) {
6154
- insert.onClick = () => {
6155
- this.form.onSuccessBase = () => {
6156
- this.modal.hide();
6157
- this.load();
6258
+ for (const access of this.permissions.getAccesses().filter(x => x.InputAction !== PermissionInputActionEnum.None)) {
6259
+ const accessInp = new InputClass(this.environment, this.l, access.Name, access.Icon, access.InputType === PermissionInputTypeEnum.Button ? InputType.Button : InputType.Icon, 'w-u h-30');
6260
+ if (access.Action === 'Insert') {
6261
+ if (this.form) {
6262
+ this.form.url = this.form.baseUrl = this.url + 'Insert';
6263
+ if (!this.form.onTop) {
6264
+ accessInp.onClick = () => {
6265
+ this.form.onSuccessBase = () => {
6266
+ this.modal.hide();
6267
+ this.load();
6268
+ };
6269
+ this.showInsertModal();
6158
6270
  };
6159
- this.showInsertModal();
6160
- };
6161
- this.buttons.unshift(insert);
6271
+ this.buttons.unshift(accessInp);
6272
+ }
6273
+ else {
6274
+ this.form.displayLabel = false;
6275
+ }
6162
6276
  }
6163
6277
  else {
6164
- this.form.displayLabel = false;
6278
+ this.buttons.unshift(accessInp);
6279
+ if (this.modal) {
6280
+ accessInp.onClick = () => {
6281
+ this.modal.show();
6282
+ };
6283
+ }
6284
+ else {
6285
+ accessInp.url = this.url + 'Insert';
6286
+ }
6165
6287
  }
6166
6288
  }
6167
- else {
6168
- this.buttons.unshift(insert);
6169
- if (this.modal) {
6170
- insert.onClick = () => {
6171
- this.modal.show();
6172
- };
6173
- }
6174
- else {
6175
- insert.url = this.url + 'Insert';
6176
- }
6289
+ else if (access.InputAction === PermissionInputActionEnum.Report) {
6290
+ const p = new PermissionClass();
6291
+ p.RelatedId = 'Index';
6292
+ p.Area = this.permissions.Area;
6293
+ p.Controller = 'Print';
6294
+ p.Action = this.permissions.Controller;
6295
+ accessInp.url = '/Report' + p.getUrl();
6296
+ accessInp.urlNewTab = true;
6177
6297
  }
6298
+ this.buttons.push(accessInp);
6178
6299
  }
6179
- const reportAccess = this.permissions.getAccess('Report');
6180
- if (reportAccess != null) {
6181
- const report = new InputClass(this.environment, this.l, reportAccess.Name, reportAccess.Icon, InputType.Button, 'm-h-5');
6182
- const p = new PermissionClass();
6183
- p.RelatedId = 'Index';
6184
- p.Area = this.permissions.Area;
6185
- p.Controller = 'Print';
6186
- p.Action = this.permissions.Controller;
6187
- report.url = '/Report' + p.getUrl();
6188
- report.urlNewTab = true;
6189
- this.extraButtons.push(report);
6190
- }
6191
- if ((this.permissions.hasAccess('Insert') || this.permissions.hasAccess('Update')) && this.form) {
6300
+ if ((this.permissions.hasAccess('Insert') || this.permissions.hasOption('Update')) && this.form) {
6192
6301
  this.form.addButtons('Save', 'green', true, this.permissions.Type === PermissionTypeEnum.Form ? (data) => {
6193
6302
  if (data.Id) {
6194
6303
  const i = this.rows.findIndex(x => x.Id === data.Id);
@@ -6216,105 +6325,6 @@ class TableClass {
6216
6325
  this.modal.form = this.form;
6217
6326
  }
6218
6327
  }
6219
- for (const option of this.permissions.getOptions()) {
6220
- if (this.options.filter(x => x.name === option.Name).length > 0) {
6221
- continue;
6222
- }
6223
- const opt = new InputClass(this.environment, this.l, option.Name, option.Icon, option.OptionType === PermissionOptionTypeEnum.Icon ? InputType.Icon : InputType.Button, 'blue h-25 m-h-5 d-ib va-m f-u');
6224
- opt.condition = option.Condition;
6225
- if (option.Type === PermissionTypeEnum.OptionLink || option.Type === PermissionTypeEnum.OptionLinkNewTab) {
6226
- const p = new PermissionClass();
6227
- p.RelatedId = this.permissions.RelatedId;
6228
- p.Area = this.permissions.Area;
6229
- p.Controller = option.Controller ? option.Controller : this.permissions.Controller;
6230
- p.Action = this.permissions.Action;
6231
- opt.url = p.getUrl() + option.Action + '/{}';
6232
- opt.urlNewTab = option.Type === PermissionTypeEnum.OptionLinkNewTab;
6233
- }
6234
- else if (option.Type === PermissionTypeEnum.OptionModal) {
6235
- opt.modal = option.Modal;
6236
- opt.onClick = (btn) => {
6237
- if (opt.modal.table) {
6238
- const p = new PermissionClass();
6239
- p.RelatedId = btn.row.Id;
6240
- p.Area = this.permissions.Area;
6241
- p.Controller = this.permissions.Controller;
6242
- p.Action = option.Action;
6243
- p.Accesses = option.Accesses;
6244
- opt.modal.table.permissions = p;
6245
- if (opt.modal.table.form) {
6246
- opt.modal.table.form.url = p.getUrl() + 'Insert';
6247
- opt.modal.table.form.baseUrl = p.getUrl() + 'Insert';
6248
- }
6249
- opt.modal.table.set();
6250
- }
6251
- if (opt.modal.form) {
6252
- opt.modal.form.name = option.Name;
6253
- opt.modal.form.url = opt.modal.form.baseUrl + 'Update/' + btn.row.Id;
6254
- opt.modal.form.loadData(opt.modal.form.baseUrl + 'Get/' + btn.row.Id);
6255
- opt.modal.form.onSuccessBase = () => {
6256
- opt.modal.hide();
6257
- };
6258
- }
6259
- if (opt.modal.accordion) {
6260
- for (const r of opt.modal.accordion.rows) {
6261
- if (r.table) {
6262
- const p = new PermissionClass();
6263
- p.RelatedId = btn.row.Id;
6264
- p.Area = this.permissions.Area;
6265
- p.Controller = this.permissions.Controller;
6266
- p.Action = r.name;
6267
- p.Accesses = option.Accesses;
6268
- r.table.permissions = p;
6269
- if (r.table.form) {
6270
- r.table.form.url = p.getUrl() + 'Insert';
6271
- r.table.form.baseUrl = p.getUrl() + 'Insert';
6272
- }
6273
- r.table.set();
6274
- }
6275
- }
6276
- }
6277
- };
6278
- }
6279
- else if (option.Type === PermissionTypeEnum.OptionReport) {
6280
- const p = new PermissionClass();
6281
- p.RelatedId = 'Index';
6282
- p.Area = this.permissions.Area;
6283
- p.Controller = 'Print';
6284
- p.Action = option.Action;
6285
- opt.url = '/Report' + p.getUrl() + '/{}';
6286
- opt.urlNewTab = true;
6287
- }
6288
- else if (option.Type === PermissionTypeEnum.OptionFile) {
6289
- const p = new PermissionClass();
6290
- p.RelatedId = this.permissions.RelatedId;
6291
- p.Area = this.permissions.Area;
6292
- p.Controller = this.permissions.Controller;
6293
- p.Action = (this.permissions.Action ? this.permissions.Action : '') + option.Action;
6294
- opt.url = '/File' + p.getUrl() + '/{}';
6295
- opt.urlNewTab = true;
6296
- }
6297
- else if (option.Type === PermissionTypeEnum.OptionConfirm) {
6298
- opt.onClick = (btn) => {
6299
- const p = new PermissionClass();
6300
- p.RelatedId = this.permissions.RelatedId;
6301
- p.Area = this.permissions.Area;
6302
- p.Controller = this.permissions.Controller;
6303
- p.Action = option.Action;
6304
- this.showConfirm(this.l(option.Action + 'Confirm'), p.getUrl() + '/' + btn.row.Id, null, () => {
6305
- this.load();
6306
- });
6307
- };
6308
- }
6309
- else if (option.Type === PermissionTypeEnum.Option) {
6310
- if (option.OnClick) {
6311
- opt.onClick = (btn) => {
6312
- option.OnClick(btn);
6313
- };
6314
- }
6315
- }
6316
- this.options.push(opt);
6317
- }
6318
6328
  }
6319
6329
  }
6320
6330
  class TableCollClass {
@@ -6346,5 +6356,5 @@ class TableRowClass {
6346
6356
  * Generated bundle index. Do not edit.
6347
6357
  */
6348
6358
 
6349
- export { AccordionClass, AccordionComponent, AccordionRowClass, AlertComponent, BaseComponent, ConfirmComponent, DayClass, EnumUtils, FooterComponent, FormBankCardComponent, FormButtonComponent, FormCarComponent, FormCarSearchComponent, FormCheckboxComponent, FormClass, FormComponent, FormDateComponent, FormDatetimeComponent, FormFileComponent, FormFingerComponent, FormIconComponent, FormLabelComponent, FormPlaqueComponent, FormPlaqueSelectComponent, FormRadioComponent, FormSelectComponent, FormTableComponent, FormTextareaComponent, FormTextboxComponent, FormTimeComponent, FormTreeComponent, HeaderComponent, HelperClass, InputClass, InputError, InputType, LangClass, LayoutComponent, LoadingComponent, LoginClass, LoginStepClass, Method, ModalClass, ModalComponent, NotfoundComponent, OperationEnum, OptionClass, PaymentStatusEnum, PermissionClass, PermissionOptionTypeEnum, PermissionTypeEnum, Progress, PsToolkitUiModule, RequestClass, ResultStatusEnum, SidebarClass, SidebarComponent, StatusEnum, StepsClass, StepsComponent, StepsItemClass, SubHeaderComponent, TableClass, TableCollClass, TableCollType, TableComponent, TableOptionType, TableRowClass, TooltipComponent, TreeRowClass, UserType, VehicleType, FormSelectItemComponent as ɵa, TablePaginationComponent as ɵb, SidebarItemComponent as ɵc, PsToolkitUiConfigService as ɵd, TableLoadingComponent as ɵe, FormTreeItemComponent as ɵf, TableRowComponent as ɵg, TableReportComponent as ɵh, SafeStylePipe as ɵi, LoginComponent as ɵj, NotificationComponent as ɵk };
6359
+ export { AccordionClass, AccordionComponent, AccordionRowClass, AlertComponent, BaseComponent, ConfirmComponent, DayClass, EnumUtils, FooterComponent, FormBankCardComponent, FormButtonComponent, FormCarComponent, FormCarSearchComponent, FormCheckboxComponent, FormClass, FormComponent, FormDateComponent, FormDatetimeComponent, FormFileComponent, FormFingerComponent, FormIconComponent, FormLabelComponent, FormPlaqueComponent, FormPlaqueSelectComponent, FormRadioComponent, FormSelectComponent, FormTableComponent, FormTextareaComponent, FormTextboxComponent, FormTimeComponent, FormTreeComponent, HeaderComponent, HelperClass, InputClass, InputError, InputType, LangClass, LayoutComponent, LoadingComponent, LoginClass, LoginStepClass, Method, ModalClass, ModalComponent, NotfoundComponent, OperationEnum, OptionClass, PaymentStatusEnum, PermissionClass, PermissionInputActionEnum, PermissionInputTypeEnum, PermissionTypeEnum, Progress, PsToolkitUiModule, RequestClass, ResultStatusEnum, SidebarClass, SidebarComponent, StatusEnum, StepsClass, StepsComponent, StepsItemClass, SubHeaderComponent, TableClass, TableCollClass, TableCollType, TableComponent, TableOptionType, TableRowClass, TooltipComponent, TreeRowClass, UserType, VehicleType, FormSelectItemComponent as ɵa, TablePaginationComponent as ɵb, SidebarItemComponent as ɵc, PsToolkitUiConfigService as ɵd, TableLoadingComponent as ɵe, FormTreeItemComponent as ɵf, TableRowComponent as ɵg, TableReportComponent as ɵh, SafeStylePipe as ɵi, LoginComponent as ɵj, NotificationComponent as ɵk };
6350
6360
  //# sourceMappingURL=ps-toolkit-ui.js.map