Skip to content

DEV-250 [FIX] Ensures the component reacts to data changes when entries are added to or removed from the connected Data Source. #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions js/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ function fetchCurrentDataSourceEntries(entries) {

// On initial load, create an empty spreadsheet as this speeds up subsequent loads
if (initialLoad) {
if (table) {
table.destroy();
}

table = spreadsheet({ columns: columns, rows: [], initialLoad: true });

setTimeout(function() {
Expand All @@ -435,6 +439,10 @@ function fetchCurrentDataSourceEntries(entries) {
$('#versions').removeClass('hidden');
}, 0);
} else {
if (table) {
table.destroy();
}

table = spreadsheet({ columns: columns, rows: rows });
$('.table-entries').css('visibility', 'visible');

Expand Down Expand Up @@ -673,6 +681,7 @@ function saveCurrentData() {
var columns;

table.onSave();
fetchCurrentDataSourceEntries();

var entries = table.getData({
parseJSON: true,
Expand Down Expand Up @@ -725,6 +734,10 @@ function saveCurrentData() {
currentDataSourceUpdatedAt = TD(new Date(), { format: 'lll', locale: locale });

var payload = getCommitPayload(entries);
var deletedEntries = payload.delete;
var deletedEntriesKey = 'deleted-entries-' + currentDataSourceId;

localStorage.setItem(deletedEntriesKey, JSON.stringify(deletedEntries));

return currentDataSource.commit({
entries: payload.entries,
Expand Down