argous 1.2.177 → 1.2.178

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.
@@ -88,6 +88,14 @@ export interface ArgousComplexTableProps extends ArgousComplexTableBodyProps, Ar
88
88
  * @returns {void} Sem retorno
89
89
  */
90
90
  onMethodResponse?: (response: Object) => void,
91
+ /**
92
+ * Boolean que define se o erro do método será tratado automaticamente na ServerAction
93
+ */
94
+ handleMethodError?: boolean,
95
+ /**
96
+ * Boolean que permite solicitar o método
97
+ */
98
+ allowMethodRequest?: boolean,
91
99
  /**
92
100
  * @deprecated
93
101
  *
@@ -165,13 +165,13 @@ var initialState = function (defaultRowsPerPage) { return ({
165
165
  loading: false
166
166
  }); };
167
167
  var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
168
- var _b = _a.ToolbarComponent, ToolbarComponent = _b === void 0 ? __1.ArgousComplexTableToolbar : _b, _c = _a.HeadComponent, HeadComponent = _c === void 0 ? __1.ArgousComplexTableHead : _c, _d = _a.BodyComponent, BodyComponent = _d === void 0 ? __1.ArgousComplexTableBody : _d, _e = _a.PaginationComponent, PaginationComponent = _e === void 0 ? __1.ArgousComplexPagination : _e, _f = _a.FooterComponent, FooterComponent = _f === void 0 ? undefined : _f, footerProps = _a.footerProps, dados = _a.dados, _g = _a.head, head = _g === void 0 ? [] : _g, _h = _a.line, line = _h === void 0 ? function (i) { return i; } : _h, actions = _a.actions, title = _a.title, _j = _a.defaultRowsPerPage, defaultRowsPerPage = _j === void 0 ? 10 : _j, _k = _a.rowsPerPageOptions, rowsPerPageOptions = _k === void 0 ? [10, 25, 50] : _k, checkEnabled = _a.enableCheck, disableCheckIf = _a.disableCheckIf, showCount = _a.showCount, lineStyle = _a.lineStyle, _l = _a.lineClass, lineClass = _l === void 0 ? function () { return undefined; } : _l, onClick = _a.onClick, onDoubleClick = _a.onDoubleClick, _m = _a.children, children = _m === void 0 ? undefined : _m, style = _a.style, className = _a.className, columnStyles = _a.columnStyles, headerColumnStyles = _a.headerColumnStyles, columnOptions = _a.columnOptions, disableFilter = _a.disableFilter, _o = _a.filterLabel, filterLabel = _o === void 0 ? 'Filtro' : _o, _p = _a.indexToSelect, indexToSelect = _p === void 0 ? 0 : _p, _q = _a.disableSorting, disableSorting = _q === void 0 ? [] : _q, _r = _a.size, size = _r === void 0 ? 'small' : _r, onOpen = _a.onOpen, lineTitle = _a.lineTitle, onClose = _a.onClose, method = _a.method, methodPrms = _a.methodPrms, _s = _a.methodResultList, methodResultList = _s === void 0 ? 'lista' : _s, onMethodResponse = _a.onMethodResponse, field = _a.field, fixedToolbar = _a.fixedToolbar, onSelect = _a.onSelect, customKey = _a.customKey, _t = _a.columnProps, columnProps = _t === void 0 ? function () { return ''; } : _t, _u = _a.rowProps, rowProps = _u === void 0 ? function () { return ''; } : _u, _v = _a.savedState, savedState = _v === void 0 ? {} : _v, containerProps = _a.containerProps, _w = _a.onClickAway, onClickAway = _w === void 0 ? function () { return undefined; } : _w, enableCheckIfSelected = _a.enableCheckIfSelected, enableDrag = _a.enableDrag, onDrop = _a.onDrop, tableProps = _a.tableProps, toolbarProps = _a.toolbarProps;
168
+ var _b = _a.ToolbarComponent, ToolbarComponent = _b === void 0 ? __1.ArgousComplexTableToolbar : _b, _c = _a.HeadComponent, HeadComponent = _c === void 0 ? __1.ArgousComplexTableHead : _c, _d = _a.BodyComponent, BodyComponent = _d === void 0 ? __1.ArgousComplexTableBody : _d, _e = _a.PaginationComponent, PaginationComponent = _e === void 0 ? __1.ArgousComplexPagination : _e, _f = _a.FooterComponent, FooterComponent = _f === void 0 ? undefined : _f, footerProps = _a.footerProps, dados = _a.dados, _g = _a.head, head = _g === void 0 ? [] : _g, _h = _a.line, line = _h === void 0 ? function (i) { return i; } : _h, actions = _a.actions, title = _a.title, _j = _a.defaultRowsPerPage, defaultRowsPerPage = _j === void 0 ? 10 : _j, _k = _a.rowsPerPageOptions, rowsPerPageOptions = _k === void 0 ? [10, 25, 50] : _k, checkEnabled = _a.enableCheck, disableCheckIf = _a.disableCheckIf, showCount = _a.showCount, lineStyle = _a.lineStyle, _l = _a.lineClass, lineClass = _l === void 0 ? function () { return undefined; } : _l, onClick = _a.onClick, onDoubleClick = _a.onDoubleClick, _m = _a.children, children = _m === void 0 ? undefined : _m, style = _a.style, className = _a.className, columnStyles = _a.columnStyles, headerColumnStyles = _a.headerColumnStyles, columnOptions = _a.columnOptions, disableFilter = _a.disableFilter, _o = _a.filterLabel, filterLabel = _o === void 0 ? 'Filtro' : _o, _p = _a.indexToSelect, indexToSelect = _p === void 0 ? 0 : _p, _q = _a.disableSorting, disableSorting = _q === void 0 ? [] : _q, _r = _a.size, size = _r === void 0 ? 'small' : _r, onOpen = _a.onOpen, lineTitle = _a.lineTitle, onClose = _a.onClose, method = _a.method, methodPrms = _a.methodPrms, _s = _a.methodResultList, methodResultList = _s === void 0 ? 'lista' : _s, onMethodResponse = _a.onMethodResponse, _t = _a.handleMethodError, handleMethodError = _t === void 0 ? true : _t, _u = _a.allowMethodRequest, allowMethodRequest = _u === void 0 ? true : _u, field = _a.field, fixedToolbar = _a.fixedToolbar, onSelect = _a.onSelect, customKey = _a.customKey, _v = _a.columnProps, columnProps = _v === void 0 ? function () { return ''; } : _v, _w = _a.rowProps, rowProps = _w === void 0 ? function () { return ''; } : _w, _x = _a.savedState, savedState = _x === void 0 ? {} : _x, containerProps = _a.containerProps, _y = _a.onClickAway, onClickAway = _y === void 0 ? function () { return undefined; } : _y, enableCheckIfSelected = _a.enableCheckIfSelected, enableDrag = _a.enableDrag, onDrop = _a.onDrop, tableProps = _a.tableProps, toolbarProps = _a.toolbarProps;
169
169
  var classes = useStyles();
170
- var _x = react_1.useReducer(reducer, initialState(defaultRowsPerPage)), state = _x[0], dispatch = _x[1];
170
+ var _z = react_1.useReducer(reducer, initialState(defaultRowsPerPage)), state = _z[0], dispatch = _z[1];
171
171
  var memoState = react_1.useMemo(function () { return (__assign(__assign({}, state), { dispatch: dispatch })); }, [state, dispatch]);
172
172
  var selected = memoState.selected, page = memoState.page, rowsPerPage = memoState.rowsPerPage, order = memoState.order, orderBy = memoState.orderBy, filter = memoState.filter, open = memoState.open;
173
- var _y = react_1.useState(dados /*.map(linha => isArray(linha) ? linha : Object.values(linha))*/ || []), lista = _y[0], setLista = _y[1];
174
- var _z = react_1.useState({ qtRegs: defaultRowsPerPage, pgAtl: 1 }), ctrlPgn = _z[0], setCtrlPgn = _z[1];
173
+ var _0 = react_1.useState(dados /*.map(linha => isArray(linha) ? linha : Object.values(linha))*/ || []), lista = _0[0], setLista = _0[1];
174
+ var _1 = react_1.useState({ qtRegs: defaultRowsPerPage, pgAtl: 1 }), ctrlPgn = _1[0], setCtrlPgn = _1[1];
175
175
  var qtRegs = ctrlPgn.qtRegs, pgAtl = ctrlPgn.pgAtl, ordCols = ctrlPgn.ordCols;
