complete home page
This commit is contained in:
parent
7272ce4fad
commit
8d75ee67bf
@ -0,0 +1,91 @@
|
||||
package com.pudonghot.ambition.crm.controller;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import me.chyxion.tigon.model.ListResult;
|
||||
import me.chyxion.tigon.model.ViewModel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.pudonghot.ambition.crm.model.User;
|
||||
import com.pudonghot.ambition.crm.model.HomePage;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import com.pudonghot.ambition.crm.service.HomePageService;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.pudonghot.ambition.crm.form.create.HomePageFormForCreate;
|
||||
import com.pudonghot.ambition.crm.form.update.HomePageFormForUpdate;
|
||||
|
||||
/**
|
||||
* @author Shaun Chyxion <br>
|
||||
* chyxion@163.com <br>
|
||||
* Mar 01, 2018 22:57:52
|
||||
*/
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequestMapping("/home-page")
|
||||
public class HomePageController
|
||||
extends BaseQueryController<HomePage> {
|
||||
private static final String[] SEARCH_COLS = new String[] {
|
||||
HomePage.NAME,
|
||||
HomePage.NOTE
|
||||
};
|
||||
|
||||
@RequestMapping("/list")
|
||||
@RequiresRoles(User.ROLE_ADMIN)
|
||||
public ListResult<ViewModel<HomePage>> list(
|
||||
@Min(0)
|
||||
@RequestParam(value = "start", defaultValue = "0")
|
||||
final int start,
|
||||
@Min(1)
|
||||
@Max(512)
|
||||
@RequestParam(value = "limit", defaultValue = "64")
|
||||
final int limit,
|
||||
@RequestParam(value = "search", required = false)
|
||||
final String search) {
|
||||
|
||||
return listViewModels(start, limit, search, null);
|
||||
}
|
||||
|
||||
@RequiresRoles(User.ROLE_ADMIN)
|
||||
@RequestMapping(value = "/create", method = RequestMethod.POST)
|
||||
public ViewModel<HomePage> create(
|
||||
@Valid HomePageFormForCreate form) {
|
||||
return ((HomePageService) queryService).create(form);
|
||||
}
|
||||
|
||||
@RequiresRoles(User.ROLE_ADMIN)
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public ViewModel<HomePage> update(
|
||||
@Valid HomePageFormForUpdate form) {
|
||||
return ((HomePageService) queryService).update(form);
|
||||
}
|
||||
|
||||
@RequiresRoles(User.ROLE_ADMIN)
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
public void delete(@NotBlank @Param("id") String id) {
|
||||
((HomePageService) queryService).delete(id);
|
||||
}
|
||||
|
||||
@RequiresRoles(User.ROLE_ADMIN)
|
||||
@RequestMapping(value = "/apply", method = RequestMethod.POST)
|
||||
public void apply(@NotBlank String id) {
|
||||
((HomePageService) queryService).apply(id, getUserId());
|
||||
}
|
||||
|
||||
@RequestMapping("/applying")
|
||||
public ViewModel<HomePage> applying() {
|
||||
return ((HomePageService) queryService).applying();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String[] searchCols() {
|
||||
return SEARCH_COLS;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.pudonghot.ambition.crm.service;
|
||||
|
||||
import me.chyxion.tigon.model.ViewModel;
|
||||
import com.pudonghot.ambition.crm.model.HomePage;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import me.chyxion.tigon.service.BaseCrudByFormService;
|
||||
import com.pudonghot.ambition.crm.form.create.HomePageFormForCreate;
|
||||
import com.pudonghot.ambition.crm.form.update.HomePageFormForUpdate;
|
||||
|
||||
/**
|
||||
* @author Shaun Chyxion <br>
|
||||
* chyxion@163.com <br>
|
||||
* Mar 01, 2018 22:58:16
|
||||
*/
|
||||
public interface HomePageService extends
|
||||
BaseCrudByFormService<String,
|
||||
HomePage,
|
||||
HomePageFormForCreate,
|
||||
HomePageFormForUpdate> {
|
||||
|
||||
/**
|
||||
* apply home page
|
||||
* @param id home page id
|
||||
* @param operator operator
|
||||
*/
|
||||
void apply(@NotBlank String id, @NotBlank String operator);
|
||||
|
||||
/**
|
||||
* @return applying home page
|
||||
*/
|
||||
ViewModel<HomePage> applying();
|
||||
}
|
||||
|
@ -0,0 +1,99 @@
|
||||
package com.pudonghot.ambition.crm.service.support;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.util.Assert;
|
||||
import me.chyxion.tigon.mybatis.Search;
|
||||
import me.chyxion.tigon.model.ViewModel;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.pudonghot.ambition.crm.model.HomePage;
|
||||
import com.pudonghot.ambition.crm.mapper.HomePageMapper;
|
||||
import com.pudonghot.ambition.crm.service.HomePageService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.pudonghot.ambition.crm.form.create.HomePageFormForCreate;
|
||||
import com.pudonghot.ambition.crm.form.update.HomePageFormForUpdate;
|
||||
import me.chyxion.tigon.service.support.BaseCrudByFormServiceSupport;
|
||||
|
||||
/**
|
||||
* @author Shaun Chyxion <br>
|
||||
* chyxion@163.com <br>
|
||||
* Mar 01, 2018 22:58:09
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class HomePageServiceSupport
|
||||
extends BaseCrudByFormServiceSupport<String, HomePage,
|
||||
HomePageFormForCreate, HomePageFormForUpdate, HomePageMapper>
|
||||
implements HomePageService {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void apply(final String id, final String operator) {
|
||||
final HomePage homePage = find(id);
|
||||
Assert.state(homePage != null, "No home page [" + id + "] found");
|
||||
Assert.state(homePage.isEnabled(), "Home page [" + id + "] is not enabled");
|
||||
Assert.state(!homePage.isApplying(), "Home page [" + id + "] is applying");
|
||||
final Date now = new Date();
|
||||
toggleApplying(now, operator);
|
||||
homePage.setApplying(true);
|
||||
homePage.setUpdatedBy(operator);
|
||||
homePage.setDateUpdated(now);
|
||||
update(homePage);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public ViewModel<HomePage> applying() {
|
||||
return findViewModel(
|
||||
new Search(HomePage.APPLYING, true)
|
||||
.eq(HomePage.ENABLED, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int delete(final String id) {
|
||||
final HomePage homePage = find(id);
|
||||
Assert.state(homePage != null, "No home page [" + id + "] found");
|
||||
Assert.state(!homePage.isEnabled(), "Home page [" + id + "] is enabled");
|
||||
return super.delete(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void beforeInsert(final HomePage homePage) {
|
||||
super.beforeInsert(homePage);
|
||||
if (homePage.isApplying()) {
|
||||
toggleApplying(homePage.getDateCreated(), homePage.getCreatedBy());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void beforeUpdate(final HomePage homePage) {
|
||||
super.beforeUpdate(homePage);
|
||||
if (homePage.isApplying()) {
|
||||
toggleApplying(homePage.getDateUpdated(), homePage.getUpdatedBy());
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleApplying(final Date date, final String operator) {
|
||||
final Map<String, Object> update = new HashMap<>();
|
||||
update.put(HomePage.APPLYING, false);
|
||||
update.put(HomePage.UPDATED_BY, operator);
|
||||
update.put(HomePage.DATE_UPDATED, date != null ? date : new Date());
|
||||
update(update, new Search(HomePage.APPLYING, true));
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.pudonghot.ambition.crm.web;
|
||||
|
||||
import org.slf4j.MDC;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import javax.servlet.ServletRequestEvent;
|
||||
import javax.servlet.ServletRequestListener;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import me.chyxion.tigon.sequence.IdSequence;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @author Shaun Chyxion <br>
|
||||
* chyxion@163.com <br>
|
||||
* Mar 04, 2018 14:33:09
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RequestListener implements ServletRequestListener {
|
||||
@Autowired
|
||||
private IdSequence idSeq;
|
||||
|
||||
@Override
|
||||
public void requestInitialized(final ServletRequestEvent sre) {
|
||||
MDC.put("requestId", idSeq.get());
|
||||
sre.getServletRequest().setAttribute("startTime", System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestDestroyed(final ServletRequestEvent sre) {
|
||||
final HttpServletRequest request = (HttpServletRequest) sre.getServletRequest();
|
||||
log.info("Request [{}] took {} ms.",
|
||||
request.getRequestURI(),
|
||||
System.currentTimeMillis() -
|
||||
(Long) request.getAttribute("startTime"));
|
||||
MDC.remove("requestId");
|
||||
}
|
||||
}
|
@ -3,11 +3,11 @@
|
||||
<Properties>
|
||||
<Property name="log.level">DEBUG</Property>
|
||||
<Property name="log.dir">.logs</Property>
|
||||
<Property name="pattern">%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t][%c{1}] %m%n</Property>
|
||||
<Property name="pattern">%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t][%X{requestId}][%c{1}] %m%n</Property>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%highlight{%-d{yyyy-MM-dd HH:mm:ss,SSS}}{FATAL=magenta, ERROR=magenta, WARN=magenta, INFO=magenta, DEBUG=magenta, TRACE=magenta} %highlight{%-5p}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=black, DEBUG=green bold, TRACE=blue} [%t][%highlight{%c{1.}}{FATAL=cyan, ERROR=cyan, WARN=cyan, INFO=cyan, DEBUG=cyan, TRACE=cyan}] %m%n"/>
|
||||
<PatternLayout pattern="%highlight{%-d{yyyy-MM-dd HH:mm:ss,SSS}}{FATAL=magenta, ERROR=magenta, WARN=magenta, INFO=magenta, DEBUG=magenta, TRACE=magenta} %highlight{%-5p}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=black, DEBUG=green bold, TRACE=blue} [%t][%X{requestId}][%highlight{%c{1.}}{FATAL=cyan, ERROR=cyan, WARN=cyan, INFO=cyan, DEBUG=cyan, TRACE=cyan}] %m%n"/>
|
||||
</Console>
|
||||
<RollingFile name="File"
|
||||
fileName="${log.dir}/${project.artifactId}.log"
|
||||
|
@ -3,7 +3,7 @@
|
||||
<Properties>
|
||||
<Property name="log.level">INFO</Property>
|
||||
<Property name="log.dir">/data/program/logs/${project.artifactId}</Property>
|
||||
<Property name="pattern">%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t][%c{1}] %m%n</Property>
|
||||
<Property name="pattern">%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t][%X{requestId}][%c{1}] %m%n</Property>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
|
@ -3,7 +3,7 @@
|
||||
<Properties>
|
||||
<Property name="log.level">INFO</Property>
|
||||
<Property name="log.dir">/data/program/logs/${project.artifactId}</Property>
|
||||
<Property name="pattern">%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t][%c{1}] %m%n</Property>
|
||||
<Property name="pattern">%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t][%X{requestId}][%c{1}] %m%n</Property>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.pudonghot.ambition.crm.mapper;
|
||||
|
||||
import me.chyxion.tigon.mybatis.BaseMapper;
|
||||
import com.pudonghot.ambition.crm.model.HomePage;
|
||||
|
||||
/**
|
||||
* @version 0.0.1
|
||||
* @author Auto Generated <br>
|
||||
* Tech Support <a href="mailto:chyxion@163.com">Shaun Chyxion</a><br>
|
||||
* Feb 27, 2018 9:16:03 AM
|
||||
*/
|
||||
public interface HomePageMapper extends BaseMapper<String, HomePage> {
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/**
|
||||
* @version 0.0.1
|
||||
* @author Auto Generated <br>
|
||||
* Tech Support <a href="mailto:chyxion@163.com">Shaun Chyxion</a><br>
|
||||
* Feb 27, 2018 9:16:03 AM
|
||||
*/
|
||||
-->
|
||||
<!DOCTYPE mapper PUBLIC
|
||||
"-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.pudonghot.ambition.crm.mapper.HomePageMapper">
|
||||
</mapper>
|
@ -0,0 +1,63 @@
|
||||
package com.pudonghot.ambition.crm.mapper;
|
||||
|
||||
import org.junit.Test;
|
||||
import java.util.Date;
|
||||
import org.junit.Assert;
|
||||
import org.junit.runner.RunWith;
|
||||
import com.pudonghot.ambition.crm.model.HomePage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
|
||||
|
||||
/**
|
||||
* @version 0.0.1
|
||||
* @author Auto Generated <br>
|
||||
* Tech Support <a href="mailto:chyxion@163.com">Shaun Chyxion</a><br>
|
||||
* Feb 27, 2018 9:16:03 AM
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath*:spring/spring-*.xml")
|
||||
public class HomePageMapperTest extends AbstractTransactionalJUnit4SpringContextTests {
|
||||
@Autowired
|
||||
private HomePageMapper mapper;
|
||||
|
||||
@Test
|
||||
public void mapperTest() {
|
||||
// String id = String.valueOf(new Date().getTime());
|
||||
// init model
|
||||
HomePage m = new HomePage();
|
||||
String id = "id";
|
||||
m.setId(id);
|
||||
m.setDateCreated(new Date());
|
||||
m.setContent("s");
|
||||
m.setApplying(true);
|
||||
mapper.insert(m);
|
||||
Assert.assertTrue(mapper.list(null).size() > 0);
|
||||
/*
|
||||
// Your Test Logics
|
||||
HomePage m1 = mapper.find(id);
|
||||
// asserts
|
||||
Assert.assertEquals(id, m1.getId());
|
||||
Assert.assertEquals("s", m.getPage());
|
||||
Assert.assertEquals("s", m.getApplying());
|
||||
// update
|
||||
m.setDateUpdated(new Date());
|
||||
m.setPage("S");
|
||||
m.setApplying("S");
|
||||
mapper.update(m);
|
||||
m1 = mapper.find(id);
|
||||
// asserts
|
||||
Assert.assertEquals(id, m1.getId());
|
||||
Assert.assertNotNull(m1.getDateUpdated());
|
||||
Assert.assertEquals("S", m.getPage());
|
||||
Assert.assertEquals("S", m.getApplying());
|
||||
// list
|
||||
Assert.assertTrue(mapper.list(null).size() > 0);
|
||||
// delete
|
||||
mapper.delete(id);
|
||||
m1 = mapper.find(id);
|
||||
Assert.assertNull(m1);
|
||||
*/
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ package com.pudonghot.ambition.crm.form.create;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chyxion.tigon.form.FC2;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import me.chyxion.tigon.format.annotation.Trim;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
@ -15,11 +15,15 @@ import org.hibernate.validator.constraints.NotBlank;
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class CustomerPermissionFormForCreate extends FC2<String> {
|
||||
public class HomePageFormForCreate extends FC2<String> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// Properties
|
||||
@Trim
|
||||
@NotBlank
|
||||
@Length(max = 64)
|
||||
private String name;
|
||||
@Trim
|
||||
@NotBlank
|
||||
private String content;
|
||||
private boolean applying;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.pudonghot.ambition.crm.form.update;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chyxion.tigon.form.FU2;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @version 0.0.1
|
||||
* @since 0.0.1
|
||||
* @author Shaun Chyxion <br>
|
||||
* chyxion@163.com <br>
|
||||
* May 10, 2016 1:42:01 PM
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class HomePageFormForUpdate extends FU2<String, String> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank
|
||||
private String name;
|
||||
@NotBlank
|
||||
private String content;
|
||||
private boolean applying;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.pudonghot.ambition.crm.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chyxion.tigon.model.M3;
|
||||
import me.chyxion.tigon.mybatis.Table;
|
||||
|
||||
/**
|
||||
* @version 0.0.1
|
||||
* @author Auto Generated <br>
|
||||
* Tech Support <a href="mailto:chyxion@163.com">Shaun Chyxion</a><br>
|
||||
* Feb 27, 2018 9:16:03 AM
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Table("crm_home_page")
|
||||
public class HomePage extends M3<String, String> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// Column Names
|
||||
public static final String NAME = "name";
|
||||
public static final String CONTENT = "content";
|
||||
public static final String APPLYING = "applying";
|
||||
|
||||
// Properties
|
||||
private String name;
|
||||
private String content;
|
||||
private boolean applying;
|
||||
}
|
38
server/model/src/main/resources/log4j2.xml
Normal file
38
server/model/src/main/resources/log4j2.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Properties>
|
||||
<Property name="log.level">DEBUG</Property>
|
||||
<Property name="log.dir">.logs</Property>
|
||||
<Property name="pattern">%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t][%c{1}] %m%n</Property>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="${pattern}" />
|
||||
</Console>
|
||||
<RollingFile name="File"
|
||||
fileName="${log.dir}/${project.artifactId}.log"
|
||||
filePattern="${log.dir}/$${date:yyyy-MM}/${project.artifactId}-%d{yyyy-MM-dd}-%i.log">
|
||||
<PatternLayout pattern="${pattern}" />
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy size="16 MB" />
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="32" />
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework" level="INFO" additivity="false">
|
||||
<AppenderRef ref="File" />
|
||||
</Logger>
|
||||
<Logger name="org.apache" level="WARN" additivity="false">
|
||||
<AppenderRef ref="File" />
|
||||
</Logger>
|
||||
<Logger name="org.hibernate.validator" level="WARN" additivity="false">
|
||||
<AppenderRef ref="File" />
|
||||
</Logger>
|
||||
<Root level="${log.level}" additivity="false">
|
||||
<AppenderRef ref="File" level="${log.level}" />
|
||||
<AppenderRef ref="Console" level="${log.level}" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
8
server/model/src/main/resources/spring/config.properties
Normal file
8
server/model/src/main/resources/spring/config.properties
Normal file
@ -0,0 +1,8 @@
|
||||
# Config Dev
|
||||
|
||||
# Database
|
||||
datasource.host=127.0.0.1
|
||||
datasource.port=63306
|
||||
datasource.database-name=ambition_crm_test
|
||||
datasource.username=root
|
||||
datasource.password=696@2^~)oZ@^#*Q
|
@ -3,27 +3,42 @@ import BaseFormInput from './base-form-input';
|
||||
|
||||
export default BaseFormInput.extend({
|
||||
didInsertElement() {
|
||||
let me = this;
|
||||
const me = this;
|
||||
me._super(...arguments);
|
||||
//intialize wysiwyg editor
|
||||
me.$('.wysiwyg-editor').ace_wysiwyg({
|
||||
toolbar: [
|
||||
'bold',
|
||||
'italic',
|
||||
'strikethrough',
|
||||
'underline',
|
||||
'font',
|
||||
null,
|
||||
'justifyleft',
|
||||
'justifycenter',
|
||||
'justifyright',
|
||||
'fontSize',
|
||||
null,
|
||||
'createLink',
|
||||
'unlink',
|
||||
'bold',
|
||||
'italic',
|
||||
'strikethrough',
|
||||
'underline',
|
||||
null,
|
||||
'undo',
|
||||
'insertunorderedlist',
|
||||
'insertorderedlist',
|
||||
'outdent',
|
||||
'indent',
|
||||
null,
|
||||
'justifyleft',
|
||||
'justifycenter',
|
||||
'justifyright',
|
||||
'justifyfull',
|
||||
null,
|
||||
'createLink',
|
||||
'unlink',
|
||||
// null,
|
||||
// 'insertImage',
|
||||
null,
|
||||
'foreColor',
|
||||
null,
|
||||
'undo',
|
||||
'redo'
|
||||
]}).on('DOMSubtreeModified propertychange', function() {
|
||||
]
|
||||
}).on('DOMSubtreeModified propertychange', function() {
|
||||
me.setVal(Ember.$(this).html());
|
||||
}).html(me.getVal()).prev().addClass('wysiwyg-style1');
|
||||
}).html(me.getVal()).prev().addClass('wysiwyg-style2');
|
||||
}
|
||||
});
|
||||
|
@ -68,6 +68,12 @@ Router.map(function() {
|
||||
this.route('database-backup', function() {
|
||||
this.route('list');
|
||||
});
|
||||
|
||||
this.route('home-page', function() {
|
||||
this.route('list', {path: '/list/:page'});
|
||||
this.route('create');
|
||||
this.route('edit', {path: '/:id/edit'});
|
||||
});
|
||||
});
|
||||
|
||||
export default Router;
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Ember from 'ember';
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
export default Route.extend({
|
||||
getLoginRoute() {
|
||||
return Ember.getOwner(this).lookup('route:login');
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Ember from 'ember';
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
export default Route.extend({
|
||||
toolService: Ember.inject.service('tool-service'),
|
||||
beforeModel(transition) {
|
||||
let me = this;
|
||||
|
10
web/app/routes/home-page/create.js
Normal file
10
web/app/routes/home-page/create.js
Normal file
@ -0,0 +1,10 @@
|
||||
import BaseRoute from '../base';
|
||||
|
||||
export default BaseRoute.extend({
|
||||
breadcrumbs: [{route: 'home-page.list', params: 1, text: 'Home Pages'}, {text: 'Create Home Page'}],
|
||||
model() {
|
||||
return {
|
||||
enabled: true,
|
||||
};
|
||||
}
|
||||
});
|
11
web/app/routes/home-page/edit.js
Normal file
11
web/app/routes/home-page/edit.js
Normal file
@ -0,0 +1,11 @@
|
||||
import BaseEditRoute from '../base-edit';
|
||||
|
||||
export default BaseEditRoute.extend({
|
||||
afterModel(model) {
|
||||
const me = this;
|
||||
me._super(...arguments);
|
||||
me.set('breadcrumbs',
|
||||
[{route: 'home-page.list', params: 1, text: 'Home Pages'},
|
||||
{text: 'Edit Home Page [' + model.name + ']'}]);
|
||||
}
|
||||
});
|
18
web/app/routes/home-page/list.js
Normal file
18
web/app/routes/home-page/list.js
Normal file
@ -0,0 +1,18 @@
|
||||
import Ember from 'ember';
|
||||
import BaseListRoute from './../base-list';
|
||||
|
||||
export default BaseListRoute.extend({
|
||||
breadcrumbs: [{text: 'Home Pages'}],
|
||||
actions: {
|
||||
apply(page) {
|
||||
const me = this;
|
||||
console.log('apply page: ', page);
|
||||
me.get('dialog').confirm('Are you sure to apply home page [' + page.name + ']?', () => {
|
||||
me.get('ajax').doPost('home-page/apply', {id: page.id}, () => {
|
||||
me.get('message').alert('Home page [' + page.name + '] applied');
|
||||
me.refresh();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
@ -1,11 +1,17 @@
|
||||
import Ember from 'ember';
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
beforeModel() {
|
||||
export default Route.extend({
|
||||
model() {
|
||||
const me = this;
|
||||
me._super(...arguments);
|
||||
return me.get('store').ajaxGet('home-page/applying');
|
||||
},
|
||||
afterModel(model) {
|
||||
console.log('home page loaded: ', model);
|
||||
if (model.content) {
|
||||
// model.content =
|
||||
model.content = Ember.String.htmlSafe(model.content);
|
||||
}
|
||||
// this.transitionTo('app.list', 1);
|
||||
},
|
||||
// activate() {
|
||||
// Ember.Logger.info('Index active.');
|
||||
// Ember.run.later(() => Ember.$('.page-content').addClass('desktop'), 1000)
|
||||
// }
|
||||
});
|
||||
|
20
web/app/services/home-page/service.js
Normal file
20
web/app/services/home-page/service.js
Normal file
@ -0,0 +1,20 @@
|
||||
import BaseService from '../service';
|
||||
|
||||
export default BaseService.extend({
|
||||
modelName: 'HomePage',
|
||||
constraints: {
|
||||
name: {
|
||||
presence: true,
|
||||
length: {
|
||||
minimum: 1,
|
||||
maximum: 36
|
||||
}
|
||||
},
|
||||
content: {
|
||||
presence: true
|
||||
},
|
||||
applying: {
|
||||
presence: true,
|
||||
}
|
||||
}
|
||||
});
|
@ -1,6 +1,6 @@
|
||||
<label class="col-xs-3 control-label no-padding-right"> {{label}} </label>
|
||||
<div class="col-xs-4">
|
||||
<label class="no-margin">
|
||||
<label class="no-margin" style="padding-top: 3px;">
|
||||
{{input type='hidden' name=name value=(mut (get model name))}}
|
||||
{{input type='checkbox' class='ace ace-switch ace-switch-5' checked=(mut (get model name))}}
|
||||
<span class="lbl"></span>
|
||||
|
@ -78,6 +78,12 @@
|
||||
<span class="menu-text"> Import Records </span>
|
||||
{{/link-to}}
|
||||
</li>
|
||||
<li>
|
||||
{{#link-to 'home-page.list' 1}}
|
||||
<i class="menu-icon fa fa-newspaper-o blue"></i>
|
||||
<span class="menu-text"> Home Page </span>
|
||||
{{/link-to}}
|
||||
</li>
|
||||
<li>
|
||||
{{#link-to 'database-backup.list'}}
|
||||
<i class="menu-icon fa fa-archive blue"></i>
|
||||
|
@ -1,3 +1,2 @@
|
||||
<div class="wysiwyg-editor"></div>
|
||||
{{input type='hidden' name=name value=(get model name)}}
|
||||
{{form-input-errors-msg name=name}}
|
||||
<div class="wysiwyg-editor" style="border-width: 1px;"></div>
|
||||
{{input type='hidden' name=name value=(mut (get model name))}}
|
@ -3,6 +3,5 @@
|
||||
{{form-input type='hidden' name='enabled'}}
|
||||
{{form-input name='issue' label='Comment' type='textarea'}}
|
||||
<hr />
|
||||
{{!form-footer-buttons type='update' backRouteName='customer.show' backRouteParams=model.customerId}}
|
||||
{{form-footer-buttons type='update'}}
|
||||
{{/form-content}}
|
||||
|
10
web/app/templates/home-page/create.hbs
Normal file
10
web/app/templates/home-page/create.hbs
Normal file
@ -0,0 +1,10 @@
|
||||
{{#form-content}}
|
||||
{{form-input name='name' label='Name'}}
|
||||
{{#form-input name='content' label='Content'}}
|
||||
{{wysiwyg-editor model=model name='content'}}
|
||||
{{/form-input}}
|
||||
{{form-input-checkbox name='applying' label='Applying' enabledText='TRUE' disabledText='FALSE'}}
|
||||
{{form-input name='note' label='Remark'}}
|
||||
<hr />
|
||||
{{form-footer-buttons}}
|
||||
{{/form-content}}
|
12
web/app/templates/home-page/edit.hbs
Normal file
12
web/app/templates/home-page/edit.hbs
Normal file
@ -0,0 +1,12 @@
|
||||
{{#form-content}}
|
||||
{{input type='hidden' name='id' value=model.id}}
|
||||
{{form-input name='name' label='Name'}}
|
||||
{{#form-input name='content' label='Content'}}
|
||||
{{wysiwyg-editor model=model name='content'}}
|
||||
{{/form-input}}
|
||||
{{form-input-checkbox name='applying' label='Applying'}}
|
||||
{{form-input-checkbox label='Enabled'}}
|
||||
{{form-input name='note' label='Remark'}}
|
||||
<hr />
|
||||
{{form-footer-buttons type='update'}}
|
||||
{{/form-content}}
|
102
web/app/templates/home-page/list.hbs
Normal file
102
web/app/templates/home-page/list.hbs
Normal file
@ -0,0 +1,102 @@
|
||||
{{#main-content}}
|
||||
<div class="widget-box transparent">
|
||||
{{#grid-header}}
|
||||
<li>
|
||||
{{#link-to 'home-page.create'}}
|
||||
<i class="ace-icon fa fa-plus-circle bigger-110 green"></i>
|
||||
Create Home Page
|
||||
{{/link-to}}
|
||||
</li>
|
||||
{{/grid-header}}
|
||||
|
||||
<div class="widget-body">
|
||||
<!-- #section:custom/scrollbar -->
|
||||
<div class="widget-main no-padding no-border">
|
||||
<table class="table table-striped table-bordered table-hover dataTable" style="border: 1px solid #ddd;">
|
||||
<thead class="thin-border-bottom">
|
||||
<tr>
|
||||
<th>
|
||||
Name
|
||||
</th>
|
||||
<th>
|
||||
<i class="ace-icon fa fa-sticky-note-o bigger-110 hidden-480"></i>
|
||||
Remark
|
||||
</th>
|
||||
<th>
|
||||
Applying
|
||||
</th>
|
||||
<th>
|
||||
<i class="ace-icon fa fa-exchange bigger-110 hidden-480"></i>
|
||||
Enabled
|
||||
</th>
|
||||
<th>
|
||||
<i class="ace-icon fa fa-cogs bigger-110 hidden-480"></i>
|
||||
Settings
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{{#each model.data as |it|}}
|
||||
<tr>
|
||||
<td>
|
||||
{{it.name}}
|
||||
</td>
|
||||
<td>
|
||||
{{editable-cell model=it field='note'}}
|
||||
</td>
|
||||
<td>
|
||||
{{status-cell model=it name='applying' enabledText='TRUE' disabledText='FALSE'}}
|
||||
</td>
|
||||
<td>
|
||||
{{status-cell model=it enabledText='TRUE' disabledText='FALSE'}}
|
||||
</td>
|
||||
<td>
|
||||
<div class="hidden-sm hidden-xs btn-group">
|
||||
{{status-toggle-button model=it}}
|
||||
{{#if (not it.applying)}}
|
||||
<button class="btn btn-xs btn-info2" data-rel="tooltip" title="Apply" {{action (route-action 'apply' it)}}>
|
||||
<i class="ace-icon fa fa-floppy-o bigger-120"></i>
|
||||
</button>
|
||||
{{/if}}
|
||||
{{#link-to 'home-page.edit' it.id class='btn btn-xs btn-info' data-rel="tooltip" title='Edit'}}
|
||||
<i class="ace-icon fa fa-pencil bigger-120"></i>
|
||||
{{/link-to}}
|
||||
</div>
|
||||
<div class="hidden-md hidden-lg">
|
||||
<div class="inline pos-rel">
|
||||
<button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
|
||||
<i class="ace-icon fa fa-cog icon-only bigger-110"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
|
||||
<li>
|
||||
{{status-toggle-button model=it iconOnly=true}}
|
||||
</li>
|
||||
{{#if (not it.applying)}}
|
||||
<li>
|
||||
<a class="tooltip-info" title="Apply" {{action (route-action 'apply' it)}}>
|
||||
<i class="ace-icon fa fa-floppy-o bigger-120"></i>
|
||||
</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
<li>
|
||||
{{#link-to 'home-page.edit' it.id class='tooltip-info' data-rel='tooltip' title='Edit'}}
|
||||
<span class="blue">
|
||||
<i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
|
||||
</span>
|
||||
{{/link-to}}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{pagination-bar}}
|
||||
</div>
|
||||
</div>
|
||||
{{/main-content}}
|
||||
{{outlet}}
|
@ -1,54 +1,6 @@
|
||||
{{!home-board}}
|
||||
{{#main-content}}
|
||||
<div class="col-sm-12 index-content">
|
||||
<h3>User tips: </h3>
|
||||
<p class="bold">{{repeat-it ' ' 4}}Customer Status:</p>
|
||||
<p>{{repeat-it ' ' 8}}Active – Auto assigned, Active customer, with PO in current year</p>
|
||||
<p>{{repeat-it ' ' 8}}Occasional – Auto assigned, Not very active, no PO in current year, but occasional PO within past 2 years</p>
|
||||
<p>{{repeat-it ' ' 8}}Sleeping – Auto assigned, Sleeping customer and no PO within past 2 years, still use PUSH-PULL</p>
|
||||
<p>{{repeat-it ' ' 8}}NA – Manually assigned, Not PUSH-PULL customer anymore</p>
|
||||
<br />
|
||||
<p class="bold">{{repeat-it ' ' 4}}Customer Basic Information to collect: </p>
|
||||
<p>{{repeat-it ' ' 8}}General info: </p>
|
||||
<p>{{repeat-it ' ' 8}}Global Project (for CA only): </p>
|
||||
<p>{{repeat-it ' ' 8}}Cust. Core Business: </p>
|
||||
<p>{{repeat-it ' ' 8}}LEMO app: </p>
|
||||
<p>{{repeat-it ' ' 8}}LEMO rivals(%): </p>
|
||||
<p>{{repeat-it ' ' 8}}Cust. staff qty: </p>
|
||||
<p>{{repeat-it ' ' 8}}Cust. competitors: </p>
|
||||
|
||||
<br />
|
||||
<p class="bold">{{repeat-it ' ' 4}}LMCN Week Goals: </p>
|
||||
<p>{{repeat-it ' ' 8}}每次访客时100%向需要的客户推广:新产品、光纤、组件和技术研讨会。</p>
|
||||
|
||||
<hr />
|
||||
<h3>Admin Tips: </h3>
|
||||
<p>{{repeat-it ' ' 4}}Step 1 – Import Customers: QAD 2.2.23</p>
|
||||
<p>{{repeat-it ' ' 4}}Step 2 – Import Sales Data: QAD 7.17.13</p>
|
||||
|
||||
{{!--
|
||||
User tips:
|
||||
Customer Status:
|
||||
Active – Auto assigned, Active customer, with PO in current year
|
||||
Occasional – Auto assigned, Not very active, no PO in current year, but occasional PO within past 2 years
|
||||
Sleeping – Auto assigned, Sleeping customer and no PO within past 2 years, still use PUSH-PULL
|
||||
NA – Manually assigned, Not PUSH-PULL customer anymore
|
||||
|
||||
Customer Basic Information to collect:
|
||||
General info:
|
||||
Global Project (for CA only):
|
||||
Cust. Core Business:
|
||||
LEMO app:
|
||||
LEMO rivals(%):
|
||||
Cust. staff qty:
|
||||
Cust. competitors:
|
||||
|
||||
LMCN Week Goals:
|
||||
每次访客时100%向需要的客户推广:新产品、光纤、组件和技术研讨会。
|
||||
|
||||
Admin Tips:
|
||||
Step 1 – Import Customers: QAD 2.2.23
|
||||
Step 2 – Import Sales Data: QAD 7.17.13
|
||||
--}}
|
||||
{{model.content}}
|
||||
</div>
|
||||
{{/main-content}}
|
||||
|
@ -14,4 +14,3 @@
|
||||
<hr />
|
||||
{{form-footer-buttons}}
|
||||
{{/form-content}}
|
||||
|
||||
|
@ -18,8 +18,7 @@
|
||||
"jquery-colorbox": "^1.6.4",
|
||||
"fuelux": "^3.15.4",
|
||||
"jquery.hotkeys": "*",
|
||||
"bootstrap-wysiwyg": "*",
|
||||
"editor.md": "^1.5.0"
|
||||
"bootstrap-wysiwyg": "*"
|
||||
},
|
||||
"resolutions": {
|
||||
"ember": "release"
|
||||
|
@ -89,6 +89,11 @@ module.exports = function(defaults) {
|
||||
destDir: '/assets/img'
|
||||
});
|
||||
|
||||
// JQuery HotKeys
|
||||
importVendor(app, 'bower_components/jquery.hotkeys/jquery.hotkeys.js');
|
||||
// Bootstrap WYSIWYG
|
||||
importVendor(app, 'bower_components/bootstrap-wysiwyg/bootstrap-wysiwyg.js');
|
||||
|
||||
// Select2, must before ace
|
||||
importVendor(app, 'vendor/ace/js/select2.js');
|
||||
importVendor(app, 'vendor/ace/css/select2.css');
|
||||
@ -119,7 +124,7 @@ module.exports = function(defaults) {
|
||||
// importVendor(app, 'vendor/ace/js/ace/elements.fileinput.js');
|
||||
// importVendor(app, 'vendor/ace/js/ace/elements.spinner.js');
|
||||
// importVendor(app, 'vendor/ace/js/ace/elements.treeview.js');
|
||||
// importVendor(app, 'vendor/ace/js/ace/elements.wysiwyg.js');
|
||||
importVendor(app, 'vendor/ace/js/ace/elements.wysiwyg.js');
|
||||
|
||||
// importVendor(app, 'vendor/ace/js/jquery-ui.custom.js');
|
||||
|
||||
|
11
web/tests/unit/routes/home-page/create-test.js
Normal file
11
web/tests/unit/routes/home-page/create-test.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:home-page/create', 'Unit | Route | home page/create', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.subject();
|
||||
assert.ok(route);
|
||||
});
|
11
web/tests/unit/routes/home-page/edit-test.js
Normal file
11
web/tests/unit/routes/home-page/edit-test.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:home-page/edit', 'Unit | Route | home page/edit', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.subject();
|
||||
assert.ok(route);
|
||||
});
|
11
web/tests/unit/routes/home-page/list-test.js
Normal file
11
web/tests/unit/routes/home-page/list-test.js
Normal file
@ -0,0 +1,11 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:home-page/list', 'Unit | Route | home page/list', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let route = this.subject();
|
||||
assert.ok(route);
|
||||
});
|
12
web/tests/unit/services/home-page/service-test.js
Normal file
12
web/tests/unit/services/home-page/service-test.js
Normal file
@ -0,0 +1,12 @@
|
||||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('service:home-page/service', 'Unit | Service | home page/service', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['service:foo']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let service = this.subject();
|
||||
assert.ok(service);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user