Skip to content

Commit

Permalink
update sign posting when trying to edit more than the updateLimit num…
Browse files Browse the repository at this point in the history
…ber of tiles, re #11117
  • Loading branch information
apeters committed Aug 8, 2024
1 parent de3e7cf commit 51d442d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ define([
'select-woo'
], function(ko, $, uuid, arches, JsonErrorAlertViewModel, baseStringEditorTemplate) {
const ViewModel = function(params) {
console.log(params);
const self = this;
this.config = params.config;
this.state = params.state;
this.editHistoryUrl = `${arches.urls.edit_history}?transactionid=${ko.unwrap(params.selectedLoadEvent)?.loadid}`;
this.load_details = params.load_details ?? {};
Expand All @@ -34,6 +34,10 @@ define([
//paging
this.currentPageIndex = ko.observable(0);
this.tilesToRemove = ko.observableArray();
//length table
this.numberOfTiles = ko.observable();
this.numberOfResources = ko.observable();
this.previewLimit = ko.observable();
//loading status
this.formatTime = params.formatTime;
this.selectedLoadEvent = params.selectedLoadEvent || ko.observable();
Expand All @@ -55,9 +59,6 @@ define([
self.formData.append('tilesToRemove', self.tilesToRemove());
};

//length table
self.listLength = ko.observable();

//paging
// Function to navigate to the previous page
self.previousPage = function() {
Expand All @@ -77,7 +78,7 @@ define([
});
// Computed observable to calculate the maximum page index
self.maxPageIndex = ko.computed(function() {
return Math.ceil(self.listLength() / 5) - 1;
return Math.ceil(self.numberOfTiles() / 5) - 1;
});

// Computed observable to paginate rows
Expand Down Expand Up @@ -119,7 +120,7 @@ define([
});

this.allowEditOperation = ko.computed(() => {
return self.ready() && self.listLength() > 0 && self.showPreview();
return self.ready() && self.numberOfTiles() > 0 && self.showPreview();
});

this.inTileList = (tileToFind) => {
Expand All @@ -139,9 +140,10 @@ define([
this.getPreviewData = function() {
self.showPreview(true);
self.submit('preview').then(data => {
self.listLength(data.result.number_of_tiles);
self.numberOfResources(data.result.number_of_resources);
self.numberOfTiles(data.result.number_of_tiles);
self.previewLimit(data.result.preview_limit);
self.paginatedRows(data.result.values);

}).fail(function(err) {
self.alert(
new JsonErrorAlertViewModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,23 @@ <h3>

<!-- ko if: showPreview-->
<section class="etl-preview">
<!-- ko if: listLength() === 0 -->
<!-- ko if: numberOfTiles() === 0 -->
<h3 style="margin-top: 0px;">
<span style="margin: 2px;" class="fa fa-info-circle"></span><span data-bind="text: $root.translations.noDataToPreview"></span>
</h3>
<!-- /ko -->
<!-- ko if: listLength() > 0 -->
<div data-bind="visible: ready">
<div>
<p style="margin-top: 10px; color: rgb(17, 15, 15); display: inline-block; font-size: 15px;">
Affected resources:<span data-bind="text: listLength() === 0 ? 0 : (currentPageIndex() * 5 + 1)"></span>
<!-- ko if: listLength() !== 0 -->
to <span data-bind="text: Math.min((currentPageIndex() + 1) * 5, listLength())"></span>
out of <span data-bind="text: listLength()"></span>
<!-- /ko -->
</p>
<!-- ko if: numberOfTiles() > 0 -->
<h3 style="margin-top: 0px;">
<span data-bind="text: $root.translations.previewCountStats(numberOfTiles()>previewLimit()?previewLimit():numberOfTiles(),numberOfTiles(),numberOfResources())"></span>
<div style="display: inline-flex;">
<button data-bind="click: previousPage, enable: currentPageIndex() > 0" class="btn btn-success" style="display: inline-block; margin-right: 10px;">Previous</button>
<button data-bind="click: nextPage, enable: currentPageIndex() < maxPageIndex()" class="btn btn-success" style="display: inline-block;">Next</button>
</div>
</h3>
<h3 style="margin-top: 0px;color:red;" data-bind="if: numberOfTiles() > config.updateLimit">
<span style="margin: 2px;" class="fa fa-info-circle"></span><span data-bind="text: $root.translations.bulkEditLimitWarning(config.updateLimit.toLocaleString())"></span>
</h3>
<div data-bind="visible: ready">
<table class="table table-striped csv-mapping-table">
<thead>
<tr>
Expand Down

0 comments on commit 51d442d

Please sign in to comment.