add image
This commit is contained in:
parent
b9c9ecd7cd
commit
2a30d4639b
@ -1,6 +1,7 @@
|
||||
package com.pudonghot.ambition.crm.service.support;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -13,6 +14,7 @@ import com.pudonghot.ambition.crm.model.Application;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.pudonghot.ambition.crm.model.ApplicationImage;
|
||||
import com.pudonghot.ambition.crm.mapper.ApplicationMapper;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import com.pudonghot.ambition.crm.service.ApplicationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import me.chyxion.tigon.service.support.BaseCrudServiceSupport;
|
||||
@ -38,6 +40,8 @@ public class ApplicationServiceSupport
|
||||
private ApplicationImageMapper imageMapper;
|
||||
@Autowired
|
||||
private AmbitionFileApi fileApi;
|
||||
@Value("${file.base-path}")
|
||||
private String fileBasePath;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@ -68,10 +72,12 @@ public class ApplicationServiceSupport
|
||||
*/
|
||||
@Override
|
||||
public ViewModel<Application> findViewModel(final String id) {
|
||||
final List<ApplicationImage> images = imageMapper.list(
|
||||
new Search(ApplicationImage.APPLICATION_ID, id)
|
||||
.asc(ApplicationImage.SORT));
|
||||
images.forEach(image -> image.setUrl(fileBasePath + imageFolder(id) + "/" + image.getId()));
|
||||
return super.findViewModel(id)
|
||||
.setAttr("images", imageMapper.list(
|
||||
new Search(ApplicationImage.APPLICATION_ID, id)
|
||||
.asc(ApplicationImage.SORT)));
|
||||
.setAttr("images", images);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chyxion.tigon.model.M3;
|
||||
import me.chyxion.tigon.mybatis.Table;
|
||||
import me.chyxion.tigon.mybatis.Transient;
|
||||
|
||||
/**
|
||||
* @author Shaun Chyxion <br>
|
||||
@ -23,4 +24,6 @@ public class ApplicationImage extends M3<String, String> {
|
||||
// Properties
|
||||
private String applicationId;
|
||||
private float sort;
|
||||
@Transient
|
||||
private String url;
|
||||
}
|
||||
|
@ -20,5 +20,28 @@ export default BaseEditRoute.extend({
|
||||
const me = this;
|
||||
me.get('controller.model.images').removeObject(image);
|
||||
},
|
||||
moveUp(image) {
|
||||
let me = this;
|
||||
let images = me.get('controller.model.images');
|
||||
if (images && images.length > 1) {
|
||||
let index = images.indexOf(image);
|
||||
images.removeObject(image);
|
||||
images.insertAt(index - 1, image);
|
||||
me.updateImage(image);
|
||||
}
|
||||
},
|
||||
moveDown(image) {
|
||||
let me = this;
|
||||
let images = me.get('controller.model.images');
|
||||
if (images && images.length > 1) {
|
||||
let index = images.indexOf(image);
|
||||
images.removeObject(image);
|
||||
images.insertAt(index + 1, image);
|
||||
me.updateImage(image);
|
||||
}
|
||||
}
|
||||
},
|
||||
updateImage(image) {
|
||||
this.get('ajax').doPost('application/update-image', image, false);
|
||||
}
|
||||
});
|
||||
|
@ -47,10 +47,20 @@
|
||||
{{image.id}}
|
||||
</td>
|
||||
<td>
|
||||
{{image.note}}
|
||||
{{editable-cell model=image field='note' post-url='application/update-image'}}
|
||||
</td>
|
||||
<td>
|
||||
{{u.note}}
|
||||
{{!image.note}}
|
||||
{{#if (not-eq model.images.firstObject.id image.id)}}
|
||||
<button class="btn btn-xs btn-purple" data-rel="tooltip" title="Move Up" {{action (route-action 'moveUp' image)}}>
|
||||
<i class="ace-icon fa fa-arrow-up bigger-90"></i>
|
||||
</button>
|
||||
{{/if}}
|
||||
{{#if (not-eq model.images.lastObject.id image.id)}}
|
||||
<button class="btn btn-xs" data-rel="tooltip" title="Move Down" {{action (route-action 'moveDown' image)}}>
|
||||
<i class="ace-icon fa fa-arrow-down bigger-90"></i>
|
||||
</button>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user