176
176
  var enableCheck = checkEnabled || (enableCheckIfSelected && !!selected.length);
177
177
  react_1.useEffect(function () {
@@ -203,7 +203,7 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
203
203
  return __generator(this, function (_g) {
204
204
  switch (_g.label) {
205
205
  case 0:
206
- if (!method)
206
+ if (!method || !allowMethodRequest)
207
207
  return [2 /*return*/];
208
208
  dispatch({ type: 'setLoading', value: true });
209
209
  return [4 /*yield*/, api_1.serverAction(method, __assign({ ctrlPgn: {
@@ -211,7 +211,7 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
211
211
  acao: retornaAcao(ctrlPgn.pgAtl, page + 1),
212
212
  tpOrdem: orderBy >= 0 ? (order === 'asc' ? 'A' : 'D') : undefined,
213
213
  indOrdem: orderBy >= 0 ? orderBy : undefined
214
- } }, methodPrms), true)];
214
+ } }, methodPrms), handleMethodError)];
215
215
  case 1:
216
216
  res = _g.sent();
217
217
  onMethodResponse && onMethodResponse(res);
@@ -223,7 +223,7 @@ var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
223
223
  return [2 /*return*/];
224
224
  }
225
225
  });
226
- }); }, [method, qtRegs, pgAtl, order, orderBy, retornaAcao, ctrlPgn.pgAtl, page, methodPrms, methodResultList]);
226
+ }); }, [method, qtRegs, pgAtl, order, orderBy, retornaAcao, ctrlPgn.pgAtl, page, methodPrms, methodResultList, handleMethodError, allowMethodRequest]);
227
227
  react_1.useEffect(function () {
228
228
  buscaMetodo();
229
229
  }, [buscaMetodo]);
