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

This commit is contained in:
Llewellyn van der Merwe 2020-01-05 06:24:34 +02:00
parent 185dad4273
commit f67dbfdd53
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
9 changed files with 628 additions and 32 deletions

View File

@ -144,11 +144,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 3rd January, 2020 + *Last Build*: 5th January, 2020
+ *Version*: 2.10.10 + *Version*: 2.10.10
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **280105** + *Line count*: **280701**
+ *Field count*: **1503** + *Field count*: **1503**
+ *File count*: **1769** + *File count*: **1769**
+ *Folder count*: **280** + *Folder count*: **280**

View File

@ -144,11 +144,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 3rd January, 2020 + *Last Build*: 5th January, 2020
+ *Version*: 2.10.10 + *Version*: 2.10.10
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **280105** + *Line count*: **280701**
+ *Field count*: **1503** + *Field count*: **1503**
+ *File count*: **1769** + *File count*: **1769**
+ *Folder count*: **280** + *Folder count*: **280**

View File

@ -591,3 +591,406 @@ function getKeyID(key) {
// return the id build // return the id build
return keyID; return keyID;
} }
jQuery.string_replace = function (search, replace, subject, countObj) {
// discuss at: https://locutus.io/php/str_replace/
// original by: Kevin van Zonneveld (https://kvz.io)
// improved by: Gabriel Paderni
// improved by: Philip Peterson
// improved by: Simon Willison (https://simonwillison.net)
// improved by: Kevin van Zonneveld (https://kvz.io)
// improved by: Onno Marsman (https://twitter.com/onnomarsman)
// improved by: Brett Zamir (https://brett-zamir.me)
// revised by: Jonas Raoni Soares Silva (https://www.jsfromhell.com)
// bugfixed by: Anton Ongson
// bugfixed by: Kevin van Zonneveld (https://kvz.io)
// bugfixed by: Oleg Eremeev
// bugfixed by: Glen Arason (https://CanadianDomainRegistry.ca)
// bugfixed by: Glen Arason (https://CanadianDomainRegistry.ca)
// input by: Onno Marsman (https://twitter.com/onnomarsman)
// input by: Brett Zamir (https://brett-zamir.me)
// input by: Oleg Eremeev
// note 1: The countObj parameter (optional) if used must be passed in as a
// note 1: object. The count will then be written by reference into it's `value` property
// example 1: str_replace(' ', '.', 'Kevin van Zonneveld')
// returns 1: 'Kevin.van.Zonneveld'
// example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars')
// returns 2: 'hemmo, mars'
// example 3: str_replace(Array('S','F'),'x','ASDFASDF')
// returns 3: 'AxDxAxDx'
// example 4: var countObj = {}
// example 4: str_replace(['A','D'], ['x','y'] , 'ASDFASDF' , countObj)
// example 4: var $result = countObj.value
// returns 4: 4
var i = 0
var j = 0
var temp = ''
var repl = ''
var sl = 0
var fl = 0
var f = [].concat(search)
var r = [].concat(replace)
var s = subject
var ra = Object.prototype.toString.call(r) === '[object Array]'
var sa = Object.prototype.toString.call(s) === '[object Array]'
s = [].concat(s)
var $global = (typeof window !== 'undefined' ? window : global)
$global.$locutus = $global.$locutus || {}
var $locutus = $global.$locutus
$locutus.php = $locutus.php || {}
if (typeof (search) === 'object' && typeof (replace) === 'string') {
temp = replace
replace = []
for (i = 0; i < search.length; i += 1) {
replace[i] = temp
}
temp = ''
r = [].concat(replace)
ra = Object.prototype.toString.call(r) === '[object Array]'
}
if (typeof countObj !== 'undefined') {
countObj.value = 0
}
for (i = 0, sl = s.length; i < sl; i++) {
if (s[i] === '') {
continue
}
for (j = 0, fl = f.length; j < fl; j++) {
temp = s[i] + ''
repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0]
s[i] = (temp).split(f[j]).join(repl)
if (typeof countObj !== 'undefined') {
countObj.value += ((temp.split(f[j])).length - 1)
}
}
}
return sa ? s : s[0]
}
/**
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
;(function($){
"use strict";
$.subformRepeatableVDM = function(container, options){
this.$container = $(container);
// check if already exist
if(this.$container.data("subformRepeatableVDM")){
return self;
}
// Add a reverse reference to the DOM object
this.$container.data("subformRepeatableVDM", self);
// merge options
this.options = $.extend({}, $.subformRepeatableVDM.defaults, options);
// template for the repeating group
this.template = '';
// prepare a row template, and find available field names
this.prepareTemplate();
// check rows container
this.$containerRows = this.options.rowsContainer ? this.$container.find(this.options.rowsContainer) : this.$container;
// To avoid scope issues,
var self = this;
// bind add button
this.$container.on('click', this.options.btAdd, function (e) {
e.preventDefault();
var after = $(this).parents(self.options.repeatableElement);
if(!after.length){
after = null;
}
self.addRow(after);
});
// bind remove button
this.$container.on('click', this.options.btRemove, function (e) {
e.preventDefault();
var $row = $(this).parents(self.options.repeatableElement);
self.removeRow($row);
});
// bind move button
if(this.options.btMove){
this.$containerRows.sortable({
items: this.options.repeatableElement,
handle: this.options.btMove,
tolerance: 'pointer'
});
}
// tell all that we a ready
this.$container.trigger('subform-ready');
};
// prepare a template that we will use repeating
$.subformRepeatableVDM.prototype.prepareTemplate = function(){
// create from template
if (this.options.rowTemplateSelector) {
// Find the template element and get its HTML content, this is our template.
var $tmplElement = this.$container.find(this.options.rowTemplateSelector).last();
this.template = $.trim($tmplElement.html()) || '';
// This is IE fix for <template>
$tmplElement.css('display', 'none'); // Make sure it not visible
var map = {'SUBFORMLT': '<', 'SUBFORMGT': '>'};
this.template = this.template.replace(/(SUBFORMLT)|(SUBFORMGT)/g, function(match){
return map[match];
});
}
// create from existing rows
else {
//find first available
var row = this.$container.find(this.options.repeatableElement).get(0),
$row = $(row).clone();
// clear scripts that can be attached to the fields
try {
this.clearScripts($row);
} catch (e) {
if(window.console){
console.log(e);
}
}
this.template = $row.prop('outerHTML');
}
};
// add new row
$.subformRepeatableVDM.prototype.addRow = function(after){
// count how much we already have
var count = this.$containerRows.find(this.options.repeatableElement).length;
if(count >= this.options.maximum){
return null;
}
// make new from template
var row = $.parseHTML(this.template);
// add to container
if(after){
$(after).after(row);
} else {
this.$containerRows.append(row);
}
var $row = $(row);
//add marker that it is new
$row.attr('data-new', 'true');
// fix names and id`s, and reset values
this.fixUniqueAttributes($row, count);
// fix VDM dynamic values (real pain, could they not have made this easier!!!)
var _vdm_counter = $row.attr('data-group');
_vdm_counter = _vdm_counter.replace ( /[^\d.]/g, '' );
$row[0].innerHTML = $.string_replace("VDM-XX", _vdm_counter, $row[0].innerHTML);
// try find out with related scripts,
// tricky thing, so be careful
try {
this.fixScripts($row);
} catch (e) {
if(window.console){
console.log(e);
}
}
// tell everyone about the new row
this.$container.trigger('subform-row-add', $row);
return $row;
};
// remove row
$.subformRepeatableVDM.prototype.removeRow = function($row){
// count how much we have
var count = this.$containerRows.find(this.options.repeatableElement).length;
if(count <= this.options.minimum){
return;
}
// tell everyoune about the row will be removed
this.$container.trigger('subform-row-remove', $row);
$row.remove();
};
// fix names and id`s for fields in $row
$.subformRepeatableVDM.prototype.fixUniqueAttributes = function(
$row, // the jQuery object to do fixes in
_count, // existing count of rows
_group, // current group name, e.g. 'optionsX'
_basename // group base name, without count, e.g. 'options'
) {
var group = (typeof _group === 'undefined' ? $row.attr('data-group') : _group),
basename = (typeof _basename === 'undefined' ? $row.attr('data-base-name') : _basename),
count = (typeof _count === 'undefined' ? 0 : _count),
groupnew = basename + count;
$row.attr('data-group', groupnew);
// Fix inputs that have a "name" attribute
var haveName = $row.find('[name]'),
ids = {}; // Collect id for fix checkboxes and radio
for (var i = 0, l = haveName.length; i < l; i++) {
var $el = $(haveName[i]),
name = $el.attr('name'),
id = name.replace(/(\[\]$)/g, '').replace(/(\]\[)/g, '__').replace(/\[/g, '_').replace(/\]/g, ''), // id from name
nameNew = name.replace('[' + group + '][', '['+ groupnew +']['), // New name
idNew = id.replace(group, groupnew).replace(/\W/g, '_'), // Count new id
countMulti = 0, // count for multiple radio/checkboxes
forOldAttr = id; // Fix "for" in the labels
if ($el.prop('type') === 'checkbox' && name.match(/\[\]$/)) { // <input type="checkbox" name="name[]"> fix
// Recount id
countMulti = ids[id] ? ids[id].length : 0;
if (!countMulti) {
// Set the id for fieldset and group label
$el.closest('fieldset.checkboxes').attr('id', idNew);
$row.find('label[for="' + id + '"]').attr('for', idNew).attr('id', idNew + '-lbl');
}
forOldAttr = forOldAttr + countMulti;
idNew = idNew + countMulti;
}
else if ($el.prop('type') === 'radio') { // <input type="radio"> fix
// Recount id
countMulti = ids[id] ? ids[id].length : 0;
if (!countMulti) {
// Set the id for fieldset and group label
$el.closest('fieldset.radio').attr('id', idNew);
$row.find('label[for="' + id + '"]').attr('for', idNew).attr('id', idNew + '-lbl');
}
forOldAttr = forOldAttr + countMulti;
idNew = idNew + countMulti;
}
// Cache already used id
if (ids[id]) {
ids[id].push(true);
} else {
ids[id] = [true];
}
// Replace the name to new one
$el.attr('name', nameNew);
// Set new id
$el.attr('id', idNew);
// Guess there a label for this input
$row.find('label[for="' + forOldAttr + '"]').attr('for', idNew).attr('id', idNew + '-lbl');
}
/**
* Recursively replace our basename + old group with basename + new group
* inside of nested subform template elements. First we try to find such
* template elements, then we iterate through them and do the same replacements
* that we have made here inside of them.
*/
var nestedTemplates = $row.find(this.options.rowTemplateSelector);
// If we found it, iterate over the found ones (might be more than one!)
for (var j = 0; j < nestedTemplates.length; j++) {
// Get the nested templates content (as DocumentFragment) and cast it
// to a jQuery object
var nestedTemplate = $($(nestedTemplates[j]).prop('content'));
// Fix the attributes for this nested template.
this.fixUniqueAttributes(nestedTemplate, count, group, basename);
}
};
// remove scripts attached to fields
// @TODO: make thing better when something like that will be accepted https://github.com/joomla/joomla-cms/pull/6357
$.subformRepeatableVDM.prototype.clearScripts = function($row){
// destroy chosen if any
if($.fn.chosen){
$row.find('select.chzn-done').each(function(){
var $el = $(this);
$el.next('.chzn-container').remove();
$el.show().addClass('fix-chosen');
});
}
};
// method for hack the scripts that can be related
// to the one of field that in given $row
// @TODO Stop using this function. Elements within subforms should initialize themselves
$.subformRepeatableVDM.prototype.fixScripts = function($row){
// fix media field
$row.find('a[onclick*="jInsertFieldValue"]').each(function(){
var $el = $(this),
inputId = $el.siblings('input[type="text"]').attr('id'),
$select = $el.prev(),
oldHref = $select.attr('href');
// update the clear button
$el.attr('onclick', "jInsertFieldValue('', '" + inputId + "');return false;")
// update select button
$select.attr('href', oldHref.replace(/&fieldid=(.+)&/, '&fieldid=' + inputId + '&'));
});
};
// defaults
$.subformRepeatableVDM.defaults = {
// button selector for "add" action, must be unique per nested subform!
btAdd: ".group-add",
// button selector for "remove" action, must be unique per nested subform!
btRemove: ".group-remove",
// button selector for "move" action, must be unique per nested subform!
btMove: ".group-move",
// minimum repeating
minimum: 0,
// maximum repeating
maximum: 10,
// selector for the repeatable element inside the main container,
// must be unique per nested subform!
repeatableElement: ".subform-repeatable-group",
// selector for the row template element with URL-encoded template inside it,
// must *NOT* be unique per nested subform!
rowTemplateSelector: 'template.subform-repeatable-template-section',
// container for rows, same as main container by default
rowsContainer: null
};
$.fn.subformRepeatableVDM = function(options){
return this.each(function(){
var options = options || {},
data = $(this).data();
if(data.subformRepeatableVDM){
// Alredy initialized, nothing to do here
return;
}
for (var p in data) {
// check options in the element
if (data.hasOwnProperty(p)) {
options[p] = data[p];
}
}
var inst = new $.subformRepeatableVDM(this, options);
$(this).data('subformRepeatableVDM', inst);
});
};
// initialise all available on load and again within any added row
$(function ($) {
initSubform();
$(document).on('subform-row-add', initSubform);
function initSubform (event, container) {
$(container || document).find('div.subform-repeatable-vdm').subformRepeatableVDM();
}
});
})(jQuery);

