The-M-Project icon indicating copy to clipboard operation
The-M-Project copied to clipboard

Included labels only render computed value contentbinding once

Open stephentcannon opened this issue 12 years ago • 6 comments

It appears that if you include a label on more than one view and the label (and possibly other widgets) have a computed value contentbinding the data only shows on one view.

For example, a footer that shows what user is logged in.

From your entry page...

m_require('app/views/PrivateFooter.js');

file name PrivateFooter.js contents

myProject.PrivateFooter = M.ToolbarView.design({
    childViews: 'footerLabel',
    anchorLocation: M.BOTTOM,
    footerLabel: M.LabelView.design({
        computedValue:{
            contentBinding: {
                target: myProject.LoginController,
                property: 'userName'
            },
            value: '',
            operation: function(v){
                return M.I18N.l('loggedInAs') + v;
            }
        },
        anchorLocation: M.CENTER
    })
});

LoginController property must be set to username. We are setting it from eventBus to Vertx, but you could use anything to simulate a controller property set.

Place this on entry page and a few others pages.

footer: EtherPOS.PrivateFooter

Visit all pages. Only one page will show Controller Property which is username in this case.

Side Note: Issue #67 already covers duplication of Button (and other widgets) when included for on render. You may experience that when replicating this issue.

stephentcannon avatar Jul 16 '12 21:07 stephentcannon

Hey stephentcannon, thanks for the report. We will have a look at this and looking forward to find the bug. Your Issue #67 https://github.com/mwaylabs/The-M-Project/issues/67 is also responsible for this. best regards marco

hano avatar Jul 19 '12 07:07 hano

Hi Stephen,

try to replace your

  footer: EtherPOS.PrivateFooter

with

  footer: EtherPOS.PrivateFooter.design({})

sebastianwerler avatar Jul 20 '12 08:07 sebastianwerler

That throws a

Uncaught TypeError: Cannot call method 'design' of undefined

Do I maybe need the latest branch of the project to test this?

stephentcannon avatar Jul 20 '12 11:07 stephentcannon

Either it's an m_require issue or your view really doesn't exist...

In your example you write:

  myProject.PrivateFooter

Is "myProject" your namespace/app name? Because then you'll have to write:

  footer: myProject.PrivateFooter

instead of EtherPOS... so, maybe a typo?

This "feature" is there from the very beginning of TMP, so this shouldn't be an issue with your version...

sebastianwerler avatar Jul 20 '12 11:07 sebastianwerler

Yes, was m_require issue. Very early here, just woke up.

Now, Page1 loads footer fine and renders 'User: admin'

Page2 only shows 'User:' and is missing the admin.

No word admin, which is who I am logging in as.

I did another test that just uses contentbinding with no computed value in the privatefooter.

So, LoginController has currentUserText: nul

on login sets it to EtherPOS.LoginController.set('currentUserText', M.I18N.l('loggedInAs') + values.username);

Page1 shows 'User: admin'

Page2 shows: undefined

I think this strategy is more the M-Project way and I think I was complicating it by using both computervalue and contentbinding before.

Basically, I just want the footer to show the current logged in user. But it appears using just content binding is not working across pages either like this.

stephentcannon avatar Jul 20 '12 12:07 stephentcannon

I'm curious if anyone has found a solution to this yet? (I posted a similar comment on issue #69).

wsolem avatar Mar 21 '13 00:03 wsolem