Skip to content

Commit

Permalink
[VSPC-187] add ? to thymeleaf expressions to avoid null issues (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdamerow authored Aug 18, 2021
1 parent 47aeab6 commit 4b38b9c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ <h4>Spaces</h4>
<div class="grid" style="margin-top: 10px;">
<div th:each="space,iterStat: ${recentSpaces}" th:if="${iterStat.index}<5" style="width: 12rem;">
<div class="spaceImage">
<a th:href="@{'/staff/space/'+${space.id}}">
<img class="card-img-top" th:src="@{'/api/image/'+${space.image.id}}" alt="Space image">
<a th:href="@{'/staff/space/'+${space?.id}}">
<img class="card-img-top" th:src="@{'/api/image/'+${space.image?.id}}" alt="Space image">
</a>
</div>
<div class="btn-group dropdown">
<a th:href="@{'/staff/space/'+${space.id}}" class="btn btn-light skew" style="width: 10.25rem;">
<a th:href="@{'/staff/space/'+${space?.id}}" class="btn btn-light skew" style="width: 10.25rem;">
<span class="card-head" style="white-space: normal;">[[${space.name}]]</span>
</a>
<button type="button" class="btn btn-light dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" th:href="@{'/staff/space/'+${space.id}+'/edit'}"><span class="icon-edit"></span>&nbsp;Edit Space</a>
<a class="dropdown-item" th:href="@{'/staff/space/'+${space?.id}+'/edit'}"><span class="icon-edit"></span>&nbsp;Edit Space</a>
<div class="dropdown-divider"></div>
<a th:onclick="javascript:checkSpaceLinkPresent('[(${space.id})]', '[(@{'/staff/'})]', '[('?'+${_csrf.parameterName}+'='+${_csrf.token})]',$('#headerSpaceValue'))"
<a th:onclick="javascript:checkSpaceLinkPresent('[(${space?.id})]', '[(@{'/staff/'})]', '[('?'+${_csrf.parameterName}+'='+${_csrf.token})]',$('#headerSpaceValue'))"
class="checkSpaceLinkPresent dropdown-item" data-toggle="modal">
<span class="checkSpaceLinkPresent" id="deleteSpace">
<span class="icon-trash error"></span></span>&nbsp;Delete
Expand All @@ -47,7 +47,7 @@ <h4>Modules</h4>
<div class="list" style="margin-top: 10px;">
<ul class="list-group list-group-flush" th:each="module,iterStat: ${recentModules}" th:if="${iterStat.index}<5" >
<li class="list-group-item">
<a th:href="@{'/staff/module/'+${module.id}}" style="white-space: normal;overflow-wrap: break-word;">
<a th:href="@{'/staff/module/'+${module?.id}}" style="white-space: normal;overflow-wrap: break-word;">
<span class='icon-2x2-grid'></span>&nbsp;&nbsp;&nbsp;&nbsp;[[${module.name}]]
</a>
(Created on <span class="date">[[${module.creationDate}]]</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h3>Spaces</h3>

<ul class="list-group list-group-flush" th:each="space: ${recentSpaces}">
<li class="list-group-item">
<a th:href="@{/staff/space/${space.id}}">
<a th:href="@{/staff/space/${space?.id}}">
<span data-feather="box"></span> ${space.name}
</a>
(Created on <span class="date">${space.creationDate}</span> by ${space.createdBy})
Expand All @@ -32,7 +32,7 @@ <h3>Modules</h3>

<ul class="list-group list-group-flush" th:each="module: ${recentModules}">
<li class="list-group-item">
<a th:href="@{/staff/module/${module.id}}">
<a th:href="@{/staff/module/${module?.id}}">
<span data-feather="grid"></span> [[${module.name}]]
</a>
(Created on <span class="date">[[${module.creationDate}]]</span> by [[${module.createdBy})]]
Expand Down
52 changes: 26 additions & 26 deletions vspace/src/main/webapp/WEB-INF/views/staff/spaces/space.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@

$.ajax({
type: "GET",
url: "[(@{'/staff/space/'+${space.id}+'/links'})]",
url: "[(@{'/staff/space/'+${space?.id}+'/links'})]",
cache : false,
contentType : false,
processData : false,
Expand Down Expand Up @@ -641,8 +641,8 @@

$(function(){
$("#deleteSpace").click(function(){
var spaceId = "${space.id}";
checkSpaceLinkPresent('[(${space.id})]', '[(@{'/staff/'})]', '[('?'+${_csrf.parameterName}+'='+${_csrf.token})]',$('#headerSpaceValue'));
var spaceId = "${space?.id}";
checkSpaceLinkPresent('[(${space?.id})]', '[(@{'/staff/'})]', '[('?'+${_csrf.parameterName}+'='+${_csrf.token})]',$('#headerSpaceValue'));
});

$( document ).ready(function() {
Expand Down Expand Up @@ -768,7 +768,7 @@
var spaceLinkInfo = createSpaceLinkInfo();
$.ajax({
type: "POST",
url: "[(@{'/staff/space/'+${space.id}+'/spacelink?'+${_csrf.parameterName}+'='+${_csrf.token}})]",
url: "[(@{'/staff/space/'+${space?.id}+'/spacelink?'+${_csrf.parameterName}+'='+${_csrf.token}})]",
cache : false,
contentType : false,
processData : false,
Expand Down Expand Up @@ -844,7 +844,7 @@
$.ajax({
type: "POST",

url: "[(@{'/staff/space/'+${space.id}+'/modulelink?'+${_csrf.parameterName}+'='+${_csrf.token}})]",
url: "[(@{'/staff/space/'+${space?.id}+'/modulelink?'+${_csrf.parameterName}+'='+${_csrf.token}})]",
cache : false,
contentType : false,
processData : false,
Expand Down Expand Up @@ -892,7 +892,7 @@
var moduleLinkInfo = editModuleLinkInfo();
$.ajax({
type: "POST",
url: "[(@{'/staff/space/link/module/'+${space.id}+'?'+${_csrf.parameterName}+'='+${_csrf.token}})]",
url: "[(@{'/staff/space/link/module/'+${space?.id}+'?'+${_csrf.parameterName}+'='+${_csrf.token}})]",
cache: false,
contentType: false,
processData: false,
Expand Down Expand Up @@ -941,7 +941,7 @@
var spaceLinkInfo = editSpaceLinkInfo();
$.ajax({
type: "POST",
url: "[(@{'/staff/space/link/space/'+${space.id}+'?'+${_csrf.parameterName}+'='+${_csrf.token}})]",
url: "[(@{'/staff/space/link/space/'+${space?.id}+'?'+${_csrf.parameterName}+'='+${_csrf.token}})]",
cache: false,
contentType : false,
processData : false,
Expand Down Expand Up @@ -990,7 +990,7 @@
var externalLinkInfo = editExternalLinkInfo();
$.ajax({
type: "POST",
url: "[(@{'/staff/space/link/external/'+${space.id}+'?'+${_csrf.parameterName}+'='+${_csrf.token}})]",
url: "[(@{'/staff/space/link/external/'+${space?.id}+'?'+${_csrf.parameterName}+'='+${_csrf.token}})]",
cache: false,
contentType : false,
processData : false,
Expand Down Expand Up @@ -1062,7 +1062,7 @@

$.ajax({
type: "POST",
url: "[(@{'/staff/space/'+${space.id}+'/externallink?'+${_csrf.parameterName}+'='+${_csrf.token}})]",
url: "[(@{'/staff/space/'+${space?.id}+'/externallink?'+${_csrf.parameterName}+'='+${_csrf.token}})]",
cache : false,
contentType : false,
processData : false,
Expand Down Expand Up @@ -1100,7 +1100,7 @@
$("#deleteSpaceLinkButton").click(function() {
var linkId = $("#spaceLinkIdValueEdit").val();
$.ajax({
url: "[(@{'/staff/space/'+${space.id}+'/spacelink/'})]"+ linkId + '?[(${_csrf.parameterName})]=[(${_csrf.token})]',
url: "[(@{'/staff/space/'+${space?.id}+'/spacelink/'})]"+ linkId + '?[(${_csrf.parameterName})]=[(${_csrf.token})]',
method: "DELETE",
beforeSend: function () {
$(".saveLoader").show();
Expand Down Expand Up @@ -1130,7 +1130,7 @@
$("#deleteModuleLinkButton").click(function() {
var linkId = $("#moduleLinkIdValueEdit").val();
$.ajax({
url: "[(@{'/staff/space/'+${space.id}+'/modulelink/'})]"+ linkId + '?[(${_csrf.parameterName})]=[(${_csrf.token})]',
url: "[(@{'/staff/space/'+${space?.id}+'/modulelink/'})]"+ linkId + '?[(${_csrf.parameterName})]=[(${_csrf.token})]',
method: "DELETE",
beforeSend: function () {
$(".saveLoader").show();
Expand All @@ -1150,7 +1150,7 @@
$("#deleteExternalLinkButton").click(function() {
var linkId = $("#externalLinkIdValueEdit").val();
$.ajax({
url: "[(@{'/staff/space/'+${space.id}+'/externallink/'})]"+ linkId + '?[(${_csrf.parameterName})]=[(${_csrf.token})]',
url: "[(@{'/staff/space/'+${space?.id}+'/externallink/'})]"+ linkId + '?[(${_csrf.parameterName})]=[(${_csrf.token})]',
method: "DELETE",
beforeSend: function () {
$(".saveLoader").show();
Expand Down Expand Up @@ -1341,7 +1341,7 @@ <h2>
<span style="color: var(--dark-grey)">Space:</span> [[${space.name}]]
<i class="fa fa-info-circle black" data-toggle="tooltip" data-html="true" data-placement="top"
th:title="|Created on <span class='date'>${space.creationDate}</span> by ${space.createdBy}|"></i>
<a th:href="@{'/staff/space/'+${space.id}+'/edit'}"><span class="icon-edit"></span></a>
<a th:href="@{'/staff/space/'+${space?.id}+'/edit'}"><span class="icon-edit"></span></a>
</h2>
<p>[[${space.description}]]</p>
<div class="flex-spacing">
Expand All @@ -1352,8 +1352,8 @@ <h2>
<div class="dropdown-menu" aria-labelledby="incominglinks">
<span th:if="${#lists.isEmpty(linksToThisSpace)}"><small>There are no links to this space.</small></span>
<div th:each="spaceLinks : ${linksToThisSpace}">
<a th:href="@{'/staff/space/'+${spaceLinks.sourceSpace.id}}" style="padding: .25rem; color: var(--secondary);"
th:id="${spaceLinks.id}"><small>[[${spaceLinks.sourceSpace.name}]]</small> <span class="icon-warning secondary unpublishedSpaceClass"
<a th:href="@{'/staff/space/'+${spaceLinks.sourceSpace?.id}}" style="padding: .25rem; color: var(--secondary);"
th:id="${spaceLinks?.id}"><small>[[${spaceLinks.sourceSpace.name}]]</small> <span class="icon-warning secondary unpublishedSpaceClass"
th:if="${#strings.equals(spaceLinks.sourceSpace.spaceStatus,'UNPUBLISHED')}" style="font-size: 100%; font-weight: 400;"></span></a>
</div>
</div>
Expand All @@ -1366,9 +1366,9 @@ <h2>
<div class="dropdown-menu" aria-labelledby="outgoinglinks">
<span th:if="${#lists.isEmpty(linksOnThisSpace)}"><small>There are no links from this space.</small></span>
<div th:each="spaceLinks : ${linksOnThisSpace}">
<a th:href="@{'/staff/space/'+${spaceLinks.targetSpace.id}}" style="padding: .25rem; color: var(--secondary);"
<a th:href="@{'/staff/space/'+${spaceLinks.targetSpace?.id}}" style="padding: .25rem; color: var(--secondary);"
th:if="${spaceLinks.targetSpace != null}"
th:id="${spaceLinks.id}"><small>[[${spaceLinks.targetSpace.name}]]</small> <span class="icon-warning secondary unpublishedSpaceClass"
th:id="${spaceLinks?.id}"><small>[[${spaceLinks.targetSpace.name}]]</small> <span class="icon-warning secondary unpublishedSpaceClass"
th:if="${#strings.equals(spaceLinks.targetSpace.spaceStatus,'UNPUBLISHED')}" style="font-size: 100%; font-weight: 400;"></span></a>
</div>
</div>
Expand All @@ -1379,7 +1379,7 @@ <h2>
</div>
<div>
<label style="margin-right: 10px;">Space Status</label>
<form method="POST" th:action="@{'/staff/space/'+${space.id}+'/status'}">
<form method="POST" th:action="@{'/staff/space/'+${space?.id}+'/status'}">
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
<select class="form-control-sm" name="statusParam" style="width: 200px; display: inline;">
<option th:id="Published" th:value="PUBLISHED" th:selected="${#strings.equals(space.spaceStatus,'PUBLISHED')}">Published</option>
Expand All @@ -1390,7 +1390,7 @@ <h2>
</p>
</form>
<label style="margin-right: 10px;">Show Links to Unpublished Spaces</label>
<form method="POST" th:action="@{'/staff/space/'+${space.id}+'/showSpaceLinks'}" name="f">
<form method="POST" th:action="@{'/staff/space/'+${space?.id}+'/showSpaceLinks'}" name="f">
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
<select class="form-control-sm" name="showSpaceLinksParam" style="width: 200px; display: inline;">
<option th:id="No" th:value=false th:selected="${!space.showUnpublishedLinks}">No</option>
Expand Down Expand Up @@ -1419,7 +1419,7 @@ <h2>
&nbsp;
</div>
<div id="space" th:style="|max-width: ${display.width+400}px;|" th:if="${space.image != null}" class="link-modal flex-spacing">
<img id="bgImage" th:style="|max-width: ${display.width}px;|" th:src="@{'/api/image/'+${space.image.id}}" />
<img id="bgImage" th:style="|max-width: ${display.width}px;|" th:src="@{'/api/image/'+${space.image?.id}}" />
<div id="errorAlert"
class="alert alert-danger alert-dismissible fade show"
role="alert"
Expand Down Expand Up @@ -1488,7 +1488,7 @@ <h5 class="alert-heading">Create new Space Link</h5>
<div class="col-sm-8">
<select id="linkedSpace" name="linkedSpace" class="form-control-sm target" style="background: var(--base-grey); width: inherit;">
<option th:selected>Choose...</option>
<option th:each="space : ${spaces}" th:value="${space.id}">[[${space.name}]]
<option th:each="space : ${spaces}" th:value="${space?.id}">[[${space.name}]]
<span th:if="${#strings.equals(space.spaceStatus,'UNPUBLISHED')}">(Unpublished)</span></option>
</select>
</div>
Expand Down Expand Up @@ -1558,7 +1558,7 @@ <h5 class="alert-heading">Create new Module Link</h5>
<div class="col-sm-8">
<select id="linkedModule" name="linkedModule" class="form-control-sm modulelink-target" style="width: inherit; background: var(--base-grey)">
<option th:selected>Choose...</option>
<option th:value="${module.id}"
<option th:value="${module?.id}"
th:each="module : ${moduleList}">[[${module.name}]]</option>
</select>
</div>
Expand Down Expand Up @@ -1708,7 +1708,7 @@ <h6 class="alert-heading"><span style="color: var(--dark-grey)"> Space Link:</sp
<div class="col-sm-8">
<select id="spaceLinkIdEdit" name="linkedSpace" class="form-control-sm spacelink-targetEdit"
style="width: inherit; background: var(--base-grey)">
<option th:each=" space : ${spaces}" th:value="${space.id}">[[${space.name}]]
<option th:each=" space : ${spaces}" th:value="${space?.id}">[[${space.name}]]
<span th:if="${#strings.equals(space.spaceStatus,'UNPUBLISHED')}">(Unpublished)</span>
</option>

Expand Down Expand Up @@ -1798,7 +1798,7 @@ <h6 class="alert-heading">
style="width: inherit; background: var(--base-grey)">
<option
th:each=" module : ${moduleList}"
th:value="${module.id}">[[${module.name}]]</option>
th:value="${module?.id}">[[${module.name}]]</option>
</select>
</div>
</div>
Expand Down Expand Up @@ -1900,7 +1900,7 @@ <h6 class="alert-heading">
</div>
</div>
<form method="post"
th:action="@{|/staff/space/update/${space.id}?${_csrf.parameterName}=${_csrf.token}|}"
th:action="@{|/staff/space/update/${space?.id}?${_csrf.parameterName}=${_csrf.token}|}"
enctype="multipart/form-data">
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<div id="changeBgImgAlert" class="alert alert-secondary"
Expand Down Expand Up @@ -1956,7 +1956,7 @@ <h5 class="modal-title" id="deleteModalTitle">Confirm
<div id="loader" style="position: absolute; font-size: 30px;">
<i class="fa fa-spinner fa-spin" aria-hidden="true"></i>
</div>
<img id="main-bgImage" th:style="|max-width: ${display.width}px;|" th:src="@{'/api/image/'+${space.image.id}}" />
<img id="main-bgImage" th:style="|max-width: ${display.width}px;|" th:src="@{'/api/image/'+${space.image?.id}}" />
</div>
<p class="text-right" style="margin-top: 50px">
<button type="button" id="deleteSpace" class="btn primary-btn btn-sm"><i class="fa fa-trash"></i>&emsp;Delete Space</button>
Expand Down

0 comments on commit 4b38b9c

Please sign in to comment.