Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/vspc 271 - Exhibition Configuration: if not exhibition language should be required #348

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import java.util.stream.Collectors;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import org.javers.common.collections.Arrays;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -25,6 +28,7 @@
import edu.asu.diging.vspace.core.model.impl.Exhibition;
import edu.asu.diging.vspace.core.services.IExhibitionManager;
import edu.asu.diging.vspace.core.services.ISpaceManager;
import edu.asu.diging.vspace.web.staff.forms.ExhibitionConfigurationForm;

@Controller
public class ExhibitionConfigurationController {
Expand Down Expand Up @@ -77,19 +81,26 @@ public String showExhibitions(Model model) {
* @param spaceParam
* @param attributes
* @return
*/
*/
@RequestMapping(value = "/staff/exhibit/config", method = RequestMethod.POST)
public RedirectView createOrUpdateExhibition(HttpServletRequest request,
@RequestParam(required = false, name = "exhibitionParam") String exhibitID,
@RequestParam("spaceParam") String spaceID, @RequestParam("title") String title,
@RequestParam("exhibitMode") ExhibitionModes exhibitMode,
@RequestParam(value = "customMessage", required = false, defaultValue = "") String customMessage,
@RequestParam("exhibitLanguage") List<String> languages,
@RequestParam("defaultExhibitLanguage") String defaultLanguage,
@RequestParam("spaceParam") String spaceID,
@Valid @ModelAttribute("exhibitionConfigurationForm") ExhibitionConfigurationForm exhibitionConfigForm,
BindingResult result,
RedirectAttributes attributes) throws IOException {

ISpace startSpace = spaceManager.getSpace(spaceID);

if(result.hasErrors()) {
attributes.addAttribute("showAlert", true);
attributes.addAttribute("alertType", "danger");
attributes.addAttribute("message", result.getFieldError().getDefaultMessage());
return new RedirectView(request.getContextPath() + "/staff/exhibit/config");
}
String title = exhibitionConfigForm.getTitle();
ExhibitionModes exhibitMode = exhibitionConfigForm.getExhibitMode();
List<String> languages = exhibitionConfigForm.getExhibitLanguage();
String defaultLanguage = exhibitionConfigForm.getDefaultExhibitLanguage();
String customMessage = exhibitionConfigForm.getCustomMessage();
ISpace startSpace = spaceManager.getSpace(spaceID);
Exhibition exhibition;
if (exhibitID == null || exhibitID.isEmpty()) {
exhibition = (Exhibition) exhibitFactory.createExhibition();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package edu.asu.diging.vspace.web.staff.forms;

import java.util.List;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

import edu.asu.diging.vspace.core.model.ExhibitionModes;

public class ExhibitionConfigurationForm {

private String customMessage;

private String defaultExhibitLanguage;

@NotEmpty(message = "Please select exhibition languages")
private List<String> exhibitLanguage;

@NotNull(message = "Please select exhibit mode")
private ExhibitionModes exhibitMode;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is not really a reason to save 3 characters, just write out "exhibition" (and in the message it definitely need to be written out)


@NotEmpty(message = "Please enter title")
private String title;

public String getCustomMessage() {
return customMessage;
}

public void setCustomMessage(String customMessage) {
this.customMessage = customMessage;
}

public String getDefaultExhibitLanguage() {
return defaultExhibitLanguage;
}

public void setDefaultExhibitLanguage(String defaultExhibitLanguage) {
this.defaultExhibitLanguage = defaultExhibitLanguage;
}

public List<String> getExhibitLanguage() {
return exhibitLanguage;
}

public void setExhibitLanguage(List<String> exhibitLanguage) {
this.exhibitLanguage = exhibitLanguage;
}

public ExhibitionModes getExhibitMode() {
return exhibitMode;
}

public void setExhibitMode(ExhibitionModes exhibitMode) {
this.exhibitMode = exhibitMode;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}
jdamerow marked this conversation as resolved.
Show resolved Hide resolved
}
16 changes: 12 additions & 4 deletions vspace/src/main/webapp/WEB-INF/views/staff/exhibit/config.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@

<html layout:decorate="~{layouts/main_staff}">
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<script th:inline="javascript">
$(document).ready(function() {

$(function (){
$('[data-toggle="tooltip"]').tooltip()
});

var offlineMessage = $('#offlineMessage');
if ('[(${exhibition})]' != null && '[(${exhibition.mode})]' == 'OFFLINE') {
offlineMessage.show();
}
else {
offlineMessage.hide();
}
}
});

function modeChange(modeChosen) {
Expand Down Expand Up @@ -54,7 +61,7 @@ <h2>Exhibition Configuration</h2>
<a style="color:blue;" th:href="@{|/preview/${exhibition.previewId}|}"> [[${#strings.defaultString(@environment.getProperty('baseUrl'),'')}]][[@{|/preview/${exhibition.previewId}|}]]</a></p>
</div>
<div style="padding: 30px 0;">
<form th:action="@{/staff/exhibit/config}" method="POST" name="f">
<form th:action="@{/staff/exhibit/config}" method="POST" name="f" modelAttribute="${exhibitionConfigurationForm}">
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<input type="hidden" th:value="${exhibition?.id}" name="exhibitionParam"/>
<label for="space">Select the start space of the exhibition:</label>
Expand All @@ -76,8 +83,9 @@ <h2>Exhibition Configuration</h2>
</select>
</div>
<div style="padding-top: 20px;">
<label for="title">Exhibition Languages:</label>
<select class="form-control" name="exhibitLanguage" multiple="multiple" >
<label for="title">Exhibition Languages: <span class="fa fa-question-circle secondary" aria-hidden="true" data-toggle="tooltip" data-html="true" data-placement="right" title="To select multiple languages, hold down the shift key when selecting."></span>
</label>
<select class="form-control" name="exhibitLanguage" multiple="multiple" required>
<option th:each="language: ${languageList}" th:id=${language.code} th:value=${language.code} th:selected="${savedExhibitionLanguages!=null && savedExhibitionLanguages.contains(language.label)}">[[${language.label}]]</option>
</select>
</div>
Expand Down