View File

@ -5025,6 +5025,7 @@ COM_COMPONENTBUILDER_FIELD_BASIC_ENCRYPTION_LOCALDBKEY="Basic Encryption (local-
COM_COMPONENTBUILDER_FIELD_BIGINT="BIGINT" COM_COMPONENTBUILDER_FIELD_BIGINT="BIGINT"
COM_COMPONENTBUILDER_FIELD_BLOB="BLOB" COM_COMPONENTBUILDER_FIELD_BLOB="BLOB"
COM_COMPONENTBUILDER_FIELD_BSB_NOT_FOUND_IN_LOCAL_DATABASE_TABLE_S_SO_IMPORTED_OF_ITS_VALUES_FAILED_PLEASE_UPDATE_YOUR_JCB_INSTALL_AND_TRY_AGAIN="Field <b>%s</b> not found in local database table (%s) so imported of its values failed, please update your JCB install and try again." COM_COMPONENTBUILDER_FIELD_BSB_NOT_FOUND_IN_LOCAL_DATABASE_TABLE_S_SO_IMPORTED_OF_ITS_VALUES_FAILED_PLEASE_UPDATE_YOUR_JCB_INSTALL_AND_TRY_AGAIN="Field <b>%s</b> not found in local database table (%s) so imported of its values failed, please update your JCB install and try again."
COM_COMPONENTBUILDER_FIELD_BUILDER="Field Builder"
COM_COMPONENTBUILDER_FIELD_CATID_DESCRIPTION="select one of the following categories" COM_COMPONENTBUILDER_FIELD_CATID_DESCRIPTION="select one of the following categories"
COM_COMPONENTBUILDER_FIELD_CATID_LABEL="Category" COM_COMPONENTBUILDER_FIELD_CATID_LABEL="Category"
COM_COMPONENTBUILDER_FIELD_CHAR="CHAR" COM_COMPONENTBUILDER_FIELD_CHAR="CHAR"
@ -5114,7 +5115,7 @@ COM_COMPONENTBUILDER_FIELD_MODIFIED_BY_DESC="The last user that modified this Fi
COM_COMPONENTBUILDER_FIELD_MODIFIED_BY_LABEL="Modified By" COM_COMPONENTBUILDER_FIELD_MODIFIED_BY_LABEL="Modified By"
COM_COMPONENTBUILDER_FIELD_MODIFIED_DATE_DESC="The date this Field was modified." COM_COMPONENTBUILDER_FIELD_MODIFIED_DATE_DESC="The date this Field was modified."
COM_COMPONENTBUILDER_FIELD_MODIFIED_DATE_LABEL="Modified Date" COM_COMPONENTBUILDER_FIELD_MODIFIED_DATE_LABEL="Modified Date"
COM_COMPONENTBUILDER_FIELD_NAME="Name" COM_COMPONENTBUILDER_FIELD_NAME="Field Name"
COM_COMPONENTBUILDER_FIELD_NAME_DESCRIPTION="Enter Name Here" COM_COMPONENTBUILDER_FIELD_NAME_DESCRIPTION="Enter Name Here"
COM_COMPONENTBUILDER_FIELD_NAME_HINT="Name Here" COM_COMPONENTBUILDER_FIELD_NAME_HINT="Name Here"
COM_COMPONENTBUILDER_FIELD_NAME_LABEL="Name" COM_COMPONENTBUILDER_FIELD_NAME_LABEL="Name"
@ -5266,6 +5267,7 @@ COM_COMPONENTBUILDER_FIELD_TINYBLOB="TINYBLOB"
COM_COMPONENTBUILDER_FIELD_TINYINT="TINYINT" COM_COMPONENTBUILDER_FIELD_TINYINT="TINYINT"
COM_COMPONENTBUILDER_FIELD_TWO_HUNDRED_AND_FIFTY_FIVE="255" COM_COMPONENTBUILDER_FIELD_TWO_HUNDRED_AND_FIFTY_FIVE="255"
COM_COMPONENTBUILDER_FIELD_TWO_THOUSAND_AND_FORTY_EIGHT="2048" COM_COMPONENTBUILDER_FIELD_TWO_THOUSAND_AND_FORTY_EIGHT="2048"
COM_COMPONENTBUILDER_FIELD_TYPE="Field Type"
COM_COMPONENTBUILDER_FIELD_TYPE_INFO="Type Info" COM_COMPONENTBUILDER_FIELD_TYPE_INFO="Type Info"
COM_COMPONENTBUILDER_FIELD_UNIQUE_KEY="UNIQUE KEY" COM_COMPONENTBUILDER_FIELD_UNIQUE_KEY="UNIQUE KEY"
COM_COMPONENTBUILDER_FIELD_VARCHAR="VARCHAR" COM_COMPONENTBUILDER_FIELD_VARCHAR="VARCHAR"
@ -5517,6 +5519,7 @@ COM_COMPONENTBUILDER_ISOLATE="Isolate"
COM_COMPONENTBUILDER_ISSUE="issue" COM_COMPONENTBUILDER_ISSUE="issue"
COM_COMPONENTBUILDER_IS_NOT_ONLY_FOUR_LISTRADIOCHECKBOXES="Is Not (only 4 list/radio/checkboxes)" COM_COMPONENTBUILDER_IS_NOT_ONLY_FOUR_LISTRADIOCHECKBOXES="Is Not (only 4 list/radio/checkboxes)"
COM_COMPONENTBUILDER_IS_ONLY_FOUR_LISTRADIOCHECKBOXES="Is (only 4 list/radio/checkboxes)" COM_COMPONENTBUILDER_IS_ONLY_FOUR_LISTRADIOCHECKBOXES="Is (only 4 list/radio/checkboxes)"
COM_COMPONENTBUILDER_ITEM_DISPLAY="Item Display"
COM_COMPONENTBUILDER_IWEBSITEI_BSB="<i>Website:</i> <b>%s</b>" COM_COMPONENTBUILDER_IWEBSITEI_BSB="<i>Website:</i> <b>%s</b>"
COM_COMPONENTBUILDER_JCB_COMMUNITY="JCB Community" COM_COMPONENTBUILDER_JCB_COMMUNITY="JCB Community"
COM_COMPONENTBUILDER_JCB_COMMUNITY_PACKAGES="JCB Community Packages" COM_COMPONENTBUILDER_JCB_COMMUNITY_PACKAGES="JCB Community Packages"
@ -7952,6 +7955,7 @@ COM_COMPONENTBUILDER_REVERT_ALL_AHEAD_SNIPPETS="Revert All Ahead Snippets"
COM_COMPONENTBUILDER_REVIEW_THIS_ISSUE_ON_GITHUB="Review this issue on Github" COM_COMPONENTBUILDER_REVIEW_THIS_ISSUE_ON_GITHUB="Review this issue on Github"
COM_COMPONENTBUILDER_RIGHT_IN_TAB="Right in Tab" COM_COMPONENTBUILDER_RIGHT_IN_TAB="Right in Tab"
COM_COMPONENTBUILDER_RIGHT_OF_TABS="Right of Tabs" COM_COMPONENTBUILDER_RIGHT_OF_TABS="Right of Tabs"
COM_COMPONENTBUILDER_ROW_SELECTION="Row Selection"
COM_COMPONENTBUILDER_RUN_EXPANSION="Run Expansion" COM_COMPONENTBUILDER_RUN_EXPANSION="Run Expansion"
COM_COMPONENTBUILDER_SAVE_SUCCESS="Great! Item successfully saved." COM_COMPONENTBUILDER_SAVE_SUCCESS="Great! Item successfully saved."
COM_COMPONENTBUILDER_SAVE_WARNING="The value already existed so please select another." COM_COMPONENTBUILDER_SAVE_WARNING="The value already existed so please select another."

