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

javascript dto automatically generated #402


User avatar
0
cicciottino created

does exist in the framework a javascript function to create objects(javascript dto objects) based on the serviceLayer (dto/dtoInput)

var newPerson = {
    name: 'Dougles Adams',
    age: 42
};

abp.ajax({
    url: '/People/SavePerson',
    data: JSON.stringify(newPerson)
}).done(function(data) {
    abp.notify.success('created new person with id = ' + data.personId);
});

something that creates for me a "newPerson" based on the structure that i've defined in my dto?


6 Answer(s)
  • User Avatar
    0
    ddnils created

    I usually use a newPerson in $scope and bind its properties to my newForm directly so that the object is filled through angular.

    To prefill use this: var emptyPerson = { name: "", age: 0 } $scope.newPerson = jQuery.extend({}, emptyPerson); // makes a copy of the object

    hope this helps

  • User Avatar
    0
    hikalkan created
    Support Team

    There is no such a built-in DTO creation. I did think creating such DTOs before, but I realize that it has no benefit. Why you need it? If you would use Typescript, I could understand it, you could have an intellisense support. But javascript objects is already dynamic, so I don't see a good reason for that.

  • User Avatar
    0
    cicciottino created

    no particular reason, just a quick way to have a javascript object similar and (and already with "camelCase" notation) to the server one. Only a way to be less typing error prone

    forgive me for my english

  • User Avatar
    0
    hikalkan created
    Support Team

    Then it should be generated in development time (like after every project build we need to create js files). Right? If you like this, please create a feature request on Github, and we will see :) Thanks.

  • User Avatar
    0
    slambert created

    This is awesome! I was able to create the typescript for all of my generated proxies. Very Cool! I feel like I found a hidden gem that needs to be shared with the world.

    One question though... Do you plan to offer a d.ts for the rest of the abp framework. I search the [https://www.nuget.org/profiles/DefinitelyTyped]) nuget but found nothing.

    It would make the conversion to typescript a lot easier. I am currently looking at converting the abp.js right now and would love it if someone has something to share already.

    Thanks as usual.

    Ron

  • User Avatar
    0
    hikalkan created
    Support Team

    I did not planned it in near feature. For ABP, moving to ASP.NET Core 1.0 is more important than Typescript for now. But, it's very appriciated if you can contribute it.

    Thanks.