@senior-agronegocio/angular-components 0.0.9864 → 0.0.9866
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.
- package/bundles/senior-agronegocio-angular-components.umd.js +199 -85
- package/bundles/senior-agronegocio-angular-components.umd.js.map +1 -1
- package/bundles/senior-agronegocio-angular-components.umd.min.js +2 -2
- package/bundles/senior-agronegocio-angular-components.umd.min.js.map +1 -1
- package/components/financial-title-table/financial-title-table.component.d.ts +66 -4
- package/components/financial-title-table/index.d.ts +1 -1
- package/components/financial-title-table/services/financial/index.d.ts +2 -0
- package/esm2015/components/financial-title-table/financial-title-table.component.js +196 -82
- package/esm2015/components/financial-title-table/index.js +2 -2
- package/esm2015/components/financial-title-table/services/financial/index.js +2 -1
- package/esm5/components/financial-title-table/financial-title-table.component.js +198 -83
- package/esm5/components/financial-title-table/index.js +2 -2
- package/esm5/components/financial-title-table/services/financial/index.js +2 -1
- package/fesm2015/senior-agronegocio-angular-components.js +195 -82
- package/fesm2015/senior-agronegocio-angular-components.js.map +1 -1
- package/fesm5/senior-agronegocio-angular-components.js +196 -82
- package/fesm5/senior-agronegocio-angular-components.js.map +1 -1
- package/package.json +1 -1
|
@@ -6999,17 +6999,17 @@
|
|
|
6999
6999
|
return AgroEntityService;
|
|
7000
7000
|
}());
|
|
7001
7001
|
|
|
7002
|
-
|
|
7002
|
+
|
|
7003
7003
|
(function (TypeAccount) {
|
|
7004
7004
|
TypeAccount["PAYABLE"] = "PAYABLE";
|
|
7005
7005
|
TypeAccount["RECEIVABLE"] = "RECEIVABLE";
|
|
7006
|
-
})(TypeAccount || (TypeAccount = {}));
|
|
7007
|
-
|
|
7006
|
+
})(exports.TypeAccount || (exports.TypeAccount = {}));
|
|
7007
|
+
|
|
7008
7008
|
(function (StatusType) {
|
|
7009
7009
|
StatusType["OPEN"] = "OPEN";
|
|
7010
7010
|
StatusType["PAID"] = "PAID";
|
|
7011
7011
|
StatusType["CANCELLED"] = "CANCELLED";
|
|
7012
|
-
})(StatusType || (StatusType = {}));
|
|
7012
|
+
})(exports.StatusType || (exports.StatusType = {}));
|
|
7013
7013
|
var TitleFieldsOrderBy;
|
|
7014
7014
|
(function (TitleFieldsOrderBy) {
|
|
7015
7015
|
TitleFieldsOrderBy["NUMBER_TITLE"] = "NUMBER_TITLE";
|
|
@@ -7113,8 +7113,8 @@
|
|
|
7113
7113
|
this.form = new forms.FormGroup({
|
|
7114
7114
|
titlesForm: new forms.FormArray([], []),
|
|
7115
7115
|
});
|
|
7116
|
+
this.currentListParams = { first: 0, rows: 10, sortField: null, sortOrder: null, filters: {} };
|
|
7116
7117
|
this.ngUnsubscribe = new core.EventEmitter();
|
|
7117
|
-
this.currentListParams = { page: 0, size: 10, sort: [], filterData: {} };
|
|
7118
7118
|
common.registerLocaleData(localePt);
|
|
7119
7119
|
}
|
|
7120
7120
|
Object.defineProperty(FinancialTitleTableComponent.prototype, "titlesForm", {
|
|
@@ -7124,38 +7124,40 @@
|
|
|
7124
7124
|
enumerable: true,
|
|
7125
7125
|
configurable: true
|
|
7126
7126
|
});
|
|
7127
|
+
/**
|
|
7128
|
+
* Inicializa colunas da tabela e campos exibidos no sidebar,
|
|
7129
|
+
* depois dispara a primeira busca de títulos com os filtros informados em {@link options}.
|
|
7130
|
+
*/
|
|
7127
7131
|
FinancialTitleTableComponent.prototype.ngOnInit = function () {
|
|
7128
7132
|
this.gridColumns = [
|
|
7129
|
-
this.getFields("title", "agro.angular_components.title", ["numberTitle"], angularComponents.FieldType.String),
|
|
7130
|
-
this.getFields("type", "agro.angular_components.type", ["titleType.cod", "titleType.desc"], angularComponents.FieldType.String),
|
|
7131
|
-
this.getFields("entryDate", "agro.angular_components.entry", ["issueDate"], angularComponents.FieldType.Date),
|
|
7132
|
-
this.getFields("dueDate", "agro.angular_components.due_date", ["dueDate"], angularComponents.FieldType.Date),
|
|
7133
|
-
this.getFields("valueOrigin", "agro.angular_components.original_value", ["values.originalValue"], angularComponents.FieldType.Money),
|
|
7134
|
-
this.getFields("valueOpen", "agro.angular_components.open_value", ["values.openValue"], angularComponents.FieldType.Money),
|
|
7135
|
-
this.getFields("valueNet", "agro.angular_components.value_net", ["values.netValue"], angularComponents.FieldType.Money),
|
|
7136
|
-
this.getFields("valuePaid", "agro.angular_components.value_to_pay", ["valuePaid"], angularComponents.FieldType.Money),
|
|
7133
|
+
this.getFields("title", "agro.angular_components.title", ["numberTitle"], angularComponents.FieldType.String, TitleFieldsOrderBy.NUMBER_TITLE),
|
|
7134
|
+
this.getFields("type", "agro.angular_components.type", ["titleType.cod", "titleType.desc"], angularComponents.FieldType.String, null),
|
|
7135
|
+
this.getFields("entryDate", "agro.angular_components.entry", ["issueDate"], angularComponents.FieldType.Date, TitleFieldsOrderBy.ISSUE_DATE),
|
|
7136
|
+
this.getFields("dueDate", "agro.angular_components.due_date", ["dueDate"], angularComponents.FieldType.Date, TitleFieldsOrderBy.DUE_DATE),
|
|
7137
|
+
this.getFields("valueOrigin", "agro.angular_components.original_value", ["values.originalValue"], angularComponents.FieldType.Money, TitleFieldsOrderBy.ORIGINAL_VALUE),
|
|
7138
|
+
this.getFields("valueOpen", "agro.angular_components.open_value", ["values.openValue"], angularComponents.FieldType.Money, TitleFieldsOrderBy.OPEN_VALUE),
|
|
7139
|
+
this.getFields("valueNet", "agro.angular_components.value_net", ["values.netValue"], angularComponents.FieldType.Money, TitleFieldsOrderBy.NET_VALUE),
|
|
7140
|
+
this.getFields("valuePaid", "agro.angular_components.value_to_pay", ["valuePaid"], angularComponents.FieldType.Money, null),
|
|
7137
7141
|
];
|
|
7138
7142
|
this.sidebarFields = __spread([
|
|
7139
|
-
this.getFields("company", "agro.angular_components.company", ["company.cod", "company.desc"], angularComponents.FieldType.String),
|
|
7140
|
-
this.getFields("branch", "agro.angular_components.branch", ["branch.cod", "branch.desc"], angularComponents.FieldType.String),
|
|
7141
|
-
this.getFields("producer", "agro.angular_components.producer", ["producer.cod", "producer.desc"], angularComponents.FieldType.String)
|
|
7143
|
+
this.getFields("company", "agro.angular_components.company", ["company.cod", "company.desc"], angularComponents.FieldType.String, null),
|
|
7144
|
+
this.getFields("branch", "agro.angular_components.branch", ["branch.cod", "branch.desc"], angularComponents.FieldType.String, null),
|
|
7145
|
+
this.getFields("producer", "agro.angular_components.producer", ["producer.cod", "producer.desc"], angularComponents.FieldType.String, null)
|
|
7142
7146
|
], this.gridColumns.filter(function (col) { return !["valuePaid", "valueNet"].includes(col.field); }), [
|
|
7143
|
-
this.getFields("valueFees", "agro.angular_components.value_fees", ["values.feesValue"], angularComponents.FieldType.Money),
|
|
7144
|
-
this.getFields("valueFine", "agro.angular_components.value_fine", ["values.fineValue"], angularComponents.FieldType.Money),
|
|
7145
|
-
this.getFields("valueCharge", "agro.angular_components.value_charge", ["values.chargeValue"], angularComponents.FieldType.Money),
|
|
7146
|
-
this.getFields("valueCorrection", "agro.angular_components.value_correction", ["values.monetaryCorrectionValue"], angularComponents.FieldType.Money),
|
|
7147
|
-
this.getFields("valueAdditional", "agro.angular_components.value_additional", ["values.otherAdditionValue"], angularComponents.FieldType.Money),
|
|
7148
|
-
this.getFields("valueDiscount", "agro.angular_components.value_discount", ["values.discountValue"], angularComponents.FieldType.Money),
|
|
7149
|
-
this.getFields("valueOtherDiscount", "agro.angular_components.value_other_discount", ["values.otherDiscountValue"], angularComponents.FieldType.Money)
|
|
7147
|
+
this.getFields("valueFees", "agro.angular_components.value_fees", ["values.feesValue"], angularComponents.FieldType.Money, null),
|
|
7148
|
+
this.getFields("valueFine", "agro.angular_components.value_fine", ["values.fineValue"], angularComponents.FieldType.Money, null),
|
|
7149
|
+
this.getFields("valueCharge", "agro.angular_components.value_charge", ["values.chargeValue"], angularComponents.FieldType.Money, null),
|
|
7150
|
+
this.getFields("valueCorrection", "agro.angular_components.value_correction", ["values.monetaryCorrectionValue"], angularComponents.FieldType.Money, null),
|
|
7151
|
+
this.getFields("valueAdditional", "agro.angular_components.value_additional", ["values.otherAdditionValue"], angularComponents.FieldType.Money, null),
|
|
7152
|
+
this.getFields("valueDiscount", "agro.angular_components.value_discount", ["values.discountValue"], angularComponents.FieldType.Money, null),
|
|
7153
|
+
this.getFields("valueOtherDiscount", "agro.angular_components.value_other_discount", ["values.otherDiscountValue"], angularComponents.FieldType.Money, null)
|
|
7150
7154
|
], this.gridColumns.filter(function (col) { return ["valueNet"].includes(col.field); }));
|
|
7151
|
-
this.updateGrid(
|
|
7152
|
-
first: 0,
|
|
7153
|
-
rows: this.getPageSize(),
|
|
7154
|
-
sortField: this.getSortField(),
|
|
7155
|
-
sortOrder: this.getSortOrder(),
|
|
7156
|
-
});
|
|
7157
|
-
this.subscribeToValuePaidChanges();
|
|
7155
|
+
this.updateGrid(this.currentListParams);
|
|
7158
7156
|
};
|
|
7157
|
+
/**
|
|
7158
|
+
* Após a renderização da tabela, sincroniza o estado de checkbox/linha editável
|
|
7159
|
+
* com o array de títulos selecionados para evitar acesso a referências ainda não criadas.
|
|
7160
|
+
*/
|
|
7159
7161
|
FinancialTitleTableComponent.prototype.ngAfterViewInit = function () {
|
|
7160
7162
|
this.tableInitialized = true;
|
|
7161
7163
|
this.synchronizeCheckboxAndEditableFieldState();
|
|
@@ -7165,32 +7167,37 @@
|
|
|
7165
7167
|
this.ngUnsubscribe.complete();
|
|
7166
7168
|
};
|
|
7167
7169
|
FinancialTitleTableComponent.prototype.getPageSize = function () {
|
|
7168
|
-
|
|
7170
|
+
var _a;
|
|
7171
|
+
return (_a = this.currentListParams) === null || _a === void 0 ? void 0 : _a.rows;
|
|
7169
7172
|
};
|
|
7170
7173
|
FinancialTitleTableComponent.prototype.getRowIndex = function () {
|
|
7171
|
-
|
|
7174
|
+
var _a;
|
|
7175
|
+
return (_a = this.currentListParams) === null || _a === void 0 ? void 0 : _a.first;
|
|
7172
7176
|
};
|
|
7173
7177
|
FinancialTitleTableComponent.prototype.getSortField = function () {
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
}
|
|
7177
|
-
return this.currentListParams.sort[0].field;
|
|
7178
|
+
var _a;
|
|
7179
|
+
return (_a = this.currentListParams) === null || _a === void 0 ? void 0 : _a.sortField;
|
|
7178
7180
|
};
|
|
7179
7181
|
FinancialTitleTableComponent.prototype.getSortOrder = function () {
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
}
|
|
7183
|
-
return this.currentListParams.sort[0].order;
|
|
7182
|
+
var _a;
|
|
7183
|
+
return (_a = this.currentListParams) === null || _a === void 0 ? void 0 : _a.sortOrder;
|
|
7184
7184
|
};
|
|
7185
|
+
/**
|
|
7186
|
+
* Faz requisição paginada/ordenada para listar os títulos, monta o formulário
|
|
7187
|
+
* reativo para cada linha e trata erros de backend exibindo mensagem ao usuário.
|
|
7188
|
+
*
|
|
7189
|
+
* @param event parâmetros de paginação, ordenação e filtros vindos do PrimeNG.
|
|
7190
|
+
*/
|
|
7185
7191
|
FinancialTitleTableComponent.prototype.updateGrid = function (event) {
|
|
7186
7192
|
var _this = this;
|
|
7187
7193
|
this.componentLoading = true;
|
|
7188
7194
|
var size = event.rows;
|
|
7189
7195
|
var page = event.first / size;
|
|
7190
|
-
var
|
|
7191
|
-
|
|
7196
|
+
var field = event.sortField;
|
|
7197
|
+
var sortOrder = event.sortOrder;
|
|
7198
|
+
this.currentListParams = event;
|
|
7192
7199
|
var input = {
|
|
7193
|
-
pageRequest: { offset: page, size: size },
|
|
7200
|
+
pageRequest: { offset: page, orderBy: this.getRecOrderBy(field, sortOrder), size: size },
|
|
7194
7201
|
filter: this.options,
|
|
7195
7202
|
};
|
|
7196
7203
|
this.financialService
|
|
@@ -7202,14 +7209,7 @@
|
|
|
7202
7209
|
}))
|
|
7203
7210
|
.subscribe(function (list) {
|
|
7204
7211
|
_this.gridData = list.titles || [];
|
|
7205
|
-
_this.
|
|
7206
|
-
_this.gridData.forEach(function (item, index) {
|
|
7207
|
-
var selectedItem = _this.selected.find(function (sel) { return sel.id === item.id; });
|
|
7208
|
-
_this.form.get("titlesForm").push(new forms.FormGroup({
|
|
7209
|
-
id: new forms.FormControl(item.id || null, []),
|
|
7210
|
-
valuePaid: new forms.FormControl((selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.valuePaid) || null, []),
|
|
7211
|
-
}));
|
|
7212
|
-
});
|
|
7212
|
+
_this.createFormGroupForTitle();
|
|
7213
7213
|
_this.gridTotalRecords = list.totalElements;
|
|
7214
7214
|
_this.componentLoading = false;
|
|
7215
7215
|
_this.synchronizeCheckboxAndEditableFieldState();
|
|
@@ -7220,10 +7220,23 @@
|
|
|
7220
7220
|
this.synchronizeCheckboxAndEditableFieldState();
|
|
7221
7221
|
this.selectionChange.emit(this.selected);
|
|
7222
7222
|
};
|
|
7223
|
+
/**
|
|
7224
|
+
* Quando um item é desmarcado, limpa o `valuePaid` correspondente
|
|
7225
|
+
* tanto no modelo da linha quanto no {@link titlesForm}, sem disparar novos eventos.
|
|
7226
|
+
*
|
|
7227
|
+
* @param event evento de desmarcação emitido pelo PrimeNG.
|
|
7228
|
+
*/
|
|
7223
7229
|
FinancialTitleTableComponent.prototype.onUnselect = function (event) {
|
|
7230
|
+
var _a;
|
|
7224
7231
|
var row = this.gridData.find(function (r) { return r.id === event.data.id; });
|
|
7225
7232
|
if (row) {
|
|
7226
7233
|
row.valuePaid = null;
|
|
7234
|
+
// atualiza form control correspondente
|
|
7235
|
+
var idx = this.gridData.findIndex(function (g) { return g.id === row.id; });
|
|
7236
|
+
var ctrl = (_a = this.titlesForm.at(idx)) === null || _a === void 0 ? void 0 : _a.get("valuePaid");
|
|
7237
|
+
if (ctrl) {
|
|
7238
|
+
ctrl.setValue(null, { emitEvent: false });
|
|
7239
|
+
}
|
|
7227
7240
|
}
|
|
7228
7241
|
};
|
|
7229
7242
|
FinancialTitleTableComponent.prototype.showDetails = function (rowData) {
|
|
@@ -7279,52 +7292,134 @@
|
|
|
7279
7292
|
}
|
|
7280
7293
|
return result;
|
|
7281
7294
|
};
|
|
7282
|
-
|
|
7295
|
+
/**
|
|
7296
|
+
* Reconstrói o {@link titlesForm} com base na {@link gridData} atual,
|
|
7297
|
+
* preservando valores já informados em itens selecionados e registrando listeners de mudança.
|
|
7298
|
+
*/
|
|
7299
|
+
FinancialTitleTableComponent.prototype.createFormGroupForTitle = function () {
|
|
7300
|
+
var _this = this;
|
|
7301
|
+
var titlesFormArray = this.form.get("titlesForm");
|
|
7302
|
+
titlesFormArray.clear();
|
|
7303
|
+
this.gridData.forEach(function (item) {
|
|
7304
|
+
var _a;
|
|
7305
|
+
var selectedItem = _this.selected.find(function (sel) { return sel.id === item.id; });
|
|
7306
|
+
var group = new forms.FormGroup({
|
|
7307
|
+
id: new forms.FormControl(item.id || null, []),
|
|
7308
|
+
valuePaid: new forms.FormControl((_a = selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.valuePaid) !== null && _a !== void 0 ? _a : null, []),
|
|
7309
|
+
});
|
|
7310
|
+
_this.subscribeToValuePaidChanges(group, item);
|
|
7311
|
+
titlesFormArray.push(group);
|
|
7312
|
+
});
|
|
7313
|
+
};
|
|
7314
|
+
/**
|
|
7315
|
+
* Observa mudanças no campo `valuePaid` de uma linha.
|
|
7316
|
+
* Atualiza o array {@link selected} quando o título está selecionado,
|
|
7317
|
+
* aplica o limite do valor líquido (`netValue`) e evita loops de eventos usando
|
|
7318
|
+
* `setValue` com `emitEvent: false`.
|
|
7319
|
+
*
|
|
7320
|
+
* @param formGroup grupo de formulário associado à linha da tabela.
|
|
7321
|
+
* @param item título financeiro correspondente à linha.
|
|
7322
|
+
*/
|
|
7323
|
+
FinancialTitleTableComponent.prototype.subscribeToValuePaidChanges = function (formGroup, item) {
|
|
7283
7324
|
var _this = this;
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7325
|
+
var valuePaidControl = formGroup.get("valuePaid");
|
|
7326
|
+
valuePaidControl.valueChanges.pipe(operators.takeUntil(this.ngUnsubscribe)).subscribe(function (rawValue) {
|
|
7327
|
+
var _a, _b, _c, _d;
|
|
7328
|
+
var valuePaid = _this.parseNumberSafe(rawValue);
|
|
7329
|
+
var titleId = (_a = formGroup.get("id")) === null || _a === void 0 ? void 0 : _a.value;
|
|
7330
|
+
// atualiza selected se o título estiver selecionado
|
|
7331
|
+
var selIndex = _this.selected.findIndex(function (s) { return s.id === titleId; });
|
|
7332
|
+
if (selIndex !== -1) {
|
|
7333
|
+
// garante que valuePaid seja numérico ou null
|
|
7334
|
+
_this.selected[selIndex].valuePaid = valuePaid;
|
|
7335
|
+
var net = Number((_c = (_b = _this.selected[selIndex]) === null || _b === void 0 ? void 0 : _b.values) === null || _c === void 0 ? void 0 : _c.netValue) || 0;
|
|
7336
|
+
if (valuePaid !== null && valuePaid > net) {
|
|
7337
|
+
_this.selected[selIndex].valuePaid = net;
|
|
7338
|
+
// Usado para evitar loop infinito de eventos
|
|
7339
|
+
valuePaidControl.setValue(net, { emitEvent: false });
|
|
7290
7340
|
}
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7341
|
+
// atualiza flag de erro
|
|
7342
|
+
_this.selected[selIndex].hasError = valuePaidControl.invalid;
|
|
7343
|
+
// emite mudança de seleção
|
|
7344
|
+
_this.selectionChange.emit(_this.selected);
|
|
7345
|
+
}
|
|
7346
|
+
else {
|
|
7347
|
+
// se não estiver selecionado, apenas aplica limite local baseado no item
|
|
7348
|
+
var net = Number((_d = item === null || item === void 0 ? void 0 : item.values) === null || _d === void 0 ? void 0 : _d.netValue) || 0;
|
|
7349
|
+
if (valuePaid !== null && valuePaid > net) {
|
|
7350
|
+
valuePaidControl.setValue(net, { emitEvent: false });
|
|
7294
7351
|
}
|
|
7295
|
-
|
|
7296
|
-
});
|
|
7297
|
-
_this.selectionChange.emit(_this.selected);
|
|
7352
|
+
}
|
|
7298
7353
|
});
|
|
7299
7354
|
};
|
|
7355
|
+
FinancialTitleTableComponent.prototype.parseNumberSafe = function (value) {
|
|
7356
|
+
if (value === null || value === undefined || value === "") {
|
|
7357
|
+
return null;
|
|
7358
|
+
}
|
|
7359
|
+
if (typeof value === "number") {
|
|
7360
|
+
return value;
|
|
7361
|
+
}
|
|
7362
|
+
if (typeof value === "string") {
|
|
7363
|
+
var cleaned = value.replace(/\./g, "").replace(",", ".");
|
|
7364
|
+
var n = parseFloat(cleaned);
|
|
7365
|
+
return isNaN(n) ? null : n;
|
|
7366
|
+
}
|
|
7367
|
+
return null;
|
|
7368
|
+
};
|
|
7369
|
+
/**
|
|
7370
|
+
* Inicia o modo de edição na linha da tabela PrimeNG e aplica regras de validação
|
|
7371
|
+
* no formulário reativo correspondente àquela linha.
|
|
7372
|
+
*
|
|
7373
|
+
* @param row objeto de linha recebido da tabela.
|
|
7374
|
+
*/
|
|
7300
7375
|
FinancialTitleTableComponent.prototype.initRowEdit = function (row) {
|
|
7301
7376
|
if (this.table) {
|
|
7302
7377
|
this.table.initRowEdit(row);
|
|
7303
7378
|
this.applyValidationToRowEdit(row);
|
|
7304
7379
|
}
|
|
7305
7380
|
};
|
|
7381
|
+
/**
|
|
7382
|
+
* Adiciona validadores dinamicamente ao campo `valuePaid` da linha em edição,
|
|
7383
|
+
* marca o controle como sujo e força revalidação imediata para exibir erros na tela.
|
|
7384
|
+
*
|
|
7385
|
+
* @param row objeto de linha para aplicar validação.
|
|
7386
|
+
*/
|
|
7306
7387
|
FinancialTitleTableComponent.prototype.applyValidationToRowEdit = function (row) {
|
|
7307
|
-
var _a, _b, _c;
|
|
7308
7388
|
var rowIndex = this.gridData.findIndex(function (r) { return r.id === row.id; });
|
|
7309
7389
|
var formGroup = this.titlesForm.at(rowIndex);
|
|
7310
|
-
(
|
|
7311
|
-
|
|
7312
|
-
|
|
7390
|
+
if (!formGroup) {
|
|
7391
|
+
return;
|
|
7392
|
+
}
|
|
7393
|
+
var valuePaidControl = formGroup.get("valuePaid");
|
|
7394
|
+
valuePaidControl === null || valuePaidControl === void 0 ? void 0 : valuePaidControl.setValidators([this.getValidatorsForRowEdit(), forms.Validators.required]);
|
|
7395
|
+
valuePaidControl === null || valuePaidControl === void 0 ? void 0 : valuePaidControl.markAsDirty();
|
|
7396
|
+
valuePaidControl === null || valuePaidControl === void 0 ? void 0 : valuePaidControl.updateValueAndValidity();
|
|
7313
7397
|
};
|
|
7398
|
+
/**
|
|
7399
|
+
* Constrói o {@link ValidatorFn} que valida o `valuePaid`:
|
|
7400
|
+
* - deve ser maior que zero;
|
|
7401
|
+
* - não pode ultrapassar o valor líquido (`netValue`) do título.
|
|
7402
|
+
*
|
|
7403
|
+
* Retorna os erros consumidos pelo componente `s-control-errors`.
|
|
7404
|
+
*/
|
|
7314
7405
|
FinancialTitleTableComponent.prototype.getValidatorsForRowEdit = function () {
|
|
7315
7406
|
var _this = this;
|
|
7316
7407
|
return function (control) {
|
|
7317
7408
|
var _a, _b;
|
|
7318
|
-
var
|
|
7319
|
-
var
|
|
7320
|
-
var
|
|
7409
|
+
var parent = control.parent;
|
|
7410
|
+
var titleId = (_a = parent === null || parent === void 0 ? void 0 : parent.get("id")) === null || _a === void 0 ? void 0 : _a.value;
|
|
7411
|
+
var rawValue = control.value;
|
|
7412
|
+
var valuePaid = _this.parseNumberSafe(rawValue);
|
|
7321
7413
|
if (valuePaid === null || valuePaid === undefined) {
|
|
7322
7414
|
return null;
|
|
7323
7415
|
}
|
|
7324
7416
|
if (valuePaid <= exports.AGRO_NUMBERS.ZERO) {
|
|
7325
7417
|
return { lessThanZero: true };
|
|
7326
7418
|
}
|
|
7327
|
-
|
|
7419
|
+
// procura pelo título no selected ou no gridData (prioriza selected)
|
|
7420
|
+
var selectedRow = _this.selected.find(function (sel) { return sel.id === titleId; }) || _this.gridData.find(function (g) { return g.id === titleId; });
|
|
7421
|
+
var netValue = Number((_b = selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.values) === null || _b === void 0 ? void 0 : _b.netValue) || 0;
|
|
7422
|
+
if (valuePaid > netValue) {
|
|
7328
7423
|
return { greatherThanAllowed: true };
|
|
7329
7424
|
}
|
|
7330
7425
|
return null;
|
|
@@ -7335,30 +7430,39 @@
|
|
|
7335
7430
|
this.table.cancelRowEdit(row);
|
|
7336
7431
|
}
|
|
7337
7432
|
};
|
|
7433
|
+
/**
|
|
7434
|
+
* Mantém o estado visual da tabela (checkbox marcado e linha editável) em
|
|
7435
|
+
* sincronia com o array de títulos selecionados, inclusive restaurando valores
|
|
7436
|
+
* digitados ao recarregar, ordenar ou paginar a grid.
|
|
7437
|
+
*/
|
|
7338
7438
|
FinancialTitleTableComponent.prototype.synchronizeCheckboxAndEditableFieldState = function () {
|
|
7339
7439
|
var _this = this;
|
|
7340
7440
|
if (!this.gridData || !this.tableInitialized) {
|
|
7341
7441
|
return;
|
|
7342
7442
|
}
|
|
7343
|
-
this.
|
|
7344
|
-
var
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7443
|
+
this.gridData.forEach(function (row, index) {
|
|
7444
|
+
var _a;
|
|
7445
|
+
var selectedRow = _this.selected.find(function (sel) { return sel.id === row.id; });
|
|
7446
|
+
var ctrl = (_a = _this.titlesForm.at(index)) === null || _a === void 0 ? void 0 : _a.get("valuePaid");
|
|
7447
|
+
if (selectedRow) {
|
|
7448
|
+
// Sincroniza o valor pago do item selecionado
|
|
7449
|
+
row.valuePaid = selectedRow.valuePaid;
|
|
7450
|
+
if (ctrl) {
|
|
7451
|
+
ctrl.setValue(selectedRow.valuePaid, { emitEvent: false });
|
|
7452
|
+
}
|
|
7353
7453
|
_this.initRowEdit(row);
|
|
7354
7454
|
}
|
|
7355
7455
|
else {
|
|
7456
|
+
// Cancela a edição se não estiver selecionado
|
|
7457
|
+
if (ctrl) {
|
|
7458
|
+
ctrl.setValue(null, { emitEvent: false });
|
|
7459
|
+
}
|
|
7356
7460
|
_this.cancelRowEdit(row);
|
|
7357
7461
|
}
|
|
7358
7462
|
});
|
|
7359
7463
|
};
|
|
7360
|
-
FinancialTitleTableComponent.prototype.getFields = function (field, header, path, type) {
|
|
7361
|
-
return { field: field, path: path, type: type, header: this.translate.instant(header) };
|
|
7464
|
+
FinancialTitleTableComponent.prototype.getFields = function (field, header, path, type, fieldOrderBy) {
|
|
7465
|
+
return { field: field, path: path, type: type, header: this.translate.instant(header), orderBy: fieldOrderBy };
|
|
7362
7466
|
};
|
|
7363
7467
|
FinancialTitleTableComponent.prototype.addMessage = function (severity, summary, detail, sticky) {
|
|
7364
7468
|
if (sticky === void 0) { sticky = false; }
|
|
@@ -7369,6 +7473,16 @@
|
|
|
7369
7473
|
detail: this.translate.instant(detail),
|
|
7370
7474
|
});
|
|
7371
7475
|
};
|
|
7476
|
+
FinancialTitleTableComponent.prototype.getRecOrderBy = function (field, order) {
|
|
7477
|
+
var gridColumnField = this.gridColumns.find(function (col) { return col.field === field; });
|
|
7478
|
+
if ((gridColumnField === null || gridColumnField === void 0 ? void 0 : gridColumnField.orderBy) === null) {
|
|
7479
|
+
return null;
|
|
7480
|
+
}
|
|
7481
|
+
return {
|
|
7482
|
+
field: (gridColumnField === null || gridColumnField === void 0 ? void 0 : gridColumnField.orderBy) || TitleFieldsOrderBy.NUMBER_TITLE,
|
|
7483
|
+
order: order === 1 ? OrderByType.ASC : OrderByType.DESC,
|
|
7484
|
+
};
|
|
7485
|
+
};
|
|
7372
7486
|
FinancialTitleTableComponent.ctorParameters = function () { return [
|
|
7373
7487
|
{ type: LibTranslationService },
|
|
7374
7488
|
{ type: AgroFinancialService },
|
|
@@ -7389,7 +7503,7 @@
|
|
|
7389
7503
|
FinancialTitleTableComponent = __decorate([
|
|
7390
7504
|
core.Component({
|
|
7391
7505
|
selector: "s-financial-title-table",
|
|
7392
|
-
template: "<ng-container *sLoadingState=\"componentLoading\">\r\n <div [hidden]=\"gridData?.length > 0\">\r\n <s-empty-state\r\n iconClass=\"fa fa-inbox\"\r\n title=\"{{ 'agro.angular_components.no_accounts_found_title' | libTranslate }}\"\r\n [showPrimaryAction]=\"false\"\r\n description=\"{{ 'agro.angular_components.no_accounts_found_description' | libTranslate }}\"\r\n ></s-empty-state>\r\n </div>\r\n <p-table\r\n #TitleTable\r\n [hidden]=\"gridData?.length === 0\"\r\n [value]=\"gridData\"\r\n [columns]=\"gridColumns\"\r\n dataKey=\"id\"\r\n [lazy]=\"true\"\r\n [paginator]=\"true\"\r\n [totalRecords]=\"gridTotalRecords\"\r\n [sortField]=\"getSortField()\"\r\n [sortOrder]=\"getSortOrder()\"\r\n [first]=\"getRowIndex()\"\r\n [rows]=\"getPageSize()\"\r\n [lazyLoadOnInit]=\"false\"\r\n [rowsPerPageOptions]=\"[10, 20, 50, 100]\"\r\n (onLazyLoad)=\"updateGrid($event)\"\r\n [(selection)]=\"selected\"\r\n (selectionChange)=\"onSelectionChange($event)\"\r\n (onRowUnselect)=\"onUnselect($event)\"\r\n sortMode=\"
|
|
7506
|
+
template: "<ng-container *sLoadingState=\"componentLoading\">\r\n <div [hidden]=\"gridData?.length > 0\">\r\n <s-empty-state\r\n iconClass=\"fa fa-inbox\"\r\n title=\"{{ 'agro.angular_components.no_accounts_found_title' | libTranslate }}\"\r\n [showPrimaryAction]=\"false\"\r\n description=\"{{ 'agro.angular_components.no_accounts_found_description' | libTranslate }}\"\r\n ></s-empty-state>\r\n </div>\r\n <p-table\r\n #TitleTable\r\n [hidden]=\"gridData?.length === 0\"\r\n [value]=\"gridData\"\r\n [columns]=\"gridColumns\"\r\n dataKey=\"id\"\r\n [lazy]=\"true\"\r\n [paginator]=\"true\"\r\n [totalRecords]=\"gridTotalRecords\"\r\n [sortField]=\"getSortField()\"\r\n [sortOrder]=\"getSortOrder()\"\r\n [first]=\"getRowIndex()\"\r\n [rows]=\"getPageSize()\"\r\n [lazyLoadOnInit]=\"false\"\r\n [rowsPerPageOptions]=\"[10, 20, 50, 100]\"\r\n (onLazyLoad)=\"updateGrid($event)\"\r\n [(selection)]=\"selected\"\r\n (selectionChange)=\"onSelectionChange($event)\"\r\n (onRowUnselect)=\"onUnselect($event)\"\r\n sortMode=\"single\"\r\n [selectionMode]=\"'multiple'\"\r\n editMode=\"row\"\r\n [scrollable]=\"true\"\r\n [sTableFrozenPosition]=\"'right'\"\r\n [sTableFrozenValue]=\"gridData\"\r\n frozenWidth=\"160px\"\r\n >\r\n <ng-template pTemplate=\"header\" let-columns>\r\n <tr>\r\n <th class=\"table-checkbox-header\" scope=\"col\" [ngStyle]=\"getStyleColumns('checkbox')\">\r\n <p-tableHeaderCheckbox></p-tableHeaderCheckbox>\r\n </th>\r\n <ng-container *ngFor=\"let col of columns; let i = index\">\r\n <ng-container *ngIf=\"col.orderBy; else notSortable\">\r\n <th [pSortableColumn]=\"col.field\" [scope]=\"'col'\" [ngStyle]=\"getStyleColumns(col.field)\">\r\n {{ col.header }}\r\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\r\n </th>\r\n </ng-container>\r\n <ng-template #notSortable>\r\n <th [scope]=\"'col'\" [ngStyle]=\"getStyleColumns(col.field)\">\r\n {{ col.header }}\r\n </th>\r\n </ng-template>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n <ng-template pTemplate=\"frozenheader\">\r\n <tr>\r\n <th scope=\"col\" pFrozenColumn>\r\n {{ 'agro.angular_components.details' | libTranslate }}\r\n </th>\r\n </tr>\r\n </ng-template>\r\n <ng-template\r\n pTemplate=\"body\"\r\n let-rowData\r\n let-columns=\"columns\"\r\n let-rowIndex=\"rowIndex\"\r\n let-editing=\"editing\"\r\n let-ri=\"rowIndex\"\r\n >\r\n <tr [pEditableRow]=\"rowData\" [formGroup]=\"$any(titlesForm.at(rowIndex))\">\r\n <td class=\"table-checkbox-header\" [ngStyle]=\"getStyleColumns('checkbox')\">\r\n <p-tableCheckbox [value]=\"rowData\"></p-tableCheckbox>\r\n </td>\r\n <td *ngFor=\"let col of columns; let i = index\" [ngStyle]=\"getStyleColumns(col.field)\">\r\n <p-cellEditor>\r\n <ng-template pTemplate=\"input\">\r\n <ng-container [ngSwitch]=\"col.field\">\r\n <ng-container *ngSwitchCase=\"'valuePaid'\">\r\n <input\r\n pInputText\r\n sNumberInput\r\n class=\"w-full\"\r\n id=\"valuePaid-input-{{ rowData.id || rowIndex }}\"\r\n decimalSeparator=\",\"\r\n thousandsSeparator=\".\"\r\n formControlName=\"valuePaid\"\r\n type=\"text\"\r\n [scale]=\"2\"\r\n [allowNegative]=\"false\"\r\n [attr.aria-label]=\"'agro.angular_components.value_paid' | libTranslate\"\r\n />\r\n <br />\r\n <s-control-errors\r\n [control]=\"$any(titlesForm.at(rowIndex)).get('valuePaid')\"\r\n [errorMessages]=\"errorMessage\"\r\n >\r\n </s-control-errors>\r\n </ng-container>\r\n <ng-container *ngSwitchDefault>\r\n {{ getProp(rowData, col) }}\r\n </ng-container>\r\n </ng-container>\r\n </ng-template>\r\n <ng-template pTemplate=\"output\">\r\n <ng-container [ngSwitch]=\"col.field\">\r\n <ng-container *ngSwitchCase=\"'valuePaid'\">\r\n {{ rowData['valuePaid'] || 0 | currency: 'BRL':'symbol':'1.2-2':'pt-BR' }}\r\n </ng-container>\r\n <ng-container *ngSwitchDefault>\r\n {{ getProp(rowData, col) }}\r\n </ng-container>\r\n </ng-container>\r\n </ng-template>\r\n </p-cellEditor>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n <ng-template pTemplate=\"frozenbody\" let-rowData let-columns>\r\n <tr [pEditableRow]=\"rowData\">\r\n <td pFrozenColumn>\r\n <s-button\r\n id=\"details-{{ rowData.id }}\"\r\n (click)=\"showDetails(rowData)\"\r\n (keydown.enter)=\"showDetails(rowData)\"\r\n label=\"{{ 'agro.angular_components.details' | libTranslate }}\"\r\n [priority]=\"buttonPriority.Default\"\r\n [disabled]=\"false\"\r\n [auxiliary]=\"true\"\r\n [size]=\"buttonSize.Small\"\r\n iconClass=\"fa fa-rocket\"\r\n ></s-button>\r\n </td>\r\n </tr>\r\n </ng-template>\r\n </p-table>\r\n</ng-container>\r\n<s-sidebar\r\n [(visible)]=\"showSidebar\"\r\n position=\"right\"\r\n [header]=\"('agro.angular_components.account_details' | libTranslate) + ' ' + (selectedRow?.numberTitle || '')\"\r\n>\r\n <div class=\"ui-fluid\">\r\n <div class=\"ui-g\">\r\n <ng-container *ngFor=\"let field of sidebarFields\">\r\n <div class=\"ui-g-4\">\r\n <span>\r\n <strong>{{ field.header }}</strong>\r\n </span>\r\n <p>{{ getProp(selectedRow, field) || '-' }}</p>\r\n </div>\r\n </ng-container>\r\n <ng-template #noValue>-</ng-template>\r\n <div class=\"ui-g-4\">\r\n <span>\r\n <strong>{{ 'agro.angular_components.status_label' | libTranslate }}</strong>\r\n </span>\r\n <p>\r\n <ng-container [ngSwitch]=\"selectedRow?.status\">\r\n <span *ngSwitchCase=\"'OPEN'\">\r\n <s-badge\r\n [color]=\"badgeColors.Yellow\"\r\n text=\"{{ 'agro.angular_components.status_open' | libTranslate }}\"\r\n [selectable]=\"false\"\r\n ></s-badge>\r\n </span>\r\n <span *ngSwitchCase=\"'PAID'\">\r\n <s-badge\r\n [color]=\"badgeColors.Green\"\r\n text=\"{{ 'agro.angular_components.status_paid' | libTranslate }}\"\r\n [selectable]=\"false\"\r\n ></s-badge>\r\n </span>\r\n </ng-container>\r\n </p>\r\n </div>\r\n </div>\r\n </div>\r\n <s-footer>\r\n <s-button label=\"{{ 'agro.angular_components.close' | libTranslate }}\" (onClick)=\"closeDetails()\"> </s-button>\r\n </s-footer>\r\n</s-sidebar>\r\n",
|
|
7393
7507
|
styles: [".error-message{color:#c13018;margin-top:5px;font-size:12px}"]
|
|
7394
7508
|
})
|
|
7395
7509
|
], FinancialTitleTableComponent);
|