View File

@ -29,24 +29,18 @@ defined('JPATH_BASE') or die('Restricted access');
*/ */
extract($displayData); extract($displayData);
// Add script
if ($multiple)
{
JHtml::_('jquery.ui', array('core', 'sortable'));
JHtml::_('script', 'system/subform-repeatable.js', array('version' => 'auto', 'relative' => true));
}
// the subform field layout // the subform field layout
$subform_fields = array( $subform_fields = array(
'left' => array('name'), 'left' => array('name'),
'right' => array('list_name'), 'right' => array('list_name'),
'bottom' => array('builder') 'bottom' => array('builder'),
'modal' => array('fields' => array('fields'), 'listview' => array('columns'), 'display' => array('display'))
); );
?> ?>
<div class="row-fluid"> <div class="row-fluid">
<div class="subform-repeatable-wrapper subform-layout"> <div class="subform-repeatable-wrapper subform-layout">
<div class="subform-repeatable" <div class="subform-repeatable-vdm"
data-bt-add="a.group-add-<?php echo $unique_subform_id; ?>" data-bt-add="a.group-add-<?php echo $unique_subform_id; ?>"
data-bt-remove="a.group-remove-<?php echo $unique_subform_id; ?>" data-bt-remove="a.group-remove-<?php echo $unique_subform_id; ?>"
data-bt-move="a.group-move-<?php echo $unique_subform_id; ?>" data-bt-move="a.group-move-<?php echo $unique_subform_id; ?>"
@ -69,6 +63,7 @@ $subform_fields = array(
'fields' => $subform_fields, 'fields' => $subform_fields,
'basegroup' => $fieldname, 'basegroup' => $fieldname,
'group' => $fieldname . $k, 'group' => $fieldname . $k,
'vdm' => $fieldname . $k,
'buttons' => $buttons, 'buttons' => $buttons,
'unique_subform_id' => $unique_subform_id, 'unique_subform_id' => $unique_subform_id,
)); ));
@ -86,6 +81,7 @@ $subform_fields = array(
'fields' => $subform_fields, 'fields' => $subform_fields,
'basegroup' => $fieldname, 'basegroup' => $fieldname,
'group' => $fieldname . 'X', 'group' => $fieldname . 'X',
'vdm' => $fieldname . 'VDM-XX',
'buttons' => $buttons, 'buttons' => $buttons,
'unique_subform_id' => $unique_subform_id 'unique_subform_id' => $unique_subform_id
)) ))

