mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 16:48:42 +02:00
form for dashboard
This commit is contained in:
@@ -14,6 +14,7 @@ class ChoicesElement extends HTMLSelectElement {
|
||||
plugins: this.plugins,
|
||||
wrapperClass: 'ts-wrapper ibo-input-wrapper ibo-input-select-wrapper--with-buttons ibo-input-select-autocomplete-wrapper',
|
||||
controlClass: 'ts-control ibo-input ibo-input-select ibo-input-select-autocomplete',
|
||||
dropdownParent: 'body',
|
||||
render: {
|
||||
dropdown: function (data, escape) {
|
||||
return `<div class="selectize-dropdown"></div>`;
|
||||
|
||||
@@ -41,19 +41,22 @@ class CollectionEntryElement extends HTMLElement {
|
||||
*/
|
||||
updateButtonStates() {
|
||||
|
||||
if(this.previousElementSibling === null) {
|
||||
this.#eBtnMoveUp.setAttribute('disabled', 'disabled');
|
||||
}
|
||||
else{
|
||||
this.#eBtnMoveUp.removeAttribute('disabled');
|
||||
if (this.dataset.allowOrdering) {
|
||||
|
||||
if (this.previousElementSibling === null) {
|
||||
this.#eBtnMoveUp.setAttribute('disabled', 'disabled');
|
||||
} else {
|
||||
this.#eBtnMoveUp.removeAttribute('disabled');
|
||||
}
|
||||
|
||||
if (this.nextElementSibling === null) {
|
||||
this.#eBtnMoveDown.setAttribute('disabled', 'disabled');
|
||||
} else {
|
||||
this.#eBtnMoveDown.removeAttribute('disabled');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(this.nextElementSibling === null) {
|
||||
this.#eBtnMoveDown.setAttribute('disabled', 'disabled');
|
||||
}
|
||||
else{
|
||||
this.#eBtnMoveDown.removeAttribute('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
25
js/forms/custom-elements/turbo_stream_event.js
Normal file
25
js/forms/custom-elements/turbo_stream_event.js
Normal file
@@ -0,0 +1,25 @@
|
||||
class TurboStreamEvent extends HTMLElement {
|
||||
|
||||
// register the custom element
|
||||
static {
|
||||
customElements.define('turbo-stream-event', TurboStreamEvent);
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.style.display = 'none';
|
||||
|
||||
const event = new CustomEvent("itop:TurboStreamEvent", {
|
||||
detail: {
|
||||
id: this.getAttribute('id'),
|
||||
block_class: this.dataset.formBlockClass,
|
||||
view_data: this.dataset.viewData,
|
||||
valid: this.dataset.valid,
|
||||
},
|
||||
});
|
||||
|
||||
document.dispatchEvent(event);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,4 +25,3 @@ function isCheckbox (element) {
|
||||
return element instanceof HTMLInputElement
|
||||
&& element.getAttribute('type') === 'checkbox'
|
||||
}
|
||||
|
||||
|
||||
@@ -1120,6 +1120,7 @@ abstract class Controller extends AbstractController
|
||||
|
||||
} else {
|
||||
|
||||
// Display turbo response
|
||||
$this->DisplayTurboAjaxPage(['current_form' => $oForm->createView()]);
|
||||
|
||||
}
|
||||
|
||||
@@ -186,6 +186,7 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage
|
||||
$this->LinkScriptFromAppRoot('js/forms/custom-elements/oql.js');
|
||||
$this->LinkScriptFromAppRoot('js/forms/custom-elements/collection.js');
|
||||
$this->LinkScriptFromAppRoot('js/forms/custom-elements/collection_entry.js');
|
||||
$this->LinkScriptFromAppRoot('js/forms/custom-elements/turbo_stream_event.js');
|
||||
|
||||
// Used by inline image, CKEditor and other places
|
||||
$this->LinkScriptFromAppRoot('node_modules/magnific-popup/dist/jquery.magnific-popup.min.js');
|
||||
|
||||
@@ -108,6 +108,7 @@ abstract class AbstractFormBlock implements IFormBlock
|
||||
protected function RegisterOptions(OptionsRegister $oOptionsRegister): void
|
||||
{
|
||||
$oOptionsRegister->SetOption('form_block', $this);
|
||||
$oOptionsRegister->SetOption('form_block_class', get_class($this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,8 +45,8 @@ class ClassAttributeGroupByFormBlock extends AttributeChoiceFormBlock
|
||||
$sExtKeyAttCode = $oModelReflection->GetAttributeProperty($sTargetClass, $sExtFieldAttCode, 'extkey_attcode');
|
||||
$sTargetAttCode = $oModelReflection->GetAttributeProperty($sTargetClass, $sExtFieldAttCode, 'target_attcode');
|
||||
$sTargetClass = $oModelReflection->GetAttributeProperty($sTargetClass, $sExtKeyAttCode, 'targetclass');
|
||||
$aTargetAttCodes = AttributeChoiceFormBlock::ListAttributeCodesByCategory($sTargetClass, 'group_by');
|
||||
$sAttType = $aTargetAttCodes[$sTargetAttCode];
|
||||
// $aTargetAttCodes = AttributeChoiceFormBlock::ListAttributeCodesByCategory($sTargetClass, 'group_by');
|
||||
$sAttType = $sTargetAttCode;
|
||||
$sExtFieldAttCode = $sTargetAttCode;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ class FormTypeExtension extends AbstractTypeExtension
|
||||
{
|
||||
$resolver->setDefined([
|
||||
'form_block',
|
||||
'form_block_class',
|
||||
'builder_listener',
|
||||
'prevent_form_build',
|
||||
]);
|
||||
@@ -55,6 +56,7 @@ class FormTypeExtension extends AbstractTypeExtension
|
||||
{
|
||||
if (array_key_exists('form_block', $options)) {
|
||||
$view->vars['form_block'] = $options['form_block'];
|
||||
$view->vars['form_block_class'] = $options['form_block_class'];
|
||||
|
||||
$oFormBlock = $options['form_block'];
|
||||
$view->vars['trigger_form_submit_on_modify'] = $oFormBlock->ImpactDependentsBlocks();
|
||||
|
||||
@@ -16,5 +16,6 @@
|
||||
{% if current_form %}
|
||||
{% UITurboStream Replace { sTarget: current_form.vars.id} %}
|
||||
{{ form_widget(current_form) }}
|
||||
<turbo-stream-event id="{{ current_form.vars.id }}-turbo-stream-event" data-form-block-class="{{ current_form.vars.form_block_class }}" data-view-data="{{ current_form.vars.value|json_encode }}" data-valid="{{ current_form.vars.valid }}"/>
|
||||
{% EndUITurboStream %}
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user