How can we improve Breeze.js?

Support evaluation of custom Annotations for Enums through the meta data

If I crete an "advanced" ENUM on server side, including custom annotations, I would like to be able to use that ENUM at client side without redefining it there. Following method can be used to automatically create enums on client side as global variables. In addtion to that I would like to be able to evaluate annotation metadata of the ENUMS to transfer the data that is given by my custom Annotations.

-------------------------------------------------------------

fetchMetadata()
.then(function(data) {


//create global ENUMs from breeze meta data
//see http://stackoverflow.com/questions/15732072/dropdown-filled-with-options-provided-by-an-enum-server-side-with-breeze

var enumTypes = data.schema.enumType;
var size = enumTypes.length;

if (size == null) {
createGlobalEnum(enumTypes);
} else {
ko.utils.arrayForEach(enumTypes, createGlobalEnum);
}

function createGlobalEnum(enumDefinition) {

var globalEnum = {};
var enumName = enumDefinition.name;
var enumMembers = enumDefinition.member;
var values = ko.observableArray();
ko.utils.arrayForEach(enumMembers, function(enumMember) {

var memberName = enumMember.name;
var memberValue = enumMember.value;

var member = {
id: ko.observable(memberValue), //= enum index, e.g. 0
name: ko.observable(memberName),
title: ko.observable(language.getValue(memberName))
};

globalEnum[memberName] = member;

values.push(member);

});

globalEnum.values = values;

window[enumName] = globalEnum;

}

--------------------------------------------

Enum value with custom annotation:

[StringValue("€")]
Euro

Also see section "Enums" in
http://www.codeproject.com/Articles/11130/String-Enumerations-in-C

--------------------------------------------

As an alternative to those enums with custom annotations, I could create an entity for each enum. However, this would create an extra table for each enum... which I do not really need .... and those extra entities are still not as nice to use as enums.

-------------------------------------------------
The "automatic generation of enums" inclusive view models that can easily be used for enum combo boxes would also be a nice feature of Breeze.

1 vote
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    matameko shared this idea  ·   ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base