2

I added a new attribute in the soap service artifact that store unbounded operations of the service (it's like the table of contacts or endpoints)

My question is how to show that attribute table in the Store?

I tried edditing the asset-attributes.hbs putting the new attribute like this

<div class="es-col-lg-12 col-lg-12">
    <h4>{{t "Operaciones del Servicio Web"}}</h4><hr>


    {{#each this.attributes.operaciones_nombre }}


    <div class="es-col-lg-12 col-lg-12 divrow">
        <div class="col-lg-2"><b>{{t "Nombre"}} :</b></div>
        <div class="col-lg-10">{{ this.attributes.operaciones_nombre}}</div>
    </div>

    {{/each}}

But the problem is that it doesnt show the this.attributes.operaciones_nombre when it's inside of the #each, even when i used this.attributes.operaciones_nombre.[0] to show only the first element

And why the loop only work with {{#each this.attributes.operaciones_nombre }} and not {{#each this.attributes.operaciones }}? Do I need to define it in the asset.js and how I do that?

Community
  • 1
  • 1
Skeitho
  • 113
  • 1
  • 9

1 Answers1

1

for contacts use this. I tested below code for restservice and its works fine. for endpoints and for your case you can use the same.

In the relevant asset.js add below asset.renderer,

asset.renderer = function (ctx) {
    return {
        pageDecorators: {
            jsonFormatter: function (page) {
                if (page.meta.pageName === 'details') {
                    var contacts = page.assets.attributes.contacts_entry;
                    if (contacts) {
                        var contacts_entry = [];
                        if (contacts.constructor === Array) {
                            for (var index in contacts) {
                                var contact = contacts[index].split(':');
                                var contact_entry = {};
                                contact_entry.name = contact[0];
                                contact_entry.value = contact[1];
                                contacts_entry.push(contact_entry);
                            }
                        } else {
                            var contact = contacts.split(':');
                            var contact_entry = {};
                            contact_entry.name = contact[0];
                            contact_entry.value = contact[1];
                            contacts_entry.push(contact_entry);
                        }
                        page.assets.attributes.contacts_entry = contacts_entry;
                    }
                }
            }
        }
    };
};

Note: if there is already pageDecorators defined here, separate those methods using a comma and add above method.

In the asset-attributes.hbs add below lines,

<div class="col-lg-12">
        <h4>Contacts</h4><hr>
        <div class="col-lg-12 table table-striped table-hover divrow">
            {{#each attributes.contacts_entry}}
            <div class="col-lg-2">{{name}}</div>
            <div class="col-lg-10">{{value}}</div>
            {{/each}}
        </div>
    </div>

Note: In your asset extension you need to have asset-attributes.hbs(/{GREG_HOME}/repository/deployment/server/jaggeryapps/store/extensions/assets/{SHORTNAME}/themes/store/partials/asset-attributes.hbs) file overriding the default file which is located in greg-store-defaults.

Please find the sample screenshots of publisher and store,

Publisher

Pub view

Store

store view

Note: there are some alignment issues. CSS/bootstrap! ;)

Please refer this blog post.

Note: next time please add the rxt definition for the relevant attribute as well.

tk_
  • 16,415
  • 8
  • 80
  • 90
  • Thanks!. But I dont undersantd this part _var contacts = page.assets.attributes.contacts_entry;_.Should I put _page.assets.attributes.operaciones_entry_ (Doesnt work, tested it)? Where is this _entry_ came from? – Skeitho Aug 24 '16 at 18:57
  • @Daniels did you try it out first? BTW tested and working fine, attached the screenshots as well. :) – tk_ Aug 25 '16 at 03:14
  • As far as I understand for your case it should be, 'page.assets.attributes.operaciones_entry' – tk_ Aug 25 '16 at 05:53