diff --git a/src/idnode.c b/src/idnode.c index e25a4e16..15ad9095 100644 --- a/src/idnode.c +++ b/src/idnode.c @@ -768,6 +768,17 @@ idclass_get_class (const idclass_t *idc) return NULL; } +static const char * +idclass_get_order (const idclass_t *idc) +{ + while (idc) { + if (idc->ic_class) + return idc->ic_order; + idc = idc->ic_super; + } + return NULL; +} + static int ic_cmp ( const idclass_link_t *a, const idclass_link_t *b ) { @@ -816,6 +827,8 @@ idclass_serialize0(const idclass_t *idc, int optmask) htsmsg_add_str(m, "caption", s); if ((s = idclass_get_class(idc))) htsmsg_add_str(m, "class", s); + if ((s = idclass_get_order(idc))) + htsmsg_add_str(m, "order", s); /* Props */ if ((p = idnode_params(idc, NULL, optmask))) diff --git a/src/idnode.h b/src/idnode.h index ee505d2a..20d41901 100644 --- a/src/idnode.h +++ b/src/idnode.h @@ -46,6 +46,7 @@ typedef struct idclass { const struct idclass *ic_super; /// Parent class const char *ic_class; /// Class name const char *ic_caption; /// Class description + const char *ic_order; /// Property order (comma separated) const property_t *ic_properties; /// Property list const char *ic_event; /// Events to fire on add/delete/title diff --git a/src/input/mpegts/mpegts_service.c b/src/input/mpegts/mpegts_service.c index 57e5199d..da851305 100644 --- a/src/input/mpegts/mpegts_service.c +++ b/src/input/mpegts/mpegts_service.c @@ -60,6 +60,7 @@ const idclass_t mpegts_service_class = .ic_super = &service_class, .ic_class = "mpegts_service", .ic_caption = "MPEGTS Service", + .ic_order = "enabled,channel,svcname", .ic_properties = (const property_t[]){ { .type = PT_STR, diff --git a/src/webui/static/app/idnode.js b/src/webui/static/app/idnode.js index 5a8577e3..947e95e3 100644 --- a/src/webui/static/app/idnode.js +++ b/src/webui/static/app/idnode.js @@ -121,6 +121,7 @@ tvheadend.IdNodeField = function (conf) this.store = null; if (this.enum) this.store = tvheadend.idnode_enum_store(this); + this.ordered = false; /* * Methods @@ -245,10 +246,41 @@ tvheadend.IdNode = function (conf) this.clazz = conf.class; this.text = conf.caption || this.clazz; this.props = conf.props; - this.fields = [] + this.order = []; + this.fields = []; for (var i = 0; i < this.props.length; i++) { this.fields.push(new tvheadend.IdNodeField(this.props[i])); } + var o = []; + if (conf.order) + o = conf.order.split(','); + if (o) { + while (o.length < this.fields.length) + o.push(null); + for (var i = 0; i < o.length; i++) { + this.order[i] = null; + if (o[i]) { + for (var j = 0; j < this.fields.length; j++) { + if (this.fields[j].id == o[i]) { + this.order[i] = this.fields[j]; + this.fields[j].ordered = true; + break; + } + } + } + } + for (var i = 0; i < o.length; i++) { + if (this.order[i] == null) { + for (var j = 0; j < this.fields.length; j++) { + if (!this.fields[j].ordered) { + this.fields[j].ordered = true; + this.order[i] = this.fields[j]; + break; + } + } + } + } + } /* * Methods @@ -257,6 +289,10 @@ tvheadend.IdNode = function (conf) this.length = function () { return this.fields.length; } + + this.field = function ( index ) { + if (this.order) return this.order[index]; else return this.fields[index]; + } } @@ -616,7 +652,7 @@ tvheadend.idnode_grid = function(panel, conf) /* Model */ var idnode = new tvheadend.IdNode(d); for (var i = 0; i < idnode.length(); i++) { - var f = idnode.fields[i]; + var f = idnode.field(i); var c = f.column(); fields.push(f.id); columns.push(c);