Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into expect-button-enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
raubersn committed Jun 18, 2024
2 parents 1b1a590 + b6e4eb5 commit fffd8e0
Show file tree
Hide file tree
Showing 19 changed files with 2,336 additions and 235 deletions.
6 changes: 3 additions & 3 deletions assets/application/html/my-applications.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div data-ppid="1003d965-cb80-30fa-1020-83bae673e396" class="row sectionBlockLayout sectionPrimaryColor" style="display: flex; flex-wrap: wrap; height: 15px; min-height: 15px; padding: 8px; margin: 0px;"></div>
<div data-ppid="df73fcea-dace-db33-05a9-631efd69edef" class="row sectionBlockLayout text-left" style="display: flex; flex-wrap: wrap; margin: 0px; min-height: 374px; padding: 8px; background-color: rgb(255, 255, 255);">
<div data-ppid="a56a155d-2ae1-2fd4-88b3-def7d92988aa" class="container" style="display: flex; flex-wrap: wrap;">
<p>Please note that the system only allows for one active application at a time. To start a new application, any unsubmitted draft must first be deleted.</p>
<div data-ppid="2b7c0fa4-2337-4b3a-750b-a24b5e2175ee" class="col-md-12 columnBlockLayout" style="word-break: break-word; flex-grow: 1; display: flex; flex-direction: column; min-width: 300px; padding: 16px; margin: 60px 0px;">{% include 'entity_list' key: 'My Application List' %}</div>
<div data-ppid="a56a155d-2ae1-2fd4-88b3-def7d92988aa" class="container" style="display: flex; flex-wrap: wrap; margin-top: 30px;">
<p>To edit/submit an application, please click on the drop down arrow.</p>
<div data-ppid="2b7c0fa4-2337-4b3a-750b-a24b5e2175ee" class="col-md-12 columnBlockLayout" style="word-break: break-word; flex-grow: 1; display: flex; flex-direction: column; min-width: 300px; padding: 16px; margin: 30px 0px;">{% include 'entity_list' key: 'My Application List' %}</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<!--
-------------------
FILE INFO
-------------------
version: 1.0.1
name: Claims Eligible Expense Grid
type: Web Resource (HTML Content)
description: This is the HTML content used to render the elgible expense grid on Staff Portal.
-->
<html>
<head>
<script
source="ClientGlobalContext.js.aspx"
type="text/javascript"
></script>

<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
crossorigin="anonymous"
/>

<script type="text/javascript">
function onLoad() {
console.log('WebResource version: 1.0.1');
loadjQuery(() => {
loadPowerpod(() => {
let rows = JSON.stringify([
{
type: '',
description: '',
amount: '',
},
]);

if (
parent?.Xrm?.Page &&
parent?.Xrm?.Page.getControl('quartech_eligibleexpenses')
) {
// Get the form context
var formContext = parent.Xrm.Page;
const fetchedRowValues = formContext
.getControl('quartech_eligibleexpenses')
.getAttribute()
.getValue();

if (fetchedRowValues && fetchedRowValues !== '[]') {
rows = fetchedRowValues;
}

formContext
.getControl('quartech_eligibleexpenses')
.setVisible(false);
}

const customElement = document.getElementsByTagName(
'expense-report-table'
)?.[0];

const columns = JSON.stringify([
{
id: 'type',
name: 'Expense Type',
width: '35%',
},
{
id: 'description',
name: 'Description',
width: '50%',
},
{
id: 'amount',
name: 'Amount ($CAD)',
width: '15%',
},
]);
customElement.setAttribute('columns', columns);
customElement.setAttribute('rows', rows);
});
});
}

function loadPowerpod(callback) {
const src =
'https://cdn.jsdelivr.net/gh/bcgov/nr-af-pods@dev/powerpod/releases/powerpod-1.5.1.min.js';
const script = document.createElement('script');
script.setAttribute('async', '');
script.src = src;
document.head.appendChild(script);

// Check if Powerpod is loaded
script.onload = function () {
if (typeof window.powerpod !== 'undefined') {
console.log('Powerpod loaded successfully');
if (callback && typeof callback === 'function') {
callback();
}
} else {
console.error('Failed to load Powerpod');
}
};
}

function loadjQuery(callback) {
// Create a script element
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://code.jquery.com/jquery-3.6.2.min.js';
script.async = false; // This ensures the script is loaded synchronously

// Append the script to the head
document.head.appendChild(script);

// Check if jQuery is loaded
script.onload = function () {
if (typeof jQuery !== 'undefined') {
console.log('jQuery loaded successfully');
if (callback && typeof callback === 'function') {
callback();
}
} else {
console.error('Failed to load jQuery');
}
};
}
</script>
</head>

