From 7647161de13af7d40affbb4ed208c91a2b6d12ef Mon Sep 17 00:00:00 2001 From: devezhao Date: Sat, 7 Nov 2020 00:03:56 +0800 Subject: [PATCH] fix: forms --- .../rebuild/core/privileges/UserStore.java | 2 + src/main/resources/web/.eslintrc.js | 1 + src/main/resources/web/assets/js/rb-base.js | 7 +++ src/main/resources/web/assets/js/rb-forms.js | 61 ++++++++++++------- 4 files changed, 49 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/rebuild/core/privileges/UserStore.java b/src/main/java/com/rebuild/core/privileges/UserStore.java index 57be1f81b..6831c6fcc 100644 --- a/src/main/java/com/rebuild/core/privileges/UserStore.java +++ b/src/main/java/com/rebuild/core/privileges/UserStore.java @@ -535,6 +535,8 @@ public class UserStore implements Initialization { for (User user : USERS.values()) { Role role = user.getOwningRole(); + if (role == null) continue; + if (role.getIdentity().equals(roleId) || (role instanceof CombinedRole && ((CombinedRole) role).getRoleAppends().contains(roleId))) { refreshUserRoleAppends(user); diff --git a/src/main/resources/web/.eslintrc.js b/src/main/resources/web/.eslintrc.js index c7f6c619f..6a4c52897 100644 --- a/src/main/resources/web/.eslintrc.js +++ b/src/main/resources/web/.eslintrc.js @@ -105,5 +105,6 @@ module.exports = { $fromNow: true, $expired: true, $L: true, + $isTrue: true }, } diff --git a/src/main/resources/web/assets/js/rb-base.js b/src/main/resources/web/assets/js/rb-base.js index e566c923f..abe0ee956 100644 --- a/src/main/resources/web/assets/js/rb-base.js +++ b/src/main/resources/web/assets/js/rb-base.js @@ -416,6 +416,13 @@ var $stopEvent = function (e) { return false } +/** + * 是否为 true 或 'true' + */ +var $isTrue = function (a) { + return a === true || a === 'true' +} + /** * 定位到指定元素 */ diff --git a/src/main/resources/web/assets/js/rb-forms.js b/src/main/resources/web/assets/js/rb-forms.js index 7a6755e77..28e329874 100644 --- a/src/main/resources/web/assets/js/rb-forms.js +++ b/src/main/resources/web/assets/js/rb-forms.js @@ -46,13 +46,19 @@ class RbFormModal extends React.Component { } componentDidMount() { - $(this._rbmodal) + const $root = $(this._rbmodal) .modal({ show: false, backdrop: 'static', keyboard: false, }) - .on('hidden.bs.modal', () => $keepModalOpen()) + .on('hidden.bs.modal', () => { + $keepModalOpen() + if (this.props.disposeOnHide === true) { + $root.modal('dispose') + $unmount($root.parent().parent()) + } + }) this.showAfter({}, true) } @@ -151,13 +157,20 @@ class RbFormModal extends React.Component { /** * @param {*} props */ - static create(props) { - const that = this - if (that.__HOLDER) that.__HOLDER.show(props) - else + static create(props, newDlg) { + if (newDlg === true) { + renderRbcomp() + return + } + + if (this.__HOLDER) { + this.__HOLDER.show(props) + } else { + const that = this renderRbcomp(, null, function () { that.__HOLDER = this }) + } } } @@ -197,24 +210,27 @@ class RbForm extends React.Component { renderFormAction() { const pmodel = this.props.$$$parent.state.__formModel const moreActions = [] - if (pmodel.hadApproval) + if (pmodel.hadApproval) { moreActions.push( this.post(103)}> {$L('SaveAndSubmit')} ) - if (pmodel.isMain === true) + } + + if (pmodel.isMain === true) { moreActions.push( this.post(102)}> {$L('SaveAndAddDetail')} ) - else if (pmodel.isDetail === true) + } else if (pmodel.isDetail === true) { moreActions.push( this.post(101)}> {$L('SaveAndAdd')} ) + } let actionBtn = (