WIP edit records

This commit is contained in:
AJ ONeal 2018-01-20 21:23:59 -07:00
parent 4612f2cbad
commit 2aa57739ed
1 changed files with 10 additions and 11 deletions

View File

@ -245,28 +245,28 @@
}); });
$on('button.js-record-edit', 'click', function (ev) { $on('button.js-record-edit', 'click', function (ev) {
console.log(ev.target);
var id = ev.target.parentElement.querySelector('.js-record-id').value; var id = ev.target.parentElement.querySelector('.js-record-id').value;
console.log(id);
var record = cache.recordsMap[id]; var record = cache.recordsMap[id];
console.log(record); var formTpl = tpls.formsMap[record.type.toLowerCase()];
var formTpl;
formTpl = tpls.formsMap[record.type.toLowerCase()];
if (!formTpl) { if (!formTpl) {
record.typex = 'typex'; record.typex = 'typex';
formTpl = tpls.formsMap.typex; formTpl = tpls.formsMap.typex;
} }
console.log(ev.target);
console.log(id);
console.log(record);
formTpl = tpls.formsMap[record.typex || record.type.toLowerCase()]; 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('select.js-record-form-type').dispatchEvent(new Event('change', { bubbles: true }));
$qs('.js-record-form-tpl').innerHTML = formTpl || ''; $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:');
console.log(record.type.toLowerCase()); console.log(record.type.toLowerCase());
Object.keys(record).forEach(function (key) { Object.keys(record).forEach(function (key) {
var $el = $qs('.js-record-' + key, $qs('.js-record-form-tpl')); var $el = $qs('.js-record-' + key, $qs('.js-record-form-tpl'));
if (!$el) { if (!$el) {
@ -274,9 +274,8 @@
} }
$el.value = record[key]; $el.value = record[key];
}); });
if (!record.host) { if (!record.host) { $qs('.js-record-host').placeholder = '@'; }
$qs('.js-record-host').placeholder = '@'; $qs('.js-record-type', $qs('.js-record-form-tpl')).innerHTML = record.type;
}
}); });
$qs('select.js-record-form-type').value = ''; $qs('select.js-record-form-type').value = '';