diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-02-23 21:50:18 +0200 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-02-26 16:52:56 +0200 |
commit | 14a41b574b937a8b904c609ea55dfe72810a0019 (patch) | |
tree | 88129181d045268b7e903b65e961acb59dbfa23d /web/widget/table | |
parent | 095de0678bca136947b4c49ab2867de7b93b8798 (diff) | |
download | acf2-14a41b574b937a8b904c609ea55dfe72810a0019.tar.bz2 acf2-14a41b574b937a8b904c609ea55dfe72810a0019.tar.xz |
web client: tabular layout: link to details
Diffstat (limited to 'web/widget/table')
-rw-r--r-- | web/widget/table/header.js | 5 | ||||
-rw-r--r-- | web/widget/table/row.js | 28 |
2 files changed, 27 insertions, 6 deletions
diff --git a/web/widget/table/header.js b/web/widget/table/header.js index 7c2f760..5a0ac6f 100644 --- a/web/widget/table/header.js +++ b/web/widget/table/header.js @@ -26,9 +26,8 @@ define(["acf2/widget/table/row", "jquery"], function(Base, $) { }, appendWidget: function(el, label) { - el = Base.appendWidget.call(this, el, label); - if (el) this.header.append($("<th>").text(label)); - return el; + this.header.append($("<th>").text(label)); + return Base.appendWidget.call(this, el, label); } }); }); diff --git a/web/widget/table/row.js b/web/widget/table/row.js index 7e617b2..2e963c7 100644 --- a/web/widget/table/row.js +++ b/web/widget/table/row.js @@ -4,8 +4,8 @@ */ define( - ["acf2/dom", "acf2/widget/abstract/fields", "jquery"], - function(dom, Base, $) { + ["acf2/dom", "acf2/widget/abstract/fields", "jquery", "underscore"], + function(dom, Base, $, _) { return Base.extend({ createEl: function() { this.prevAction = null; @@ -22,8 +22,30 @@ define( ); }, + createModelWidgets: function(fields, editable) { + Base.createModelWidgets.call(this, fields, editable); + + var self = this; + var tdFields = []; + _.each(fields, function(field) { + if (field.name in self.widgets && + self.widgets[field.name].is("td")) + tdFields.push(field); + }); + if (_.size(tdFields) == _.size(fields)) return; + + Base.createModelWidgets.call(this, tdFields, false); + this.wrapped.trigger("hasDetails", [this.path]); + }, + + createWidget: function(name, meta, editable, removable) { + if (!meta.condition) + return Base.createWidget.call( + this, name, meta, editable, removable + ); + }, + appendWidget: function(el, label) { - if (!el.is("td")) return null; if (this.prevWidget) this.prevWidget.after(el); else { var ph = this.el.find(".placeholder"); |