@@ -88,6 +88,14 @@ export interface ArgousComplexTableProps extends ArgousComplexTableBodyProps, Ar
88
88
  * @returns {void} Sem retorno
89
89
  */
90
90
  onMethodResponse?: (response: Object) => void,
91
+ /**
92
+ * Boolean que define se o erro do método será tratado automaticamente na ServerAction
93
+ */
94
+ handleMethodError?: boolean,
95
+ /**
96
+ * Boolean que permite solicitar o método
97
+ */
98
+ allowMethodRequest?: boolean,
91
99
  /**
92
100
  * @deprecated
93
101
  *
@@ -159,6 +159,8 @@ const ArgousComplexTable = forwardRef(({
159
159
  methodPrms,
160
160
  methodResultList = 'lista',
161
161
  onMethodResponse,
162
+ handleMethodError = true,
163
+ allowMethodRequest = true,
162
164
  field,
163
165
  fixedToolbar,
164
166
  onSelect,
@@ -207,7 +209,7 @@ const ArgousComplexTable = forwardRef(({
207
209
  }, [ctrlPgn.recordCount]);
208
210
 
209
211
  const buscaMetodo = useCallback(async () => {
210
- if (!method) return;
212
+ if (!method || !allowMethodRequest) return;
211
213
  dispatch({ type: 'setLoading', value: true });
212
214
  const res = await serverAction(method, {
213
215
  ctrlPgn: {
@@ -216,14 +218,14 @@ const ArgousComplexTable = forwardRef(({
216
218
  tpOrdem: orderBy >= 0 ? (order === 'asc' ? 'A' : 'D') : undefined,
217
219
  indOrdem: orderBy >= 0 ? orderBy : undefined
218
220
  }, ...methodPrms
219
- }, true);
221
+ }, handleMethodError);
220
222
  onMethodResponse && onMethodResponse(res);
221
223
  if (res.status) {
222
224
  setCtrlPgn({ ...res.ctrlPgn, recordCount: res.ctrlPgn?.recordCount || res[methodResultList]?.length < res.ctrlPgn?.qtRegs ? res[methodResultList]?.length : res.ctrlPgn?.qtPaginas * res.ctrlPgn?.qtRegs });
223
225
  setLista(res[methodResultList] || []);
224
226
  }
225
227
  dispatch({ type: 'setLoading', value: false });
226
- }, [method, qtRegs, pgAtl, order, orderBy, retornaAcao, ctrlPgn.pgAtl, page, methodPrms, methodResultList]);
228
+ }, [method, qtRegs, pgAtl, order, orderBy, retornaAcao, ctrlPgn.pgAtl, page, methodPrms, methodResultList, handleMethodError, allowMethodRequest]);
227
229
 
228
230
  useEffect(() => {
229
231
  buscaMetodo();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.177",
3
+ "version": "1.2.178",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",