mirror of
https://github.com/getrebuild/rebuild.git
synced 2025-03-13 15:44:26 +08:00
Merge branch 'master' into develop
This commit is contained in:
commit
23c50c2bb9
7 changed files with 59 additions and 34 deletions
|
@ -57,7 +57,8 @@ public class AutoFillinManager implements ConfigManager {
|
|||
// 内置字段无配置 @see field-edit.html
|
||||
if (easyField.isBuiltin()) return JSONUtils.EMPTY_ARRAY;
|
||||
|
||||
final List<ConfigBean> config = getConfig(field);
|
||||
final List<ConfigBean> config = new ArrayList<>();
|
||||
for (ConfigBean cb : getConfig(field)) config.add(cb.clone());
|
||||
|
||||
// 父级级联
|
||||
// 利用表单回填做父级级联字段回填
|
||||
|
@ -70,7 +71,7 @@ public class AutoFillinManager implements ConfigManager {
|
|||
.set("whenCreate", true)
|
||||
.set("whenUpdate", true)
|
||||
.set("fillinForce", true);
|
||||
|
||||
|
||||
// 移除冲突的表单回填配置
|
||||
for (Iterator<ConfigBean> iter = config.iterator(); iter.hasNext(); ) {
|
||||
ConfigBean cb = iter.next();
|
||||
|
@ -89,28 +90,28 @@ public class AutoFillinManager implements ConfigManager {
|
|||
Entity sourceEntity = MetadataHelper.getEntity(source.getEntityCode());
|
||||
Entity targetEntity = field.getOwnEntity();
|
||||
Set<String> sourceFields = new HashSet<>();
|
||||
for (ConfigBean e : config) {
|
||||
for (Iterator<ConfigBean> iter = config.iterator(); iter.hasNext(); ) {
|
||||
ConfigBean e = iter.next();
|
||||
String sourceField = e.getString("source");
|
||||
String targetField = e.getString("target");
|
||||
if (!MetadataHelper.checkAndWarnField(sourceEntity, sourceField)
|
||||
|| !MetadataHelper.checkAndWarnField(targetEntity, targetField)) {
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
sourceFields.add(sourceField);
|
||||
}
|
||||
if (sourceFields.isEmpty()) {
|
||||
return JSONUtils.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
if (sourceFields.isEmpty()) return JSONUtils.EMPTY_ARRAY;
|
||||
|
||||
String ql = String.format("select %s from %s where %s = ?",
|
||||
StringUtils.join(sourceFields, ","),
|
||||
sourceEntity.getName(),
|
||||
sourceEntity.getPrimaryField().getName());
|
||||
Record sourceRecord = Application.createQueryNoFilter(ql).setParameter(1, source).record();
|
||||
if (sourceRecord == null) {
|
||||
return JSONUtils.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
if (sourceRecord == null) return JSONUtils.EMPTY_ARRAY;
|
||||
|
||||
JSONArray fillin = new JSONArray();
|
||||
for (ConfigBean e : config) {
|
||||
|
|
|
@ -405,7 +405,7 @@ public class PrivilegesManager {
|
|||
* @param action
|
||||
* @param ep
|
||||
* @return
|
||||
* @see RoleBaseQueryFilter#buildCustomFilter(Privileges)
|
||||
* @see RoleBaseQueryFilter#buildCustomFilter(Privileges, Field)
|
||||
*/
|
||||
private boolean andPassCustomFilter(ID user, ID target, Permission action, Privileges ep) {
|
||||
if (!(ep instanceof CustomEntityPrivileges)) return true;
|
||||
|
|
|
@ -18,6 +18,8 @@ import cn.devezhao.persist4j.Entity;
|
|||
import cn.devezhao.persist4j.Field;
|
||||
import cn.devezhao.persist4j.Filter;
|
||||
import cn.devezhao.persist4j.engine.ID;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.rebuild.core.metadata.EntityHelper;
|
||||
import com.rebuild.core.metadata.MetadataHelper;
|
||||
|
@ -26,6 +28,7 @@ import com.rebuild.core.privileges.bizz.CustomEntityPrivileges;
|
|||
import com.rebuild.core.privileges.bizz.Department;
|
||||
import com.rebuild.core.privileges.bizz.User;
|
||||
import com.rebuild.core.service.query.AdvFilterParser;
|
||||
import com.rebuild.utils.JSONUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
|
@ -127,7 +130,7 @@ public class RoleBaseQueryFilter implements Filter, QueryFilter {
|
|||
owningFormat = dtmField.getName() + "." + owningFormat;
|
||||
}
|
||||
|
||||
final String customFilter = buildCustomFilter(ep);
|
||||
final String customFilter = buildCustomFilter(ep, dtmField);
|
||||
final String shareFilter = buildShareFilter(entity, dtmField);
|
||||
|
||||
final DepthEntry depth = ep.superlative(useAction);
|
||||
|
@ -183,19 +186,19 @@ public class RoleBaseQueryFilter implements Filter, QueryFilter {
|
|||
* 共享权限
|
||||
*
|
||||
* @param entity
|
||||
* @param detailToMainField
|
||||
* @param dtmField
|
||||
* @return
|
||||
*/
|
||||
private String buildShareFilter(Entity entity, Field detailToMainField) {
|
||||
private String buildShareFilter(Entity entity, Field dtmField) {
|
||||
if (user == null) return null;
|
||||
|
||||
String shareFilter = "exists (select rights from ShareAccess where belongEntity = '%s' and shareTo = '%s' and recordId = ^%s)";
|
||||
|
||||
// 明细实体,使用主实体的共享
|
||||
if (detailToMainField != null) {
|
||||
// 使用主实体的共享(明细实体)
|
||||
if (dtmField != null) {
|
||||
shareFilter = String.format(shareFilter,
|
||||
detailToMainField.getOwnEntity().getMainEntity().getName(),
|
||||
user.getId(), detailToMainField.getName());
|
||||
dtmField.getOwnEntity().getMainEntity().getName(),
|
||||
user.getId(), dtmField.getName());
|
||||
} else {
|
||||
shareFilter = String.format(shareFilter,
|
||||
entity.getName(), user.getId(), entity.getPrimaryField().getName());
|
||||
|
@ -207,16 +210,33 @@ public class RoleBaseQueryFilter implements Filter, QueryFilter {
|
|||
* 自定义权限
|
||||
*
|
||||
* @param ep
|
||||
* @param dtmField
|
||||
* @return
|
||||
* @see PrivilegesManager#andPassCustomFilter(ID, ID, Permission, Privileges)
|
||||
*/
|
||||
private String buildCustomFilter(Privileges ep) {
|
||||
private String buildCustomFilter(Privileges ep, Field dtmField) {
|
||||
if (user == null || useAction == null
|
||||
|| !(ep instanceof CustomEntityPrivileges)) return null;
|
||||
|
||||
JSONObject hasFilter = ((CustomEntityPrivileges) ep).getCustomFilter(useAction);
|
||||
if (hasFilter == null) return null;
|
||||
|
||||
// 兼容转换(明细实体)
|
||||
if (dtmField != null) {
|
||||
final JSONArray items = hasFilter.getJSONArray("items");
|
||||
|
||||
JSONArray items2 = new JSONArray();
|
||||
for (Object item : items) {
|
||||
JSONObject c = (JSONObject) JSONUtils.clone((JSON) item);
|
||||
c.put("field", String.format("%s.%s", dtmField.getName(), c.getString("field")));
|
||||
items2.add(c);
|
||||
}
|
||||
|
||||
hasFilter = JSONUtils.toJSONObject(
|
||||
new String[] { "entity", "items" },
|
||||
new Object[] { dtmField.getOwnEntity().getName(), items2 });
|
||||
}
|
||||
|
||||
AdvFilterParser advFilterParser = new AdvFilterParser(hasFilter);
|
||||
advFilterParser.setUser(user.getId());
|
||||
return advFilterParser.toSqlWhere();
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Map;
|
|||
* @since 2021/11/15
|
||||
*/
|
||||
public class CustomEntityPrivileges extends EntityPrivileges {
|
||||
private static final long serialVersionUID = 2658045031880710476L;
|
||||
|
||||
private Map<String, JSON> customAdvFilters = new HashMap<>();
|
||||
|
||||
|
|
|
@ -110,16 +110,19 @@ public class AutoFillinController extends BaseController {
|
|||
for (Object[] o : array) {
|
||||
String sourceField = (String) o[1];
|
||||
String targetField = (String) o[2];
|
||||
if (!MetadataHelper.checkAndWarnField(sourceEntity, sourceField)
|
||||
|| !MetadataHelper.checkAndWarnField(targetEntity, targetField)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String sourceFieldLabel = sourceEntity.containsField(sourceField)
|
||||
? EasyMetaFactory.getLabel(sourceEntity.getField(sourceField))
|
||||
: String.format("[%s]", sourceField.toUpperCase());
|
||||
String targetFieldLabel = targetEntity.containsField(targetField)
|
||||
? EasyMetaFactory.getLabel(targetEntity.getField(targetField))
|
||||
: String.format("[%s]", targetField.toUpperCase());
|
||||
|
||||
JSON rule = JSONUtils.toJSONObject(
|
||||
new String[]{ "id", "sourceField", "sourceFieldLabel", "targetField", "targetFieldLabel", "extConfig" },
|
||||
new Object[]{ o[0],
|
||||
sourceField, EasyMetaFactory.getLabel(sourceEntity.getField(sourceField)),
|
||||
targetField, EasyMetaFactory.getLabel(targetEntity.getField(targetField)),
|
||||
sourceField, sourceFieldLabel,
|
||||
targetField, targetFieldLabel,
|
||||
JSON.parse((String) o[3])});
|
||||
rules.add(rule);
|
||||
}
|
||||
|
|
|
@ -422,9 +422,8 @@ a.btn {
|
|||
}
|
||||
|
||||
.input-search input + .btn-input-clear::before {
|
||||
font-family: 'Material-Design-Iconic-Font';
|
||||
font-family: 'Material-Design-Iconic-Font', serif;
|
||||
font-size: 1.308rem;
|
||||
content: '\f135';
|
||||
content: '\f136';
|
||||
}
|
||||
|
||||
|
@ -949,7 +948,7 @@ select.form-control:not([disabled]) {
|
|||
|
||||
.type-N2NREFERENCE .select2-container--default .select2-selection--multiple::after {
|
||||
content: '\f2f9';
|
||||
font-family: 'Material-Design-Iconic-Font';
|
||||
font-family: 'Material-Design-Iconic-Font', serif;
|
||||
font-size: 1.6rem;
|
||||
font-weight: 400;
|
||||
line-height: 35px;
|
||||
|
@ -1012,7 +1011,6 @@ select.form-control:not([disabled]) {
|
|||
.img-field .img-upload[disabled] .zmdi {
|
||||
opacity: 1 !important;
|
||||
color: #dbdbdb !important;
|
||||
cursor: default !important;
|
||||
cursor: not-allowed !important;
|
||||
}
|
||||
|
||||
|
@ -1621,7 +1619,7 @@ th.column-fixed {
|
|||
transform: translateX(100%);
|
||||
box-shadow: inset 10px 0 8px -8px rgba(0, 0, 0, 0.15);
|
||||
transition: box-shadow 0.3s;
|
||||
width: 20px;
|
||||
/*width: 20px;*/
|
||||
/* fix: Safari */
|
||||
width: 24px;
|
||||
}
|
||||
|
@ -4375,7 +4373,7 @@ html.external-auth .auth-body.must-center .login {
|
|||
|
||||
.user-popup .infos p.phone,
|
||||
.user-popup .infos p.email {
|
||||
font-family: 'Material-Design-Iconic-Font';
|
||||
font-family: 'Material-Design-Iconic-Font', serif;
|
||||
}
|
||||
|
||||
.user-popup .infos p.phone::after,
|
||||
|
@ -4439,7 +4437,7 @@ pre.unstyle {
|
|||
}
|
||||
|
||||
.dropdown-item.check::after {
|
||||
font-family: 'Material-Design-Iconic-Font';
|
||||
font-family: 'Material-Design-Iconic-Font', serif;
|
||||
content: '\f26b';
|
||||
float: right;
|
||||
font-size: 1.2rem;
|
||||
|
@ -4515,7 +4513,7 @@ pre.unstyle {
|
|||
}
|
||||
|
||||
.sign-pad-canvas .pen-colors > a.active::after {
|
||||
font-family: 'Material-Design-Iconic-Font';
|
||||
font-family: 'Material-Design-Iconic-Font', serif;
|
||||
content: '\f26b';
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,8 @@ class RbPreview extends React.Component {
|
|||
onLoad={() => this.setState({ imgRendered: true })}
|
||||
onError={() => {
|
||||
RbHighbar.error($L('无法读取图片'))
|
||||
this.hide()
|
||||
// this.hide()
|
||||
// Qiniu: {"error":"xxx is not within the limit, area is out of range [1, 24999999]"}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
@ -181,8 +182,9 @@ class RbPreview extends React.Component {
|
|||
const currentUrl = this.props.urls[this.state.currentIndex]
|
||||
const fileName = $fileCutName(currentUrl)
|
||||
if (this._isDoc(fileName)) {
|
||||
const ispdf = fileName.toLowerCase().endsWith('.pdf')
|
||||
const setPreviewUrl = function (url) {
|
||||
const previewUrl = (rb._officePreviewUrl || 'https://view.officeapps.live.com/op/embed.aspx?src=') + $encode(url)
|
||||
const previewUrl = ispdf ? url : (rb._officePreviewUrl || 'https://view.officeapps.live.com/op/embed.aspx?src=') + $encode(url)
|
||||
that.setState({ previewUrl: previewUrl, errorMsg: null })
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue