Skip to content

Commit

Permalink
fix: organisation settings were not fetched automatically
Browse files Browse the repository at this point in the history
Signed-off-by: Oleh Astappiev <[email protected]>
  • Loading branch information
astappiev committed Mar 6, 2024
1 parent 4c77813 commit 016b8e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main/java/de/l3s/learnweb/user/OrganisationDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ default List<Organisation> findAll() {
.registerRowMapper(new OrganisationMapper())
.mapTo(Organisation.class)
.map(organisation -> {
if (organisation.getSettings() == null) {
if (!organisation.getSettings().fetched) {
organisation.setSettings(loadSettings(organisation.getId()));
}
return organisation;
Expand All @@ -72,6 +72,7 @@ default OrganisationSettings loadSettings(int organisationId) {
} else {
settings.setValue(key, value);
}
settings.fetched = true;
return settings;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class OrganisationSettings implements Serializable {
private static final long serialVersionUID = -22791512601303567L;
private static final Logger log = LogManager.getLogger(OrganisationSettings.class);

protected boolean fetched = false;
private final EnumMap<Settings, Object> settings = new EnumMap<>(Settings.class);

public Set<Map.Entry<Settings, Object>> getValues() {
Expand Down
12 changes: 7 additions & 5 deletions src/main/webapp/lw/admin/chat-feedback.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
<div class="row">
<div class="col-12 col-md-6">
<p:panel header="Prompt survey" id="prompt">
<p:commandButton action="#{adminChatFeedbackBean.createPromptSurvey}" value="#{msg.create}" update="@parent"
rendered="#{empty adminChatFeedbackBean.promptSurvey}"/>
<h:form rendered="#{empty adminChatFeedbackBean.promptSurvey}">
<p:commandButton action="#{adminChatFeedbackBean.createPromptSurvey}" value="#{msg.create}" update="@form:@parent"/>
</h:form>

<c:if test="#{not empty adminChatFeedbackBean.responseSurvey}">
<c:if test="#{not empty adminChatFeedbackBean.promptSurvey}">
<ui:decorate template="/WEB-INF/templates/blocks/survey/snippet_page_edit.xhtml">
<ui:param name="page" value="#{adminChatFeedbackBean.promptSurvey}"/>
</ui:decorate>
Expand All @@ -31,8 +32,9 @@

<div class="col-12 col-md-6">
<p:panel header="Response survey" id="response">
<p:commandButton action="#{adminChatFeedbackBean.createResponseSurvey}" value="#{msg.create}" update="@parent"
rendered="#{empty adminChatFeedbackBean.responseSurvey}"/>
<h:form rendered="#{empty adminChatFeedbackBean.responseSurvey}">
<p:commandButton action="#{adminChatFeedbackBean.createResponseSurvey}" value="#{msg.create}" update="@form:@parent"/>
</h:form>

<c:if test="#{not empty adminChatFeedbackBean.responseSurvey}">
<ui:decorate template="/WEB-INF/templates/blocks/survey/snippet_page_edit.xhtml">
Expand Down

0 comments on commit 016b8e7

Please sign in to comment.