draft table forms (no remote updates yet)

This commit is contained in:
Dennis Eichhorn 2022-04-29 22:12:22 +02:00
parent b890a5e8f9
commit ec8b64e79a
3 changed files with 692 additions and 612 deletions

File diff suppressed because it is too large Load Diff

View File

@ -65,7 +65,9 @@ export class UIStateManager
switch (element.tagName.toLowerCase()) { switch (element.tagName.toLowerCase()) {
case 'input': case 'input':
if (state === '1') { if ((state === '1' && !element.checked)
|| (state === '0' && element.checked)
) {
element.click(); element.click();
} }
@ -73,7 +75,7 @@ export class UIStateManager
if (this.getAttribute('type') === 'checkbox' if (this.getAttribute('type') === 'checkbox'
|| this.getAttribute('type') === 'radio' || this.getAttribute('type') === 'radio'
) { ) {
window.localStorage.setItem('ui-state-' + this.id, JSON.stringify('1')); window.localStorage.setItem('ui-state-' + this.id, JSON.stringify(this.checked ? '1' : '0'));
} else { } else {
window.localStorage.setItem('ui-state-' + this.id, JSON.stringify(this.value)); window.localStorage.setItem('ui-state-' + this.id, JSON.stringify(this.value));
} }
@ -85,6 +87,10 @@ export class UIStateManager
element.scrollLeft = state.x; element.scrollLeft = state.x;
element.scrollTop = state.y; element.scrollTop = state.y;
console.log(state.y);
element.scrollTo({ top: state.y, left: state.x })
element.addEventListener('scroll', function () { element.addEventListener('scroll', function () {
window.localStorage.setItem('ui-state-' + this.id, JSON.stringify({ x: this.scrollLeft, y: this.scrollTop })); window.localStorage.setItem('ui-state-' + this.id, JSON.stringify({ x: this.scrollLeft, y: this.scrollTop }));
}); });

View File

@ -189,7 +189,8 @@ export class FormView
return parent.querySelectorAll( return parent.querySelectorAll(
'button[form=' + this.id + '].update-form, ' 'button[form=' + this.id + '].update-form, '
+ '.update-form[data-form=' + this.id + '], ' + '.update-form[data-form=' + this.id + '], '
+ '#' + this.id + ' .update-form' + '#' + this.id + ' .update-form, '
+ '[form="' + this.id + '"].update-form'
+ (e !== null ? ', .update-form' : '') + (e !== null ? ', .update-form' : '')
); );
}; };
@ -210,7 +211,8 @@ export class FormView
return parent.querySelectorAll( return parent.querySelectorAll(
'button[form=' + this.id + '].save-form, ' 'button[form=' + this.id + '].save-form, '
+ '.save-form[data-form=' + this.id + '], ' + '.save-form[data-form=' + this.id + '], '
+ '#' + this.id + ' .save-form' + '#' + this.id + ' .save-form, '
+ '[form="' + this.id + '"].save-form'
+ (e !== null ? ', .save-form' : '') + (e !== null ? ', .save-form' : '')
); );
}; };
@ -231,7 +233,8 @@ export class FormView
return parent.querySelectorAll( return parent.querySelectorAll(
'button[form=' + this.id + '].cancel-form, ' 'button[form=' + this.id + '].cancel-form, '
+ '.cancel-form[data-form=' + this.id + '], ' + '.cancel-form[data-form=' + this.id + '], '
+ '#' + this.id + ' .cancel-form' + '#' + this.id + ' .cancel-form, '
+ '[form="' + this.id + '"].cancel-form'
+ (e !== null ? ', .cancel-form' : '') + (e !== null ? ', .cancel-form' : '')
); );
}; };
@ -252,7 +255,8 @@ export class FormView
return parent.querySelectorAll( return parent.querySelectorAll(
'button[form=' + this.id + '].remove-form, ' 'button[form=' + this.id + '].remove-form, '
+ '.remove-form[data-form=' + this.id + '], ' + '.remove-form[data-form=' + this.id + '], '
+ '#' + this.id + ' .remove-form' + '#' + this.id + ' .remove-form, '
+ '[form="' + this.id + '"].remove-form'
+ (e !== null ? ', .remove-form' : '') + (e !== null ? ', .remove-form' : '')
); );
}; };
@ -275,7 +279,8 @@ export class FormView
return parent.querySelectorAll( return parent.querySelectorAll(
'button[form=' + this.id + '].add-form, ' 'button[form=' + this.id + '].add-form, '
+ '.add-form[data-form=' + this.id + '], ' + '.add-form[data-form=' + this.id + '], '
+ '#' + this.id + ' .add-form' + '#' + this.id + ' .add-form, '
+ '[form="' + this.id + '"].add-form'
+ (e !== null ? ', .add-form' : '') + (e !== null ? ', .add-form' : '')
); );
}; };
@ -770,35 +775,15 @@ export class FormView
} }
}; };
/** getElementsToBind(e = null)
* Unbind form
*
* @return {void}
*
* @since 1.0.0
*/
unbind ()
{ {
const elements = this.getFormElements(); const parent = e === null ? document : e;
const length = elements.length;
for (let i = 0; i < length; ++i) { const externalElements = parent.querySelectorAll('[form=' + this.id + ']');
switch (elements[i].tagName) {
case 'input': return Array.prototype.slice.call(externalElements).concat(
Input.unbind(elements[i]); Array.prototype.slice.call([this.form])
break; ).filter(function (val) { return val; });
case 'select':
this.bindSelect(elements[i]);
break;
case 'textarea':
this.bindTextarea(elements[i]);
break;
case 'button':
this.bindButton(elements[i]);
break;
default:
}
}
}; };
/** /**
@ -810,7 +795,6 @@ export class FormView
*/ */
clean () clean ()
{ {
this.unbind();
this.initializeMembers(); this.initializeMembers();
}; };
}; };