download name client config over exam
This commit is contained in:
parent
c72bf2cf9c
commit
0790b5827f
3 changed files with 22 additions and 18 deletions
|
@ -14,11 +14,13 @@ import java.util.function.Predicate;
|
|||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.rap.rwt.RWT;
|
||||
import org.eclipse.rap.rwt.client.service.UrlLauncher;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -57,22 +59,25 @@ public class ExamCreateClientConfigPopup {
|
|||
|
||||
private final PageService pageService;
|
||||
private final DownloadService downloadService;
|
||||
private final String downloadFileName;
|
||||
|
||||
public ExamCreateClientConfigPopup(
|
||||
final PageService pageService,
|
||||
final DownloadService downloadService,
|
||||
@Value("${sebserver.gui.seb.exam.config.download.filename}") final String downloadFileName) {
|
||||
final DownloadService downloadService) {
|
||||
|
||||
this.pageService = pageService;
|
||||
this.downloadService = downloadService;
|
||||
this.downloadFileName = downloadFileName;
|
||||
}
|
||||
|
||||
public Function<PageAction, PageAction> exportFunction(final Long examInstitutionId) {
|
||||
public Function<PageAction, PageAction> exportFunction(
|
||||
final Long examInstitutionId,
|
||||
final String examName) {
|
||||
|
||||
return action -> {
|
||||
|
||||
final DateTime now = DateTime.now(DateTimeZone.UTC);
|
||||
final String downloadFileName = StringUtils.remove(examName, " ") + "_" + now.getYear() + "-"
|
||||
+ now.getMonthOfYear() + "-" + now.getDayOfMonth() + ".seb";
|
||||
|
||||
final ModalInputDialog<FormHandle<?>> dialog =
|
||||
new ModalInputDialog<FormHandle<?>>(
|
||||
action.pageContext().getParent().getShell(),
|
||||
|
@ -88,7 +93,8 @@ public class ExamCreateClientConfigPopup {
|
|||
this.pageService,
|
||||
action.pageContext(),
|
||||
action.getEntityKey(),
|
||||
formHandle);
|
||||
formHandle,
|
||||
downloadFileName);
|
||||
|
||||
dialog.open(
|
||||
TITLE_KEY,
|
||||
|
@ -104,7 +110,8 @@ public class ExamCreateClientConfigPopup {
|
|||
final PageService pageService,
|
||||
final PageContext pageContext,
|
||||
final EntityKey examKey,
|
||||
final FormHandle<?> formHandle) {
|
||||
final FormHandle<?> formHandle,
|
||||
final String downloadFileName) {
|
||||
|
||||
if (formHandle == null) {
|
||||
return true;
|
||||
|
@ -116,7 +123,7 @@ public class ExamCreateClientConfigPopup {
|
|||
modelId,
|
||||
examKey.modelId,
|
||||
SEBClientConfigDownload.class,
|
||||
this.downloadFileName);
|
||||
downloadFileName);
|
||||
urlLauncher.openURL(downloadURL);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.eclipse.swt.layout.GridData;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -141,8 +140,7 @@ public class ExamForm implements TemplateComposer {
|
|||
final ExamDeletePopup examDeletePopup,
|
||||
final ExamFormConfigs examFormConfigs,
|
||||
final ExamFormIndicators examFormIndicators,
|
||||
final ExamCreateClientConfigPopup examCreateClientConfigPopup,
|
||||
@Value("${sebserver.gui.seb.exam.config.download.filename}") final String downloadFileName) {
|
||||
final ExamCreateClientConfigPopup examCreateClientConfigPopup) {
|
||||
|
||||
this.pageService = pageService;
|
||||
this.resourceService = pageService.getResourceService();
|
||||
|
@ -358,6 +356,7 @@ public class ExamForm implements TemplateComposer {
|
|||
final PageActionBuilder actionBuilder = this.pageService.pageActionBuilder(formContext
|
||||
.clearEntityKeys()
|
||||
.removeAttribute(AttributeKeys.IMPORT_FROM_QUIZ_DATA));
|
||||
|
||||
// propagate content actions to action-pane
|
||||
actionBuilder
|
||||
|
||||
|
@ -380,7 +379,9 @@ public class ExamForm implements TemplateComposer {
|
|||
|
||||
.newAction(ActionDefinition.EXAM_SEB_CLIENT_CONFIG_EXPORT)
|
||||
.withEntityKey(entityKey)
|
||||
.withExec(this.examCreateClientConfigPopup.exportFunction(exam.institutionId))
|
||||
.withExec(this.examCreateClientConfigPopup.exportFunction(
|
||||
exam.institutionId,
|
||||
exam.getName()))
|
||||
.publishIf(() -> writeGrant && readonly)
|
||||
|
||||
.newAction(ActionDefinition.EXAM_MODIFY_SEB_RESTRICTION_DETAILS)
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -35,14 +34,11 @@ public class SEBClientConfigDownload extends AbstractDownloadServiceHandler {
|
|||
private static final Logger log = LoggerFactory.getLogger(SEBClientConfigDownload.class);
|
||||
|
||||
private final RestService restService;
|
||||
public final String downloadFileName;
|
||||
|
||||
protected SEBClientConfigDownload(
|
||||
final RestService restService,
|
||||
@Value("${sebserver.gui.seb.client.config.download.filename}") final String downloadFileName) {
|
||||
final RestService restService) {
|
||||
|
||||
this.restService = restService;
|
||||
this.downloadFileName = downloadFileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue