From 2aa57739eda50f4b78feb6c76e8b55b06dda29c0 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 20 Jan 2018 21:23:59 -0700 Subject: [PATCH] WIP edit records --- lib/public/js/app.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/public/js/app.js b/lib/public/js/app.js index 3fe33c1..ba6a326 100644 --- a/lib/public/js/app.js +++ b/lib/public/js/app.js @@ -245,28 +245,28 @@ }); $on('button.js-record-edit', 'click', function (ev) { - console.log(ev.target); var id = ev.target.parentElement.querySelector('.js-record-id').value; - console.log(id); var record = cache.recordsMap[id]; - console.log(record); - var formTpl; - - formTpl = tpls.formsMap[record.type.toLowerCase()]; + var formTpl = tpls.formsMap[record.type.toLowerCase()]; if (!formTpl) { record.typex = 'typex'; formTpl = tpls.formsMap.typex; } + console.log(ev.target); + console.log(id); + console.log(record); + formTpl = tpls.formsMap[record.typex || record.type.toLowerCase()]; - $qs('select.js-record-form-type').value = record.typex || record.type; + $qs('select.js-record-form-type').value = record.typex || record.type.toLowerCase(); $qs('select.js-record-form-type').dispatchEvent(new Event('change', { bubbles: true })); $qs('.js-record-form-tpl').innerHTML = formTpl || ''; - record.host = record.name.replace(new RegExp('\\.?' + record.zone.replace(/\./g, '\\.') + '$'), ''); + record.host = record.name.replace(new RegExp('\\.?' + (record.zone || record.name).replace(/\./g, '\\.') + '$'), ''); console.log('record.type:'); console.log(record.type.toLowerCase()); + Object.keys(record).forEach(function (key) { var $el = $qs('.js-record-' + key, $qs('.js-record-form-tpl')); if (!$el) { @@ -274,9 +274,8 @@ } $el.value = record[key]; }); - if (!record.host) { - $qs('.js-record-host').placeholder = '@'; - } + if (!record.host) { $qs('.js-record-host').placeholder = '@'; } + $qs('.js-record-type', $qs('.js-record-form-tpl')).innerHTML = record.type; }); $qs('select.js-record-form-type').value = '';