如何理解多租户在视图中是否已启用?

时间:2018-03-14 08:59:41

标签: aspnetboilerplate

我们没有使用多租户。禁用时,大多数与租户相关的UI都会被隐藏,但在LinkedAccount页面中,用户可以查看租赁名称(默认值)。我们想在UI中隐藏它。试图找到像IsMultiTenancyEnabled但找不到的属性(实际上它位于IMultiTenancyConfig但不适用于剃刀页面)。那么,如果未启用Multitenancy,如何隐藏UI元素?

//This is the code we want to hide. 
<div class="form-group">
        <label>@L("TenancyName")</label>
        <input type="text" name="TenancyName" class="form-control" value="@(ViewBag.TenancyName ?? "")" maxlength="@TurkKizilayi.RFL.MultiTenancy.Tenant.MaxTenancyNameLength">
</div>

还有一件事:如果我们隐藏此代码会发生什么?我们应该更改模型或应用程序服务(是)吗?

2 个答案:

答案 0 :(得分:1)

Angular项目中已有服务<ScrollView> <View> <Image source={ require('../Images/5.jpg') } style = { styles.image } /> { this.state.details.map(a => <View> <Text style={ styles.textStyle } > { a.content = a.content.replace(regex, '') } < /Text> < RadioForm style= {{ width: 350 - 30 }} outerColor = "#080103" innerColor = "#FF5733" itemShowKey = "label" itemRealKey = "item" dataSource = { transform(a.options) } onPress = {(item)=>this._onSelect(item)}/> </View>) } </View> </ScrollView> const styles = StyleSheet.create({ image: { flex: 1, resizeMode: 'cover', position: 'absolute', width: "100%", flexDirection: 'column' }, textStyle: { fontSize: 16, color: '#000', padding: 5, }, }); AbpMultiTenancyService已定义AppComponentBase。因此,如果您的组件类继承自multiTenancy,那么您可以直接使用此服务。

您可以在AppComponentBase文件中定义属性,如下所示。

*.ts

然后您可以在HTML中使用相同的内容。

isMultiTenancyEnabled: boolean = this.multiTenancy.isEnabled

或者您只需使用以下代码即可。

*ngIf="isMultiTenancyEnabled"

答案 1 :(得分:1)

对于MVC,您可以将IMultiTenancyConfig注入视图中。 这是你想要的最终代码;

@inject IMultiTenancyConfig MultiTenancyConfig
@using Abp.Configuration.Startup
@using MyCompanyName.AbpZeroTemplate.Web.Areas.AppAreaName.Models.Common.Modals
@Html.Partial("~/Areas/AppAreaName/Views/Common/Modals/_ModalHeader.cshtml", new ModalHeaderViewModel(L("LinkNewAccount")))

<div class="modal-body">
    <form name="LinkAccountModalForm" role="form" novalidate class="form-validation">

        @if (MultiTenancyConfig.IsEnabled)
        {
            <div class="form-group">
                <label>@L("TenancyName")</label>
                <input type="text" name="TenancyName" class="form-control" value="@(ViewBag.TenancyName ?? "")" maxlength="@MyCompanyName.AbpZeroTemplate.MultiTenancy.Tenant.MaxTenancyNameLength">
            </div>
        }

        <div class="form-group">
            <label>@L("UserName")</label>
            <input class="form-control" type="text" name="UsernameOrEmailAddress" required maxlength="@MyCompanyName.AbpZeroTemplate.Authorization.Users.User.MaxEmailAddressLength">
        </div>

        <div class="form-group">
            <label>@L("Password")</label>
            <input type="password" name="Password" autocomplete="off" class="form-control" required maxlength="@MyCompanyName.AbpZeroTemplate.Authorization.Users.User.MaxPasswordLength">
        </div>
    </form>

</div>

@Html.Partial("~/Areas/AppAreaName/Views/Common/Modals/_ModalFooterWithSaveAndCancel.cshtml")