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()) {
case 'input':
if (state === '1') {
if ((state === '1' && !element.checked)
|| (state === '0' && element.checked)
) {
element.click();
}
@ -73,7 +75,7 @@ export class UIStateManager
if (this.getAttribute('type') === 'checkbox'
|| 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 {
window.localStorage.setItem('ui-state-' + this.id, JSON.stringify(this.value));
}
@ -85,6 +87,10 @@ export class UIStateManager
element.scrollLeft = state.x;
element.scrollTop = state.y;
console.log(state.y);
element.scrollTo({ top: state.y, left: state.x })
element.addEventListener('scroll', function () {
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(
'button[form=' + this.id + '].update-form, '
+ '.update-form[data-form=' + this.id + '], '
+ '#' + this.id + ' .update-form'
+ '#' + this.id + ' .update-form, '
+ '[form="' + this.id + '"].update-form'
+ (e !== null ? ', .update-form' : '')
);
};
@ -210,7 +211,8 @@ export class FormView
return parent.querySelectorAll(
'button[form=' + this.id + '].save-form, '
+ '.save-form[data-form=' + this.id + '], '
+ '#' + this.id + ' .save-form'
+ '#' + this.id + ' .save-form, '
+ '[form="' + this.id + '"].save-form'
+ (e !== null ? ', .save-form' : '')
);
};
@ -231,7 +233,8 @@ export class FormView
return parent.querySelectorAll(
'button[form=' + this.id + '].cancel-form, '
+ '.cancel-form[data-form=' + this.id + '], '
+ '#' + this.id + ' .cancel-form'
+ '#' + this.id + ' .cancel-form, '
+ '[form="' + this.id + '"].cancel-form'
+ (e !== null ? ', .cancel-form' : '')
);
};
@ -252,7 +255,8 @@ export class FormView
return parent.querySelectorAll(
'button[form=' + this.id + '].remove-form, '
+ '.remove-form[data-form=' + this.id + '], '
+ '#' + this.id + ' .remove-form'
+ '#' + this.id + ' .remove-form, '
+ '[form="' + this.id + '"].remove-form'
+ (e !== null ? ', .remove-form' : '')
);
};
@ -275,7 +279,8 @@ export class FormView
return parent.querySelectorAll(
'button[form=' + this.id + '].add-form, '
+ '.add-form[data-form=' + this.id + '], '
+ '#' + this.id + ' .add-form'
+ '#' + this.id + ' .add-form, '
+ '[form="' + this.id + '"].add-form'
+ (e !== null ? ', .add-form' : '')
);
};
@ -770,35 +775,15 @@ export class FormView
}
};
/**
* Unbind form
*
* @return {void}
*
* @since 1.0.0
*/
unbind ()
getElementsToBind(e = null)
{
const elements = this.getFormElements();
const length = elements.length;
const parent = e === null ? document : e;
for (let i = 0; i < length; ++i) {
switch (elements[i].tagName) {
case 'input':
Input.unbind(elements[i]);
break;
case 'select':
this.bindSelect(elements[i]);
break;
case 'textarea':
this.bindTextarea(elements[i]);
break;
case 'button':
this.bindButton(elements[i]);
break;
default:
}
}
const externalElements = parent.querySelectorAll('[form=' + this.id + ']');
return Array.prototype.slice.call(externalElements).concat(
Array.prototype.slice.call([this.form])
).filter(function (val) { return val; });
};
/**
@ -810,7 +795,6 @@ export class FormView
*/
clean ()
{
this.unbind();
this.initializeMembers();
};
};