From f67dbfdd53c6160ab7cf4b3c755bce17e07ed651 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Sun, 5 Jan 2020 06:24:34 +0200 Subject: [PATCH] Added the modal sub subform for the view builder in the Assistant. --- README.md | 4 +- admin/README.txt | 4 +- admin/assets/js/assistant.js | 403 ++++++++++++++++++ .../en-GB/en-GB.com_componentbuilder.ini | 6 +- admin/layouts/assistantsubformrepeatable.php | 14 +- admin/layouts/assistantsubformsection.php | 25 +- .../assistant/tmpl/default_jcbviewsplan.php | 198 ++++++++- admin/views/assistant/view.html.php | 4 +- componentbuilder.xml | 2 +- 9 files changed, 628 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 053490eb9..ba0bd708d 100644 --- a/README.md +++ b/README.md @@ -144,11 +144,11 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 3rd January, 2020 ++ *Last Build*: 5th January, 2020 + *Version*: 2.10.10 + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **280105** ++ *Line count*: **280701** + *Field count*: **1503** + *File count*: **1769** + *Folder count*: **280** diff --git a/admin/README.txt b/admin/README.txt index 053490eb9..ba0bd708d 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -144,11 +144,11 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 3rd January, 2020 ++ *Last Build*: 5th January, 2020 + *Version*: 2.10.10 + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **280105** ++ *Line count*: **280701** + *Field count*: **1503** + *File count*: **1769** + *Folder count*: **280** diff --git a/admin/assets/js/assistant.js b/admin/assets/js/assistant.js index 6254ec7a4..d7b0edc41 100644 --- a/admin/assets/js/assistant.js +++ b/admin/assets/js/assistant.js @@ -591,3 +591,406 @@ function getKeyID(key) { // return the id build 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