#592 add edit page as draft
This commit is contained in:
parent
762a3043bd
commit
89d0a413d2
6 changed files with 229 additions and 3 deletions
|
@ -18,10 +18,7 @@ package org.codelibs.fess;
|
|||
// DO NOT DEPEND OTHER JARs
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.apache.catalina.startup.Tomcat;
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.dbflute.tomcat.TomcatBoot;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.app.service.SearchService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.entity.SearchRenderData;
|
||||
import org.codelibs.fess.es.client.FessEsClient;
|
||||
|
@ -32,6 +33,7 @@ import org.codelibs.fess.exception.ResultOffsetExceededException;
|
|||
import org.codelibs.fess.helper.ProcessHelper;
|
||||
import org.codelibs.fess.helper.QueryHelper;
|
||||
import org.codelibs.fess.util.RenderDataUtil;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.lastaflute.web.Execute;
|
||||
|
@ -222,14 +224,98 @@ public class AdminSearchlistAction extends FessAdminAction {
|
|||
return asListHtml();
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse createnew() {
|
||||
saveToken();
|
||||
return asHtml(path_AdminSearchlist_AdminSearchlistEditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse edit(final EditForm form) {
|
||||
validate(form, messages -> {}, () -> asListHtml());
|
||||
// TODO load
|
||||
saveToken();
|
||||
if (form.crudMode.intValue() == CrudMode.EDIT) {
|
||||
// back
|
||||
form.crudMode = CrudMode.DETAILS;
|
||||
return asListHtml();
|
||||
} else {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asEditHtml();
|
||||
}
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
// TODO verify
|
||||
verifyToken(() -> asEditHtml());
|
||||
getDoc(form).ifPresent(entity -> {
|
||||
try {
|
||||
// TODO save
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
} catch (final Exception e) {
|
||||
logger.error("Failed to add " + entity, e);
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL, buildThrowableMessage(e)),
|
||||
() -> asEditHtml());
|
||||
}
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateInstance(GLOBAL), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, () -> asEditHtml());
|
||||
// TODO verify
|
||||
verifyToken(() -> asEditHtml());
|
||||
getDoc(form).ifPresent(entity -> {
|
||||
try {
|
||||
// TODO save
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
} catch (final Exception e) {
|
||||
logger.error("Failed to update " + entity, e);
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToUpdateCrudTable(GLOBAL, buildThrowableMessage(e)),
|
||||
() -> asEditHtml());
|
||||
}
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), () -> asEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// JSP
|
||||
// =========
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, () -> asListHtml());
|
||||
}
|
||||
}
|
||||
|
||||
protected OptionalEntity<Map<String, Object>> getDoc(final CreateForm form) {
|
||||
// TODO
|
||||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
private HtmlResponse asListHtml() {
|
||||
return asHtml(path_AdminSearchlist_AdminSearchlistJsp);
|
||||
}
|
||||
|
||||
private HtmlResponse asEditHtml() {
|
||||
return asHtml(path_AdminSearchlist_AdminSearchlistEditJsp);
|
||||
}
|
||||
|
||||
protected static class WebRenderData extends SearchRenderData {
|
||||
|
||||
public void register(final RenderData data) {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2012-2016 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.searchlist;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class CreateForm {
|
||||
|
||||
@ValidateTypeFailure
|
||||
public Integer crudMode;
|
||||
|
||||
public Map<String, Object> doc;
|
||||
|
||||
public void initialize() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright 2012-2016 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.searchlist;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class EditForm extends CreateForm {
|
||||
|
||||
@Required
|
||||
public String id;
|
||||
|
||||
@Required
|
||||
@ValidateTypeFailure
|
||||
public Integer versionNo;
|
||||
|
||||
}
|
|
@ -285,6 +285,9 @@ public interface FessHtmlPath {
|
|||
/** The path of the HTML: /admin/searchlist/admin_searchlist.jsp */
|
||||
HtmlNext path_AdminSearchlist_AdminSearchlistJsp = new HtmlNext("/admin/searchlist/admin_searchlist.jsp");
|
||||
|
||||
/** The path of the HTML: /admin/searchlist/admin_searchlist_edit.jsp */
|
||||
HtmlNext path_AdminSearchlist_AdminSearchlistEditJsp = new HtmlNext("/admin/searchlist/admin_searchlist_edit.jsp");
|
||||
|
||||
/** The path of the HTML: /admin/systeminfo/admin_systeminfo.jsp */
|
||||
HtmlNext path_AdminSysteminfo_AdminSysteminfoJsp = new HtmlNext("/admin/systeminfo/admin_systeminfo.jsp");
|
||||
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><la:message key="labels.admin_brand_title" /> | <la:message
|
||||
key="labels.search_list_configuration" /></title>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/head.jsp"></jsp:include>
|
||||
</head>
|
||||
<body class="hold-transition skin-blue sidebar-mini">
|
||||
<div class="wrapper">
|
||||
<jsp:include page="/WEB-INF/view/common/admin/header.jsp"></jsp:include>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/sidebar.jsp">
|
||||
<jsp:param name="menuCategoryType" value="log" />
|
||||
<jsp:param name="menuType" value="searchList" />
|
||||
</jsp:include>
|
||||
<div class="content-wrapper">
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
<la:message key="labels.search_list_configuration" />
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li class="active"><la:link href="/admin/searchlist">
|
||||
<la:message key="labels.search_list_configuration" />
|
||||
</la:link></li>
|
||||
</ol>
|
||||
</section>
|
||||
<section class="content">
|
||||
<la:form action="/admin/searchlist/" styleClass="form-horizontal">
|
||||
<la:hidden property="crudMode" />
|
||||
<c:if test="${crudMode==2}">
|
||||
<la:hidden property="id" />
|
||||
</c:if>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div
|
||||
class="box <c:if test="${crudMode == 1}">box-success</c:if><c:if test="${crudMode == 2}">box-warning</c:if>">
|
||||
<div class="box-header with-border">
|
||||
<jsp:include page="/WEB-INF/view/common/admin/crud/header.jsp"></jsp:include>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body">
|
||||
<div>
|
||||
<la:info id="msg" message="true">
|
||||
<div class="alert alert-info">${msg}</div>
|
||||
</la:info>
|
||||
<la:errors property="_global" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="title" class="col-sm-3 control-label"><la:message
|
||||
key="labels.user_surname" /></label>
|
||||
<div class="col-sm-9">
|
||||
<la:errors property="doc.title" />
|
||||
<la:text property="doc.title" styleClass="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
<div class="box-footer">
|
||||
<jsp:include page="/WEB-INF/view/common/admin/crud/buttons.jsp"></jsp:include>
|
||||
</div>
|
||||
<!-- /.box-footer -->
|
||||
</div>
|
||||
<!-- /.box -->
|
||||
</div>
|
||||
</div>
|
||||
</la:form>
|
||||
</section>
|
||||
</div>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/footer.jsp"></jsp:include>
|
||||
</div>
|
||||
<jsp:include page="/WEB-INF/view/common/admin/foot.jsp"></jsp:include>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Reference in a new issue