Open Closed

javascript dto automatically generated #402


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)
  • 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

  • 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.

  • 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

  • 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.

  • 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

  • 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.