Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "martin"

I checked the forum posts and only found something about Angular and Core (I'm using Core and JQuery) https://support.aspnetzero.com/QA/Questions/5582

I did a bit of reading with regards to JQuery Validation and it leads me to believe that it should focus to the first element that failed validation.

We have a very large Modal form which is a few pages long (the boss wants it this way) my solution doesn't focus to the first invalid element.

I found an answer or sorts. https://stackoverflow.com/questions/9392133/when-form-is-validated-how-to-scroll-to-the-first-error-instead-of-jumping

Problem is I can't get it to work, if I replace the animate method with focus it works, but only when I click the "Save" button. If I push the "Enter" key on any other element it sets focus but also displays the modal validation error form.

            _$employeeInformationForm.validate({
                focusInvalid: false,
                invalidHandler: function (form, validator) {
                    if (!validator.numberOfInvalids()) return;

                    $(validator.errorList[0].element).focus();
                    //$('html, body').animate({
                    //    scrollTop: $(validator.errorList[0].element).offset().top
                    //}, 2000);                    
                }
            });

What do I need to do to get the solution to focus to the first element that failed validation ? To be honest the focus method isn't suitable since it can trigger other things like a dropdown opening of the datepicker opening the date selector.

We are attempting to add a HTML title to all the Index pages when they are loaded.

So in all the _Layout.cshtml pages for the Default, Theme11 .... the code

@section Title{
    @RenderSection("Title", true)
}

was added, then for each Index.html page the code

@section Title{
    @L("Settings")
}

was added which works correctly.

We are having an issue with Theme8 which has a _Layout.cshtml page with a different layout. So I get an exception since it finds a title in an Index page which shouldn't be there (because it isn't picking up the boolean switch).

Is this the correct way to achieve this ? Or is there a better method for added a title to each Index.html page ?

Question

So we are looking at using Telerik with ASP.NET Zero and their guide details how to setup a ASP.NET Core project and get it all working. https://docs.telerik.com/aspnet-core/getting-started/getting-started#configuration Which is fine and works great, they also supply a demo project which shows everything working.

I used the manual process for adding the Client Side resources. https://docs.telerik.com/aspnet-core/getting-started/getting-started-copy-client-resources#manual-installation

Step 4. Register the Kendo UI styles and scripts in ~/Views/Shared/_Layout.cshtml

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - TelerikSetup</title>

    <environment include="Development">
        <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />

        <link rel="stylesheet" href="~/lib/kendo-ui/styles/kendo.common-nova.min.css" />
        <link rel="stylesheet" href="~/lib/kendo-ui/styles/kendo.nova.min.css" />

        <script src="~/lib/jquery/dist/jquery.js"></script>

        @* Place Kendo UI scripts after jQuery *@
        <script src="~/lib/kendo-ui/js/kendo.all.min.js"></script>
        <script src="~/lib/kendo-ui/js/kendo.aspnetmvc.min.js"></script>
    </environment>
    <environment exclude="Development">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css"
              asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
              asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute"
              crossorigin="anonymous"
              integrity="sha256-eSi1q2PG6J7g7ib17yAaWMcrr5GrtohYChqibrV7PBE=" />

        <link rel="stylesheet"
              href="https://kendo.cdn.telerik.com/2019.1.115/styles/kendo.common-nova.min.css"
              asp-fallback-href="~/lib/kendo-ui/styles/kendo.common-nova.min.css"
              asp-fallback-test-class="k-common-test-class"
              asp-fallback-test-property="opacity" asp-fallback-test-value="0" />

        <link rel="stylesheet"
              href="https://kendo.cdn.telerik.com/2019.1.115/styles/kendo.nova.min.css"
              asp-fallback-href="~/lib/kendo-ui/styles/kendo.nova.min.css"
              asp-fallback-test-class="k-theme-test-class"
              asp-fallback-test-property="opacity" asp-fallback-test-value="0" />

        <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
                asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
                asp-fallback-test="window.jQuery"
                crossorigin="anonymous"
                integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk">
        </script>

        @* Place Kendo UI scripts after jQuery *@
        <script src="https://kendo.cdn.telerik.com/2019.1.115/js/kendo.all.min.js"
                asp-fallback-src="~/lib/kendo-ui/js/kendo.all.min.js"
                asp-fallback-test="window.kendo">
        </script>
        <script src="https://kendo.cdn.telerik.com/2019.1.115/js/kendo.aspnetmvc.min.js"
                asp-fallback-src="~/lib/kendo-ui/js/kendo.aspnetmvc.min.js"
                asp-fallback-test="kendo.data.transports['aspnetmvc-ajax']">
        </script>
    </environment>
    <link rel="stylesheet" href="~/css/site.css" />
</head>

So how do I acheive that using the ASPNET.Core framework ?

/.Web.Mvc does have anything that is similar to a _Layout.cshtml page.

As per the information on their site I installed Font-Awesome after my boss purchased it

npm config set "@fortawesome:registry" https://npm.fontawesome.com/ npm config set "//npm.fontawesome.com/:_authToken" <out-token-value> npm install --save-dev @fortawesome/fontawesome-pro

I also tired

yarn add --dev @fortawesome/fontawesome-pro

This has installed the fonts and I can see everything I need to know in the file ..\src\epayday.Web.Mvc\wwwroot\metronic\src\vendors\fontawesome5\css\all.css

