Skip to content

Commit

Permalink
BUG 3838: Fix doc prev uploaded loading, release 1.2.2 (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
mihailistov committed Apr 15, 2024
1 parent 2b2bd50 commit d99d8df
Show file tree
Hide file tree
Showing 6 changed files with 506 additions and 27 deletions.
2 changes: 1 addition & 1 deletion assets/claim/js/claim.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function () {
const src =
'https://cdn.jsdelivr.net/gh/bcgov/nr-af-pods@dev/powerpod/releases/powerpod-1.2.1.min.js';
'https://cdn.jsdelivr.net/gh/bcgov/nr-af-pods@dev/powerpod/releases/powerpod-1.2.2.min.js';
const script = document.createElement('script');
script.setAttribute('async', '');
script.src = src;
Expand Down
2 changes: 1 addition & 1 deletion powerpod/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "powerpod",
"type": "module",
"version": "1.2.1",
"version": "1.2.2",
"description": "Powerpod is a jQuery plugin that enhances functionality of Power Pages components.",
"main": "dist/powerpod",
"scripts": {
Expand Down
479 changes: 479 additions & 0 deletions powerpod/releases/powerpod-1.2.2.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion powerpod/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import typescript from '@rollup/plugin-typescript';
import css from 'rollup-plugin-import-css';

const licenseContent = `/*!
* powerpod 1.2.1
* powerpod 1.2.2
* https://github.com/bcgov/nr-af-pods/powerpod
*
* @license GPLv3 for open source use only
Expand Down
46 changes: 23 additions & 23 deletions powerpod/src/js/claim/documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,29 @@ function setUploadBtnOnClick(context) {
});
}

function cloneNotesContent(notes) {
function cloneNotesContent(context) {
const notes = context?.getElementById('notescontrol');
const observerAlreadySet = POWERPOD.documents.observerSet;

if (!observerAlreadySet) {
logger.info({
fn: checkForFilesToUpload,
message: 'Observer not set yet, observe iframe notes for changes',
data: { observerAlreadySet },
});
POWERPOD.documents.observerSet = true;
observeChanges(notes.parentNode, () => cloneNotesContent(context));
return;
}

if (isNotesStillLoading(context)) {
logger.warn({
fn: checkForFilesToUpload,
message: 'Notes still loading... defering till load is detected',
});
return;
}

const parentNotes = doc.getElementById('notescontrol');
const parentEntityNotes = parentNotes?.querySelector('.entity-notes');

Expand Down Expand Up @@ -929,15 +951,13 @@ function isNotesStillLoading(context) {

async function checkForFilesToUpload(context, uploadedFilesString = '') {
const userHasFilesSelectedToUpload = hasUserSelectedAnyNewFilesToUpload();
const observerAlreadySet = POWERPOD.documents.observerSet;

logger.info({
fn: checkForFilesToUpload,
message: 'Checking if any selected files have been uploaded',
data: {
userHasFilesSelectedToUpload,
documents: POWERPOD.documents,
observerAlreadySet,
},
});

Expand All @@ -960,26 +980,6 @@ async function checkForFilesToUpload(context, uploadedFilesString = '') {
message: 'Found notes and notes.textContent',
data: { notesTextContent: notes.textContent },
});

if (!observerAlreadySet) {
logger.info({
fn: checkForFilesToUpload,
message: 'Observer not set yet, observe iframe notes for changes',
data: { observerAlreadySet },
});
POWERPOD.documents.observerSet = true;
observeChanges(notes.parentNode, () => checkForFilesToUpload(context));
}

if (isNotesStillLoading(context)) {
logger.warn({
fn: checkForFilesToUpload,
message: 'Notes still loading... defering till load is detected',
});
return;
}

cloneNotesContent(notes);
}

const failedToUpload = [];
Expand Down
2 changes: 1 addition & 1 deletion powerpod/src/js/powerpod.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function setAPI() {
};
};
// @ts-ignore
POWERPOD.version = '1.2.1';
POWERPOD.version = '1.2.2';
// @ts-ignore
win.powerpod = POWERPOD;
}

0 comments on commit d99d8df

Please sign in to comment.