Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add persistent flag to properties
  • Loading branch information
perexg committed Jan 19, 2016
1 parent a0fe071 commit 3f70394
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/prop.c
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/prop.h
Expand Up @@ -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
Expand Down
26 changes: 19 additions & 7 deletions src/webui/static/app/idnode.js
Expand Up @@ -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'])
Expand Down Expand Up @@ -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) {
Expand All @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions src/wizard.c
Expand Up @@ -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), \
Expand Down

0 comments on commit 3f70394

Please sign in to comment.