I understand that I can define in code settings with SettingDefinition. What if I do not know what kind of settings Tenants wants, then I would like the ability to let tenant to define those settings. Have anyone implemented it? Or its a new feature? Can SettingDefinition be loaded or added on the fly? Or only in the init stage?
Thanks.
11 Answer(s)
-
0
The Setting Manager saves settings in database when the value is changed. So it reads database first, when initializing... But you shouldn't update database via T-SQL because it caches settings on the server-side.
-
0
Hi @vladsd,
All settings are added in <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/6076a126f975ea1721348f24c89ed7b44e9f2d6e/src/Abp/Configuration/SettingDefinitionManager.cs#L28">https://github.com/aspnetboilerplate/as ... ger.cs#L28</a>.
SettingDefinitionManager is initialized here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp/AbpKernelModule.cs#L76">https://github.com/aspnetboilerplate/as ... ule.cs#L76</a>
So, you can create a custom SettingDefinitionManager which can load new setting definitions from a database table. But in that way, you need to restart your app for every added setting definition.
-
0
Hi Vlad, It seems we are on similar paths! Add the settings during initialisation using the instructions above and then allow your tenant to change them by adding an extra tab in tenant-settings.component.html. For example I have three settings, registration code for devices (we have spoken about this privately), and data provider name and api (I allow a tenants to load and save data to a third-party system). To facilitate tenant changes to these values I use the following code:
<tab *ngIf="true" heading="YourCompanyName" customClass="m-tabs__item"> <h5>{{l("Devices")}}</h5> <div class="form-group"> <label>{{l("RegistrationCode")}}</label> <input type="text" #registrationCode="ngModel" name="registrationCode" class="form-control" [ngClass]="{'edited':settings.nuage.registrationCode}" [(ngModel)]="settings.nuage.registrationCode" maxlength="6" minlength="4" pattern="[A-Za-z0-9]+" required> <div [hidden]="registrationCode.valid || registrationCode.pristine" class="m-form__help m--font-danger"> <div [hidden]="!registrationCode.hasError('required')">{{l("RequiredField", l('RegistrationCode'))}}</div> <div [hidden]="!registrationCode.hasError('pattern')">{{l("OnlyCharactersAndNumbersAllowed")}}</div> <div [hidden]="!registrationCode.hasError('minlength') && !registrationCode.hasError('maxlength')">{{l("StringLengthDoesntMatch", l('RegistrationCode'), "4", "6")}}</div> </div> </div> <h5>{{l("DataProviders")}}</h5> <div class="form-group"> <label>{{l("DataProvider")}}</label> <input readonly type="text" name="dataProvider" class="form-control" [ngClass]="{'edited':settings.nuage.dataProvider}" [(ngModel)]="settings.nuage.dataProvider" maxlength="256"> </div> <div class="form-group"> <label>{{l("DataProviderApiUrl")}}</label> <input type="text" name="dataProviderApiUrl" class="form-control" [ngClass]="{'edited':settings.nuage.dataProviderApiUrl}" [(ngModel)]="settings.nuage.dataProviderApiUrl" maxlength="256"> </div> </tab>
Hope this helps.
-
0
Thank you all, I understand I can preconfigure settings and let the framework handle.
Maybe settings is not a best place to customize tenant preferences.
I am looking for a simple way for each tenant to define the preferences they want, each preference can be bool, int, string, single selection or multi selection.
My challenge is that I would not know what specific preferences tenant might want.
-
0
Vlad, Dynamic forms, eh? We seem to have a lot in common!
-
0
@vladsd,
My challenge is that I would not know what specific preferences tenant might want.
If this is the case, how are you planning to handle this in your code ? I'm asking because I want to hear a real life usage, so we can consider adding this into ABP framework.
Thanks.
-
0
@ ismcagdas, thanks for your interest.
real life example is straightforward.
I would like to allow tenants to define their own preferences for their users based on their specific business needs.
Dynamic web forms will open so much more use cases, for example one can implement google like forms, etc.
Tenants can create surveys, basic forms to collect data, etc, etc.
Hope it makes sense.
-
0
@vladsd,
So, if I understand correctly, a tenant will create a new survey in your scenario and then define the fields (questions) of the survey using dynamic settings ?
-
0
@ismcagdas, I think dynamic forms would be an excellent feature addition but it's a big topic. Vlad quite rightly points to [https://www.google.co.uk/forms/about/]) as a great example. In my case I am building forms grouped into templates for different scenarios (care actions, quality inspections, ISO reviews, site audits etc.) which are saved as JSON objects in the database. These forms can then be delivered to the client (in my case an Ionic app) and the JSON is dynamically rendered as a form. The form is completed on the client and the results are displayed in Zero. Please try and avoid the word survey which appears to have become de rigueur when describing dynamic forms. Every time I see this I end up reading about how someone has implemented another list of questions and answers usually using checkboxes.
-
0
@ ismcagdas, you are correct and @BobIngham has a good description of forms idea and his implementation approach seems to be very standard.
-
0
@vladsd actually we haven't designed setting system for such dynamic usages. We will consider this internally with the team and I will let you know what we can do about it.