<body
onload="onLoad()"
onfocusout="parent.setEmailRange();"
style="overflow-wrap: break-word"
>
<expense-report-table readOnly="true"></expense-report-table>
</body>
</html>
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.5.0",
"version": "1.5.1",
"description": "Powerpod is a jQuery plugin that enhances functionality of Power Pages components.",
"main": "dist/powerpod",
"scripts": {
Expand Down
1,848 changes: 1,848 additions & 0 deletions powerpod/releases/powerpod-1.5.1.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.5.0
* powerpod 1.5.1
* https://github.com/bcgov/nr-af-pods/powerpod
*
* @license GPLv3 for open source use only
Expand Down
15 changes: 9 additions & 6 deletions powerpod/src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const logger = Logger('app');
function autoinit() {
logger.info({
fn: autoinit,
message: `starting autoinit, href: ${win.location.href}`,
message: `starting autoinit, href: ${window.location.href}`,
});
const { host, pathname: path } = win.location;
const { host, pathname: path } = window.location;

// TODO: auto-detect environment based on host URL
// for now manually configure these options:
Expand Down Expand Up @@ -40,12 +40,15 @@ function autoinit() {

// ensure current path is in the list of allowed paths from options
if (
!getOptions().allowedPaths.some((allowedPath) => path.includes(allowedPath))
!getOptions().allowedPaths.some((allowedPath) =>
path.includes(allowedPath)
) &&
!host.includes('crm')
) {
logger.error({
fn: autoinit,
message: `current path is not in list of allowed paths, path: ${path}, allowedPaths:`,
data: getOptions().allowedPaths,
data: { allowedPaths: getOptions().allowedPaths, host },
});
return;
}
Expand Down Expand Up @@ -96,7 +99,7 @@ async function start() {
(function () {
logger.info({ message: 'checking for jQuery...' });
// @ts-ignore
if (win.jQuery) {
if (window.jQuery) {
logger.info({ message: 'jQuery found, running start...' });
start();
} else if (doc.readyState === 'complete') {
Expand Down Expand Up @@ -146,7 +149,7 @@ async function start() {
message:
'jQuery not found AND doc.addEventListener not found, adding listener for window loaded state...',
});
win.addEventListener('load', () => {
window.addEventListener('load', () => {
start();
});
} else {
Expand Down
4 changes: 2 additions & 2 deletions powerpod/src/js/common/applicationUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ POWERPOD.applicationUtils = {
};

export function getFormType() {
const { pathname: path } = win.location;
const { pathname: path } = window.location;
if (ClaimPaths.some((claimPath) => path.includes(claimPath))) {
logger.info({
fn: getFormType,
Expand All @@ -38,7 +38,7 @@ export function getFormType() {
});
return Form.Application;
} else {
logger.error({
logger.warn({
fn: getFormType,
message: `Unable to autodetect form type, path: ${path}`,
});
Expand Down
6 changes: 5 additions & 1 deletion powerpod/src/js/common/components.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { doc } from './constants';
import { doc, POWERPOD } from './constants';
import { Logger } from './logger';

const logger = Logger('common/components');

POWERPOD.components = {
renderCustomComponent,
};

// this accepts an id of an existing dynamics field
// and re-renders a custom component in its place
// the custom component will update the dynamics field
Expand Down
11 changes: 8 additions & 3 deletions powerpod/src/js/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ export const Environment = {
};

export const Hosts = {
[Environment.DEV]: 'af-pods-dev.powerappsportals.com',
[Environment.TEST]: 'af-pods-test.powerappsportals.com',
[Environment.PROD]: 'af-pods.powerappsportals.com',
[Environment.DEV]: [
'af-pods-dev.powerappsportals.com',
'af-pods-dev.crm3.dynamics.com',
],
[Environment.TEST]: ['af-pods-test.powerappsportals.com'],
[Environment.PROD]: ['af-pods.powerappsportals.com'],
};
export const ClaimPaths = ['/claim/', '/claim-dev/'];
export const ApplicationPaths = ['/application/', '/application-dev/'];

export const Form = {
Application: 'Application',
Claim: 'Claim',
StaffPortalClaim: 'StaffPortalClaim',
};

export const HtmlElementType = {
Expand Down Expand Up @@ -111,4 +115,5 @@ export const POWERPOD = {
saveButton: {},
doNotUnhideLoader: false,
redirectToNewId: false,
components: {},
};
6 changes: 4 additions & 2 deletions powerpod/src/js/common/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ POWERPOD.env = {
};

export function getEnv() {
const { host } = win.location;
const { host } = window.location;

const env = Object.keys(Hosts).find((key) => Hosts[key] === host);
const env = Object.keys(Hosts).find(
(key) => Hosts[key].includes(host)
);

if (!env) {
logger.error({
Expand Down
6 changes: 3 additions & 3 deletions powerpod/src/js/common/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ function log({ namespace, fn, type, message, data }) {
// if level of requested log is less than log level of env, do not log
if (logLevel < envLogLevel) return;

if (!win.console || !win.console[type]) {
win.console.error('[POWERPOD]: issue using logger');
if (!window.console || !window.console[type]) {
window.console.error('[POWERPOD]: issue using logger');
return;
}

const logFn = win.console[type]; // default log
const logFn = window.console[type]; // default log

let prefix = '';
prefix += namespace ? ` (${namespace})` : '';
Expand Down
6 changes: 3 additions & 3 deletions powerpod/src/js/common/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ POWERPOD.options = {
// TODO: Update for production
const ALLOWED_ENVS = [Environment.DEV, Environment.TEST, Environment.PROD];
const ALLOWED_HOSTS = [
Hosts[Environment.DEV],
Hosts[Environment.TEST],
Hosts[Environment.PROD],
...Hosts[Environment.DEV],
...Hosts[Environment.TEST],
...Hosts[Environment.PROD],
];
const ALLOWED_PATHS = [
'/claim/',
Expand Down
Loading

0 comments on commit fffd8e0

Please sign in to comment.