Skip to content

Commit

Permalink
SAK-48323 webcomponents. Bundle and remove empathise. (sakaiproject#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Jan 18, 2024
1 parent 87a3f66 commit f590201
Show file tree
Hide file tree
Showing 737 changed files with 425,476 additions and 28,916 deletions.
6 changes: 6 additions & 0 deletions .codacy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
exclude_paths:
- "**/test/**"
- "**/tests/**"
- "**/bundle-entry-points/**"
- "**/web-test-runner.config.mjs"
100 changes: 100 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
module.exports = {
"env": { "browser": true, "es2022": true },
"globals": {
"$": "readonly",
"bootstrap": "readonly",
"sakai": "readonly",
"sakaiSessionId": "readonly",
"portal": "readonly",
"profile": "readonly",
"CKEDITOR": "readonly",
"moment": "readonly",
"confirmDatePlugin": "readonly",
"flatpickr": "readonly",
"jQuery": "readonly",
"MathJax": "readonly",
"globalThis": "readonly",
},
"extends": [ "eslint:recommended" ],
"parserOptions": { "ecmaVersion": 2022, "sourceType": "module" },
"rules": {
"accessor-pairs": "error",
"array-bracket-spacing": [ 'error', 'always' ],
"array-callback-return": "error",
"arrow-parens": [ "error", "as-needed" ],
"arrow-spacing": "error",
"block-spacing": "error",
"camelcase" : "error",
"comma-spacing": "error",
"curly": [ "error", "multi-line" ],
"dot-notation": "error",
"indent": ["warn", 2, { "SwitchCase": 1, "MemberExpression": "off", "ImportDeclaration": "off", "ignoredNodes": ["TemplateLiteral > *"] }],
"keyword-spacing": "error",
"linebreak-style": ["error", "unix"],
"no-array-constructor": "error",
"no-caller": "error",
"no-cond-assign": "error",
"no-constructor-return": "error",
"no-duplicate-imports": "error",
"no-else-return": "error",
"no-empty": ["error", { allowEmptyCatch: true }],
"no-eval": "error",
"no-extend-native": ["error", { "exceptions": ["Date"] }],
"no-extra-bind": "error",
"no-implied-eval": "error",
"no-iterator": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-loss-of-precision": "error",
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "error",
"no-proto": "error",
"no-redeclare": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": ["error", { "allow": ["html"] }],
"no-tabs": "error",
"no-trailing-spaces": "error",
"no-multi-spaces" : "error",
"no-undef": "error",
"no-undef-init": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
"no-unreachable-loop": "error",
"no-unused-vars": ["error"],
"no-use-before-define": ["error", "nofunc"],
"no-useless-backreference": "error",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-constructor": "error",
"no-useless-escape": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "error",
"object-curly-spacing": [ 'error', 'always' ],
"object-shorthand": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error",
"prefer-exponentiation-operator": "error",
"prefer-numeric-literals": "error",
"prefer-object-spread": "error",
"prefer-regex-literals": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"require-atomic-updates": "error",
"semi": ["error", "always"],
"space-infix-ops": "error",
"space-before-blocks": "error",
"strict": "error",
"yoda": ["error", "never", { onlyEquality: true }],
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,6 @@ private Map<String, Object> submissionToMap(Set<String> activeSubmitters, Assign
Map<String, Object> submission = new HashMap<>();

submission.put("id", as.getId());
submission.put("assignmentCloseTime", simpleAssignment.getCloseTime());
submission.put("hydrated", hydrate);

if (as.getUserSubmission()) submission.put("submitted", as.getUserSubmission());
Expand Down Expand Up @@ -937,6 +936,8 @@ public ActionReturn getFullSubmissions(EntityView view , Map<String, Object> par

Map<String, Object> data = new HashMap<>();

data.put("assignmentCloseTime", assignment.getCloseDate());

data.put("groups", assignmentService.getGroupsAllowGradeAssignment(assignmentReference)
.stream().map(SimpleGroup::new).collect(Collectors.toList()));

Expand Down Expand Up @@ -1229,7 +1230,8 @@ public ActionReturn setGrade(Map<String, Object> params) {
if (submission != null) {
boolean anonymousGrading = assignmentService.assignmentUsesAnonymousGrading(assignment);
try {
return new ActionReturn(submissionToMap(activeSubmitters, assignment, new SimpleAssignment(assignment), submission, true));
return new ActionReturn(Map.of("assignmentCloseTime", assignment.getCloseDate(),
"submission", submissionToMap(activeSubmitters, assignment, new SimpleAssignment(assignment), submission, true)));
} catch (Exception e) {
throw new EntityException("Failed to set grade on " + submissionId, "", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,6 @@ public String buildMainPanelContext(VelocityPortlet portlet, Context context, Ru
context.put("dateFormat", getDateFormatString());
context.put("cheffeedbackhelper", this);
context.put("service", assignmentService);
context.put("rubricsService", rubricsService);

String contextString = (String) state.getAttribute(STATE_CONTEXT_STRING);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,6 @@
#end
#end
#macro( rubricsRequirements )
#javascript("/webcomponents/rubrics/sakai-rubrics-utils.js")
#module("/webcomponents/rubrics/rubric-association-requirements.js")
#module("/webcomponents/bundles/rubric-association-requirements.js")
#end
<!-- end: assignment_macros.vm -->
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- start: chef_assignments_instructor_grading_submission_withgrader.vm -->

<!-- GRADER JAVASCRIPT -->
#module("/webcomponents/grader/sakai-grader.js")
#module("/webcomponents/bundles/grader.js")
<script>
ASN.currentGradingSubmission = "$formattedText.escapeUrl( $!submissionReference )";
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#set( $H = '-' )
#set( $T = 'T' )
<script>includeLatestJQuery('assignments');</script>
#module("/webcomponents/grader/grader-toggle.js")
#module("/webcomponents/sakai-user-photo.js")
#module("/webcomponents/bundles/assignments.js")

<script>
function printView(url) {
Expand Down Expand Up @@ -35,7 +34,7 @@ function printView(url) {
</h1>
</div>
<div>
<grader-toggle #if(!$useGraderByDefault)unchecked-by-default#end tool="assignments"></grader-toggle>
<sakai-grader-toggle #if(!$useGraderByDefault)unchecked-by-default#end tool="assignments"></sakai-grader-toggle>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
</div>

<div class="longtext form-group row form-required">
<label for="new_assignment_instructions" class="block form-control-label col-sm-12">
<label for="$name_Description" class="block form-control-label col-sm-12">
$tlang.getString("gen.assinf")
</label>
<div class="col-sm-12">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!-- start: chef_assignments_instructor_report_submissions.vm -->
#module("/webcomponents/sakai-user-photo.js")
<div class="portletBody sakai-asn-grade-report">
#navBarHREF( $allowAddAssignment $withGrade $allowGradeSubmission $allowAddAssignment $allowRecoverAssignment $allowAllGroups $assignmentscheck $allowUpdateSite $enableViewOption $view "" )

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<!-- start: chef_assignments_instructor_student_list_submissions.vm -->
#module("/webcomponents/sakai-user-photo.js")
<div class="portletBody container-fluid">
#navBarHREF( $allowAddAssignment $withGrade $allowGradeSubmission $allowAddAssignment $allowRecoverAssignment $allowAllGroups $assignmentscheck $allowUpdateSite $enableViewOption $view "" )
<div class="page-header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
</script>

<div class="portletBody container-fluid">

#if ($allowAddAssignment || ($withGrade && $!allowGradeSubmission))
## for user who cannot create assignment nor grade submission, no need to show "Assignment List" link at all since there is really no other toolbar choices
#navBarHREF( $allowAddAssignment $withGrade $allowGradeSubmission $allowAddAssignment $allowRecoverAssignment $allowAllGroups $assignmentscheck $allowUpdateSite $enableViewOption $view "" )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,19 @@ This section contains the options for grading this assignment, including rubrics
dont-associate-value="0"
associate-label="$tlang.getString("associate.label")"
associate-value="1"
tool-id="sakai.assignment.grades"
#if("$!rubric_association" != "")
association='$rubric_association'
#else
#if("$!assignment.Id" != "")
entity-id="$assignment.Id"
#end
tool-id="sakai.assignment.grades"
#elseif("$!assignment.Id" != "")
entity-id="$assignment.Id"
#end
fine-tune-points="$tlang.getString("option.pointsoverride")"
hide-student-preview="$tlang.getString("option.studentpreview")"
student-self-report="$tlang.getString("option.selfreport")"
student-self-report-mode-0="$tlang.getString("option.selfreport.must")"
student-self-report-mode-1="$tlang.getString("option.selfreport.partialmust")"
student-self-report-mode-2="$tlang.getString("option.selfreport.notamust")"
show-self-report-check="true"
>
show-self-report-check="true">
</sakai-rubric-association>
</div>

Expand Down
11 changes: 4 additions & 7 deletions basiclti/web-ifp/src/bundle/vm/main.vm
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
<div class="portletBody">
<script type="module" src="/webcomponents/bundles/lti.js"></script>
#if ($alertMessage)<div class="sak-banner-error">$tlang.getString("gen.alert") $alertMessage</div>#end
## See also assignment/tool/src/webapp/vm/assignment/chef_assignments_view_launch.vm
#if ($!newpage)
<script type="module" src="/webcomponents/sakai-lti-popup.js"></script>
<p>
<sakai-lti-popup
launch-url="$!source"
/>
<sakai-lti-popup launch-url="$!source"></sakai-lti-popup>
</p>
#else
<script type="module" src="/webcomponents/sakai-lti-iframe.js"></script>
<p>
<sakai-lti-iframe
allow-resize="yes"
launch-url="$!source"
height="$!height"
allow="$!browser-feature-allow"
/>
allow="$!browser-feature-allow">
</sakai-lti-iframe>
</p>
#end
</div>
1 change: 0 additions & 1 deletion chat/chat-tool/tool/src/webapp/jsp/room.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<sakai:view title="#{msgs['custom.chatroom']}">
<h:outputText value="#{Portal.latestJQuery}" escape="false"/>
<script src='/sakai-chat-tool/js/chatscript.js<h:outputText value="#{Portal.CDNQuery}" />'></script>
<script type="module" src='/webcomponents/sakai-user-photo.js<h:outputText value="#{Portal.CDNQuery}" />'></script>
<script>
if ( window.frameElement) window.frameElement.className='wcwmenu';
$(document).ready( function () {
Expand Down
1 change: 0 additions & 1 deletion commons/tool/src/webapp/WEB-INF/bootstrap.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<script src="/commons-tool/js/commons_utils.js${portalCDNQuery}"></script>
<script src="/commons-tool/js/commons_permissions.js${portalCDNQuery}"></script>
<script src="/profile2-tool/javascript/profile2-eb.js${portalCDNQuery}"></script>
<script type="module" src="/webcomponents/sakai-user-photo.js${portalCDNQuery}"></script>

<div id="Mrphs-sakai-commons" class="portletBody commons-portletBody">

Expand Down
11 changes: 4 additions & 7 deletions commons/tool/src/webapp/js/commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,11 @@ commons.switchState = function (state, arg) {

$(document).ready(function () {

import("/webcomponents/sakai-i18n.js").then(m => {
loadProperties({bundle: 'commons'}).then(i18n => {

m.loadProperties({bundle: 'commons'}).then(i18n => {

commons.i18n = i18n;
commonsHelpers["tr"] = (key, options) => new Handlebars.SafeString(m.tr("commons", key, options.hash));
languagesLoaded();
});
commons.i18n = i18n;
commonsHelpers["tr"] = (key, options) => new Handlebars.SafeString(tr("commons", key, options.hash));
languagesLoaded();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link media="all" href="/library/skin/tool_base.css" rel="stylesheet" type="text/css" />
<script type="module" th:src="@{~/webcomponents/conversations/sakai-conversations.js} + ${cdnQuery}"></script>
[(${sakaiHtmlHead})]
</head>
<body onload="setMainFrameHeight('Mainmercuryx710');setFocus(focus_path);" class="Mrphs-container Mrphs-sakai-dropbox">
<script type="module" th:src="@{~/webcomponents/bundles/conversations.js} + ${cdnQuery}"></script>
<script>includeLatestJQuery('conversations');</script>
<div class="portletBody">
<!--sakai-conversations th:topic-id="${topicId}" th:site-id="${siteId}" th:state="${state}" th:base-url="${baseUrl}"></sakai-conversations-->
<sakai-conversations th:topic-id="${topicId}" th:post-id="${postId}" th:site-id="${siteId}" th:base-url="${baseUrl}"></sakai-conversations>
</div>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<script src="/library/js/headscripts.js"></script>
<script>includeWebjarLibrary('ckeditor');</script>
<script src="/library/editor/ckeditor.launch.js"></script>
<script type="module" th:src="@{~/webcomponents/coursedashboard/sakai-course-dashboard.js} + ${cdnQuery}"></script>
[(${sakaiHtmlHead})]
</head>
<body>
<script type="module" th:src="@{~/webcomponents/bundles/dashboards.js} + ${cdnQuery}"></script>
<div class="portletBody">
<sakai-course-dashboard th:site-id="${siteId}" th:user-id="${userId}"></sakai-course-dashboard>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<link media="all" href="/library/skin/tool_base.css" rel="stylesheet" type="text/css" />
<script src="/library/js/headscripts.js"></script>
<script>includeWebjarLibrary('ckeditor');</script>
<script type="module" th:src="@{~/webcomponents/sakai-home-dashboard.js} + ${cdnQuery}"></script>
</head>
<body>
<script type="module" th:src="@{~/webcomponents/bundles/dashboards.js} + ${cdnQuery}"></script>
<div class="portletBody">
<sakai-home-dashboard th:user-id="${userId}"></sakai-home-dashboard>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<html>
<wicket:panel xmlns:wicket="http://wicket.apache.org">
<script wicket:id="messagerScript"></script>
<script wicket:id="userPhotoScript"></script>
<script type="module" wicket:id="messagerScript"></script>
<div id="gradeTableWrapper">
<div wicket:id="gradeTable" id="gradeTable" accesskey="g" wicket:message="aria-label:gradetable.wrapper.tooltip" aria-describedby="gradeTableCaption"></div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,9 @@ public GbGradeTable(final String id, final IModel model) {
final String version = PortalUtils.getCDNQuery();

Label messagerLabel = new Label("messagerScript", "");
messagerLabel.add(new AttributeAppender("type", "module"));
messagerLabel.add(new AttributeAppender("src", String.format("/webcomponents/sakai-submission-messager.js%s", version)));
messagerLabel.add(new AttributeAppender("src", String.format("/webcomponents/bundles/gradebook.js%s", version)));
add(messagerLabel);

Label photoScriptLabel = new Label("userPhotoScript", "");
photoScriptLabel.add(new AttributeAppender("type", "module"));
photoScriptLabel.add(new AttributeAppender("src", String.format("/webcomponents/sakai-user-photo.js%s", version)));
add(photoScriptLabel);

component = new WebMarkupContainer("gradeTable").setOutputMarkupId(true);

component.add(new AjaxEventBehavior("gbgradetable.action") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,6 @@ public void renderHead(final IHeaderResponse response) {

final String version = PortalUtils.getCDNQuery();
response.render(StringHeaderItem.forString(
"<script src=\"/webcomponents/rubrics/sakai-rubrics-utils.js" + version + "\"></script>"));
response.render(StringHeaderItem.forString(
"<script type=\"module\" src=\"/webcomponents/rubrics/rubric-association-requirements.js" + version + "\"></script>"));
"<script type=\"module\" src=\"/webcomponents/bundles/rubric-association-requirements.js" + version + "\"></script>"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,7 @@ public void renderHead(final IHeaderResponse response) {

final String version = PortalUtils.getCDNQuery();
response.render(StringHeaderItem.forString(
"<script src=\"/webcomponents/rubrics/sakai-rubrics-utils.js" + version + "\"></script>"));
response.render(StringHeaderItem.forString(
"<script type=\"module\" src=\"/webcomponents/rubrics/rubric-association-requirements.js" + version + "\"></script>"));
"<script type=\"module\" src=\"/webcomponents/bundles/rubric-association-requirements.js" + version + "\"></script>"));
}

private Component newPopoverFlag(String id, String msg, boolean visible) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ public void renderHead(final IHeaderResponse response) {

final String version = PortalUtils.getCDNQuery();
response.render(StringHeaderItem.forString(
"<script src=\"/webcomponents/rubrics/sakai-rubrics-utils.js" + version + "\"></script>"));
response.render(StringHeaderItem.forString(
"<script type=\"module\" src=\"/webcomponents/rubrics/rubric-association-requirements.js" + version + "\"></script>"));
"<script type=\"module\" src=\"/webcomponents/bundles/rubric-association-requirements.js" + version + "\"></script>"));
}
}
Loading

0 comments on commit f590201

Please sign in to comment.