View File

@ -56,7 +56,7 @@ extract($displayData);
<div class="uk-width-medium-1-1"> <div class="uk-width-medium-1-1">
<div class="uk-panel"> <div class="uk-panel">
<?php foreach($fields['top'] as $field): ?> <?php foreach($fields['top'] as $field): ?>
<?php echo $form->renderField($field); ?> <?php echo str_replace('[[[VDM]]]', $vdm, $form->renderField($field)); ?>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
</div> </div>
@ -70,7 +70,7 @@ extract($displayData);
<div class="uk-width-medium-1-2"> <div class="uk-width-medium-1-2">
<div class="uk-panel uk-panel-box"> <div class="uk-panel uk-panel-box">
<?php foreach($_fields as $field): ?> <?php foreach($_fields as $field): ?>
<?php echo $form->renderField($field); ?> <?php echo str_replace('[[[VDM]]]', $vdm, $form->renderField($field)); ?>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
</div> </div>
@ -84,10 +84,29 @@ extract($displayData);
<div class="uk-width-medium-1-1"> <div class="uk-width-medium-1-1">
<div class="uk-panel"> <div class="uk-panel">
<?php foreach($fields['bottom'] as $field): ?> <?php foreach($fields['bottom'] as $field): ?>
<?php echo $form->renderField($field); ?> <?php echo str_replace('[[[VDM]]]', $vdm, $form->renderField($field)); ?>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if (isset($fields['modal'])): ?>
<?php foreach($fields['modal'] as $modal => $_fields): ?>
<div id="modal-<?php echo $modal; ?>-<?php echo $vdm ?>" class="uk-modal">
<div class="uk-modal-dialog uk-modal-dialog-large">
<div class="uk-panel">
<?php foreach($_fields as $field): ?>
<?php echo str_replace('[[[VDM]]]', $vdm, $form->renderField($field)); ?>
<?php endforeach; ?>
</div>
<div class="uk-modal-footer">
<div class="uk-clearfix">
<button class="uk-float-right uk-button uk-button-success uk-modal-close"><?php echo JText::_('COM_COMPONENTBUILDER_UPDATE'); ?></button>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div> </div>

