Added the modal sub subform for the view builder in the Assistant.

This commit is contained in:
2020-01-05 06:24:34 +02:00
parent 185dad4273
commit f67dbfdd53
9 changed files with 628 additions and 32 deletions

View File

@@ -28,7 +28,7 @@ function buildSubform()
'layout' => 'assistantsubformrepeatable',
'multiple' => 'true',
'icon' => 'list',
'max' => 5,
'max' => 20,
'min' => 1
);
// load the subform attributes
@@ -88,9 +88,9 @@ function buildSubform()
'label' => 'COM_COMPONENTBUILDER_BUILDER',
'description' => '
<div class="uk-button-group uk-width-1-1">
<a class="uk-button uk-button-small uk-width-1-3" href="#jcbuilder" data-uk-modal="{center:true}" onclick="setJCBuilder(this, 1)">' . JText::_('COM_COMPONENTBUILDER_FIELDS') . '</a>
<a class="uk-button uk-button-small uk-width-1-3" href="#jcbuilder" data-uk-modal="{center:true}" onclick="setJCBuilder(this, 2)">' . JText::_('COM_COMPONENTBUILDER_LIST_VIEW') . '</a>
<a class="uk-button uk-button-small uk-width-1-3" href="#jcbuilder" data-uk-modal="{center:true}" onclick="setJCBuilder(this, 3)">' . JText::_('COM_COMPONENTBUILDER_DISPLAY_VIEW') . '</a>
<a id="button-fields-[[[VDM]]]" class="uk-button uk-button-small uk-width-1-3" href="#modal-fields-[[[VDM]]]" data-uk-modal onclick="setJCBuilder(this, 1)">' . JText::_('COM_COMPONENTBUILDER_FIELDS') . '</a>
<a id="button-listview-[[[VDM]]]" class="uk-button uk-button-small uk-width-1-3" href="#modal-listview-[[[VDM]]]" data-uk-modal onclick="setJCBuilder(this, 2)">' . JText::_('COM_COMPONENTBUILDER_LIST_VIEW') . '</a>
<a id="button-display-[[[VDM]]]" class="uk-button uk-button-small uk-width-1-3" href="#modal-display-[[[VDM]]]" data-uk-modal onclick="setJCBuilder(this, 3)">' . JText::_('COM_COMPONENTBUILDER_DISPLAY_VIEW') . '</a>
</div><div class="builder"></div><br />',
'heading' => 'h5'
);
@@ -99,6 +99,186 @@ function buildSubform()
// now add the fields to the child form
ComponentbuilderHelper::xmlAppend($childForm, $noteXML);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// FIELDS SUBFORM START
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// start building the subform field XML
$sub_subformXML = new SimpleXMLElement('<field/>');
// subform attributes
$sub_subformAttribute = array(
'type' => 'subform',
'name' => 'fields',
'label' => 'COM_COMPONENTBUILDER_FIELD_BUILDER',
'layout' => 'joomla.form.field.subform.repeatable-table',
'multiple' => 'true',
'icon' => 'list',
'max' => 20,
'min' => 1
);
// load the subform attributes
ComponentbuilderHelper::xmlAddAttributes($sub_subformXML, $sub_subformAttribute);
// now add the subform child form
$sub_childform = $sub_subformXML->addChild('form');
// child form attributes
$sub_childformAttribute = array(
'hidden' => 'true',
'name' => 'list_properties',
'repeat' => 'true');
// load the child form attributes
ComponentbuilderHelper::xmlAddAttributes($sub_childform, $sub_childformAttribute);
// view building the name field XML
$nameXML = new SimpleXMLElement('<field/>');
// subform attributes
$nameAttribute = array(
'type' => 'text',
'name' => 'name',
'label' => 'COM_COMPONENTBUILDER_FIELD_NAME',
'size' => '40',
'maxlength' => '150',
'class' => 'text_area',
'hint' => 'COM_COMPONENTBUILDER_FIELD_NAME',
'filter' => 'STRING'
);
// load the subform attributes
ComponentbuilderHelper::xmlAddAttributes($nameXML, $nameAttribute);
// now add the fields to the child form
ComponentbuilderHelper::xmlAppend($sub_childform, $nameXML);
// view building the field type XML
$fieldtypeXML = new SimpleXMLElement('<field/>');
// subform attributes
$fieldtypeAttribute = array(
'type' => 'fieldtypes',
'name' => 'fieldtype',
'label' => 'COM_COMPONENTBUILDER_FIELD_TYPE',
'multiple' => false,
'required' => true,
'class' => 'btn-group',
'addfieldpath' => '/administrator/components/com_componentbuilder/models/fields'
);
// load the subform attributes
ComponentbuilderHelper::xmlAddAttributes($fieldtypeXML, $fieldtypeAttribute);
// now add the fields to the child form
ComponentbuilderHelper::xmlAppend($sub_childform, $fieldtypeXML);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// FIELDPROPERTIES SUBFORM START
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// start building the subform field XML
$sub_sub_subformXML = new SimpleXMLElement('<field/>');
// subform attributes
$sub_sub_subformAttribute = array(
'type' => 'subform',
'name' => 'properties',
'label' => 'COM_COMPONENTBUILDER_PROPERTIES',
'layout' => 'joomla.form.field.subform.repeatable',
'multiple' => 'true',
'icon' => 'list'
);
// load the subform attributes
ComponentbuilderHelper::xmlAddAttributes($sub_sub_subformXML, $sub_sub_subformAttribute);
// now add the subform child form
$sub_sub_childform = $sub_sub_subformXML->addChild('form');
// child form attributes
$sub_sub_childformAttribute = array(
'hidden' => 'true',
'name' => 'list_properties',
'repeat' => 'true');
// load the child form attributes
ComponentbuilderHelper::xmlAddAttributes($sub_sub_childform, $sub_sub_childformAttribute);
// view building the list name field XML
$propertiesXML = new SimpleXMLElement('<field/>');
// subform attributes
$propertiesAttribute = array(
'type' => 'text',
'name' => 'property',
'label' => 'COM_COMPONENTBUILDER_PROPERTY',
'size' => '100',
'maxlength' => '150',
'class' => 'text_area',
'hint' => 'COM_COMPONENTBUILDER_PROPERTY_NAME',
'filter' => 'STRING'
);
// load the subform attributes
ComponentbuilderHelper::xmlAddAttributes($propertiesXML, $propertiesAttribute);
// now add the fields to the child form
ComponentbuilderHelper::xmlAppend($sub_sub_childform, $propertiesXML);
// view building the value field XML
$valueXML = new SimpleXMLElement('<field/>');
// subform attributes
$valueAttribute = array(
'type' => 'text',
'name' => 'value',
'label' => 'COM_COMPONENTBUILDER_VALUE',
'size' => '40',
'maxlength' => '150',
'class' => 'text_area',
'hint' => 'COM_COMPONENTBUILDER_PROPERTY_VALUE',
'filter' => 'STRING'
);
// load the subform attributes
ComponentbuilderHelper::xmlAddAttributes($valueXML, $valueAttribute);
// now add the fields to the child form
ComponentbuilderHelper::xmlAppend($sub_sub_childform, $valueXML);
// no add to main sub from
ComponentbuilderHelper::xmlAppend($sub_childform, $sub_sub_subformXML);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// FIELDPROPERTIES SUBFORM END
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// no add to main sub from
ComponentbuilderHelper::xmlAppend($childForm, $sub_subformXML);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// FIELDS SUBFORM END
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// LISTVIEW START
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// start building the listview area XML
$listviewXML = new SimpleXMLElement('<field/>');
// subform attributes
$listviewAttribute = array(
'type' => 'note',
'name' => 'columns',
'label' => 'COM_COMPONENTBUILDER_ROW_SELECTION',
'description' => '
<b>More details soon, to help you select the fields for the list display of rows.</b>',
'heading' => 'h5'
);
// load the subform attributes
ComponentbuilderHelper::xmlAddAttributes($listviewXML, $listviewAttribute);
// now add the fields to the child form
ComponentbuilderHelper::xmlAppend($childForm, $listviewXML);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// LISTVIEW END
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// DISPLAY START
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// start building the display area XML
$displayXML = new SimpleXMLElement('<field/>');
// subform attributes
$displayAttribute = array(
'type' => 'note',
'name' => 'display',
'label' => 'COM_COMPONENTBUILDER_ITEM_DISPLAY',
'description' => '
<b>More details soon, to help build the site/front display of a single item.</b>',
'heading' => 'h5'
);
// load the subform attributes
ComponentbuilderHelper::xmlAddAttributes($displayXML, $displayAttribute);
// now add the fields to the child form
ComponentbuilderHelper::xmlAppend($childForm, $displayXML);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// DISPLAY END
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// setup subform with values
$subform->setup($subformXML, null, 'jcbform');
@@ -115,17 +295,9 @@ $subform = buildSubform();
<div class="controls">
<?php echo $subform->input; ?>
</div>
<div id="jcbuilder" class="uk-modal">
<div class="uk-modal-dialog uk-modal-dialog-large">
<button class="uk-modal-close uk-close" type="button"></button>
<div class="loading">loading..<span class="loading-dots"></span></div>
<div id="jcbbuilder-display" class="uk-panel">
</div>
</div>
</div>
<script type="text/javascript">
function setJCBuilder(area, target){
console.log(area);
console.log(jQuery(area).attr('id'));
console.log(target);
}
</script>

View File

@@ -38,7 +38,9 @@ class ComponentbuilderViewAssistant extends JViewLegacy
$this->sidebar = JHtmlSidebar::render();
}
// get the forms
$this->forms = $this->setForms();
$this->forms = $this->setForms();
//
JHtml::_('jquery.ui', array('core', 'sortable'));
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')