These links https://forum.aspnetboilerplate.com/viewtopic.php?p=31827 and https://support.aspnetzero.com/QA/Questions/5527 explains that I should add a link to src/index.html but where there are quite a few Index.html files in the project, is this something I need to add myself or has the something not been installed correctly.

I added a Custom JQuery Validation method :-

    $.validator.addMethod("ABN", function (value, element) {
        return /[0-9]{12}/.test(value);
    }, "Please enter a valid ABN.");
    
    this.init =
    .
    .
                $('#SuperFund_FundABN').rules("add", {
                ABN: true
            });

Which results in a 'nice' validation for my user.

Where as what has been autogenerated by the RAD tool :-

<input class="form-control" id="SuperFund_BSB" value="@Model.SuperFund.BSB" type="text" name="bsb" maxlength="@epayday.Epayday.SuperFunds.SuperFundConsts.MaxBSBLength" minlength="@epayday.Epayday.SuperFunds.SuperFundConsts.MinBSBLength" pattern="@epayday.Epayday.SuperFunds.SuperFundConsts.BSBRegex" />

Results with a modal message.

Which provides an inconsistant user experience.

Am I missing something fundamental ? Or do I have to create custom JQuery Validation methods for regular expressions ?

Earlier today someone gave me some awesome remote support, I suspect the issue was actually my understanding of how to process the result of what was returned by the Applcation Service call.

What I am trying to do is pass in an integer to the Application Service which will return a single string. I use that to work out which controls to show and hide. Main reason is to make it easier for other developers to read the code. I will eventually go with something better but this I what I am doing for now.

So when I debug my code at :-

            var result = _superFundLookupService.getSuperFundPaymentMethodFromID($('#SuperFund_PaymentMethod').val());
            console.log(result);
            debugger

I can see the results of the Application Service call as an object. I have been reading about processing Ajax via JQuery etc. But I am stuck. Some code examples show something like :-

_superFundLookupService.getSuperFundPaymentMethodFromID($('#SuperFund_PaymentMethod').val())
    .done(function (result) { <do something here> ! } );
            

I have tried a few things and nothing seems to make sense. Can someone please direct me to a page/site where I can work out what I need to do. I know there is a way to extract my return string from the response since the other examples in the project are processing the return objects.

I'm not asking to be spoon-fed but something that explains what I am trying to do would be great !

So this guide explains that I can setup an application service and it can then be accessed.

https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API

Problem I have is that the Application Services which were created by the RAD tool are available in the generated JQuery files. But the Application Services I added later aren't, what do I need to update so they are available ?

Keep in mind I am having existing problems accessing abp.custom.EntityHistory so maybe they are related ?

My solution is Auditing Entities and I can see the changes in the Database table and Admin pages.

What do I need to do to get this button/dropdown option working in the various Index.js for each Index page ?


		        var _entityTypeHistoryModal = app.modals.EntityTypeHistoryModal.create();
		        function entityHistoryIsEnabled() {
            return abp.custom.EntityHistory &&
                abp.custom.EntityHistory.IsEnabled &&
                _.filter(abp.custom.EntityHistory.EnabledEntities, entityType => entityType === _entityTypeFullName).length === 1;
        }

........

 {
                            text: app.localize('History'),
                            visible: function () {
                                return entityHistoryIsEnabled();
                            },
                            action: function (data) {
                                _entityTypeHistoryModal.open({
                                    entityTypeFullName: _entityTypeFullName,
                                    entityId: data.record.paidBy.id
                                });
                            }
						}, 
Question

When I used to the tool to add an entity it generated an error in projectDBContext.cs, simple fix of course just want to let you guys know than when you create an entity starting with the letter e it breaks the add-migration and update-database stages. I went with the second letter of the entity as a fix.

            modelBuilder.Entity<Employee>(e =>
            {
                e.HasIndex(e => new { e.TenantId });
            });

To =>

            modelBuilder.Entity<Employee>(m =>
            {
                m.HasIndex(e => new { e.TenantId });
            });

I read through https://aspnetboilerplate.com/Pages/Documents/Localization which gives some insight to how languages/culture are handled in ASP.NET Zero

At ..Migrations.Seed.Host.DefaultLanguagesCreator I changed new ApplicationLanguage(tenantId, "en", "English", "famfamfam-flags us"), to new ApplicationLanguage(tenantId, "en-AU", "English", "famfamfam-flags au"),

At ..Migrations.Seed.Host.DefaultSettingsCreator I changed AddSettingIfNotExists(LocalizationSettingNames.DefaultLanguage, "en"); to AddSettingIfNotExists(LocalizationSettingNames.DefaultLanguage, "en-AU");

Finally I changed the default Localization XML file <localizationDictionary culture="en"> to <localizationDictionary culture="en-AU">

These changes ensure that all localized tags now display correctly and not with the [] characters. Is this enough to ensure when I migrate the solution to Azure or similar it will work correctly ? The rationale behind this is the US date format will cause a LOT of grief for our customers and since this will be a domesitic product initially it is better if I remove the US option at least for now.

If these changes are correct I could someone who works for ASP.NET Zero please consider adding chaning the default language as a tutorial ? Also it might be a good idea to also add a section on how to add a new language. As ASP.NET Zero becomes more popular I think there will be more non-American developers who will need to want to do this. That or at least add a en-UK language since most Commonwealth nations use the UK date format.

Showing 1 to 10 of 12 entries