View File

@ -28,7 +28,7 @@ function buildSubform()
'layout' => 'assistantsubformrepeatable', 'layout' => 'assistantsubformrepeatable',
'multiple' => 'true', 'multiple' => 'true',
'icon' => 'list', 'icon' => 'list',
'max' => 5, 'max' => 20,
'min' => 1 'min' => 1
); );
// load the subform attributes // load the subform attributes
@ -88,9 +88,9 @@ function buildSubform()
'label' => 'COM_COMPONENTBUILDER_BUILDER', 'label' => 'COM_COMPONENTBUILDER_BUILDER',
'description' => ' 'description' => '
<div class="uk-button-group uk-width-1-1"> <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 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 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 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 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-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 />', </div><div class="builder"></div><br />',
'heading' => 'h5' 'heading' => 'h5'
); );
@ -99,6 +99,186 @@ function buildSubform()
// now add the fields to the child form // now add the fields to the child form
ComponentbuilderHelper::xmlAppend($childForm, $noteXML); 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 // setup subform with values
$subform->setup($subformXML, null, 'jcbform'); $subform->setup($subformXML, null, 'jcbform');
@ -115,17 +295,9 @@ $subform = buildSubform();
<div class="controls"> <div class="controls">
<?php echo $subform->input; ?> <?php echo $subform->input; ?>
</div> </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"> <script type="text/javascript">
function setJCBuilder(area, target){ function setJCBuilder(area, target){
console.log(area); console.log(jQuery(area).attr('id'));
console.log(target); console.log(target);
} }
</script> </script>

View File

@ -38,7 +38,9 @@ class ComponentbuilderViewAssistant extends JViewLegacy
$this->sidebar = JHtmlSidebar::render(); $this->sidebar = JHtmlSidebar::render();
} }
// get the forms // 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. // We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal') if ($this->getLayout() !== 'modal')

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade"> <extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name> <name>COM_COMPONENTBUILDER</name>
<creationDate>3rd January, 2020</creationDate> <creationDate>5th January, 2020</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail> <authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl> <authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>