From: Jaroslav Kysela Date: Mon, 18 Jan 2016 09:05:14 +0000 (+0100) Subject: add persistent flag to properties X-Git-Tag: v4.2.1~1157 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3f70394ec9de05eab3b3d7a7c749b4059e89e20f;p=thirdparty%2Ftvheadend.git add persistent flag to properties --- diff --git a/src/prop.c b/src/prop.c index d17891446..64c0be815 100644 --- a/src/prop.c +++ b/src/prop.c @@ -489,6 +489,8 @@ prop_serialize_value htsmsg_add_bool(m, "lorder", 1); if (opts & PO_MULTILINE) htsmsg_add_bool(m, "multiline", 1); + if (opts & PO_PERSIST) + htsmsg_add_bool(m, "persistent", 1); /* Enum list */ if (pl->list) { diff --git a/src/prop.h b/src/prop.h index 5227f4a00..a3f95f47c 100644 --- a/src/prop.h +++ b/src/prop.h @@ -61,6 +61,7 @@ typedef enum { #define PO_LOCALE (1<<14) // Call tvh_locale_lang on string #define PO_LORDER (1<<15) // Manage order in lists #define PO_MULTILINE (1<<16) // Multiline string +#define PO_PERSIST (1<<17) // Persistent value (return back on save) /* * Property definition diff --git a/src/webui/static/app/idnode.js b/src/webui/static/app/idnode.js index 680706cf9..9efa42796 100644 --- a/src/webui/static/app/idnode.js +++ b/src/webui/static/app/idnode.js @@ -252,6 +252,7 @@ tvheadend.IdNodeField = function(conf) this.group = conf.group; this.lorder = conf.lorder; this.multiline = conf.multiline; + this.persistent = conf.persistent; this['enum'] = conf['enum']; this.store = null; if (this['enum']) @@ -1056,6 +1057,18 @@ tvheadend.idnode_editor = function(_uilevel, item, conf) tvheadend.idnode_editor_form(uilevel, item.props || item.params, item.meta, panel, c); } + function values(form) { + var node = form.getFieldValues(); + var props = item.props || item.params; + node.uuid = conf.uuids ? conf.uuids : item.uuid; + for (var i = 0; i < props.length; i++) { + var p = props[i]; + if (p.persistent) + node[p.name] = p.value; + } + return node; + } + /* Buttons */ if (!conf.noButtons) { if (conf.cancel) { @@ -1073,10 +1086,10 @@ tvheadend.idnode_editor = function(_uilevel, item, conf) text: conf.saveText || _('Save'), iconCls: conf.saveIconCls || 'save', handler: function() { + var form = panel.getForm(); var node = null; - if (panel.getForm().isDirty() || conf.alwaysDirty) { - node = panel.getForm().getFieldValues(); - node.uuid = conf.uuids ? conf.uuids : item.uuid; + if (form.isDirty() || conf.alwaysDirty) { + node = values(form); tvheadend.Ajax({ url: conf.saveURL || 'api/idnode/save', params: { @@ -1104,10 +1117,9 @@ tvheadend.idnode_editor = function(_uilevel, item, conf) text: _('Apply'), iconCls: 'apply', handler: function() { - if (panel.getForm().isDirty()) { - var form = panel.getForm(); - var node = form.getFieldValues(); - node.uuid = conf.uuids ? conf.uuids : item.uuid; + var form = panel.getForm(); + if (form.isDirty()) { + var node = values(form); tvheadend.Ajax({ url: conf.saveURL || 'api/idnode/save', params: { diff --git a/src/wizard.c b/src/wizard.c index 1dce07402..ef693ca9d 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -543,10 +543,10 @@ static void network_save(idnode_t *in) .group = num, \ }, { \ .type = PT_STR, \ - .id = "hidden_tunerid" STRINGIFY(num), \ + .id = "tunerid" STRINGIFY(num), \ .name = "Tuner", \ .get = network_get_tidvalue##num, \ - .opts = PO_RDONLY | PO_NOUI, \ + .opts = PO_RDONLY | PO_PERSIST | PO_NOUI, \ }, { \ .type = PT_STR, \ .id = "network" STRINGIFY(num), \