Loading editor/html/js/survey-manager.js +74 −28 Changes for editor/html/js/survey-manager.js: 74 added lines, 28 removed lines. Original line number Diff line number Diff line Loading @@ -41,7 +41,8 @@ var SurveyManager = (function() { opts.push({ value: o.getAttribute('value') || '', label: o.textContent || '', icon: o.getAttribute('icon') || '' icon: o.getAttribute('icon') || '', excludes: o.getAttribute('excludes') || '' }); }); var maxsizeAttr = n.getAttribute('maxsize'); Loading Loading @@ -80,6 +81,7 @@ var SurveyManager = (function() { q.options.forEach(function(o) { var oAttrs = ' value="' + escAttr(o.value) + '"'; if (o.icon) oAttrs += ' icon="' + escAttr(o.icon) + '"'; if (o.excludes) oAttrs += ' excludes="' + escAttr(o.excludes) + '"'; lines.push(' <Option' + oAttrs + '>' + escAttr(o.label) + '</Option>'); }); lines.push(' </Question>'); Loading Loading @@ -358,39 +360,68 @@ var SurveyManager = (function() { }); addField('Typ', selType); // Parent selection var selParent = document.createElement('select'); selParent.id = 'sm-q-parent'; var noneOpt = document.createElement('option'); noneOpt.value = ''; noneOpt.textContent = '— kein Elternelement —'; selParent.appendChild(noneOpt); (_current.questions || []).forEach(function(oq) { if (oq.id === q.id) return; var o = document.createElement('option'); o.value = oq.id; o.textContent = truncate(oq.label || oq.id, 30); if (q.parent_id === oq.id) o.selected = true; selParent.appendChild(o); }); addField('Übergeordnete Frage', selParent); // Options (for radio/checkbox/select) var optsWrap = document.createElement('div'); optsWrap.id = 'sm-q-opts-wrap'; optsWrap.style.display = ['radio','checkbox','select'].indexOf(q.question_type) >= 0 ? '' : 'none'; var optsLabel = document.createElement('label'); optsLabel.textContent = 'Antwortoptionen (eine pro Zeile, Format: wert=Text)'; optsLabel.textContent = 'Antwortoptionen'; optsLabel.style.cssText = 'display:block;font-weight:600;margin-bottom:4px;'; optsWrap.appendChild(optsLabel); var optsArea = document.createElement('textarea'); optsArea.id = 'sm-q-opts'; optsArea.rows = 4; optsArea.placeholder = 'ja=Ja\nnein=Nein'; optsArea.value = (q.options || []).map(function(o) { return o.value + '=' + o.label; }).join('\n'); optsWrap.appendChild(optsArea); var optRowsDiv = document.createElement('div'); optRowsDiv.id = 'sm-q-opt-rows'; optRowsDiv.style.cssText = 'display:flex;flex-direction:column;gap:6px;'; function buildOptionRow(opt) { var row = document.createElement('div'); row.className = 'sm-opt-row'; row.style.cssText = 'display:grid;grid-template-columns:1fr 1fr auto auto;gap:4px;align-items:start;'; var inpVal = document.createElement('input'); inpVal.type = 'text'; inpVal.placeholder = 'wert'; inpVal.className = 'sm-opt-val'; inpVal.value = opt.value || ''; var inpLbl = document.createElement('input'); inpLbl.type = 'text'; inpLbl.placeholder = 'Text'; inpLbl.className = 'sm-opt-lbl'; inpLbl.value = opt.label || ''; var selExcl = document.createElement('select'); selExcl.className = 'sm-opt-excl'; selExcl.multiple = true; selExcl.title = 'Fragen ausblenden (Mehrfachauswahl)'; selExcl.style.cssText = 'min-height:36px;max-height:80px;font-size:.85em;'; var currentExcludes = (opt.excludes || '').split(',').map(function(s) { return s.trim(); }).filter(Boolean); (_current.questions || []).forEach(function(oq) { if (oq.id === q.id) return; var o = document.createElement('option'); o.value = oq.id; o.textContent = truncate(oq.label || oq.id, 28); if (currentExcludes.indexOf(oq.id) >= 0) o.selected = true; selExcl.appendChild(o); }); var btnRemove = document.createElement('button'); btnRemove.type = 'button'; btnRemove.textContent = '×'; btnRemove.style.cssText = 'padding:4px 8px;cursor:pointer;background:#c00;color:#fff;border:none;border-radius:3px;'; btnRemove.addEventListener('click', function() { row.remove(); }); row.appendChild(inpVal); row.appendChild(inpLbl); row.appendChild(selExcl); row.appendChild(btnRemove); return row; } (q.options || []).forEach(function(opt) { optRowsDiv.appendChild(buildOptionRow(opt)); }); optsWrap.appendChild(optRowsDiv); var btnAddOpt = document.createElement('button'); btnAddOpt.type = 'button'; btnAddOpt.textContent = '+ Option'; btnAddOpt.style.cssText = 'margin-top:6px;padding:4px 12px;cursor:pointer;'; btnAddOpt.addEventListener('click', function() { optRowsDiv.appendChild(buildOptionRow({ value: '', label: '', excludes: '' })); }); optsWrap.appendChild(btnAddOpt); panel.appendChild(optsWrap); // Icon options editor (for icon type) Loading @@ -410,7 +441,7 @@ var SurveyManager = (function() { function buildIconRow(opt) { var row = document.createElement('div'); row.className = 'sm-icon-opt-row'; row.style.cssText = 'display:grid;grid-template-columns:1fr 1fr 1fr auto auto;gap:4px;align-items:center;'; row.style.cssText = 'display:grid;grid-template-columns:1fr 1fr 1fr auto auto auto;gap:4px;align-items:start;'; var inpVal = document.createElement('input'); inpVal.type = 'text'; inpVal.placeholder = 'wert'; Loading Loading @@ -439,13 +470,28 @@ var SurveyManager = (function() { }); })(inpUrl); var selExcl = document.createElement('select'); selExcl.className = 'sm-icon-excl'; selExcl.multiple = true; selExcl.title = 'Fragen ausblenden (Mehrfachauswahl)'; selExcl.style.cssText = 'min-height:36px;max-height:80px;font-size:.85em;'; var currentExcludes = (opt.excludes || '').split(',').map(function(s) { return s.trim(); }).filter(Boolean); (_current.questions || []).forEach(function(oq) { if (oq.id === q.id) return; var o = document.createElement('option'); o.value = oq.id; o.textContent = truncate(oq.label || oq.id, 28); if (currentExcludes.indexOf(oq.id) >= 0) o.selected = true; selExcl.appendChild(o); }); var btnRemove = document.createElement('button'); btnRemove.type = 'button'; btnRemove.textContent = '×'; btnRemove.style.cssText = 'padding:4px 8px;cursor:pointer;background:#c00;color:#fff;border:none;border-radius:3px;'; btnRemove.addEventListener('click', function() { row.remove(); }); row.appendChild(inpVal); row.appendChild(inpLbl); row.appendChild(inpUrl); row.appendChild(btnBrowse); row.appendChild(btnRemove); row.appendChild(btnBrowse); row.appendChild(selExcl); row.appendChild(btnRemove); return row; } Loading Loading
editor/html/js/survey-manager.js +74 −28 Changes for editor/html/js/survey-manager.js: 74 added lines, 28 removed lines. Original line number Diff line number Diff line Loading @@ -41,7 +41,8 @@ var SurveyManager = (function() { opts.push({ value: o.getAttribute('value') || '', label: o.textContent || '', icon: o.getAttribute('icon') || '' icon: o.getAttribute('icon') || '', excludes: o.getAttribute('excludes') || '' }); }); var maxsizeAttr = n.getAttribute('maxsize'); Loading Loading @@ -80,6 +81,7 @@ var SurveyManager = (function() { q.options.forEach(function(o) { var oAttrs = ' value="' + escAttr(o.value) + '"'; if (o.icon) oAttrs += ' icon="' + escAttr(o.icon) + '"'; if (o.excludes) oAttrs += ' excludes="' + escAttr(o.excludes) + '"'; lines.push(' <Option' + oAttrs + '>' + escAttr(o.label) + '</Option>'); }); lines.push(' </Question>'); Loading Loading @@ -358,39 +360,68 @@ var SurveyManager = (function() { }); addField('Typ', selType); // Parent selection var selParent = document.createElement('select'); selParent.id = 'sm-q-parent'; var noneOpt = document.createElement('option'); noneOpt.value = ''; noneOpt.textContent = '— kein Elternelement —'; selParent.appendChild(noneOpt); (_current.questions || []).forEach(function(oq) { if (oq.id === q.id) return; var o = document.createElement('option'); o.value = oq.id; o.textContent = truncate(oq.label || oq.id, 30); if (q.parent_id === oq.id) o.selected = true; selParent.appendChild(o); }); addField('Übergeordnete Frage', selParent); // Options (for radio/checkbox/select) var optsWrap = document.createElement('div'); optsWrap.id = 'sm-q-opts-wrap'; optsWrap.style.display = ['radio','checkbox','select'].indexOf(q.question_type) >= 0 ? '' : 'none'; var optsLabel = document.createElement('label'); optsLabel.textContent = 'Antwortoptionen (eine pro Zeile, Format: wert=Text)'; optsLabel.textContent = 'Antwortoptionen'; optsLabel.style.cssText = 'display:block;font-weight:600;margin-bottom:4px;'; optsWrap.appendChild(optsLabel); var optsArea = document.createElement('textarea'); optsArea.id = 'sm-q-opts'; optsArea.rows = 4; optsArea.placeholder = 'ja=Ja\nnein=Nein'; optsArea.value = (q.options || []).map(function(o) { return o.value + '=' + o.label; }).join('\n'); optsWrap.appendChild(optsArea); var optRowsDiv = document.createElement('div'); optRowsDiv.id = 'sm-q-opt-rows'; optRowsDiv.style.cssText = 'display:flex;flex-direction:column;gap:6px;'; function buildOptionRow(opt) { var row = document.createElement('div'); row.className = 'sm-opt-row'; row.style.cssText = 'display:grid;grid-template-columns:1fr 1fr auto auto;gap:4px;align-items:start;'; var inpVal = document.createElement('input'); inpVal.type = 'text'; inpVal.placeholder = 'wert'; inpVal.className = 'sm-opt-val'; inpVal.value = opt.value || ''; var inpLbl = document.createElement('input'); inpLbl.type = 'text'; inpLbl.placeholder = 'Text'; inpLbl.className = 'sm-opt-lbl'; inpLbl.value = opt.label || ''; var selExcl = document.createElement('select'); selExcl.className = 'sm-opt-excl'; selExcl.multiple = true; selExcl.title = 'Fragen ausblenden (Mehrfachauswahl)'; selExcl.style.cssText = 'min-height:36px;max-height:80px;font-size:.85em;'; var currentExcludes = (opt.excludes || '').split(',').map(function(s) { return s.trim(); }).filter(Boolean); (_current.questions || []).forEach(function(oq) { if (oq.id === q.id) return; var o = document.createElement('option'); o.value = oq.id; o.textContent = truncate(oq.label || oq.id, 28); if (currentExcludes.indexOf(oq.id) >= 0) o.selected = true; selExcl.appendChild(o); }); var btnRemove = document.createElement('button'); btnRemove.type = 'button'; btnRemove.textContent = '×'; btnRemove.style.cssText = 'padding:4px 8px;cursor:pointer;background:#c00;color:#fff;border:none;border-radius:3px;'; btnRemove.addEventListener('click', function() { row.remove(); }); row.appendChild(inpVal); row.appendChild(inpLbl); row.appendChild(selExcl); row.appendChild(btnRemove); return row; } (q.options || []).forEach(function(opt) { optRowsDiv.appendChild(buildOptionRow(opt)); }); optsWrap.appendChild(optRowsDiv); var btnAddOpt = document.createElement('button'); btnAddOpt.type = 'button'; btnAddOpt.textContent = '+ Option'; btnAddOpt.style.cssText = 'margin-top:6px;padding:4px 12px;cursor:pointer;'; btnAddOpt.addEventListener('click', function() { optRowsDiv.appendChild(buildOptionRow({ value: '', label: '', excludes: '' })); }); optsWrap.appendChild(btnAddOpt); panel.appendChild(optsWrap); // Icon options editor (for icon type) Loading @@ -410,7 +441,7 @@ var SurveyManager = (function() { function buildIconRow(opt) { var row = document.createElement('div'); row.className = 'sm-icon-opt-row'; row.style.cssText = 'display:grid;grid-template-columns:1fr 1fr 1fr auto auto;gap:4px;align-items:center;'; row.style.cssText = 'display:grid;grid-template-columns:1fr 1fr 1fr auto auto auto;gap:4px;align-items:start;'; var inpVal = document.createElement('input'); inpVal.type = 'text'; inpVal.placeholder = 'wert'; Loading Loading @@ -439,13 +470,28 @@ var SurveyManager = (function() { }); })(inpUrl); var selExcl = document.createElement('select'); selExcl.className = 'sm-icon-excl'; selExcl.multiple = true; selExcl.title = 'Fragen ausblenden (Mehrfachauswahl)'; selExcl.style.cssText = 'min-height:36px;max-height:80px;font-size:.85em;'; var currentExcludes = (opt.excludes || '').split(',').map(function(s) { return s.trim(); }).filter(Boolean); (_current.questions || []).forEach(function(oq) { if (oq.id === q.id) return; var o = document.createElement('option'); o.value = oq.id; o.textContent = truncate(oq.label || oq.id, 28); if (currentExcludes.indexOf(oq.id) >= 0) o.selected = true; selExcl.appendChild(o); }); var btnRemove = document.createElement('button'); btnRemove.type = 'button'; btnRemove.textContent = '×'; btnRemove.style.cssText = 'padding:4px 8px;cursor:pointer;background:#c00;color:#fff;border:none;border-radius:3px;'; btnRemove.addEventListener('click', function() { row.remove(); }); row.appendChild(inpVal); row.appendChild(inpLbl); row.appendChild(inpUrl); row.appendChild(btnBrowse); row.appendChild(btnRemove); row.appendChild(btnBrowse); row.appendChild(selExcl); row.appendChild(btnRemove); return row; } Loading