foam-framework / foam

Feature-Oriented Active Modeller
Apache License 2.0
787 stars 55 forks source link

Table View Doesn't Show on Initial Load #344

Closed kgrgreer closed 8 years ago

kgrgreer commented 8 years ago

See: http://foam-framework.github.io/foam/foam/index.html?model=foam.demos.olympics.Controller

No data is present until you edit the columns and remove two or three.

jlhughes commented 8 years ago

Experiencing the same thing. In our case editing columns doesn't help. The data doesn't render until our 'refresh' cycle runs which does a query on the DAOs but loads no data (expected).

bshepherdson commented 8 years ago

I believe this was fixed yesterday with 644a0f15c164ed6db1c45ecfbadd9609e448c880. Olympics demo works for me on master.

Closing this issue; please reopen if there are still problems.

jlhughes commented 8 years ago

We use tableFormatter liberally with lots of Elements. Do we need to update all Element creation or just those in a tableFormatter?

Our calls are still tableFormatter: function(arg) { var e = E('span') ...

On Fri, Sep 18, 2015 at 7:29 AM, Braden Shepherdson < notifications@github.com> wrote:

I believe this was fixed yesterday with 644a0f1 https://github.com/foam-framework/foam/commit/644a0f15c164ed6db1c45ecfbadd9609e448c880. Olympics demo works for me on master.

Closing this issue; please reopen if there are still problems.

— Reply to this email directly or view it on GitHub https://github.com/foam-framework/foam/issues/344#issuecomment-141423379 .

jlhughes commented 8 years ago

Correct that, we have a mix of tableFormatter(arg) and tableFormatter(arg, obj) but we don't use the second argument 'obj' in any Element creation. Joel

On Fri, Sep 18, 2015 at 8:37 AM, Joel Hughes joel.l.hughes@gmail.com wrote:

We use tableFormatter liberally with lots of Elements. Do we need to update all Element creation or just those in a tableFormatter?

Our calls are still tableFormatter: function(arg) { var e = E('span') ...

On Fri, Sep 18, 2015 at 7:29 AM, Braden Shepherdson < notifications@github.com> wrote:

I believe this was fixed yesterday with 644a0f1 https://github.com/foam-framework/foam/commit/644a0f15c164ed6db1c45ecfbadd9609e448c880. Olympics demo works for me on master.

Closing this issue; please reopen if there are still problems.

— Reply to this email directly or view it on GitHub https://github.com/foam-framework/foam/issues/344#issuecomment-141423379 .

adamvy-google commented 8 years ago

E('span') should work in my opinion, let me look in to this.

adamvy-google commented 8 years ago

Found the real root problem, I will fix it so that your table formatters work as is.

adamvy-google commented 8 years ago

Fix pushed.

jlhughes commented 8 years ago

Must be something our side. On the latest FOAM/master the rendering issue persists regardless of the E/Element creation I use in our tableFormatters. Joel

On Fri, Sep 18, 2015 at 10:28 AM, adamvy notifications@github.com wrote:

Closed #344 https://github.com/foam-framework/foam/issues/344.

— Reply to this email directly or view it on GitHub https://github.com/foam-framework/foam/issues/344#event-413278674.

adamvy-google commented 8 years ago

Try running with the devtools set to "break on all exceptions" and see if you tableFormatter is throwing an exception.

https://developer.chrome.com/devtools/docs/javascript-debugging#pause-on-exceptions

jlhughes commented 8 years ago

Hi Adam

Does not render after (select): var future = afuture(); this.src.where(AND.apply(null, [min, max])).select(this.delegate)(function() { this.delegate.removeAll(); this.delegate.select(sink, options)(future.set); }.bind(this)); return future.get;

Does render after (refresh): this.src.where(expr).select(this.delegate)(ret); where ret is just 'function(_){}'

Can you see any javascript mistakes, perhaps with the future? Joel

On Fri, Sep 18, 2015 at 11:25 AM, adamvy notifications@github.com wrote:

Try running with the devtools set to "break on all exceptions" and see if you tableFormatter is throwing an exception.

https://developer.chrome.com/devtools/docs/javascript-debugging#pause-on-exceptions

— Reply to this email directly or view it on GitHub https://github.com/foam-framework/foam/issues/344#issuecomment-141482220 .

adamvy-google commented 8 years ago

In your second case, what does the select: method of your dao end up returning?

BTW your AND.apply can just be AND(min, max), since you know the number of arguments you're passing it.

jlhughes commented 8 years ago

refresh select returns: DeDupDAO(MDAO(Contact,TreeIndex(Id, value)))

This refresh.select call is returning the records the select.select also returned, which indicates that the delegate is empty and the 'max' test returned nothing. So the select.select is not populating the cache delegate.

    refresh_: function(ret) {

this.delegate.select(MAX(this.model.LAST_MODIFIED_DATE))(function(max) { var expr = TRUE; if (max && max.max) { expr = GTD(this.model.LAST_MODIFIED_DATE, max.max); }

            if (this.model.name === 'Workorder') {
                if (this.controller.lastDateQueryMin.compareTo(TRUE)) {
                    expr = AND.apply(null,

[this.controller.lastDateQueryMin, this.controller.lastDateQueryMax, expr]); } else { return; } } this.src.where(expr).select(this.delegate)(ret); }.bind(this)); }

select.select - the this.delegate is not being populated with the results var future = afuture(); this.src.where(AND.apply(null, [min, max])).select(this.delegate)(function() { this.delegate.removeAll(); this.delegate.select(sink, options)(future.set); }.bind(this)); return future.get;

On Fri, Sep 18, 2015 at 11:47 AM, adamvy notifications@github.com wrote:

In your second case, what does the select: method of your dao end up returning?

BTW your AND.apply can just be AND(min, max), since you know the number of arguments you're passing it.

— Reply to this email directly or view it on GitHub https://github.com/foam-framework/foam/issues/344#issuecomment-141487252 .

adamvy-google commented 8 years ago

Could this be caused by your NoSelectAllDAO which is preventing an initial select all?

The first time refresh_ is called delegate will be empty so you'll end up selecting all will you now?

jlhughes commented 8 years ago

flow:

Joel

On Fri, Sep 18, 2015 at 12:20 PM, adamvy notifications@github.com wrote:

Could this be caused by your NoSelectAllDAO which is preventing an initial select all?

The first time refresh_ is called delegate will be empty so you'll end up selecting all will you now?

— Reply to this email directly or view it on GitHub https://github.com/foam-framework/foam/issues/344#issuecomment-141497574 .

adamvy-google commented 8 years ago

Your delegate.removeAll() call looks wrong.

                var future = afuture();
                this.src.where(AND.apply(null, [min,

max])).select(this.delegate)(function() { this.delegate.removeAll(); // This right here nukes all records in the delegate this.delegate.select(sink, options)(future.set); // Causing this select to return nothing. }.bind(this)); return future.get;

I believe you wanted this.delegate.removeAll() to go right before your this.src.where().select(), so as to empty the cache before populating it.

jlhughes commented 8 years ago

Hi Adam Yes, that was it. That was above yesterday and I remember moving it before you added the 'future' which was the real 'fix' at the time for that code block.

Thanks for the second pair of eyes, and now I understand how that block works. With the removeAll I was really confused - and for good reason. So thanks for the javascript lessons as well. We have a fully working system now. Joel

On Fri, Sep 18, 2015 at 12:56 PM, adamvy notifications@github.com wrote:

Your delegate.removeAll() call looks wrong.

            var future = afuture();
            this.src.where(AND.apply(null, [min,

max])).select(this.delegate)(function() { this.delegate.removeAll(); // This right here nukes all records in the delegate this.delegate.select(sink, options)(future.set); // Causing this select to return nothing. }.bind(this)); return future.get;

I believe you wanted this.delegate.removeAll() to go right before your this.src.where().select(), so as to empty the cache before populating it.

— Reply to this email directly or view it on GitHub https://github.com/foam-framework/foam/issues/344#issuecomment-141506716 .

adamvy-google commented 8 years ago

Yay glad I could help!

Took me a while to find that too. I kept doing other work and coming back to that snippet before it finally occurred to me. Glad we got it sorted now.